@expofp/floorplan
Version:
Interactive floor plan library for expos and events
25,207 lines • 946 kB
JavaScript
(function() {
try {
var e = typeof window < "u" ? window : typeof global < "u" ? global : typeof globalThis < "u" ? globalThis : typeof self < "u" ? self : {};
e.SENTRY_RELEASE = { id: "3.47.0" };
var t = new e.Error().stack;
t && (e._sentryDebugIds = e._sentryDebugIds || {}, e._sentryDebugIds[t] = "785e6f81-b9ad-4aee-a2e9-410dc7cd777c", e._sentryDebugIdIdentifier = "sentry-dbid-785e6f81-b9ad-4aee-a2e9-410dc7cd777c");
} catch {}
})();
import { r as e, t } from "./rolldown-runtime-5rOLGCTp.js";
import { G as n, I as r, K as i, M as a, N as o, Ot as s, S as c, T as l, Z as u, b as d, g as f, h as p, l as m, q as h, s as g, w as _, x as v } from "./i18n-DlquqKCP.js";
import { s as y } from "./efp-debug-init-D3gNE8Zq.js";
import { t as b } from "./react-XuvSZP7j.js";
import { t as x } from "./jsx-runtime-BzLvm2y2.js";
import { a as S, i as C, o as w, t as T } from "./is-debug-IkNSAGo8.js";
import { a as E, c as D, h as O, l as k, n as A, r as j, u as M } from "./mobx.module-BTnTbXnp.js";
import { t as N } from "./is-webview-DA6FLdme.js";
import { t as P } from "./loadImage-iqS2KHgN.js";
import { t as ee } from "./scheduler-D5sEY0Dn.js";
import { C as te, D as ne, E as re, O as F, S as ie, T as ae, _ as oe, a as se, b as I, d as ce, f as le, g as ue, h as L, i as de, k as fe, l as pe, m as me, o as he, p as ge, r as _e, s as ve, u as ye, v as be, w as xe, x as Se, y as R } from "./debug-context-CLE9u3W1.js";
import { a as Ce, d as we, l as z, r as Te, t as Ee, u as B } from "./store-DTvNQcN7.js";
import { n as De, t as Oe } from "./event-scoped-cache-CUHa0QyF.js";
import { $a as V, $i as ke, $r as Ae, $t as je, A as Me, Aa as Ne, An as Pe, Ar as Fe, C as Ie, Cr as Le, Dt as Re, E as ze, Er as Be, F as Ve, Fi as H, Fn as He, Fr as Ue, Ft as We, G as Ge, Ga as Ke, Gn as qe, Hi as Je, Hn as Ye, Ht as Xe, Ii as Ze, In as Qe, Kn as $e, L as et, Ln as tt, Lt as nt, Mi as rt, Mr as it, Ni as at, Or as ot, Pr as st, Qa as ct, Qi as lt, Qn as ut, Qr as dt, Ri as ft, Rt as pt, Sr as mt, St as ht, U as gt, Ui as _t, Un as vt, Ur as yt, V as bt, Vn as xt, Wa as St, Wr as Ct, Xi as wt, Ya as Tt, Yt as Et, Zr as Dt, _a as Ot, _n as kt, a as At, an as jt, ar as Mt, br as Nt, bt as Pt, ca as Ft, co as It, dn as Lt, do as Rt, eo as U, er as zt, fa as Bt, fn as Vt, fr as Ht, ft as Ut, gn as Wt, gr as Gt, ha as Kt, hr as qt, in as Jt, ir as Yt, j as Xt, jn as Zt, ka as Qt, kn as $t, kr as en, la as tn, mn as nn, mt as rn, no as an, nr as on, oa as sn, on as cn, or as ln, pa as un, pn as dn, pr as fn, pt as pn, qt as mn, rr as W, sn as hn, sr as gn, to as _n, ua as vn, va as yn, x as bn, yr as xn, zi as Sn, zr as Cn } from "./three.core-DvpRLNmt.js";
//#region ../geometry/src/lib/angles.ts
function wn(e) {
return e * Math.PI / 180;
}
function Tn(e) {
return e * 180 / Math.PI;
}
function En(e, t) {
return {
x: Math.cos(t) * e,
y: Math.sin(t) * e
};
}
function Dn(e) {
let t = 2 * Math.PI, n = e % t;
return n <= -Math.PI ? n += t : n > Math.PI && (n -= t), n;
}
function On(e, t) {
return Dn(e - t);
}
//#endregion
//#region ../geometry/src/lib/point.ts
var kn = .1, An = class e {
constructor(e = 0, t = 0, n = 0) {
this.isPoint = !0, this.x = void 0, this.y = void 0, this.z = void 0, this.x = e, this.y = t, this.z = n;
}
get width() {
return this.x;
}
get height() {
return this.y;
}
set(e, t, n = this.z) {
return this.x = e, this.y = t, this.z = n, this;
}
copy(e) {
var t;
return this.set(e.x, e.y, (t = e.z) == null ? 0 : t);
}
clone(t) {
return (t == null ? new e() : t).set(this.x, this.y, this.z);
}
equals(e) {
var t;
return this.x === e.x && this.y === e.y && this.z === ((t = e.z) == null ? 0 : t);
}
distanceTo(e) {
return jn(this, e);
}
lerp(e, t, n) {
return Mn(this, e, t, n);
}
rotate(e, t, n) {
return Fn(this, e, t, n);
}
shift(e, t, n) {
return In(this, e, t, n);
}
angleBetween(e, t) {
return Ln(this, e, t);
}
add(e, t) {
return Nn(this, e, t);
}
multiply(e, t) {
return Pn(this, e, t);
}
};
function jn(e, t) {
let n = e.x - t.x, r = e.y - t.y;
return Math.sqrt(n * n + r * r);
}
function Mn(e, t, n, r) {
var i, a;
let o = (i = e.z) == null ? 0 : i, s = (a = t.z) == null ? 0 : a;
return (r == null ? new An() : r).set(e.x + (t.x - e.x) * n, e.y + (t.y - e.y) * n, o + (s - o) * n);
}
function Nn(e, t, n) {
var r, i;
let a = typeof t == "number", o = a ? t : t.x, s = a ? t : t.y, c = a || (r = t.z) == null ? 0 : r;
return (n == null ? new An() : n).set(e.x + o, e.y + s, ((i = e.z) == null ? 0 : i) + c);
}
function Pn(e, t, n) {
var r, i;
let a = typeof t == "number", o = a ? t : t.x, s = a ? t : t.y, c = a || (r = t.z) == null ? 1 : r;
return (n == null ? new An() : n).set(e.x * o, e.y * s, ((i = e.z) == null ? 0 : i) * c);
}
function Fn(e, t, n, r) {
var i;
let a = Math.cos(t), o = Math.sin(t), s = e.x - n.x, c = e.y - n.y;
return (r == null ? new An() : r).set(n.x + s * a - c * o, n.y + s * o + c * a, (i = e.z) == null ? 0 : i);
}
function In(e, t, n, r) {
return Nn(e, En(t, n), r);
}
function Ln(e, t, n) {
let r = Math.atan2(t.y - e.y, t.x - e.x);
return Math.atan2(n.y - e.y, n.x - e.x) - r;
}
//#endregion
//#region ../geometry/src/lib/mesh.ts
var Rn = class e {
constructor(e = [], t = []) {
this.isMesh = !0, this._vertices = [], this._indices = [], this._bounds = new cr(), this._planar = !0, this.set(e, t);
}
get vertices() {
return this._vertices;
}
get indices() {
return this._indices;
}
get bounds() {
return this._bounds;
}
get isPlanar() {
return this._planar;
}
set(e, t) {
return this._vertices = e.map((e) => {
var t;
return new An(e.x, e.y, (t = e.z) == null ? 0 : t);
}), this._indices = t, this._planar = Bn(this._vertices), this._bounds = zn(this), this;
}
static merge(...e) {
return Vn(e);
}
translate(t, n) {
return Hn(this, t, n == null ? new e() : n);
}
scale(t, n = this._bounds.center, r) {
return Un(this, t, n, r == null ? new e() : r);
}
rotate(t, n = this._bounds.center, r) {
return Wn(this, t, n, r == null ? new e() : r);
}
};
function zn(e) {
if (e.vertices.length === 0) return new cr();
let t = Infinity, n = Infinity, r = -Infinity, i = -Infinity;
for (let a of e.vertices) t = Math.min(t, a.x), n = Math.min(n, a.y), r = Math.max(r, a.x), i = Math.max(i, a.y);
return cr.fromMinMax({
x: t,
y: n
}, {
x: r,
y: i
});
}
function Bn(e) {
if (e.length === 0) return !0;
let t = e[0].z;
for (let n = 1; n < e.length; n++) if (Math.abs(e[n].z - t) > .1) return !1;
return !0;
}
function Vn(e, t) {
let n = [], r = [], i = 0;
for (let t of e) {
for (let e of t.vertices) n.push(e);
for (let [e, n, a] of t.indices) r.push([
e + i,
n + i,
a + i
]);
i += t.vertices.length;
}
return (t == null ? new Rn() : t).set(n, r);
}
function Hn(e, t, n) {
var r;
let i = (r = t.z) == null ? 0 : r, a = e.vertices.map((e) => {
var n;
return {
x: e.x + t.x,
y: e.y + t.y,
z: ((n = e.z) == null ? 0 : n) + i
};
});
return (n == null ? new Rn() : n).set(a, e.indices);
}
function Un(e, t, n = zn(e).center, r) {
let i = typeof t == "number" ? t : t.x, a = typeof t == "number" ? t : t.y, o = e.vertices.map((e) => {
var t;
return {
x: n.x + (e.x - n.x) * i,
y: n.y + (e.y - n.y) * a,
z: (t = e.z) == null ? 0 : t
};
});
return (r == null ? new Rn() : r).set(o, e.indices);
}
function Wn(e, t, n = zn(e).center, r) {
let i = Math.cos(t), a = Math.sin(t), o = e.vertices.map((e) => {
var t;
let r = e.x - n.x, o = e.y - n.y;
return {
x: n.x + r * i - o * a,
y: n.y + r * a + o * i,
z: (t = e.z) == null ? 0 : t
};
});
return (r == null ? new Rn() : r).set(o, e.indices);
}
//#endregion
//#region ../geometry/src/lib/polygon.ts
var Gn = class e {
constructor(e = [], t = [], n = 0) {
this.isPolygon = !0, this._vertices = [], this._indices = [], this._elevation = void 0, this._bounds = new cr(), this._elevation = n, this.set(e, t);
}
static fromConvexRing(t, n = 0) {
if (t.length < 3) return new e([], [], n);
let r = [];
for (let e = 1; e <= t.length - 2; e++) r.push([
0,
e,
e + 1
]);
return new e(t, r, n);
}
static merge(...t) {
var n, r;
return Vn(t, new e([], [], (n = (r = t[0]) == null ? void 0 : r.elevation) == null ? 0 : n));
}
get vertices() {
return this._vertices;
}
get indices() {
return this._indices;
}
get elevation() {
return this._elevation;
}
get bounds() {
return this._bounds;
}
get area() {
return Kn(this);
}
containsPoint(e, t) {
return qn(this, e, t);
}
translate(t, n) {
return Hn(this, t, n == null ? new e([], [], this._elevation) : n);
}
scale(t, n = this._bounds.center, r) {
return Un(this, t, n, r == null ? new e([], [], this._elevation) : r);
}
rotate(t, n = this._bounds.center, r) {
return Wn(this, t, n, r == null ? new e([], [], this._elevation) : r);
}
set(e, t, n = this._elevation) {
return this._vertices = e.map((e) => ({
x: e.x,
y: e.y
})), this._indices = t, this._elevation = n, this._bounds = zn(this), this;
}
};
function Kn(e) {
let t = 0;
for (let [n, r, i] of e.indices) {
let a = e.vertices[n], o = e.vertices[r], s = e.vertices[i];
t += Math.abs((o.x - a.x) * (s.y - a.y) - (s.x - a.x) * (o.y - a.y)) / 2;
}
return t;
}
function qn(e, t, n) {
var r;
let i = (r = n == null ? void 0 : n.areaTolerance) == null ? .01 : r;
for (let [n, r, a] of e.indices) {
let o = e.vertices[n], s = e.vertices[r], c = e.vertices[a], l = Math.abs((s.x - o.x) * (c.y - o.y) - (c.x - o.x) * (s.y - o.y)) / 2;
if (l === 0) continue;
let u = i * l, d = (t.x - s.x) * (o.y - s.y) - (o.x - s.x) * (t.y - s.y), f = (t.x - c.x) * (s.y - c.y) - (s.x - c.x) * (t.y - c.y), p = (t.x - o.x) * (c.y - o.y) - (c.x - o.x) * (t.y - o.y);
if (!((d < -u || f < -u || p < -u) && (d > u || f > u || p > u))) return !0;
}
return !1;
}
//#endregion
//#region ../geometry/src/lib/rect.ts
var Jn = (e) => {
var t;
return (t = e.rotation) == null ? 0 : t;
}, Yn = (e) => {
var t;
return (t = e.elevation) == null ? 0 : t;
}, Xn = class e {
constructor(e, t, n = 0, r = 0) {
this.isRect = !0, this._center = new An(), this._size = new An(), this._rotation = 0, this._elevation = 0, this.set(e.x, e.y, t.x, t.y, n, r);
}
static fromMinMax(t, n, r = 0, i = 0) {
return new e({
x: (t.x + n.x) / 2,
y: (t.y + n.y) / 2
}, {
x: Math.abs(n.x - t.x),
y: Math.abs(n.y - t.y)
}, r, i);
}
get center() {
return this._center;
}
get size() {
return this._size;
}
get rotation() {
return this._rotation;
}
get elevation() {
return this._elevation;
}
corners() {
return Zn(this);
}
get bounds() {
return Qn(this);
}
toPolygon() {
return $n(this);
}
containsPoint(e) {
return er(this, e);
}
translate(e, t) {
return tr(this, e, t);
}
rotate(e, t) {
return nr(this, e, t);
}
scale(e, t = this._center, n) {
return rr(this, e, t, n);
}
intersectLine(e) {
return or(e, this);
}
clone(t) {
return (t == null ? new e(this._center, this._size) : t).set(this._center.x, this._center.y, this._size.x, this._size.y, this._rotation, this._elevation);
}
set(e, t, n, r, i, a) {
return this._center.set(e, t), this._size.set(n, r), this._rotation = i, this._elevation = a, this;
}
};
function Zn(e) {
let t = e.size.x / 2, n = e.size.y / 2, r = Jn(e), i = Math.cos(r), a = Math.sin(r), o = e.center.x, s = e.center.y, c = (e, t) => new An(o + e * i - t * a, s + e * a + t * i);
return [
c(-t, -n),
c(t, -n),
c(t, n),
c(-t, n)
];
}
function Qn(e, t) {
let n = Jn(e), r = Math.abs(Math.cos(n)), i = Math.abs(Math.sin(n)), a = Math.abs(e.size.x), o = Math.abs(e.size.y), s = (a * r + o * i) / 2, c = (a * i + o * r) / 2, { x: l, y: u } = e.center;
return (t == null ? new cr() : t).set(l - s, u - c, l + s, u + c);
}
function $n(e) {
return Gn.fromConvexRing(Zn(e), Yn(e));
}
function er(e, t) {
let n = -Jn(e), r = Math.cos(n), i = Math.sin(n), a = t.x - e.center.x, o = t.y - e.center.y, s = a * r - o * i, c = a * i + o * r;
return Math.abs(s) <= e.size.x / 2 && Math.abs(c) <= e.size.y / 2;
}
function tr(e, t, n) {
let r = e.center.x + t.x, i = e.center.y + t.y;
return n ? n.set(r, i, e.size.x, e.size.y, Jn(e), Yn(e)) : new Xn({
x: r,
y: i
}, e.size, Jn(e), Yn(e));
}
function nr(e, t, n) {
return n ? n.set(e.center.x, e.center.y, e.size.x, e.size.y, Jn(e) + t, Yn(e)) : new Xn(e.center, e.size, Jn(e) + t, Yn(e));
}
function rr(e, t, n = e.center, r) {
let i = typeof t == "number" ? t : t.x, a = typeof t == "number" ? t : t.y, o = n.x + (e.center.x - n.x) * i, s = n.y + (e.center.y - n.y) * a, c = e.size.x * i, l = e.size.y * a;
return r ? r.set(o, s, c, l, Jn(e), Yn(e)) : new Xn({
x: o,
y: s
}, {
x: c,
y: l
}, Jn(e), Yn(e));
}
//#endregion
//#region ../geometry/src/lib/intersections.ts
function ir(e, t, n = kn) {
var r, i;
if (e.elevation != null && t.elevation != null && Math.abs(e.elevation - t.elevation) > n) return null;
let { x: a, y: o } = e.p0, { x: s, y: c } = e.p1, { x: l, y: u } = t.p0, { x: d, y: f } = t.p1, p = (a - s) * (u - f) - (o - c) * (l - d);
if (p === 0) return null;
let m = ((a - l) * (u - f) - (o - u) * (l - d)) / p, h = ((a - l) * (o - c) - (o - u) * (a - s)) / p, g = Mn(e.p0, e.p1, m);
return g.z = (r = (i = e.elevation) == null ? t.elevation : i) == null ? 0 : r, {
point: g,
onLine1: m >= 0 && m <= 1,
onLine2: h >= 0 && h <= 1
};
}
function ar(e, t, n) {
let r = ir(e, t, n);
return r != null && r.onLine1 && r.onLine2 ? r.point : null;
}
function or(e, t, n = kn) {
var r, i;
if (e.elevation != null && t.elevation != null && Math.abs(e.elevation - t.elevation) > n) return [];
let a = (r = (i = e.elevation) == null ? t.elevation : i) == null ? 0 : r, o = Zn(t), s = [];
for (let t = 0; t < 4; t++) {
let r = ar(e, {
p0: o[t],
p1: o[(t + 1) % 4]
}, n);
r && (r.z = a, s.push(r));
}
return s;
}
//#endregion
//#region ../geometry/src/lib/box.ts
function* sr(e) {
for (let t of e) yield t.min, yield t.max;
}
var cr = class e {
constructor(e = 0, t = 0, n = 0, r = 0) {
this.isBox = !0, this._min = new An(), this._max = new An(), this._center = new An(), this._size = new An(), this.set(e, t, e + n, t + r);
}
get min() {
return this._min;
}
get max() {
return this._max;
}
get center() {
return this._center;
}
get size() {
return this._size;
}
get area() {
return lr(this);
}
isEmpty() {
return ur(this);
}
static fromMinMax(t, n) {
return new e(t.x, t.y, n.x - t.x, n.y - t.y);
}
static fromCenter(t, n) {
return new e(t.x - n.x / 2, t.y - n.y / 2, n.x, n.y);
}
static fromUnion(...t) {
return e.fromPoints(sr(t));
}
static fromPoints(t) {
let n = Infinity, r = Infinity, i = -Infinity, a = -Infinity;
for (let e of t) e.x < n && (n = e.x), e.y < r && (r = e.y), e.x > i && (i = e.x), e.y > a && (a = e.y);
return n === Infinity ? new e() : e.fromMinMax({
x: n,
y: r
}, {
x: i,
y: a
});
}
static fromSvg(t) {
return new e(t.x.baseVal.value, t.y.baseVal.value, t.width.baseVal.value, t.height.baseVal.value);
}
intersects(e) {
return dr(this, e);
}
contains(e) {
return fr(this, e);
}
containsPoint(e) {
return pr(this, e);
}
equals(e) {
return mr(this, e);
}
intersection(e, t) {
return hr(this, e, t);
}
translate(e, t) {
return gr(this, e, t);
}
expand(e, t) {
return _r(this, e, t);
}
scale(e, t = this._center, n) {
return vr(this, e, t, n);
}
intersectLine(e) {
return or(e, this);
}
clone(t) {
return (t == null ? new e() : t).set(this._min.x, this._min.y, this._max.x, this._max.y);
}
set(e, t, n, r) {
let i = Math.min(e, n), a = Math.min(t, r), o = Math.max(e, n), s = Math.max(t, r);
return this._min.set(i, a), this._max.set(o, s), this._center.set((i + o) / 2, (a + s) / 2), this._size.set(o - i, s - a), this;
}
};
function lr(e) {
return (e.max.x - e.min.x) * (e.max.y - e.min.y);
}
function ur(e) {
return e.min.x === e.max.x && e.min.y === e.max.y;
}
function dr(e, t) {
return e.min.x <= t.max.x && e.max.x >= t.min.x && e.min.y <= t.max.y && e.max.y >= t.min.y;
}
function fr(e, t) {
return t.min.x >= e.min.x && t.max.x <= e.max.x && t.min.y >= e.min.y && t.max.y <= e.max.y;
}
function pr(e, t) {
return t.x >= e.min.x && t.x <= e.max.x && t.y >= e.min.y && t.y <= e.max.y;
}
function mr(e, t) {
return e.min.x === t.min.x && e.min.y === t.min.y && e.max.x === t.max.x && e.max.y === t.max.y;
}
function hr(e, t, n) {
let r = Math.max(e.min.x, t.min.x), i = Math.max(e.min.y, t.min.y), a = Math.min(e.max.x, t.max.x), o = Math.min(e.max.y, t.max.y);
return a < r || o < i ? null : (n == null ? new cr() : n).set(r, i, a, o);
}
function gr(e, t, n) {
let r = typeof t == "number" ? t : t.x, i = typeof t == "number" ? t : t.y;
return (n == null ? new cr() : n).set(e.min.x + r, e.min.y + i, e.max.x + r, e.max.y + i);
}
function _r(e, t, n) {
let r = typeof t == "number", i = r ? t : t.x, a = r ? t : t.y, o = e.min.x - i, s = e.max.x + i, c = e.min.y - a, l = e.max.y + a;
return s < o && (o = s = (o + s) / 2), l < c && (c = l = (c + l) / 2), (n == null ? new cr() : n).set(o, c, s, l);
}
function vr(e, t, n = {
x: (e.min.x + e.max.x) / 2,
y: (e.min.y + e.max.y) / 2
}, r) {
let i = typeof t == "number" ? t : t.x, a = typeof t == "number" ? t : t.y;
return (r == null ? new cr() : r).set(n.x + (e.min.x - n.x) * i, n.y + (e.min.y - n.y) * a, n.x + (e.max.x - n.x) * i, n.y + (e.max.y - n.y) * a);
}
//#endregion
//#region ../geometry/src/index.ts
function yr(e) {
return "isBox" in e;
}
function br(e) {
return "isRect" in e;
}
function xr(e) {
return "isPolygon" in e;
}
function Sr(e) {
return "isMesh" in e;
}
//#endregion
//#region src/components/Map/camera.ts
function Cr(e) {
return {
get api() {
return e.current.api;
},
state: () => e.current.state()
};
}
function wr(e) {
Er = e;
}
function Tr() {
return Er;
}
var Er, Dr = we("data", () => s());
//#endregion
//#region src/data/fp-payloads.ts
function Or() {
let e = s().fpSvgJsRef;
if (!e) throw Error("No drawing in the config (fpSvgJsRef is not set)");
return n(e);
}
function kr(e) {
let t = s().fpSvgLayerJsRefs[e];
if (t && i(t)) return n(t);
let r = Or();
if (e === "" || e === r.__fpDefaultLayer) return r;
}
function Ar(e = "") {
var t;
return (t = kr(e)) == null ? void 0 : t.__fp;
}
function jr(e = "") {
var t;
return (t = kr(e)) == null ? void 0 : t.__fpPaths;
}
function Mr() {
var e;
let t = s().wfDataJsRef;
return !t || !i(t) || (e = n(t).__wfData) == null ? null : e;
}
var Nr = {
svg: "http://www.w3.org/2000/svg",
xhtml: "http://www.w3.org/1999/xhtml",
xlink: "http://www.w3.org/1999/xlink",
xml: "http://www.w3.org/XML/1998/namespace",
xmlns: "http://www.w3.org/2000/xmlns/"
};
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/namespace.js
function Pr(e) {
var t = e += "", n = t.indexOf(":");
return n >= 0 && (t = e.slice(0, n)) !== "xmlns" && (e = e.slice(n + 1)), Nr.hasOwnProperty(t) ? {
space: Nr[t],
local: e
} : e;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/creator.js
function Fr(e) {
return function() {
var t = this.ownerDocument, n = this.namespaceURI;
return n === "http://www.w3.org/1999/xhtml" && t.documentElement.namespaceURI === "http://www.w3.org/1999/xhtml" ? t.createElement(e) : t.createElementNS(n, e);
};
}
function Ir(e) {
return function() {
return this.ownerDocument.createElementNS(e.space, e.local);
};
}
function Lr(e) {
var t = Pr(e);
return (t.local ? Ir : Fr)(t);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selector.js
function Rr() {}
function zr(e) {
return e == null ? Rr : function() {
return this.querySelector(e);
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/select.js
function Br(e) {
typeof e != "function" && (e = zr(e));
for (var t = this._groups, n = t.length, r = Array(n), i = 0; i < n; ++i) for (var a = t[i], o = a.length, s = r[i] = Array(o), c, l, u = 0; u < o; ++u) (c = a[u]) && (l = e.call(c, c.__data__, u, a)) && ("__data__" in c && (l.__data__ = c.__data__), s[u] = l);
return new Oa(r, this._parents);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/array.js
function Vr(e) {
return e == null ? [] : Array.isArray(e) ? e : Array.from(e);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selectorAll.js
function Hr() {
return [];
}
function Ur(e) {
return e == null ? Hr : function() {
return this.querySelectorAll(e);
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectAll.js
function Wr(e) {
return function() {
return Vr(e.apply(this, arguments));
};
}
function Gr(e) {
e = typeof e == "function" ? Wr(e) : Ur(e);
for (var t = this._groups, n = t.length, r = [], i = [], a = 0; a < n; ++a) for (var o = t[a], s = o.length, c, l = 0; l < s; ++l) (c = o[l]) && (r.push(e.call(c, c.__data__, l, o)), i.push(c));
return new Oa(r, i);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/matcher.js
function Kr(e) {
return function() {
return this.matches(e);
};
}
function qr(e) {
return function(t) {
return t.matches(e);
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChild.js
var Jr = Array.prototype.find;
function Yr(e) {
return function() {
return Jr.call(this.children, e);
};
}
function Xr() {
return this.firstElementChild;
}
function Zr(e) {
return this.select(e == null ? Xr : Yr(typeof e == "function" ? e : qr(e)));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/selectChildren.js
var Qr = Array.prototype.filter;
function $r() {
return Array.from(this.children);
}
function ei(e) {
return function() {
return Qr.call(this.children, e);
};
}
function ti(e) {
return this.selectAll(e == null ? $r : ei(typeof e == "function" ? e : qr(e)));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/filter.js
function ni(e) {
typeof e != "function" && (e = Kr(e));
for (var t = this._groups, n = t.length, r = Array(n), i = 0; i < n; ++i) for (var a = t[i], o = a.length, s = r[i] = [], c, l = 0; l < o; ++l) (c = a[l]) && e.call(c, c.__data__, l, a) && s.push(c);
return new Oa(r, this._parents);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sparse.js
function ri(e) {
return Array(e.length);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/enter.js
function ii() {
return new Oa(this._enter || this._groups.map(ri), this._parents);
}
function ai(e, t) {
this.ownerDocument = e.ownerDocument, this.namespaceURI = e.namespaceURI, this._next = null, this._parent = e, this.__data__ = t;
}
ai.prototype = {
constructor: ai,
appendChild: function(e) {
return this._parent.insertBefore(e, this._next);
},
insertBefore: function(e, t) {
return this._parent.insertBefore(e, t);
},
querySelector: function(e) {
return this._parent.querySelector(e);
},
querySelectorAll: function(e) {
return this._parent.querySelectorAll(e);
}
};
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/constant.js
function oi(e) {
return function() {
return e;
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/data.js
function si(e, t, n, r, i, a) {
for (var o = 0, s, c = t.length, l = a.length; o < l; ++o) (s = t[o]) ? (s.__data__ = a[o], r[o] = s) : n[o] = new ai(e, a[o]);
for (; o < c; ++o) (s = t[o]) && (i[o] = s);
}
function ci(e, t, n, r, i, a, o) {
var s, c, l = /* @__PURE__ */ new Map(), u = t.length, d = a.length, f = Array(u), p;
for (s = 0; s < u; ++s) (c = t[s]) && (f[s] = p = o.call(c, c.__data__, s, t) + "", l.has(p) ? i[s] = c : l.set(p, c));
for (s = 0; s < d; ++s) p = o.call(e, a[s], s, a) + "", (c = l.get(p)) ? (r[s] = c, c.__data__ = a[s], l.delete(p)) : n[s] = new ai(e, a[s]);
for (s = 0; s < u; ++s) (c = t[s]) && l.get(f[s]) === c && (i[s] = c);
}
function li(e) {
return e.__data__;
}
function ui(e, t) {
if (!arguments.length) return Array.from(this, li);
var n = t ? ci : si, r = this._parents, i = this._groups;
typeof e != "function" && (e = oi(e));
for (var a = i.length, o = Array(a), s = Array(a), c = Array(a), l = 0; l < a; ++l) {
var u = r[l], d = i[l], f = d.length, p = di(e.call(u, u && u.__data__, l, r)), m = p.length, h = s[l] = Array(m), g = o[l] = Array(m);
n(u, d, h, g, c[l] = Array(f), p, t);
for (var _ = 0, v = 0, y, b; _ < m; ++_) if (y = h[_]) {
for (_ >= v && (v = _ + 1); !(b = g[v]) && ++v < m;);
y._next = b || null;
}
}
return o = new Oa(o, r), o._enter = s, o._exit = c, o;
}
function di(e) {
return typeof e == "object" && "length" in e ? e : Array.from(e);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/exit.js
function fi() {
return new Oa(this._exit || this._groups.map(ri), this._parents);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/join.js
function pi(e, t, n) {
var r = this.enter(), i = this, a = this.exit();
return typeof e == "function" ? (r = e(r), r && (r = r.selection())) : r = r.append(e + ""), t != null && (i = t(i), i && (i = i.selection())), n == null ? a.remove() : n(a), r && i ? r.merge(i).order() : i;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/merge.js
function mi(e) {
for (var t = e.selection ? e.selection() : e, n = this._groups, r = t._groups, i = n.length, a = r.length, o = Math.min(i, a), s = Array(i), c = 0; c < o; ++c) for (var l = n[c], u = r[c], d = l.length, f = s[c] = Array(d), p, m = 0; m < d; ++m) (p = l[m] || u[m]) && (f[m] = p);
for (; c < i; ++c) s[c] = n[c];
return new Oa(s, this._parents);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/order.js
function hi() {
for (var e = this._groups, t = -1, n = e.length; ++t < n;) for (var r = e[t], i = r.length - 1, a = r[i], o; --i >= 0;) (o = r[i]) && (a && o.compareDocumentPosition(a) ^ 4 && a.parentNode.insertBefore(o, a), a = o);
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/sort.js
function gi(e) {
e || (e = _i);
function t(t, n) {
return t && n ? e(t.__data__, n.__data__) : !t - !n;
}
for (var n = this._groups, r = n.length, i = Array(r), a = 0; a < r; ++a) {
for (var o = n[a], s = o.length, c = i[a] = Array(s), l, u = 0; u < s; ++u) (l = o[u]) && (c[u] = l);
c.sort(t);
}
return new Oa(i, this._parents).order();
}
function _i(e, t) {
return e < t ? -1 : e > t ? 1 : e >= t ? 0 : NaN;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/call.js
function vi() {
var e = arguments[0];
return arguments[0] = this, e.apply(null, arguments), this;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/nodes.js
function yi() {
return Array.from(this);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/node.js
function bi() {
for (var e = this._groups, t = 0, n = e.length; t < n; ++t) for (var r = e[t], i = 0, a = r.length; i < a; ++i) {
var o = r[i];
if (o) return o;
}
return null;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/size.js
function xi() {
let e = 0;
for (let t of this) ++e;
return e;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/empty.js
function Si() {
return !this.node();
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/each.js
function Ci(e) {
for (var t = this._groups, n = 0, r = t.length; n < r; ++n) for (var i = t[n], a = 0, o = i.length, s; a < o; ++a) (s = i[a]) && e.call(s, s.__data__, a, i);
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/attr.js
function wi(e) {
return function() {
this.removeAttribute(e);
};
}
function Ti(e) {
return function() {
this.removeAttributeNS(e.space, e.local);
};
}
function Ei(e, t) {
return function() {
this.setAttribute(e, t);
};
}
function Di(e, t) {
return function() {
this.setAttributeNS(e.space, e.local, t);
};
}
function Oi(e, t) {
return function() {
var n = t.apply(this, arguments);
n == null ? this.removeAttribute(e) : this.setAttribute(e, n);
};
}
function ki(e, t) {
return function() {
var n = t.apply(this, arguments);
n == null ? this.removeAttributeNS(e.space, e.local) : this.setAttributeNS(e.space, e.local, n);
};
}
function Ai(e, t) {
var n = Pr(e);
if (arguments.length < 2) {
var r = this.node();
return n.local ? r.getAttributeNS(n.space, n.local) : r.getAttribute(n);
}
return this.each((t == null ? n.local ? Ti : wi : typeof t == "function" ? n.local ? ki : Oi : n.local ? Di : Ei)(n, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/window.js
function ji(e) {
return e.ownerDocument && e.ownerDocument.defaultView || e.document && e || e.defaultView;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/style.js
function Mi(e) {
return function() {
this.style.removeProperty(e);
};
}
function Ni(e, t, n) {
return function() {
this.style.setProperty(e, t, n);
};
}
function Pi(e, t, n) {
return function() {
var r = t.apply(this, arguments);
r == null ? this.style.removeProperty(e) : this.style.setProperty(e, r, n);
};
}
function Fi(e, t, n) {
return arguments.length > 1 ? this.each((t == null ? Mi : typeof t == "function" ? Pi : Ni)(e, t, n == null ? "" : n)) : Ii(this.node(), e);
}
function Ii(e, t) {
return e.style.getPropertyValue(t) || ji(e).getComputedStyle(e, null).getPropertyValue(t);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/property.js
function Li(e) {
return function() {
delete this[e];
};
}
function Ri(e, t) {
return function() {
this[e] = t;
};
}
function zi(e, t) {
return function() {
var n = t.apply(this, arguments);
n == null ? delete this[e] : this[e] = n;
};
}
function Bi(e, t) {
return arguments.length > 1 ? this.each((t == null ? Li : typeof t == "function" ? zi : Ri)(e, t)) : this.node()[e];
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/classed.js
function Vi(e) {
return e.trim().split(/^|\s+/);
}
function Hi(e) {
return e.classList || new Ui(e);
}
function Ui(e) {
this._node = e, this._names = Vi(e.getAttribute("class") || "");
}
Ui.prototype = {
add: function(e) {
this._names.indexOf(e) < 0 && (this._names.push(e), this._node.setAttribute("class", this._names.join(" ")));
},
remove: function(e) {
var t = this._names.indexOf(e);
t >= 0 && (this._names.splice(t, 1), this._node.setAttribute("class", this._names.join(" ")));
},
contains: function(e) {
return this._names.indexOf(e) >= 0;
}
};
function Wi(e, t) {
for (var n = Hi(e), r = -1, i = t.length; ++r < i;) n.add(t[r]);
}
function Gi(e, t) {
for (var n = Hi(e), r = -1, i = t.length; ++r < i;) n.remove(t[r]);
}
function Ki(e) {
return function() {
Wi(this, e);
};
}
function qi(e) {
return function() {
Gi(this, e);
};
}
function Ji(e, t) {
return function() {
(t.apply(this, arguments) ? Wi : Gi)(this, e);
};
}
function Yi(e, t) {
var n = Vi(e + "");
if (arguments.length < 2) {
for (var r = Hi(this.node()), i = -1, a = n.length; ++i < a;) if (!r.contains(n[i])) return !1;
return !0;
}
return this.each((typeof t == "function" ? Ji : t ? Ki : qi)(n, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/text.js
function Xi() {
this.textContent = "";
}
function Zi(e) {
return function() {
this.textContent = e;
};
}
function Qi(e) {
return function() {
var t = e.apply(this, arguments);
this.textContent = t == null ? "" : t;
};
}
function $i(e) {
return arguments.length ? this.each(e == null ? Xi : (typeof e == "function" ? Qi : Zi)(e)) : this.node().textContent;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/html.js
function ea() {
this.innerHTML = "";
}
function ta(e) {
return function() {
this.innerHTML = e;
};
}
function na(e) {
return function() {
var t = e.apply(this, arguments);
this.innerHTML = t == null ? "" : t;
};
}
function ra(e) {
return arguments.length ? this.each(e == null ? ea : (typeof e == "function" ? na : ta)(e)) : this.node().innerHTML;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/raise.js
function ia() {
this.nextSibling && this.parentNode.appendChild(this);
}
function aa() {
return this.each(ia);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/lower.js
function oa() {
this.previousSibling && this.parentNode.insertBefore(this, this.parentNode.firstChild);
}
function sa() {
return this.each(oa);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/append.js
function ca(e) {
var t = typeof e == "function" ? e : Lr(e);
return this.select(function() {
return this.appendChild(t.apply(this, arguments));
});
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/insert.js
function la() {
return null;
}
function ua(e, t) {
var n = typeof e == "function" ? e : Lr(e), r = t == null ? la : typeof t == "function" ? t : zr(t);
return this.select(function() {
return this.insertBefore(n.apply(this, arguments), r.apply(this, arguments) || null);
});
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/remove.js
function da() {
var e = this.parentNode;
e && e.removeChild(this);
}
function fa() {
return this.each(da);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/clone.js
function pa() {
var e = this.cloneNode(!1), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function ma() {
var e = this.cloneNode(!0), t = this.parentNode;
return t ? t.insertBefore(e, this.nextSibling) : e;
}
function ha(e) {
return this.select(e ? ma : pa);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/datum.js
function ga(e) {
return arguments.length ? this.property("__data__", e) : this.node().__data__;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/on.js
function _a(e) {
return function(t) {
e.call(this, t, this.__data__);
};
}
function va(e) {
return e.trim().split(/^|\s+/).map(function(e) {
var t = "", n = e.indexOf(".");
return n >= 0 && (t = e.slice(n + 1), e = e.slice(0, n)), {
type: e,
name: t
};
});
}
function ya(e) {
return function() {
var t = this.__on;
if (t) {
for (var n = 0, r = -1, i = t.length, a; n < i; ++n) a = t[n], (!e.type || a.type === e.type) && a.name === e.name ? this.removeEventListener(a.type, a.listener, a.options) : t[++r] = a;
++r ? t.length = r : delete this.__on;
}
};
}
function ba(e, t, n) {
return function() {
var r = this.__on, i, a = _a(t);
if (r) {
for (var o = 0, s = r.length; o < s; ++o) if ((i = r[o]).type === e.type && i.name === e.name) {
this.removeEventListener(i.type, i.listener, i.options), this.addEventListener(i.type, i.listener = a, i.options = n), i.value = t;
return;
}
}
this.addEventListener(e.type, a, n), i = {
type: e.type,
name: e.name,
value: t,
listener: a,
options: n
}, r ? r.push(i) : this.__on = [i];
};
}
function xa(e, t, n) {
var r = va(e + ""), i, a = r.length, o;
if (arguments.length < 2) {
var s = this.node().__on;
if (s) {
for (var c = 0, l = s.length, u; c < l; ++c) for (i = 0, u = s[c]; i < a; ++i) if ((o = r[i]).type === u.type && o.name === u.name) return u.value;
}
return;
}
for (s = t ? ba : ya, i = 0; i < a; ++i) this.each(s(r[i], t, n));
return this;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/dispatch.js
function Sa(e, t, n) {
var r = ji(e), i = r.CustomEvent;
typeof i == "function" ? i = new i(t, n) : (i = r.document.createEvent("Event"), n ? (i.initEvent(t, n.bubbles, n.cancelable), i.detail = n.detail) : i.initEvent(t, !1, !1)), e.dispatchEvent(i);
}
function Ca(e, t) {
return function() {
return Sa(this, e, t);
};
}
function wa(e, t) {
return function() {
return Sa(this, e, t.apply(this, arguments));
};
}
function Ta(e, t) {
return this.each((typeof t == "function" ? wa : Ca)(e, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/iterator.js
function* Ea() {
for (var e = this._groups, t = 0, n = e.length; t < n; ++t) for (var r = e[t], i = 0, a = r.length, o; i < a; ++i) (o = r[i]) && (yield o);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/selection/index.js
var Da = [null];
function Oa(e, t) {
this._groups = e, this._parents = t;
}
function ka() {
return new Oa([[document.documentElement]], Da);
}
function Aa() {
return this;
}
Oa.prototype = ka.prototype = {
constructor: Oa,
select: Br,
selectAll: Gr,
selectChild: Zr,
selectChildren: ti,
filter: ni,
data: ui,
enter: ii,
exit: fi,
join: pi,
merge: mi,
selection: Aa,
order: hi,
sort: gi,
call: vi,
nodes: yi,
node: bi,
size: xi,
empty: Si,
each: Ci,
attr: Ai,
style: Fi,
property: Bi,
classed: Yi,
text: $i,
html: ra,
raise: aa,
lower: sa,
append: ca,
insert: ua,
remove: fa,
clone: ha,
datum: ga,
on: xa,
dispatch: Ta,
[Symbol.iterator]: Ea
};
//#endregion
//#region ../../node_modules/.pnpm/d3-selection@3.0.0/node_modules/d3-selection/src/select.js
function ja(e) {
return typeof e == "string" ? new Oa([[document.querySelector(e)]], [document.documentElement]) : new Oa([[e]], Da);
}
//#endregion
//#region src/utils/extractMetaFromString.ts
function Ma(e) {
let t = e.split("$$");
if (t.length !== 2) return {
text: e,
meta: {}
};
let [n, r] = t;
return {
text: n,
meta: r.split(",").reduce((e, t) => {
let [n, r] = t.split(":");
if (n) {
var i;
e[n.trim()] = (i = r == null ? void 0 : r.trim()) == null ? "" : i;
}
return e;
}, {})
};
}
//#endregion
//#region src/data/svg.ts
var Na = Oe();
function Pa(e, t = "") {
var n;
let r = Na().get(t);
if (r) return r;
let i = new DOMParser().parseFromString(e, "image/svg+xml").documentElement;
((n = i.firstChild) == null ? void 0 : n.tagName) === "parsererror" && w.error("Parsed svg with error: ", i);
let a = /* @__PURE__ */ new Map();
return ja(i).selectAll("style").each(function() {
var e;
let t = (e = this.textContent) == null ? "" : e, n = /\.([a-z0-9.]+)\s*{[^}]*fill\s*:\s*([^};]+);[^}]*}/gi, r;
for (; (r = n.exec(t)) !== null;) {
let e = r[1], t = r[2];
a.set(e, t);
}
}), ja(i).selectAll("*[class]").each(function() {
let e = a.get(this.className.baseVal);
e !== void 0 && (this.style.fill = e);
}), Ua(i), Na().set(t, i), i;
}
function Fa() {
var e;
let t = Pa((e = Ar()) == null ? "" : e), n = Or().__viewbox, r = ja(t).select("rect#VIEWBOX").node(), i = t.viewBox.baseVal, a = new cr(i.x, i.y, i.width, i.height), o, s = !1;
n ? (o = new cr(n.x, n.y, n.width, n.height), s = !0, r == null || r.remove()) : r ? (o = cr.fromSvg(r), s = !0, r.remove()) : o = a.scale(1.1), ja(t).attr("width", a.size.width), ja(t).attr("height", a.size.height), w.log("svgArea", o, "svgViewBox", a);
let c = Or().__fpLayersMode ? ja(t).selectAll("[data-floor]").nodes().map((e) => {
var t;
return e.remove(), {
name: (t = e.dataset.floor) == null ? "" : t,
rect: cr.fromSvg(e)
};
}).sort() : [];
return {
area: o,
areaExplicit: s,
floors: c
};
}
var Ia = De(Fa);
function La() {
return Ia().area;
}
function Ra() {
return Ia().areaExplicit;
}
function za() {
return Ia().floors;
}
function Ba(e, t) {
let n = Va(e, t), r = n.positions.map((e) => [e[0], Math.abs(e[1])]), i = [];
for (let e of n.cells) i.push([
r[e[0]],
r[e[1]],
r[e[2]]
]);
return i;
}
function Va(e, t = "") {
var n;
let r = (n = jr(t)) == null ? jr() : n;
if (!r) throw Error(`No meshes for layer "${t}"`);
return r[e];
}
function Ha(e = "") {
var t, n;
Ia();
let r = typeof e == "string" ? e : (t = (n = e.rootParent) == null ? void 0 : n.name) == null ? e.name : t, i = Na().get(r);
if (i) return i;
let a = Ar(r);
return a ? Pa(a, r) : Na().get("");
}
function Ua(e) {
ja(e).selectAll("[id], [data-name]").each(function() {
let e = {}, t = this.getAttribute("data-name");
if (t && t.includes("$$")) {
let { meta: n } = Ma(t);
e = {
...e,
...n
};
}
let n = this.getAttribute("id");
if (n && n.includes("$$")) {
let { meta: t } = Ma(n);
e = {
...e,
...t
};
}
this.setAttribute("data-meta", JSON.stringify(e));
});
}
//#endregion
//#region src/tools/settings.ts
var Wa = /* @__PURE__ */ e((/* @__PURE__ */ t(((e, t) => {
var n = function(e) {
return r(e) && !i(e);
};
function r(e) {
return !!e && typeof e == "object";
}
function i(e) {
var t = Object.prototype.toString.call(e);
return t === "[object RegExp]" || t === "[object Date]" || o(e);
}
var a = typeof Symbol == "function" && Symbol.for ? Symbol.for("react.element") : 60103;
function o(e) {
return e.$$typeof === a;
}
function s(e) {
return Array.isArray(e) ? [] : {};
}
function c(e, t) {
return t.clone !== !1 && t.isMergeableObject(e) ? g(s(e), e, t) : e;
}
function l(e, t, n) {
return e.concat(t).map(function(e) {
return c(e, n);
});
}
function u(e, t) {
if (!t.customMerge) return g;
var n = t.customMerge(e);
return typeof n == "function" ? n : g;
}
function d(e) {
return Object.getOwnPropertySymbols ? Object.getOwnPropertySymbols(e).filter(function(t) {
return Object.propertyIsEnumerable.call(e, t);
}) : [];
}
function f(e) {
return Object.keys(e).concat(d(e));
}
function p(e, t) {
try {
return t in e;
} catch {
return !1;
}
}
function m(e, t) {
return p(e, t) && !(Object.hasOwnProperty.call(e, t) && Object.propertyIsEnumerable.call(e, t));
}
function h(e, t, n) {
var r = {};
return n.isMergeableObject(e) && f(e).forEach(function(t) {
r[t] = c(e[t], n);
}), f(t).forEach(function(i) {
m(e, i) || (p(e, i) && n.isMergeableObject(t[i]) ? r[i] = u(i, n)(e[i], t[i], n) : r[i] = c(t[i], n));
}), r;
}
function g(e, t, r) {
r = r || {}, r.arrayMerge = r.arrayMerge || l, r.isMergeableObject = r.isMergeableObject || n, r.cloneUnlessOtherwiseSpecified = c;
var i = Array.isArray(t);
return i === Array.isArray(e) ? i ? r.arrayMerge(e, t, r) : h(e, t, r) : c(t, r);
}
g.all = function(e, t) {
if (!Array.isArray(e)) throw Error("first argument should be an array");
return e.reduce(function(e, n) {
return g(e, n, t);
}, {});
}, t.exports = g;
})))(), 1), Ga = class {
constructor() {
this.boothLabelColor = "#fff", this.boothBorderColor = "#fff", this.backgroundColor = "#ebebeb", this.boothBorderWidth = void 0, this.heatmapColors = [
"#FDE7C7",
"#FDDBAE",
"#FDC48D",
"#FCB37C",
"#FCA26D",
"#F67B5B",
"#EB483E",
"#E03143",
"#6C0022"
], this.maxZoom = void 0;
}
}, Ka = class extends Ga {
constructor(...e) {
super(...e), this.EXPO = s().expo, this.borderless = !1, this.wayfinding = !1, this.colors = { booths: {
default: "#41b6e7",
defaultHold: "#48484A",
defaultSold: "#41b6e7",
seectedLight: null,
selected: "#fb3e59",
selectedBorder: null,
wayfinding: {
selected: "#0088D6",
selectedBorder: null
},
empty: "#aaaaaa"
} };
}
};
function qa() {
var e;
let t = new Ka();
t.EXPO.startsWith("sxsw2024") ? (t.colors.booths.selected = "#FF6400", t.colors.booths.seectedLight = "#808080") : t.EXPO === "whxdubai2026" ? (t.colors.booths.selected = "#2B66FE", t.maxZoom = 450) : t.EXPO === "whxlabs2026" ? t.colors.booths.selected = "#2B66FE" : (t.EXPO === "wineparis2026" || t.EXPO === "rdemo2025") && (t.maxZoom = 450);
let n = window.__settings, r = (e = Or().__fpSettings) == null ? {} : e;
return t = (0, Wa.default)(t, n == null ? r : n), t = (0, Wa.default)(t, r), t.wayfinding = !!(!s().hideDirections && Mr()), t;
}
var Ja = we("settings", De(qa));
//#endregion
//#region src/utils/areLayersEnabled.ts
function Ya() {
return !!Or().__fpLayers;
}
//#endregion
//#region src/components/Map/drawing/config/pin-geometry.ts
function Xa(e) {
return e > 99 ? "99+" : String(e);
}
function Za(e) {
let t = e * eo;
return {
cx: e / 2,
cy: t + to,
r: t * no
};
}
function Qa(e) {
let t = 3 * ro / 2, n = ao / 2;
return oo * e / Math.hypot(t, n);
}
var $a = 93 / 81, eo = .37, to = 1.4, no = .78, ro = .58, io = .61, ao = .72, oo = .88;
//#endregion
//#region src/components/Map/drawing/config/canvases.ts
function so(e, t, n = 1) {
let r = document.createElement("canvas");
return r.width = e, r.height = t, r.style.width = `${e / n}px`, r.style.height = `${t / n}px`, r;
}
function co(e) {
return {
width: parseFloat(e.style.width),
height: parseFloat(e.style.height)
};
}
function lo(e, t, n, r, i = 1, a, o) {
let s = n * i, c = r * i;
return new Xn({
x: e,
y: t
}, {
x: s,
y: c
}, a, o);
}
function uo(e, t = 500, n = "normal") {
let r = getComputedStyle(document.body).getPropertyValue(d), i = "Oswald, -apple-system, system-ui, BlinkMacSystemFont, \"Segoe UI\", Roboto, \"Helvetica Neue\", Arial, sans-serif";
return `${n} ${t} ${e}px ${r ? `${r}, ${i}` : i}`;
}
function fo(e) {
return e * 2 + go * 2;
}
function po(e, t) {
let n = t.toUpperCase();
if (!_o.has(n)) {
let r = fo(e), i = so(r * devicePixelRatio, r * devicePixelRatio, devicePixelRatio), a = i.getContext("2d");
a.fillStyle = t, a.beginPath(), a.arc(i.width / 2, i.height / 2, e * devicePixelRatio, 0, 2 * Math.PI), a.fill(), _o.set(n, i);
}
return _o.get(n);
}
function mo(e) {
return {
width: e,
height: e * 1.4
};
}
function ho(e, t) {
let n = e;
if (vo.has(n)) return vo.get(n);
let { width: r, height: i } = mo(e), a = so(Math.ceil(r * t), Math.ceil(i * t), t), o = a.getContext("2d");
return o.scale(t, t), o.fillStyle = "#fdbf2b", o.strokeStyle = "#fff", o.lineWidth = 4 / t, o.beginPath(), o.moveTo(0, 0), o.lineTo(0, i), o.lineTo(r / 2, i - r / 2), o.lineTo(r, i), o.lineTo(r, 0), o.lineTo(0, 0), o.fill(), o.stroke(), vo.set(n, a), a;
}
var go = 1, _o = /* @__PURE__ */ new Map(), vo = /* @__PURE__ */ new Map();
function yo(e, t, n, r = 1) {
let [i, a] = xo(e, t, n, t * r, n * r);
return {
width: i,
height: a
};
}
function bo(e, t, n, r, i = 1, a) {
let [o, s] = xo(e, t, n, t * r * i, n * r * i), c = so(o, s, r), l = c.getContext("2d");
return c.id = e.id, a === "horizontal" ? (l.scale(-1, 1), l.translate(-o, 0)) : a === "vertical" && (l.scale(1, -1), l.translate(0, -s)), l.drawImage(e, 0, 0, o, s), c;
}
function xo(e, t, n, r, i) {
let a = e ? e.width / e.height : 1;
return t / n > a ? [i * a, i] : [r, r / a];
}
function So(e, t = "#c8248b", n = e * .4, r, i, a, o = "#000") {
r = r || 95, i = i || 95;
let s = so(r * n, i * n, e), c = s.getContext("2d");
c.scale(n, n);
let l = r / 2, u = i / 2;
return c.translate(l - 35, a ? 0 : u - 35), c.beginPath(), c.fillStyle = "#FFFFFF", c.moveTo(0, 35), c.bezierCurveTo(0, 54.329966, 15.670034, 70, 35, 70), c.bezierCurveTo(54.329966, 70, 70, 54.329966, 70, 35), c.bezierCurveTo(70, 15.670034, 54.329966, 0, 35, 0), c.bezierCurveTo(15.670034, 0, 0, 15.670034, 0, 35), c.fill(), c.beginPath(), c.fillStyle = t, c.moveTo(10, 35), c.bezierCurveTo(10, 48.807119, 21.192881, 60, 35, 60), c.bezierCurveTo(48.807119, 60, 60, 48.807119, 60, 35), c.bezierCurveTo(60, 21.192881, 48.807119, 10, 35, 10), c.bezierCurveTo(21.192881, 10, 10, 21.192881, 10, 35), c.fill(), a && (c.textAlign = "center", c.textBaseline = "alphabetic", c.lineJoin = "round", c.strokeStyle = "#fff", c.fillStyle = o, c.font = uo(38), c.lineWidth = 6, c.strokeText(a, 35, 108, r), c.fillText(a, 35, 108, r)), s;
}
function Co(e, t = "#c8248b", n = e * .5) {
let r = so(70 * n, 100 * n, e), i = r.getContext("2d");
return i.scale(n, n), i.beginPath(), i.fillStyle = "rgb(255, 255, 255)", i.moveTo(32.6, 97.8), i.bezierCurveTo(24.4, 81.5, 0, 57, 0, 32.6), i.bezierCurveTo(0, 14.6, 14.6, 0, 32.6, 0), i.bezierCurveTo(50.5, 0, 65.2, 14.6, 65.2, 32.6), i.bezierCurveTo(65.2, 57, 40.7, 81.5, 32.6, 97.8), i.fill(), i.beginPath(), i.fillStyle = t, i.moveTo(32.6, 91.1), i.bezierCurveTo(25.2, 76.3, 3.1, 54.2, 3.1, 32.1), i.bezierCurveTo(3.1, 15.9, 16.3, 2.6, 32.6, 2.6), i.bezierCurveTo(48.8, 2.6, 62, 15.9, 62, 32.1), i.bezierCurveTo(62, 54.2, 39.9, 76.3, 32.6, 91.1), i.fill(), i.beginPath(), i.fillStyle = "rgb(255, 255, 255)", i.moveTo(16.2, 32.6), i.bezierCurveTo(16.2, 41.6, 23.5, 48.9, 32.5, 48.9), i.bezierCurveTo(41.5, 48.9, 48.8, 41.6, 48.8, 32.6), i.bezierCurveTo(48.8, 23.6, 41.5, 16.3, 32.5, 16.3), i.bezierCurveTo(23.5, 16.3, 16.2, 23.6, 16.2, 32.6), i.fill(), r;
}
function wo(e, t = "#c8248b", n = e * .4) {
let r = so(95 * n, 95 * n, e), i = r.getContext("2d");
return i.scale(n, n), i.beginPath(), i.arc(47, 47, 25, 0, 2 * Math.PI), i.fillStyle = t, i.fill(), i.beginPath(), i.fillStyle = t, i.moveTo(75, 27), i.lineTo(95, 47), i.lineTo(75, 67), i.lineTo(80, 47), i.closePath(), i.fill(), r;
}
function To(e, t = "#ff4343", n = e * .5) {
let r = so(77 * n, 116 * n, e), i = r.getContext("2d");
return i.scale(n, n), i.scale(n, n), i.beginPath(), i.fillStyle = "#FFFFFF", i.moveTo(68.303, 57.335), i.bezierCurveTo(77.894, 39.304, 70.649, 15.785, 50.95, 8.04), i.bezierCurveTo(30.727, 0, 8.375, 11.837, 3.207, 32.831), i.bezierCurveTo(0, 46.185, 6.644, 57.323, 13.131, 68.211), i.fill(), i.beginPath(), i.fillStyle = t, i.moveTo(51.565, 35.459), i.bezierCurveTo(51.565, 43.256, 45.201, 49.575, 37.354, 49.575), i.bezierCurveTo(29.516, 49.575, 23.159, 43.256, 23.159, 35.459), i.bezierCurveTo(23.159, 27.668, 29.516, 21.345, 37.354, 21.345), i.bezierCurveTo(45.201, 21.345, 51.565, 27.668, 51.565, 35.459), i.closePath(), i.fill(), i.beginPath(), i.moveTo(68.303, 57.335), i.bezierCurveTo(77.894, 39.304, 70.649, 15.785, 50.95, 8.04), i.bezierCurveTo(30.727, 0, 8.375, 11.837, 3.207, 32.831), i.bezierCurveTo(0, 46.185, 6.644, 57.323, 13.131, 68.211), i.lineTo(13.131, 68.211), i.lineTo(13.131, 68.211), i.bezierCurveTo(13.921, 69.533, 14.698, 70.829, 15.454, 72.137), i.bezierCurveTo(19.465, 79.158, 23.533, 86.12, 27.571, 93.086), i.lineTo(27.571, 93.086), i.bezierCurveTo(30.098, 97.421, 32.611, 101.756, 35.116, 106.077), i.bezierCurveTo(36.128, 107.868, 38.934, 107.868, 39.945, 106.077), i.bezierCurveTo(49.387, 90.003, 58.708, 74.029, 68.031, 57.951), i.bezierCurveTo(68.15, 57.743, 68.24, 57.543, 68.303, 57.335), i.closePath(), i.moveTo(60.103, 60.395), i.lineTo(63.201, 55.041), i.lineTo(63.201, 55.041), i.bezierCurveTo(73.31, 36.735, 61.285, 11.614, 39.04, 11.17), i.bezierCurveTo(19.388, 10.714, 2.759, 29.479, 9.386, 49.013), i.bezierCurveTo(10.726, 52.998, 12.657, 56.9, 14.84, 60.721), i.bezierCurveTo(15.041, 58.454, 15.938, 56.258, 17.589, 54.586), i.bezierCurveTo(19.708, 52.425, 22.216, 50.638, 24.996, 49.283), i.bezierCurveTo(28.252, 52.249, 32.595, 54.051, 37.354, 54.051), i.bezierCurveTo(42.123, 54.051, 46.47, 52.249, 49.73, 49.283), i.bezierCurveTo(52.505, 50.638, 55.017, 52.425, 57.135, 54.586), i.bezierCurveTo(58.701, 56.188, 59.701, 58.245, 60.103, 60.395), i.closePath(), i.fill("evenodd"), i.beginPath(), i.moveTo(29.024, 104.982), i.bezierCurveTo(29.024, 103.626, 27.923, 102.527, 26.57, 102.527), i.bezierCurveTo(25.214, 102.527, 24.114, 103.626, 24.114, 104.982), i.bezierCurveTo(24.114, 111.395, 30.347, 116.838, 37.444, 116.838), i.bezierCurveTo(44.54, 116.838, 50.771, 111.395, 50.771, 104.982), i.bezierCurveTo(50.771, 103.626, 49.666, 102.527, 48.317, 102.527), i.bezierCurveTo(46.961, 102.527, 45.855, 103.626, 45.855, 104.982), i.bezierCurveTo(45.855, 108.193, 42.352, 111.956, 37.444, 111.956), i.bezierCurveTo(32.528, 111.956, 29.024, 108.193, 29.024, 104.982), i.closePath(), i.fill(), r;
}
var Eo = "#ffffff", Do = .45, Oo = "#e8112d", ko = "#000000";
function Ao(e, t, n, r, i) {
let a = t / 2, o = r + i, s = n - i;
e.beginPath(), e.moveTo(a, s), e.bezierCurveTo(a - r * .55, o + r * .8, a - r, o + r * .35, a - r, o), e.bezierCurveTo(a - r, o - r * .72, a - r * .45, o - r, a, o - r), e.bezierCurveTo(a + r * .45, o - r, a + r, o - r * .72, a + r, o), e.bezierCurveTo(a + r, o + r * .35, a + r * .55, o + r * .8, a, s), e.closePath();
}
function jo(e, t, n, r, i, a, o = Eo) {
let s = e, c = e * t, l = so(s * n, c * n, n), u = l.getContext("2d");
u.scale(n, n);
let d = s * r;
return Ao(u, s, c, d, i), u.fillStyle = a, u.strokeStyle = o, u.lineWidth = i, u.lineJoin = "round", u.fill(), u.stroke(), {
canvas: l,
ctx: u,
cx: s / 2,
cy: d + i,
r: d
};
}
function Mo(e, t) {
let { canvas: n, ctx: r, cx: i, cy: a, r: o } = jo(e, $a, t, eo, to, Oo, ko);
return r.beginPath(), r.arc(i, a, o * Do, 0, 2 * Math.PI), r.fillStyle = Eo, r.fill(), n;
}
function No(e, t) {
let { canvas: n, ctx: r } = jo(e, $a, t, eo, to, Oo, ko), { cx: i, cy: a, r: o } = Za(e);
return r.beginPath(), r.arc(i, a, o, 0, 2 * Math.PI), r.fillStyle = Eo, r.fill(), n;
}
//#endregion
//#region ../../node_modules/.pnpm/color-name@1.1.4/node_modules/color-name/index.js
var Po = /* @__PURE__ */ t(((e, t) => {
t.exports = {
aliceblue: [
240,
248,
255
],
antiquewhite: [
250,
235,
215
],
aqua: [
0,
255,
255
],
aquamarine: [
127,
255,
212
],
azure: [
240,
255,
255
],
beige: [
245,
245,
220
],
bisque: [
255,
228,
196
],
black: [
0,
0,
0
],
blanchedalmond: [
255,
235,
205
],
blue: [
0,
0,
255
],
blueviolet: [
138,
43,
226
],
brown: [
165,
42,
42
],
burlywood: [
222,
184,
135
],
cadetblue: [
95,
158,
160
],
chartreuse: [
127,
255,
0
],
chocolate: [
210,
105,
30
],
coral: [
255,
127,
80
],
cornflowerblue: [
100,
149,
237
],
cornsilk: [
255,
248,
220
],
crimson: [
220,
20,
60
],
cyan: [
0,
255,
255
],
darkblue: [
0,
0,
139
],
darkcyan: [
0,
139,
139
],
darkgoldenrod: [
184,
134,
11
],
darkgray: [
169,
169,
169
],
darkgreen: [
0,
100,
0
],
darkgrey: [
169,
169,
169
],
darkkhaki: [
189,
183,
107
],
darkmagenta: [
139,
0,
139
],
darkolivegreen: [
85,
107,
47
],
darkorange: [
255,
140,
0
],
darkorchid: [
153,
50,
204
],
darkred: [
139,
0,
0
],
darksalmon: [
233,
150,
122
],
darkseagreen: [
143,
188,
143
],
darkslateblue: [
72,
61,
139
],
darkslategray: [
47,
79,
79
],
darkslategrey: [
47,
79,
79
],
darkturquoise: [
0,
206,
209
],
darkviolet: [
148,
0,
211
],
deeppink: [
255,
20,
147
],
deepskyblue: [
0,
191,
255
],
dimgray: [
105,
105,
105
],
dimgrey: [
105,
105,
105
],
dodgerblue: [
30,
144,
255
],
firebrick: [
178,
34,
34
],
floralwhite: [
255,
250,
240
],
forestgreen: [
34,
139,
34
],
fuchsia: [
255,
0,
255
],
gainsboro: [
220,
220,
220
],
ghostwhite: [
248,
248,
255
],
gold: [
255,
215,
0
],
goldenrod: [
218,
165,
32
],
gray: [
128,
128,
128
],
green: [
0,
128,
0
],
greenyellow: [
173,
255,
47
],
grey: [
128,
128,
128
],
honeydew: [
240,
255,
240
],
hotpink: [
255,
105,
180
],
indianred: [
205,
92,
92
],
indigo: [
75,
0,
130
],
ivory: [
255,
255,
240
],
khaki: [
240,
230,
140
],
lavender: [
230,
230,
250
],
lavenderblush: [
255,
240,
245
],
lawngreen: [
124,
252,
0
],
lemonchiffon: [
255,
250,
205
],
lightblue: [
173,
216,
230
],
lightcoral: [
240,
128,
128
],
lightcyan: [
224,
255,
255
],
lightgoldenrodyellow: [
250,
250,
210
],
lightgray: [
211,
211,
211
],
lightgreen: [
144,
238,
144
],
lightgrey: [
211,
211,
211
],
lightpink: [
255,
182,
193
],
lightsalmon: [
255,
160,
122
],
lightseagreen: [
32,
178,
170
],
lightskyblue: [
135,
206,
250
],
lightslategray: [
119,
136,
153
],
lightslategrey: [
119,
136,
153
],
lightsteelblue: [
176,
196,
222
],
lightyellow: [
255,
255,
224
],
lime: [
0,
255,
0
],
limegreen: [
50,
205,
50
],
linen: [
250,
240,
230
],
magenta: [
255,
0,
255
],
maroon: [
128,
0,
0
],
mediumaquamarine: [
102,
205,
170
],
mediumblue: [
0,
0,
205
],
mediumorchid: [
186,
85,
211
],
mediumpurple: [
147,
112,
219
],
mediumseagreen: [
60,
179,
113
],
mediumslateblue: [
123,
104,
238
],
mediumspringgreen: [
0,
250,
154
],
mediumturquoise: [
72,
209,
204
],
mediumvioletred: [
199,
21,
133
],
midnightblue: [
25,
25,
112
],
mintcream: [
245,
255,
250
],
mistyrose: [
255,
228,
225
],
moccasin: [
255,
228,
181
],
navajowhite: [
255,
222,
173
],
navy: [
0,
0,
128
],
oldlace: [
253,
245,
230
],
olive: [
128,
128,
0
],
olivedrab: [
107,
142,
35
],
orange: [
255,
165,
0
],
orangered: [
255,
69,
0
],
orchid: [
218,
112,
214
],
palegoldenrod: [
238,
232,
170
],
palegreen: [
152,
251,
152
],
paleturquoise: [
175,
238,
238
],
palevioletred: [
219,
112,
147
],
papayawhip: [
255,
239,
213
],
peachpuff: [
255,
218,
185
],
peru: [
205,
133,
63
],
pink: [
255,
192,
203
],
plum: [
221,
160,
221
],
powderblue: [
176,
224,
230
],
purple: [
128,
0,
128
],
rebeccapurple: [
102,
51,
153
],
red: [
255,
0,
0
],
rosybrown: [
188,
143,
143
],
royalblue: [
65,
105,
225
],
saddlebrown: [
139,
69,
19
],
salmon: [
250,
128,
114
],
sandybrown: [
244,
164,
96
],
seagreen: [
46,
139,
87
],
seashell: [
255,
245,
238
],
sienna: [
160,
82,
45
],
silver: [
192,
192,
192
],
skyblue: [
135,
206,
235
],
slateblue: [
106,
90,
205
],
slategray: [
112,
128,
144
],
slategrey: [
112,
128,
144
],
snow: [
255,
250,
250
],
springgreen: [
0,
255,
127
],
steelblue: [
70,
130,
180
],
tan: [
210,
180,
140
],
teal: [
0,
128,
128
],
thistle: [
216,
191,
216
],
tomato: [
255,
99,
71
],
turquoise: [
64,
224,
208
],
violet: [
238,
130,
238
],
wheat: [
245,
222,
179
],
white: [
255,
255,
255
],
whitesmoke: [
245,
245,
245
],
yellow: [
255,
255,
0
],
yellowgreen: [
154,
205,
50
]
};
})), Fo = /* @__PURE__ */ t(((e, t) => {
t.exports = function(e) {
return !e || typeof e == "string" ? !1 : e instanceof Array || Array.isArray(e) || e.length >= 0 && (e.splice instanceof Function || Object.getOwnPropertyDescriptor(e, e.length - 1) && e.constructor.name !== "String");
};
})), Io = /* @__PURE__ */ t(((e, t) => {
var n = Fo(), r = Array.prototype.concat, i = Array.prototype.slice, a = t.exports = function(e) {
for (var t = [], a = 0, o = e.length; a < o; a++) {
var s = e[a];
n(s) ? t = r.call(t, i.call(s)) : t.push(s);
}
return t;
};
a.wrap = function(e) {
return function() {
return e(a(arguments));
};
};
})), Lo = /* @__PURE__ */ t(((e, t) => {
var n = Po(), r = Io(), i = Object.hasOwnProperty, a = Object.create(null);
for (var o in n) i.call(n, o) && (a[n[o]] = o);
var s = t.exports = {
to: {},
get: {}
};
s.get = function(e) {
var t = e.substring(0, 3).toLowerCase(), n, r;
switch (t) {
case "hsl":
n = s.get.hsl(e), r = "hsl";
break;
case "hwb":
n = s.get.hwb(e), r = "hwb";
break;
default:
n = s.get.rgb(e), r = "rgb";
break;
}
return n ? {
model: r,
value: n
} : null;
}, s.get.rgb = function(e) {
if (!e) return null;
var t = /^#([a-f0-9]{3,4})$/i, r = /^#([a-f0-9]{6})([a-f0-9]{2})?$/i, a = /^rgba?\(\s*([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)(?=[\s,])\s*(?:,\s*)?([+-]?\d+)\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/, o = /^rgba?\(\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*,?\s*([+-]?[\d\.]+)\%\s*(?:[,|\/]\s*([+-]?[\d\.]+)(%?)\s*)?\)$/, s = /^(\w+)$/, l = [
0,
0,
0,
1
], u, d, f;
if (u = e.match(r)) {
for (f = u[2], u = u[1], d = 0; d < 3; d++) {
var p = d * 2;
l[d] = parseInt(u.slice(p, p + 2), 16);
}
f && (l[3] = parseInt(f, 16) / 255);
} else if (u = e.match(t)) {
for (u = u[1], f = u[3], d = 0; d < 3; d++) l[d] = parseInt(u[d] + u[d], 16);
f && (l[3] = parseInt(f + f, 16) / 255);
} else if (u = e.match(a)) {
for (d = 0; d < 3; d++) l[d] = parseInt(u[d + 1], 0);
u[4] && (u[5] ? l[3] = parseFloat(u[4]) * .01 : l[3] = parseFloat(u[4]));
} else if (u = e.match(o)) {
for (d = 0; d < 3; d++) l[d] = Math.round(parseFloat(u[d + 1]) * 2.55);
u[4] && (u[5] ? l[3] = parseFloat(u[4]) * .01 : l[3] = parseFloat(u[4]));
} else if (u = e.match(s)) return u[1] === "transparent" ? [
0,
0,
0,
0
] : i.call(n, u[1]) ? (l = n[u[1]], l[3] = 1, l) : null;
else return null;
for (d = 0; d < 3; d++) l[d] = c(l[d], 0, 255);
return l[3] = c(l[3], 0, 1), l;
}, s.get.hsl = function(e) {
if (!e) return null;
var t = e.match(/^hsla?\(\s*([+-]?(?:\d{0,3}\.)?\d+)(?:deg)?\s*,?\s*([+-]?[\d\.]+)%\s*,?\s*([+-]?[\d\.]+)%\s*(?:[,|\/]\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);
if (t) {
var n = parseFloat(t[4]);
return [
(parseFloat(t[1]) % 360 + 360) % 360,
c(parseFloat(t[2]), 0, 100),
c(parseFloat(t[3]), 0, 100),
c(isNaN(n) ? 1 : n, 0, 1)
];
}
return null;
}, s.get.hwb = function(e) {
if (!e) return null;
var t = e.match(/^hwb\(\s*([+-]?\d{0,3}(?:\.\d+)?)(?:deg)?\s*,\s*([+-]?[\d\.]+)%\s*,\s*([+-]?[\d\.]+)%\s*(?:,\s*([+-]?(?=\.\d|\d)(?:0|[1-9]\d*)?(?:\.\d*)?(?:[eE][+-]?\d+)?)\s*)?\)$/);
if (t) {
var n = parseFloat(t[4]);
return [
(parseFloat(t[1]) % 360 + 360) % 360,
c(parseFloat(t[2]), 0, 100),
c(parseFloat(t[3]), 0, 100),
c(isNaN(n) ? 1 : n, 0, 1)
];
}
return null;
}, s.to.hex = function() {
var e = r(arguments);
return "#" + l(e[0]) + l(e[1]) + l(e[2]) + (e[3] < 1 ? l(Math.round(e[3] * 255)) : "");
}, s.to.rgb = function() {
var e = r(arguments);
return e.length < 4 || e[3] === 1 ? "rgb(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ")" : "rgba(" + Math.round(e[0]) + ", " + Math.round(e[1]) + ", " + Math.round(e[2]) + ", " + e[3] + ")";
}, s.to.rgb.percent = function() {
var e = r(arguments), t = Math.round(e[0] / 255 * 100), n = Math.round(e[1] / 255 * 100), i = Math.round(e[2] / 255 * 100);
return e.length < 4 || e[3] === 1 ? "rgb(" + t + "%, " + n + "%, " + i + "%)" : "rgba(" + t + "%, " + n + "%, " + i + "%, " + e[3] + ")";
}, s.to.hsl = function() {
var e = r(arguments);
return e.length < 4 || e[3] === 1 ? "hsl(" + e[0] + ", " + e[1] + "%, " + e[2] + "%)" : "hsla(" + e[0] + ", " + e[1] + "%, " + e[2] + "%, " + e[3] + ")";
}, s.to.hwb = function() {
var e = r(arguments), t = "";
return e.length >= 4 && e[3] !== 1 && (t = ", " + e[3]), "hwb(" + e[0] + ", " + e[1] + "%, " + e[2] + "%" + t + ")";
}, s.to.keyword = function(e) {
return a[e.slice(0, 3)];
};
function c(e, t, n) {
return Math.min(Math.max(t, e), n);
}
function l(e) {
var t = Math.round(e).toString(16).toUpperCase();
return t.length < 2 ? "0" + t : t;
}
})), Ro = /* @__PURE__ */ t(((e, t) => {
t.exports = {
aliceblue: [
240,
248,
255
],
antiquewhite: [
250,
235,
215
],
aqua: [
0,
255,
255
],
aquamarine: [
127,
255,
212
],
azure: [
240,
255,
255
],
beige: [
245,
245,
220
],
bisque: [
255,
228,
196
],
black: [
0,
0,
0
],
blanchedalmond: [
255,
235,
205
],
blue: [
0,
0,
255
],
blueviolet: [
138,
43,
226
],
brown: [
165,
42,
42
],
burlywood: [
222,
184,
135
],
cadetblue: [
95,
158,
160
],
chartreuse: [
127,
255,
0
],
chocolate: [
210,
105,
30
],
coral: [
255,
127,
80
],
cornflowerblue: [
100,
149,
237
],
cornsilk: [
255,
248,
220
],
crimson: [
220,
20,
60
],
cyan: [
0,
255,
255
],
darkblue: [
0,
0,
139
],
darkcyan: [
0,
139,
139
],
darkgoldenrod: [
184,
134,
11
],
darkgray: [
169,
169,
169
],
darkgreen: [
0,
100,
0
],
darkgrey: [
169,
169,
169
],
darkkhaki: [
189,
183,
107
],
darkmagenta: [
139,
0,
139
],
darkolivegreen: [
85,
107,
47
],
darkorange: [
255,
140,
0
],
darkorchid: [
153,
50,
204
],
darkred: [
139,
0,
0
],
darksalmon: [
233,
150,
122
],
darkseagreen: [
143,
188,
143
],
darkslateblue: [
72,
61,
139
],
darkslategray: [
47,
79,
79
],
darkslategrey: [
47,
79,
79
],
darkturquoise: [
0,
206,
209
],
darkviolet: [
148,
0,
211
],
deeppink: [
255,
20,
147
],
deepskyblue: [
0,
191,
255
],
dimgray: [
105,
105,
105
],
dimgrey: [
105,
105,
105
],
dodgerblue: [
30,
144,
255
],
firebrick: [
178,
34,
34
],
floralwhite: [
255,
250,
240
],
forestgreen: [
34,
139,
34
],
fuchsia: [
255,
0,
255
],
gainsboro: [
220,
220,
220
],
ghostwhite: [
248,
248,
255
],
gold: [
255,
215,
0
],
goldenrod: [
218,
165,
32
],
gray: [
128,
128,
128
],
green: [
0,
128,
0
],
greenyellow: [
173,
255,
47
],
grey: [
128,
128,
128
],
honeydew: [
240,
255,
240
],
hotpink: [
255,
105,
180
],
indianred: [
205,
92,
92
],
indigo: [
75,
0,
130
],
ivory: [
255,
255,
240
],
khaki: [
240,
230,
140
],
lavender: [
230,
230,
250
],
lavenderblush: [
255,
240,
245
],
lawngreen: [
124,
252,
0
],
lemonchiffon: [
255,
250,
205
],
lightblue: [
173,
216,
230
],
lightcoral: [
240,
128,
128
],
lightcyan: [
224,
255,
255
],
lightgoldenrodyellow: [
250,
250,
210
],
lightgray: [
211,
211,
211
],
lightgreen: [
144,
238,
144
],
lightgrey: [
211,
211,
211
],
lightpink: [
255,
182,
193
],
lightsalmon: [
255,
160,
122
],
lightseagreen: [
32,
178,
170
],
lightskyblue: [
135,
206,
250
],
lightslategray: [
119,
136,
153
],
lightslategrey: [
119,
136,
153
],
lightsteelblue: [
176,
196,
222
],
lightyellow: [
255,
255,
224
],
lime: [
0,
255,
0
],
limegreen: [
50,
205,
50
],
linen: [
250,
240,
230
],
magenta: [
255,
0,
255
],
maroon: [
128,
0,
0
],
mediumaquamarine: [
102,
205,
170
],
mediumblue: [
0,
0,
205
],
mediumorchid: [
186,
85,
211
],
mediumpurple: [
147,
112,
219
],
mediumseagreen: [
60,
179,
113
],
mediumslateblue: [
123,
104,
238
],
mediumspringgreen: [
0,
250,
154
],
mediumturquoise: [
72,
209,
204
],
mediumvioletred: [
199,
21,
133
],
midnightblue: [
25,
25,
112
],
mintcream: [
245,
255,
250
],
mistyrose: [
255,
228,
225
],
moccasin: [
255,
228,
181
],
navajowhite: [
255,
222,
173
],
navy: [
0,
0,
128
],
oldlace: [
253,
245,
230
],
olive: [
128,
128,
0
],
olivedrab: [
107,
142,
35
],
orange: [
255,
165,
0
],
orangered: [
255,
69,
0
],
orchid: [
218,
112,
214
],
palegoldenrod: [
238,
232,
170
],
palegreen: [
152,
251,
152
],
paleturquoise: [
175,
238,
238
],
palevioletred: [
219,
112,
147
],
papayawhip: [
255,
239,
213
],
peachpuff: [
255,
218,
185
],
peru: [
205,
133,
63
],
pink: [
255,
192,
203
],
plum: [
221,
160,
221
],
powderblue: [
176,
224,
230
],
purple: [
128,
0,
128
],
rebeccapurple: [
102,
51,
153
],
red: [
255,
0,
0
],
rosybrown: [
188,
143,
143
],
royalblue: [
65,
105,
225
],
saddlebrown: [
139,
69,
19
],
salmon: [
250,
128,
114
],
sandybrown: [
244,
164,
96
],
seagreen: [
46,
139,
87
],
seashell: [
255,
245,
238
],
sienna: [
160,
82,
45
],
silver: [
192,
192,
192
],
skyblue: [
135,
206,
235
],
slateblue: [
106,
90,
205
],
slategray: [
112,
128,
144
],
slategrey: [
112,
128,
144
],
snow: [
255,
250,
250
],
springgreen: [
0,
255,
127
],
steelblue: [
70,
130,
180
],
tan: [
210,
180,
140
],
teal: [
0,
128,
128
],
thistle: [
216,
191,
216
],
tomato: [
255,
99,
71
],
turquoise: [
64,
224,
208
],
violet: [
238,
130,
238
],
wheat: [
245,
222,
179
],
white: [
255,
255,
255
],
whitesmoke: [
245,
245,
245
],
yellow: [
255,
255,
0
],
yellowgreen: [
154,
205,
50
]
};
})), zo = /* @__PURE__ */ t(((e, t) => {
var n = Ro(), r = {};
for (var i in n) n.hasOwnProperty(i) && (r[n[i]] = i);
var a = t.exports = {
rgb: {
channels: 3,
labels: "rgb"
},
hsl: {
channels: 3,
labels: "hsl"
},
hsv: {
channels: 3,
labels: "hsv"
},
hwb: {
channels: 3,
labels: "hwb"
},
cmyk: {
channels: 4,
labels: "cmyk"
},
xyz: {
channels: 3,
labels: "xyz"
},
lab: {
channels: 3,
labels: "lab"
},
lch: {
channels: 3,
labels: "lch"
},
hex: {
channels: 1,
labels: ["hex"]
},
keyword: {
channels: 1,
labels: ["keyword"]
},
ansi16: {
channels: 1,
labels: ["ansi16"]
},
ansi256: {
channels: 1,
labels: ["ansi256"]
},
hcg: {
channels: 3,
labels: [
"h",
"c",
"g"
]
},
apple: {
channels: 3,
labels: [
"r16",
"g16",
"b16"
]
},
gray: {
channels: 1,
labels: ["gray"]
}
};
for (var o in a) if (a.hasOwnProperty(o)) {
if (!("channels" in a[o])) throw Error("missing channels property: " + o);
if (!("labels" in a[o])) throw Error("missing channel labels property: " + o);
if (a[o].labels.length !== a[o].channels) throw Error("channel and label counts mismatch: " + o);
var s = a[o].channels, c = a[o].labels;
delete a[o].channels, delete a[o].labels, Object.defineProperty(a[o], "channels", { value: s }), Object.defineProperty(a[o], "labels", { value: c });
}
a.rgb.hsl = function(e) {
var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = a - i, s, c, l;
return a === i ? s = 0 : t === a ? s = (n - r) / o : n === a ? s = 2 + (r - t) / o : r === a && (s = 4 + (t - n) / o), s = Math.min(s * 60, 360), s < 0 && (s += 360), l = (i + a) / 2, c = a === i ? 0 : l <= .5 ? o / (a + i) : o / (2 - a - i), [
s,
c * 100,
l * 100
];
}, a.rgb.hsv = function(e) {
var t, n, r, i, a, o = e[0] / 255, s = e[1] / 255, c = e[2] / 255, l = Math.max(o, s, c), u = l - Math.min(o, s, c), d = function(e) {
return (l - e) / 6 / u + 1 / 2;
};
return u === 0 ? i = a = 0 : (a = u / l, t = d(o), n = d(s), r = d(c), o === l ? i = r - n : s === l ? i = 1 / 3 + t - r : c === l && (i = 2 / 3 + n - t), i < 0 ? i += 1 : i > 1 && --i), [
i * 360,
a * 100,
l * 100
];
}, a.rgb.hwb = function(e) {
var t = e[0], n = e[1], r = e[2], i = a.rgb.hsl(e)[0], o = 1 / 255 * Math.min(t, Math.min(n, r));
return r = 1 - 1 / 255 * Math.max(t, Math.max(n, r)), [
i,
o * 100,
r * 100
];
}, a.rgb.cmyk = function(e) {
var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i, a, o, s = Math.min(1 - t, 1 - n, 1 - r);
return i = (1 - t - s) / (1 - s) || 0, a = (1 - n - s) / (1 - s) || 0, o = (1 - r - s) / (1 - s) || 0, [
i * 100,
a * 100,
o * 100,
s * 100
];
};
function l(e, t) {
return (e[0] - t[0]) ** 2 + (e[1] - t[1]) ** 2 + (e[2] - t[2]) ** 2;
}
a.rgb.keyword = function(e) {
var t = r[e];
if (t) return t;
var i = Infinity, a;
for (var o in n) if (n.hasOwnProperty(o)) {
var s = n[o], c = l(e, s);
c < i && (i = c, a = o);
}
return a;
}, a.keyword.rgb = function(e) {
return n[e];
}, a.rgb.xyz = function(e) {
var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255;
t = t > .04045 ? ((t + .055) / 1.055) ** 2.4 : t / 12.92, n = n > .04045 ? ((n + .055) / 1.055) ** 2.4 : n / 12.92, r = r > .04045 ? ((r + .055) / 1.055) ** 2.4 : r / 12.92;
var i = t * .4124 + n * .3576 + r * .1805, a = t * .2126 + n * .7152 + r * .0722, o = t * .0193 + n * .1192 + r * .9505;
return [
i * 100,
a * 100,
o * 100
];
}, a.rgb.lab = function(e) {
var t = a.rgb.xyz(e), n = t[0], r = t[1], i = t[2], o, s, c;
return n /= 95.047, r /= 100, i /= 108.883, n = n > .008856 ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > .008856 ? r ** (1 / 3) : 7.787 * r + 16 / 116, i = i > .008856 ? i ** (1 / 3) : 7.787 * i + 16 / 116, o = 116 * r - 16, s = 500 * (n - r), c = 200 * (r - i), [
o,
s,
c
];
}, a.hsl.rgb = function(e) {
var t = e[0] / 360, n = e[1] / 100, r = e[2] / 100, i, a, o, s, c;
if (n === 0) return c = r * 255, [
c,
c,
c
];
a = r < .5 ? r * (1 + n) : r + n - r * n, i = 2 * r - a, s = [
0,
0,
0
];
for (var l = 0; l < 3; l++) o = t + 1 / 3 * -(l - 1), o < 0 && o++, o > 1 && o--, c = 6 * o < 1 ? i + (a - i) * 6 * o : 2 * o < 1 ? a : 3 * o < 2 ? i + (a - i) * (2 / 3 - o) * 6 : i, s[l] = c * 255;
return s;
}, a.hsl.hsv = function(e) {
var t = e[0], n = e[1] / 100, r = e[2] / 100, i = n, a = Math.max(r, .01), o, s;
return r *= 2, n *= r <= 1 ? r : 2 - r, i *= a <= 1 ? a : 2 - a, s = (r + n) / 2, o = r === 0 ? 2 * i / (a + i) : 2 * n / (r + n), [
t,
o * 100,
s * 100
];
}, a.hsv.rgb = function(e) {
var t = e[0] / 60, n = e[1] / 100, r = e[2] / 100, i = Math.floor(t) % 6, a = t - Math.floor(t), o = 255 * r * (1 - n), s = 255 * r * (1 - n * a), c = 255 * r * (1 - n * (1 - a));
switch (r *= 255, i) {
case 0: return [
r,
c,
o
];
case 1: return [
s,
r,
o
];
case 2: return [
o,
r,
c
];
case 3: return [
o,
s,
r
];
case 4: return [
c,
o,
r
];
case 5: return [
r,
o,
s
];
}
}, a.hsv.hsl = function(e) {
var t = e[0], n = e[1] / 100, r = e[2] / 100, i = Math.max(r, .01), a, o, s = (2 - n) * r;
return a = (2 - n) * i, o = n * i, o /= a <= 1 ? a : 2 - a, o = o || 0, s /= 2, [
t,
o * 100,
s * 100
];
}, a.hwb.rgb = function(e) {
var t = e[0] / 360, n = e[1] / 100, r = e[2] / 100, i = n + r, a, o, s, c;
i > 1 && (n /= i, r /= i), a = Math.floor(6 * t), o = 1 - r, s = 6 * t - a, a & 1 && (s = 1 - s), c = n + s * (o - n);
var l, u, d;
switch (a) {
default:
case 6:
case 0:
l = o, u = c, d = n;
break;
case 1:
l = c, u = o, d = n;
break;
case 2:
l = n, u = o, d = c;
break;
case 3:
l = n, u = c, d = o;
break;
case 4:
l = c, u = n, d = o;
break;
case 5:
l = o, u = n, d = c;
break;
}
return [
l * 255,
u * 255,
d * 255
];
}, a.cmyk.rgb = function(e) {
var t = e[0] / 100, n = e[1] / 100, r = e[2] / 100, i = e[3] / 100, a = 1 - Math.min(1, t * (1 - i) + i), o = 1 - Math.min(1, n * (1 - i) + i), s = 1 - Math.min(1, r * (1 - i) + i);
return [
a * 255,
o * 255,
s * 255
];
}, a.xyz.rgb = function(e) {
var t = e[0] / 100, n = e[1] / 100, r = e[2] / 100, i = t * 3.2406 + n * -1.5372 + r * -.4986, a = t * -.9689 + n * 1.8758 + r * .0415, o = t * .0557 + n * -.204 + r * 1.057;
return i = i > .0031308 ? 1.055 * i ** (1 / 2.4) - .055 : i * 12.92, a = a > .0031308 ? 1.055 * a ** (1 / 2.4) - .055 : a * 12.92, o = o > .0031308 ? 1.055 * o ** (1 / 2.4) - .055 : o * 12.92, i = Math.min(Math.max(0, i), 1), a = Math.min(Math.max(0, a), 1), o = Math.min(Math.max(0, o), 1), [
i * 255,
a * 255,
o * 255
];
}, a.xyz.lab = function(e) {
var t = e[0], n = e[1], r = e[2], i, a, o;
return t /= 95.047, n /= 100, r /= 108.883, t = t > .008856 ? t ** (1 / 3) : 7.787 * t + 16 / 116, n = n > .008856 ? n ** (1 / 3) : 7.787 * n + 16 / 116, r = r > .008856 ? r ** (1 / 3) : 7.787 * r + 16 / 116, i = 116 * n - 16, a = 500 * (t - n), o = 200 * (n - r), [
i,
a,
o
];
}, a.lab.xyz = function(e) {
var t = e[0], n = e[1], r = e[2], i, a = (t + 16) / 116, o;
i = n / 500 + a, o = a - r / 200;
var s = a ** 3, c = i ** 3, l = o ** 3;
return a = s > .008856 ? s : (a - 16 / 116) / 7.787, i = c > .008856 ? c : (i - 16 / 116) / 7.787, o = l > .008856 ? l : (o - 16 / 116) / 7.787, i *= 95.047, a *= 100, o *= 108.883, [
i,
a,
o
];
}, a.lab.lch = function(e) {
var t = e[0], n = e[1], r = e[2], i = Math.atan2(r, n) * 360 / 2 / Math.PI, a;
return i < 0 && (i += 360), a = Math.sqrt(n * n + r * r), [
t,
a,
i
];
}, a.lch.lab = function(e) {
var t = e[0], n = e[1], r = e[2], i, a, o = r / 360 * 2 * Math.PI;
return i = n * Math.cos(o), a = n * Math.sin(o), [
t,
i,
a
];
}, a.rgb.ansi16 = function(e) {
var t = e[0], n = e[1], r = e[2], i = 1 in arguments ? arguments[1] : a.rgb.hsv(e)[2];
if (i = Math.round(i / 50), i === 0) return 30;
var o = 30 + (Math.round(r / 255) << 2 | Math.round(n / 255) << 1 | Math.round(t / 255));
return i === 2 && (o += 60), o;
}, a.hsv.ansi16 = function(e) {
return a.rgb.ansi16(a.hsv.rgb(e), e[2]);
}, a.rgb.ansi256 = function(e) {
var t = e[0], n = e[1], r = e[2];
return t === n && n === r ? t < 8 ? 16 : t > 248 ? 231 : Math.round((t - 8) / 247 * 24) + 232 : 16 + 36 * Math.round(t / 255 * 5) + 6 * Math.round(n / 255 * 5) + Math.round(r / 255 * 5);
}, a.ansi16.rgb = function(e) {
var t = e % 10;
if (t === 0 || t === 7) return e > 50 && (t += 3.5), t = t / 10.5 * 255, [
t,
t,
t
];
var n = (~~(e > 50) + 1) * .5;
return [
(t & 1) * n * 255,
(t >> 1 & 1) * n * 255,
(t >> 2 & 1) * n * 255
];
}, a.ansi256.rgb = function(e) {
if (e >= 232) {
var t = (e - 232) * 10 + 8;
return [
t,
t,
t
];
}
e -= 16;
var n;
return [
Math.floor(e / 36) / 5 * 255,
Math.floor((n = e % 36) / 6) / 5 * 255,
n % 6 / 5 * 255
];
}, a.rgb.hex = function(e) {
var t = (((Math.round(e[0]) & 255) << 16) + ((Math.round(e[1]) & 255) << 8) + (Math.round(e[2]) & 255)).toString(16).toUpperCase();
return "000000".substring(t.length) + t;
}, a.hex.rgb = function(e) {
var t = e.toString(16).match(/[a-f0-9]{6}|[a-f0-9]{3}/i);
if (!t) return [
0,
0,
0
];
var n = t[0];
t[0].length === 3 && (n = n.split("").map(function(e) {
return e + e;
}).join(""));
var r = parseInt(n, 16);
return [
r >> 16 & 255,
r >> 8 & 255,
r & 255
];
}, a.rgb.hcg = function(e) {
var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.max(Math.max(t, n), r), a = Math.min(Math.min(t, n), r), o = i - a, s = o < 1 ? a / (1 - o) : 0, c = o <= 0 ? 0 : i === t ? (n - r) / o % 6 : i === n ? 2 + (r - t) / o : 4 + (t - n) / o + 4;
return c /= 6, c %= 1, [
c * 360,
o * 100,
s * 100
];
}, a.hsl.hcg = function(e) {
var t = e[1] / 100, n = e[2] / 100, r = 1, i = 0;
return r = n < .5 ? 2 * t * n : 2 * t * (1 - n), r < 1 && (i = (n - .5 * r) / (1 - r)), [
e[0],
r * 100,
i * 100
];
}, a.hsv.hcg = function(e) {
var t = e[1] / 100, n = e[2] / 100, r = t * n, i = 0;
return r < 1 && (i = (n - r) / (1 - r)), [
e[0],
r * 100,
i * 100
];
}, a.hcg.rgb = function(e) {
var t = e[0] / 360, n = e[1] / 100, r = e[2] / 100;
if (n === 0) return [
r * 255,
r * 255,
r * 255
];
var i = [
0,
0,
0
], a = t % 1 * 6, o = a % 1, s = 1 - o, c = 0;
switch (Math.floor(a)) {
case 0:
i[0] = 1, i[1] = o, i[2] = 0;
break;
case 1:
i[0] = s, i[1] = 1, i[2] = 0;
break;
case 2:
i[0] = 0, i[1] = 1, i[2] = o;
break;
case 3:
i[0] = 0, i[1] = s, i[2] = 1;
break;
case 4:
i[0] = o, i[1] = 0, i[2] = 1;
break;
default: i[0] = 1, i[1] = 0, i[2] = s;
}
return c = (1 - n) * r, [
(n * i[0] + c) * 255,
(n * i[1] + c) * 255,
(n * i[2] + c) * 255
];
}, a.hcg.hsv = function(e) {
var t = e[1] / 100, n = t + e[2] / 100 * (1 - t), r = 0;
return n > 0 && (r = t / n), [
e[0],
r * 100,
n * 100
];
}, a.hcg.hsl = function(e) {
var t = e[1] / 100, n = e[2] / 100 * (1 - t) + .5 * t, r = 0;
return n > 0 && n < .5 ? r = t / (2 * n) : n >= .5 && n < 1 && (r = t / (2 * (1 - n))), [
e[0],
r * 100,
n * 100
];
}, a.hcg.hwb = function(e) {
var t = e[1] / 100, n = t + e[2] / 100 * (1 - t);
return [
e[0],
(n - t) * 100,
(1 - n) * 100
];
}, a.hwb.hcg = function(e) {
var t = e[1] / 100, n = 1 - e[2] / 100, r = n - t, i = 0;
return r < 1 && (i = (n - r) / (1 - r)), [
e[0],
r * 100,
i * 100
];
}, a.apple.rgb = function(e) {
return [
e[0] / 65535 * 255,
e[1] / 65535 * 255,
e[2] / 65535 * 255
];
}, a.rgb.apple = function(e) {
return [
e[0] / 255 * 65535,
e[1] / 255 * 65535,
e[2] / 255 * 65535
];
}, a.gray.rgb = function(e) {
return [
e[0] / 100 * 255,
e[0] / 100 * 255,
e[0] / 100 * 255
];
}, a.gray.hsl = a.gray.hsv = function(e) {
return [
0,
0,
e[0]
];
}, a.gray.hwb = function(e) {
return [
0,
100,
e[0]
];
}, a.gray.cmyk = function(e) {
return [
0,
0,
0,
e[0]
];
}, a.gray.lab = function(e) {
return [
e[0],
0,
0
];
}, a.gray.hex = function(e) {
var t = Math.round(e[0] / 100 * 255) & 255, n = ((t << 16) + (t << 8) + t).toString(16).toUpperCase();
return "000000".substring(n.length) + n;
}, a.rgb.gray = function(e) {
return [(e[0] + e[1] + e[2]) / 3 / 255 * 100];
};
})), Bo = /* @__PURE__ */ t(((e, t) => {
var n = zo();
function r() {
for (var e = {}, t = Object.keys(n), r = t.length, i = 0; i < r; i++) e[t[i]] = {
distance: -1,
parent: null
};
return e;
}
function i(e) {
var t = r(), i = [e];
for (t[e].distance = 0; i.length;) for (var a = i.pop(), o = Object.keys(n[a]), s = o.length, c = 0; c < s; c++) {
var l = o[c], u = t[l];
u.distance === -1 && (u.distance = t[a].distance + 1, u.parent = a, i.unshift(l));
}
return t;
}
function a(e, t) {
return function(n) {
return t(e(n));
};
}
function o(e, t) {
for (var r = [t[e].parent, e], i = n[t[e].parent][e], o = t[e].parent; t[o].parent;) r.unshift(t[o].parent), i = a(n[t[o].parent][o], i), o = t[o].parent;
return i.conversion = r, i;
}
t.exports = function(e) {
for (var t = i(e), n = {}, r = Object.keys(t), a = r.length, s = 0; s < a; s++) {
var c = r[s];
t[c].parent !== null && (n[c] = o(c, t));
}
return n;
};
})), Vo = /* @__PURE__ */ t(((e, t) => {
var n = zo(), r = Bo(), i = {}, a = Object.keys(n);
function o(e) {
var t = function(t) {
return t == null ? t : (arguments.length > 1 && (t = Array.prototype.slice.call(arguments)), e(t));
};
return "conversion" in e && (t.conversion = e.conversion), t;
}
function s(e) {
var t = function(t) {
if (t == null) return t;
arguments.length > 1 && (t = Array.prototype.slice.call(arguments));
var n = e(t);
if (typeof n == "object") for (var r = n.length, i = 0; i < r; i++) n[i] = Math.round(n[i]);
return n;
};
return "conversion" in e && (t.conversion = e.conversion), t;
}
a.forEach(function(e) {
i[e] = {}, Object.defineProperty(i[e], "channels", { value: n[e].channels }), Object.defineProperty(i[e], "labels", { value: n[e].labels });
var t = r(e);
Object.keys(t).forEach(function(n) {
var r = t[n];
i[e][n] = s(r), i[e][n].raw = o(r);
});
}), t.exports = i;
})), Ho = /* @__PURE__ */ t(((e, t) => {
var n = Lo(), r = Vo(), i = [].slice, a = [
"keyword",
"gray",
"hex"
], o = {};
Object.keys(r).forEach(function(e) {
o[i.call(r[e].labels).sort().join("")] = e;
});
var s = {};
function c(e, t) {
if (!(this instanceof c)) return new c(e, t);
if (t && t in a && (t = null), t && !(t in r)) throw Error("Unknown model: " + t);
var l, u;
if (e == null) this.model = "rgb", this.color = [
0,
0,
0
], this.valpha = 1;
else if (e instanceof c) this.model = e.model, this.color = e.color.slice(), this.valpha = e.valpha;
else if (typeof e == "string") {
var d = n.get(e);
if (d === null) throw Error("Unable to parse color from string: " + e);
this.model = d.model, u = r[this.model].channels, this.color = d.value.slice(0, u), this.valpha = typeof d.value[u] == "number" ? d.value[u] : 1;
} else if (e.length) {
this.model = t || "rgb", u = r[this.model].channels;
var f = i.call(e, 0, u);
this.color = m(f, u), this.valpha = typeof e[u] == "number" ? e[u] : 1;
} else if (typeof e == "number") e &= 16777215, this.model = "rgb", this.color = [
e >> 16 & 255,
e >> 8 & 255,
e & 255
], this.valpha = 1;
else {
this.valpha = 1;
var p = Object.keys(e);
"alpha" in e && (p.splice(p.indexOf("alpha"), 1), this.valpha = typeof e.alpha == "number" ? e.alpha : 0);
var h = p.sort().join("");
if (!(h in o)) throw Error("Unable to parse color from object: " + JSON.stringify(e));
this.model = o[h];
var g = r[this.model].labels, _ = [];
for (l = 0; l < g.length; l++) _.push(e[g[l]]);
this.color = m(_);
}
if (s[this.model]) for (u = r[this.model].channels, l = 0; l < u; l++) {
var v = s[this.model][l];
v && (this.color[l] = v(this.color[l]));
}
this.valpha = Math.max(0, Math.min(1, this.valpha)), Object.freeze && Object.freeze(this);
}
c.prototype = {
toString: function() {
return this.string();
},
toJSON: function() {
return this[this.model]();
},
string: function(e) {
var t = this.model in n.to ? this : this.rgb();
t = t.round(typeof e == "number" ? e : 1);
var r = t.valpha === 1 ? t.color : t.color.concat(this.valpha);
return n.to[t.model](r);
},
percentString: function(e) {
var t = this.rgb().round(typeof e == "number" ? e : 1), r = t.valpha === 1 ? t.color : t.color.concat(this.valpha);
return n.to.rgb.percent(r);
},
array: function() {
return this.valpha === 1 ? this.color.slice() : this.color.concat(this.valpha);
},
object: function() {
for (var e = {}, t = r[this.model].channels, n = r[this.model].labels, i = 0; i < t; i++) e[n[i]] = this.color[i];
return this.valpha !== 1 && (e.alpha = this.valpha), e;
},
unitArray: function() {
var e = this.rgb().color;
return e[0] /= 255, e[1] /= 255, e[2] /= 255, this.valpha !== 1 && e.push(this.valpha), e;
},
unitObject: function() {
var e = this.rgb().object();
return e.r /= 255, e.g /= 255, e.b /= 255, this.valpha !== 1 && (e.alpha = this.valpha), e;
},
round: function(e) {
return e = Math.max(e || 0, 0), new c(this.color.map(u(e)).concat(this.valpha), this.model);
},
alpha: function(e) {
return arguments.length ? new c(this.color.concat(Math.max(0, Math.min(1, e))), this.model) : this.valpha;
},
red: d("rgb", 0, f(255)),
green: d("rgb", 1, f(255)),
blue: d("rgb", 2, f(255)),
hue: d([
"hsl",
"hsv",
"hsl",
"hwb",
"hcg"
], 0, function(e) {
return (e % 360 + 360) % 360;
}),
saturationl: d("hsl", 1, f(100)),
lightness: d("hsl", 2, f(100)),
saturationv: d("hsv", 1, f(100)),
value: d("hsv", 2, f(100)),
chroma: d("hcg", 1, f(100)),
gray: d("hcg", 2, f(100)),
white: d("hwb", 1, f(100)),
wblack: d("hwb", 2, f(100)),
cyan: d("cmyk", 0, f(100)),
magenta: d("cmyk", 1, f(100)),
yellow: d("cmyk", 2, f(100)),
black: d("cmyk", 3, f(100)),
x: d("xyz", 0, f(100)),
y: d("xyz", 1, f(100)),
z: d("xyz", 2, f(100)),
l: d("lab", 0, f(100)),
a: d("lab", 1),
b: d("lab", 2),
keyword: function(e) {
return arguments.length ? new c(e) : r[this.model].keyword(this.color);
},
hex: function(e) {
return arguments.length ? new c(e) : n.to.hex(this.rgb().round().color);
},
rgbNumber: function() {
var e = this.rgb().color;
return (e[0] & 255) << 16 | (e[1] & 255) << 8 | e[2] & 255;
},
luminosity: function() {
for (var e = this.rgb().color, t = [], n = 0; n < e.length; n++) {
var r = e[n] / 255;
t[n] = r <= .03928 ? r / 12.92 : ((r + .055) / 1.055) ** 2.4;
}
return .2126 * t[0] + .7152 * t[1] + .0722 * t[2];
},
contrast: function(e) {
var t = this.luminosity(), n = e.luminosity();
return t > n ? (t + .05) / (n + .05) : (n + .05) / (t + .05);
},
level: function(e) {
var t = this.contrast(e);
return t >= 7.1 ? "AAA" : t >= 4.5 ? "AA" : "";
},
isDark: function() {
var e = this.rgb().color;
return (e[0] * 299 + e[1] * 587 + e[2] * 114) / 1e3 < 128;
},
isLight: function() {
return !this.isDark();
},
negate: function() {
for (var e = this.rgb(), t = 0; t < 3; t++) e.color[t] = 255 - e.color[t];
return e;
},
lighten: function(e) {
var t = this.hsl();
return t.color[2] += t.color[2] * e, t;
},
darken: function(e) {
var t = this.hsl();
return t.color[2] -= t.color[2] * e, t;
},
saturate: function(e) {
var t = this.hsl();
return t.color[1] += t.color[1] * e, t;
},
desaturate: function(e) {
var t = this.hsl();
return t.color[1] -= t.color[1] * e, t;
},
whiten: function(e) {
var t = this.hwb();
return t.color[1] += t.color[1] * e, t;
},
blacken: function(e) {
var t = this.hwb();
return t.color[2] += t.color[2] * e, t;
},
grayscale: function() {
var e = this.rgb().color, t = e[0] * .3 + e[1] * .59 + e[2] * .11;
return c.rgb(t, t, t);
},
fade: function(e) {
return this.alpha(this.valpha - this.valpha * e);
},
opaquer: function(e) {
return this.alpha(this.valpha + this.valpha * e);
},
rotate: function(e) {
var t = this.hsl(), n = t.color[0];
return n = (n + e) % 360, n = n < 0 ? 360 + n : n, t.color[0] = n, t;
},
mix: function(e, t) {
if (!e || !e.rgb) throw Error("Argument to \"mix\" was not a Color instance, but rather an instance of " + typeof e);
var n = e.rgb(), r = this.rgb(), i = t === void 0 ? .5 : t, a = 2 * i - 1, o = n.alpha() - r.alpha(), s = ((a * o === -1 ? a : (a + o) / (1 + a * o)) + 1) / 2, l = 1 - s;
return c.rgb(s * n.red() + l * r.red(), s * n.green() + l * r.green(), s * n.blue() + l * r.blue(), n.alpha() * i + r.alpha() * (1 - i));
}
}, Object.keys(r).forEach(function(e) {
if (a.indexOf(e) === -1) {
var t = r[e].channels;
c.prototype[e] = function() {
if (this.model === e) return new c(this);
if (arguments.length) return new c(arguments, e);
var n = typeof arguments[t] == "number" ? t : this.valpha;
return new c(p(r[this.model][e].raw(this.color)).concat(n), e);
}, c[e] = function(n) {
return typeof n == "number" && (n = m(i.call(arguments), t)), new c(n, e);
};
}
});
function l(e, t) {
return Number(e.toFixed(t));
}
function u(e) {
return function(t) {
return l(t, e);
};
}
function d(e, t, n) {
return e = Array.isArray(e) ? e : [e], e.forEach(function(e) {
(s[e] || (s[e] = []))[t] = n;
}), e = e[0], function(r) {
var i;
return arguments.length ? (n && (r = n(r)), i = this[e](), i.color[t] = r, i) : (i = this[e]().color[t], n && (i = n(i)), i);
};
}
function f(e) {
return function(t) {
return Math.max(0, Math.min(e, t));
};
}
function p(e) {
return Array.isArray(e) ? e : [e];
}
function m(e, t) {
for (var n = 0; n < t; n++) typeof e[n] != "number" && (e[n] = 0);
return e;
}
t.exports = c;
}));
//#endregion
//#region ../renderer/src/utils/math.ts
function Uo(e, t, n) {
return Math.min(Math.max(e, t), n);
}
function Wo(e, t) {
return (e % t + t) % t;
}
function Go(e, t) {
let n = e.elements, r = t * 4;
return Math.hypot(n[r], n[r + 1], n[r + 2]);
}
function Ko(e, t) {
let n = qo.setFromMatrixColumn(e.matrixWorld, 2).normalize().negate(), r = Jo.setFromMatrixColumn(t, 2).normalize(), i = n.dot(r);
if (i === 0) return 0;
let a = Yo.setFromMatrixPosition(e.matrixWorld), o = Xo.setFromMatrixPosition(t).sub(a).dot(r) / i;
return o > 0 ? o : 0;
}
var qo = new U(), Jo = new U(), Yo = new U(), Xo = new U();
//#endregion
//#region ../renderer/src/controls/zoom-to.ts
function Zo(e) {
let { target: t, space: n, bearing: r, region: i, padding: a = 0, maxZoom: o } = e, s = $o(t, n), c = Qn({
center: s.center,
size: s.size,
rotation: r
}), { width: l, height: u } = c.size;
if (l <= 0 || u <= 0 || i.width <= 0 || i.height <= 0) return;
let d = 1 - 2 * a, f = Math.min(i.width * d / l, i.height * d / u), p = o === void 0 ? f : Math.min(f, o);
if (!(p > 0)) return;
let m = new An(-i.offsetX / p, -i.offsetY / p).rotate(r, es);
return {
center: {
x: c.center.x + m.x,
y: c.center.y + m.y
},
zoom: p
};
}
function Qo(e, t, n, r, i) {
if (!e) return {
width: t * r,
height: n * r,
offsetX: 0,
offsetY: 0
};
let a = i != null && i.enabled ? i.fullWidth / i.width : 1, o = i != null && i.enabled ? i.fullWidth / 2 - i.offsetX : t / 2, s = i != null && i.enabled ? i.fullHeight / 2 - i.offsetY : n / 2;
return {
width: e.size.width / a * r,
height: e.size.height / a * r,
offsetX: (e.center.x - o) / a * r,
offsetY: (e.center.y - s) / a * r
};
}
function $o(e, t) {
let n = t.planToWorld({
...e.min,
z: 0
}), r = t.planToWorld({
...e.max,
z: 0
});
return cr.fromMinMax(n, r);
}
var es = {
x: 0,
y: 0
}, ts = class {
constructor(e) {
this.context = e, this.withInvalidate = (e) => (this.context.invalidate(), e());
}
async zoomTo(e, t) {
let { controls: n, camera: r, space: i, view: a, width: o, height: s, dpr: c } = this.context;
if (!n || !r) return;
let l = Zo({
target: e,
space: i,
bearing: ns(n),
region: Qo(t == null ? void 0 : t.within, o, s, c, a()),
padding: t == null ? void 0 : t.padding,
maxZoom: t == null ? void 0 : t.maxZoom
});
if (!l) return;
let u = !(t != null && t.immediate);
await this.withInvalidate(() => Promise.all([n.moveTo(l.center.x, l.center.y, 0, u), n.dollyTo(r.zoomFactorToDistance(l.zoom), u)]));
}
zoomBy(e, t) {
let { controls: n, camera: r } = this.context;
return !n || !r ? as : this.withInvalidate(() => n.dollyTo(r.zoomFactorToDistance(r.zoomFactor * e), !(t != null && t.immediate)));
}
panTo(e, t) {
let { controls: n, space: r } = this.context;
if (!n) return as;
let i = rs(r, e);
return this.withInvalidate(() => n.moveTo(i.x, i.y, i.z, !(t != null && t.immediate)));
}
panBy(e, t) {
let { controls: n, space: r } = this.context;
if (!n) return as;
let i = rs(r, os, cs), a = rs(r, e), o = n.getTarget(ls);
return this.withInvalidate(() => n.moveTo(o.x + a.x - i.x, o.y + a.y - i.y, o.z + a.z - i.z, !(t != null && t.immediate)));
}
rollTo(e, t) {
let { controls: n } = this.context;
if (!n) return as;
let r = On(-wn(e), n.azimuthAngle);
return this.withInvalidate(() => n.rotateAzimuthTo(n.azimuthAngle + r, !(t != null && t.immediate)));
}
rollBy(e, t) {
let { controls: n } = this.context;
return n ? this.withInvalidate(() => n.rotateAzimuthTo(n.azimuthAngle - wn(e), !(t != null && t.immediate))) : as;
}
pitchTo(e, t) {
let { controls: n } = this.context;
return n ? this.withInvalidate(() => n.rotatePolarTo(wn(e), !(t != null && t.immediate))) : as;
}
pitchBy(e, t) {
let { controls: n } = this.context;
return n ? this.withInvalidate(() => n.rotatePolarTo(n.polarAngle + wn(e), !(t != null && t.immediate))) : as;
}
async reset(e = is, t) {
let { controls: n, camera: r } = this.context;
if (!n || !r) return;
let i = !(t != null && t.immediate), a = [];
e.pan && a.push(n.moveTo(0, 0, 0, i)), e.zoom && a.push(n.dollyTo(r.zoomFactorToDistance(1), i)), e.roll && a.push(n.normalizeRotations().rotateAzimuthTo(0, i)), e.pitch && a.push(n.rotatePolarTo(n.minPolarAngle, i)), await this.withInvalidate(() => Promise.all(a));
}
};
function ns(e) {
return Wo(-e.azimuthAngle, 2 * Math.PI);
}
function rs(e, t, n = ss) {
return e.planToWorld({
x: t.x,
y: t.y,
z: 0
}, n);
}
var is = {
pan: !0,
zoom: !0,
roll: !0,
pitch: !0
}, as = Promise.resolve(), os = {
x: 0,
y: 0
}, ss = new U(), cs = new U(), ls = new U(), G = /* @__PURE__ */ e(b(), 1);
function us(e, t) {
let n;
return (...r) => {
window.clearTimeout(n), n = window.setTimeout(() => e(...r), t);
};
}
function ds({ debounce: e, scroll: t, polyfill: n, offsetSize: r } = {
debounce: 0,
scroll: !1,
offsetSize: !1
}) {
let i = n || (typeof window > "u" ? class {} : window.ResizeObserver);
if (!i) throw Error("This browser does not support ResizeObserver out of the box. See: https://github.com/react-spring/react-use-measure/#resize-observer-polyfills");
let [a, o] = (0, G.useState)({
left: 0,
top: 0,
width: 0,
height: 0,
bottom: 0,
right: 0,
x: 0,
y: 0
}), s = (0, G.useRef)({
element: null,
scrollContainers: null,
resizeObserver: null,
lastBounds: a,
orientationHandler: null
}), c = e ? typeof e == "number" ? e : e.scroll : null, l = e ? typeof e == "number" ? e : e.resize : null, u = (0, G.useRef)(!1);
(0, G.useEffect)(() => (u.current = !0, () => void (u.current = !1)));
let [d, f, p] = (0, G.useMemo)(() => {
let e = () => {
if (!s.current.element) return;
let { left: e, top: t, width: n, height: i, bottom: a, right: c, x: l, y: d } = s.current.element.getBoundingClientRect(), f = {
left: e,
top: t,
width: n,
height: i,
bottom: a,
right: c,
x: l,
y: d
};
s.current.element instanceof HTMLElement && r && (f.height = s.current.element.offsetHeight, f.width = s.current.element.offsetWidth), Object.freeze(f), u.current && !gs(s.current.lastBounds, f) && o(s.current.lastBounds = f);
};
return [
e,
l ? us(e, l) : e,
c ? us(e, c) : e
];
}, [
o,
r,
c,
l
]);
function m() {
s.current.scrollContainers && (s.current.scrollContainers.forEach((e) => e.removeEventListener("scroll", p, !0)), s.current.scrollContainers = null), s.current.resizeObserver && (s.current.resizeObserver.disconnect(), s.current.resizeObserver = null), s.current.orientationHandler && ("orientation" in screen && "removeEventListener" in screen.orientation ? screen.orientation.removeEventListener("change", s.current.orientationHandler) : "onorientationchange" in window && window.removeEventListener("orientationchange", s.current.orientationHandler));
}
function h() {
s.current.element && (s.current.resizeObserver = new i(p), s.current.resizeObserver.observe(s.current.element), t && s.current.scrollContainers && s.current.scrollContainers.forEach((e) => e.addEventListener("scroll", p, {
capture: !0,
passive: !0
})), s.current.orientationHandler = () => {
p();
}, "orientation" in screen && "addEventListener" in screen.orientation ? screen.orientation.addEventListener("change", s.current.orientationHandler) : "onorientationchange" in window && window.addEventListener("orientationchange", s.current.orientationHandler));
}
return ps(p, !!t), fs(f), (0, G.useEffect)(() => {
m(), h();
}, [
t,
p,
f
]), (0, G.useEffect)(() => m, []), [
(e) => {
!e || e === s.current.element || (m(), s.current.element = e, s.current.scrollContainers = ms(e), h());
},
a,
d
];
}
function fs(e) {
(0, G.useEffect)(() => {
let t = e;
return window.addEventListener("resize", t), () => void window.removeEventListener("resize", t);
}, [e]);
}
function ps(e, t) {
(0, G.useEffect)(() => {
if (t) {
let t = e;
return window.addEventListener("scroll", t, {
capture: !0,
passive: !0
}), () => void window.removeEventListener("scroll", t, !0);
}
}, [e, t]);
}
function ms(e) {
let t = [];
if (!e || e === document.body) return t;
let { overflow: n, overflowX: r, overflowY: i } = window.getComputedStyle(e);
return [
n,
r,
i
].some((e) => e === "auto" || e === "scroll") && t.push(e), [...t, ...ms(e.parentElement)];
}
var hs = [
"x",
"y",
"top",
"bottom",
"left",
"right",
"width",
"height"
], gs = (e, t) => hs.every((n) => e[n] === t[n]), K = x();
ee();
function _s({ ref: e, children: t, fallback: n, resize: r, style: i, gl: a, events: o = ye, eventSource: s, eventPrefix: c, shadows: l, linear: u, flat: d, legacy: f, orthographic: p, frameloop: m, dpr: h, performance: g, raycaster: _, camera: v, scene: y, onPointerMissed: b, onCreated: x, ...S }) {
G.useMemo(() => le(fe), []);
let C = L(), [w, T] = ds({
scroll: !0,
debounce: {
scroll: 50,
resize: 0
},
...r
}), E = G.useRef(null), D = G.useRef(null);
G.useImperativeHandle(e, () => E.current);
let O = be(b), [k, A] = G.useState(!1), [j, M] = G.useState(!1);
if (k) throw k;
if (j) throw j;
let N = G.useRef(null);
return oe(() => {
let e = E.current;
if (T.width > 0 && T.height > 0 && e) {
N.current || (N.current = ce(e));
async function n() {
await N.current.configure({
gl: a,
scene: y,
events: o,
shadows: l,
linear: u,
flat: d,
legacy: f,
orthographic: p,
frameloop: m,
dpr: h,
performance: g,
raycaster: _,
camera: v,
size: T,
onPointerMissed: (...e) => O.current == null ? void 0 : O.current(...e),
onCreated: (e) => {
e.events.connect == null || e.events.connect(s ? ge(s) ? s.current : s : D.current), c && e.setEvents({ compute: (e, t) => {
let n = e[c + "X"], r = e[c + "Y"];
t.pointer.set(n / t.size.width * 2 - 1, -(r / t.size.height) * 2 + 1), t.raycaster.setFromCamera(t.pointer, t.camera);
} }), x == null || x(e);
}
}), N.current.render(/*#__PURE__*/ (0, K.jsx)(C, { children: /*#__PURE__*/ (0, K.jsx)(he, {
set: M,
children: /*#__PURE__*/ (0, K.jsx)(G.Suspense, {
fallback: /*#__PURE__*/ (0, K.jsx)(se, { set: A }),
children: t == null ? null : t
})
}) }));
}
n();
}
}), G.useEffect(() => {
let e = E.current;
if (e) return () => me(e);
}, []), /*#__PURE__*/ (0, K.jsx)("div", {
ref: D,
style: {
position: "relative",
width: "100%",
height: "100%",
overflow: "hidden",
pointerEvents: s ? "none" : "auto",
...i
},
...S,
children: /*#__PURE__*/ (0, K.jsx)("div", {
ref: w,
style: {
width: "100%",
height: "100%"
},
children: /*#__PURE__*/ (0, K.jsx)("canvas", {
ref: E,
style: { display: "block" },
children: n
})
})
});
}
function vs(e) {
return /*#__PURE__*/ (0, K.jsx)(Se, { children: /*#__PURE__*/ (0, K.jsx)(_s, { ...e }) });
}
//#endregion
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/typeof.js
function ys(e) {
"@babel/helpers - typeof";
return ys = typeof Symbol == "function" && typeof Symbol.iterator == "symbol" ? function(e) {
return typeof e;
} : function(e) {
return e && typeof Symbol == "function" && e.constructor === Symbol && e !== Symbol.prototype ? "symbol" : typeof e;
}, ys(e);
}
//#endregion
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPrimitive.js
function bs(e, t) {
if (ys(e) != "object" || !e) return e;
var n = e[Symbol.toPrimitive];
if (n !== void 0) {
var r = n.call(e, t || "default");
if (ys(r) != "object") return r;
throw TypeError("@@toPrimitive must return a primitive value.");
}
return (t === "string" ? String : Number)(e);
}
//#endregion
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/toPropertyKey.js
function xs(e) {
var t = bs(e, "string");
return ys(t) == "symbol" ? t : t + "";
}
//#endregion
//#region \0@oxc-project+runtime@0.139.0/helpers/esm/defineProperty.js
function q(e, t, n) {
return (t = xs(t)) in e ? Object.defineProperty(e, t, {
value: n,
enumerable: !0,
configurable: !0,
writable: !0
}) : e[t] = n, e;
}
//#endregion
//#region ../../node_modules/.pnpm/camera-controls@https+++codeload.github.com+expofp+camera-controls+tar.gz+2a2043afae83a_08c5756275d263192ffe9e9fe19d9ec1/node_modules/camera-controls/dist/camera-controls.module.js
var Ss, Cs, ws = {
LEFT: 1,
RIGHT: 2,
MIDDLE: 4
}, J = Object.freeze({
NONE: 0,
ROTATE_AZIMUTH: 1,
ROTATE_POLAR: 2,
ROTATE: 3,
TRUCK: 4,
SCREEN_PAN: 8,
OFFSET: 16,
DOLLY: 32,
ZOOM: 64,
TOUCH_ROTATE_AZIMUTH: 128,
TOUCH_ROTATE_POLAR: 256,
TOUCH_ROTATE: 384,
TOUCH_TRUCK: 512,
TOUCH_SCREEN_PAN: 1024,
TOUCH_OFFSET: 2048,
TOUCH_DOLLY: 4096,
TOUCH_ZOOM: 8192,
TOUCH_DOLLY_TRUCK: 4608,
TOUCH_DOLLY_SCREEN_PAN: 5120,
TOUCH_DOLLY_OFFSET: 6144,
TOUCH_DOLLY_ROTATE: 4480,
TOUCH_ZOOM_TRUCK: 8704,
TOUCH_ZOOM_OFFSET: 10240,
TOUCH_ZOOM_SCREEN_PAN: 9216,
TOUCH_ZOOM_ROTATE: 8576
}), Ts = {
NONE: 0,
IN: 1,
OUT: -1
};
function Es(e) {
return e.isPerspectiveCamera;
}
function Ds(e) {
return e.isOrthographicCamera;
}
var Os = Math.PI * 2, ks = Math.PI / 2, As = 1e-5, js = Math.PI / 180;
function Ms(e, t, n) {
return Math.max(t, Math.min(n, e));
}
function Ns(e, t = As) {
return Math.abs(e) < t;
}
function Ps(e, t, n = As) {
return Ns(e - t, n);
}
function Fs(e, t) {
return Math.round(e / t) * t;
}
function Is(e) {
return isFinite(e) ? e : e < 0 ? -Number.MAX_VALUE : Number.MAX_VALUE;
}
function Ls(e) {
return Math.abs(e) < Number.MAX_VALUE ? e : e * Infinity;
}
function Rs(e, t, n, r, i = Infinity, a) {
r = Math.max(1e-4, r);
let o = 2 / r, s = o * a, c = 1 / (1 + s + .48 * s * s + .235 * s * s * s), l = e - t, u = t, d = i * r;
l = Ms(l, -d, d), t = e - l;
let f = (n.value + o * l) * a;
n.value = (n.value - o * f) * c;
let p = t + (l + f) * c;
return u - e > 0 == p > u && (p = u, n.value = (p - u) / a), p;
}
function zs(e, t, n, r, i = Infinity, a, o) {
r = Math.max(1e-4, r);
let s = 2 / r, c = s * a, l = 1 / (1 + c + .48 * c * c + .235 * c * c * c), u = t.x, d = t.y, f = t.z, p = e.x - u, m = e.y - d, h = e.z - f, g = u, _ = d, v = f, y = i * r, b = y * y, x = p * p + m * m + h * h;
if (x > b) {
let e = Math.sqrt(x);
p = p / e * y, m = m / e * y, h = h / e * y;
}
u = e.x - p, d = e.y - m, f = e.z - h;
let S = (n.x + s * p) * a, C = (n.y + s * m) * a, w = (n.z + s * h) * a;
n.x = (n.x - s * S) * l, n.y = (n.y - s * C) * l, n.z = (n.z - s * w) * l, o.x = u + (p + S) * l, o.y = d + (m + C) * l, o.z = f + (h + w) * l;
let T = g - e.x, E = _ - e.y, D = v - e.z, O = o.x - g, k = o.y - _, A = o.z - v;
return T * O + E * k + D * A > 0 && (o.x = g, o.y = _, o.z = v, n.x = (o.x - g) / a, n.y = (o.y - _) / a, n.z = (o.z - v) / a), o;
}
function Bs(e, t) {
t.set(0, 0), e.forEach((e) => {
t.x += e.clientX, t.y += e.clientY;
}), t.x /= e.length, t.y /= e.length;
}
function Vs(e, t) {
return Ds(e) ? (console.warn(`${t} is not supported in OrthographicCamera`), !0) : !1;
}
var Hs = class {
constructor() {
q(this, "_listeners", {});
}
addEventListener(e, t) {
let n = this._listeners;
n[e] === void 0 && (n[e] = []), n[e].indexOf(t) === -1 && n[e].push(t);
}
hasEventListener(e, t) {
let n = this._listeners;
return n[e] !== void 0 && n[e].indexOf(t) !== -1;
}
removeEventListener(e, t) {
let n = this._listeners[e];
if (n !== void 0) {
let e = n.indexOf(t);
e !== -1 && n.splice(e, 1);
}
}
removeAllEventListeners(e) {
if (!e) {
this._listeners = {};
return;
}
Array.isArray(this._listeners[e]) && (this._listeners[e].length = 0);
}
dispatchEvent(e) {
let t = this._listeners[e.type];
if (t !== void 0) {
e.target = this;
let n = t.slice(0);
for (let t = 0, r = n.length; t < r; t++) n[t].call(this, e);
}
}
}, Us = "0.0.0-semantic-release", Ws = 1 / 8, Gs = [
"rotateAzimuth",
"rotatePolar",
"truck",
"dolly",
"zoom",
"offset"
], Ks = /Mac/.test((Ss = globalThis) == null || (Ss = Ss.navigator) == null ? void 0 : Ss.platform), Y;
function qs() {
return Y;
}
var Js, Ys, Xs, Zs, X, Qs, $s, ec, tc, nc, rc, ic, ac, oc, sc, cc, lc, uc, dc, fc, pc, mc, hc = class e extends Hs {
static install(e) {
Y = e.THREE, Js = Object.freeze(new Y.Vector3(0, 0, 0)), Ys = Object.freeze(new Y.Vector3(0, 1, 0)), Xs = Object.freeze(new Y.Vector3(0, 0, 1)), Zs = new Y.Vector2(), X = new Y.Vector3(), Qs = new Y.Vector3(), $s = new Y.Vector3(), ec = new Y.Vector3(), tc = new Y.Vector3(), nc = new Y.Vector3(), rc = new Y.Vector3(), ic = new Y.Vector3(), ac = new Y.Vector3(), oc = new Y.Spherical(), sc = new Y.Spherical(), cc = new Y.Box3(), lc = new Y.Box3(), uc = new Y.Sphere(), dc = new Y.Quaternion(), fc = new Y.Quaternion(), pc = new Y.Matrix4(), mc = new Y.Raycaster();
}
static get ACTION() {
return J;
}
set verticalDragToForward(e) {
console.warn("camera-controls: `verticalDragToForward` was removed. Use `mouseButtons.left = CameraControls.ACTION.SCREEN_PAN` instead.");
}
constructor(t, n) {
super(), q(this, "minPolarAngle", 0), q(this, "maxPolarAngle", Math.PI), q(this, "minAzimuthAngle", -Infinity), q(this, "maxAzimuthAngle", Infinity), q(this, "minDistance", 2 ** -52), q(this, "maxDistance", Infinity), q(this, "infinityDolly", !1), q(this, "minZoom", .01), q(this, "maxZoom", Infinity), q(this, "maxSpeed", Infinity), q(this, "azimuthRotateSpeed", 1), q(this, "polarRotateSpeed", 1), q(this, "dollySpeed", 1), q(this, "dollyDragInverted", !1), q(this, "truckSpeed", 2), q(this, "dollyToCursor", !1), q(this, "dragToOffset", !1), q(this, "boundaryFriction", 0), q(this, "restThreshold", .01), q(this, "colliderMeshes", []), q(this, "mouseButtons", void 0), q(this, "touches", void 0), q(this, "cancel", () => {}), q(this, "lockPointer", void 0), q(this, "unlockPointer", void 0), q(this, "_enabled", !0), q(this, "_camera", void 0), q(this, "_yAxisUpSpace", void 0), q(this, "_yAxisUpSpaceInverse", void 0), q(this, "_state", J.NONE), q(this, "_domElement", void 0), q(this, "_viewport", null), q(this, "_target", void 0), q(this, "_targetEnd", void 0), q(this, "_focalOffset", void 0), q(this, "_focalOffsetEnd", void 0), q(this, "_spherical", void 0), q(this, "_sphericalEnd", void 0), q(this, "_lastDistance", void 0), q(this, "_zoom", void 0), q(this, "_zoomEnd", void 0), q(this, "_lastZoom", void 0), q(this, "_cameraUp0", void 0), q(this, "_target0", void 0), q(this, "_position0", void 0), q(this, "_zoom0", void 0), q(this, "_focalOffset0", void 0), q(this, "_dollyControlCoord", void 0), q(this, "_changedDolly", 0), q(this, "_changedZoom", 0), q(this, "_nearPlaneCorners", void 0), q(this, "_hasRested", !0), q(this, "_boundary", void 0), q(this, "_boundaryEnclosesCamera", !1), q(this, "_needsUpdate", !0), q(this, "_updatedLastTime", !1), q(this, "_elementRect", new DOMRect()), q(this, "_isDragging", !1), q(this, "_dragNeedsUpdate", !0), q(this, "_activePointers", []), q(this, "_lockedPointer", null), q(this, "_interactiveArea", new DOMRect(0, 0, 1, 1)), q(this, "_isUserControllingRotate", !1), q(this, "_isUserControllingDolly", !1), q(this, "_isUserControllingTruck", !1), q(this, "_isUserControllingOffset", !1), q(this, "_isUserControllingZoom", !1), q(this, "_userTransitions", 0), q(this, "_userTransitionRadiusEnd", null), q(this, "_userTransitionZoomEnd", null), q(this, "_lastDollyDirection", Ts.NONE), q(this, "_thetaVelocity", { value: 0 }), q(this, "_phiVelocity", { value: 0 }), q(this, "_radiusVelocity", { value: 0 }), q(this, "_targetVelocity", new Y.Vector3()), q(this, "_focalOffsetVelocity", new Y.Vector3()), q(this, "_zoomVelocity", { value: 0 }), q(this, "_smoothTime", {}), q(this, "_controlSmoothTime", {}), q(this, "_truckInternal", (e, t, n, r) => {
let i, a;
if (Es(this._camera)) {
let n = X.copy(this._camera.position).sub(this._target), r = this._camera.getEffectiveFOV() * js, o = n.length() * Math.tan(r * .5);
i = this.truckSpeed * e * o / this._elementRect.height, a = this.truckSpeed * t * o / this._elementRect.height;
} else if (Ds(this._camera)) {
let n = this._camera;
i = this.truckSpeed * e * (n.right - n.left) / n.zoom / this._elementRect.width, a = this.truckSpeed * t * (n.top - n.bottom) / n.zoom / this._elementRect.height;
} else return;
r ? (n ? this.setFocalOffset(this._focalOffsetEnd.x + i, this._focalOffsetEnd.y, this._focalOffsetEnd.z, !0) : this.truck(i, 0, !0), this.forward(-a, !0)) : n ? this.setFocalOffset(this._focalOffsetEnd.x + i, this._focalOffsetEnd.y + a, this._focalOffsetEnd.z, !0) : this.truck(i, a, !0);
}), q(this, "_rotateInternal", (e, t, n) => {
let r = (n & (J.ROTATE_AZIMUTH | J.TOUCH_ROTATE_AZIMUTH)) !== 0, i = (n & (J.ROTATE_POLAR | J.TOUCH_ROTATE_POLAR)) !== 0, a = r ? Os * this.azimuthRotateSpeed * e / this._elementRect.height : 0, o = i ? Os * this.polarRotateSpeed * t / this._elementRect.height : 0;
this.rotate(a, o, !0);
}), q(this, "_dollyInternal", (e, t, n) => {
let r = .95 ** (-e * this.dollySpeed), i = this._sphericalEnd.radius, a = this._sphericalEnd.radius * r, o = Ms(a, this.minDistance, this.maxDistance), s = o - a;
this.infinityDolly && this.dollyToCursor ? this._dollyToNoClamp(a, !0) : (this.infinityDolly && !this.dollyToCursor && this.dollyInFixed(s, !0), this._dollyToNoClamp(o, !0)), this.dollyToCursor && (this._changedDolly += (this.infinityDolly ? a : o) - i, this._dollyControlCoord.set(t, n)), this._lastDollyDirection = Math.sign(-e);
}), q(this, "_zoomInternal", (e, t, n) => {
let r = .95 ** (e * this.dollySpeed), i = this._zoom, a = this._zoom * r;
this.zoomTo(a, !0), this.dollyToCursor && (this._changedZoom += a - i, this._dollyControlCoord.set(t, n));
}), Y === void 0 && console.error("camera-controls: `THREE` is undefined. You must first run `CameraControls.install( { THREE: THREE } )`. Check the docs for further information."), this._camera = t, this._yAxisUpSpace = new Y.Quaternion().setFromUnitVectors(this._camera.up, Ys), this._yAxisUpSpaceInverse = this._yAxisUpSpace.clone().invert(), this._state = J.NONE, this.smoothTime = .25, this.controlSmoothTime = .125, this._target = new Y.Vector3(), this._targetEnd = this._target.clone(), this._focalOffset = new Y.Vector3(), this._focalOffsetEnd = this._focalOffset.clone(), this._spherical = new Y.Spherical().setFromVector3(X.copy(this._camera.position).applyQuaternion(this._yAxisUpSpace)), this._sphericalEnd = this._spherical.clone(), this._lastDistance = this._spherical.radius, this._zoom = this._camera.zoom, this._zoomEnd = this._zoom, this._lastZoom = this._zoom, this._nearPlaneCorners = [
new Y.Vector3(),
new Y.Vector3(),
new Y.Vector3(),
new Y.Vector3()
], this._updateNearPlaneCorners(), this._boundary = new Y.Box3(new Y.Vector3(-Infinity, -Infinity, -Infinity), new Y.Vector3(Infinity, Infinity, Infinity)), this._cameraUp0 = this._camera.up.clone(), this._target0 = this._target.clone(), this._position0 = this._camera.position.clone(), this._zoom0 = this._zoom, this._focalOffset0 = this._focalOffset.clone(), this._dollyControlCoord = new Y.Vector2(), this.mouseButtons = {
left: J.ROTATE,
middle: J.DOLLY,
right: J.TRUCK,
wheel: Es(this._camera) ? J.DOLLY : Ds(this._camera) ? J.ZOOM : J.NONE
}, this.touches = {
one: J.TOUCH_ROTATE,
two: Es(this._camera) ? J.TOUCH_DOLLY_TRUCK : Ds(this._camera) ? J.TOUCH_ZOOM_TRUCK : J.NONE,
three: J.TOUCH_TRUCK
};
let r = new Y.Vector2(), i = new Y.Vector2(), a = new Y.Vector2(), o = (e) => {
if (!this._enabled || !this._domElement) return;
if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
let t = this._domElement.getBoundingClientRect(), n = e.clientX / t.width, r = e.clientY / t.height;
if (n < this._interactiveArea.left || n > this._interactiveArea.right || r < this._interactiveArea.top || r > this._interactiveArea.bottom) return;
}
let t = e.pointerType === "mouse" ? (e.buttons & ws.LEFT) === ws.LEFT ? ws.LEFT : (e.buttons & ws.MIDDLE) === ws.MIDDLE ? ws.MIDDLE : (e.buttons & ws.RIGHT) === ws.RIGHT ? ws.RIGHT : null : null;
if (t !== null) {
let e = this._findPointerByMouseButton(t);
e && this._disposePointer(e);
}
if ((e.buttons & ws.LEFT) === ws.LEFT && this._lockedPointer) return;
let n = {
pointerId: e.pointerId,
clientX: e.clientX,
clientY: e.clientY,
deltaX: 0,
deltaY: 0,
mouseButton: t
};
this._activePointers.push(n), this._domElement.ownerDocument.removeEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", c), this._domElement.ownerDocument.addEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.addEventListener("pointerup", c), this._isDragging = !0, f(e);
}, s = (e) => {
e.cancelable && e.preventDefault();
let t = e.pointerId, n = this._lockedPointer || this._findPointerById(t);
if (n) {
if (n.clientX = e.clientX, n.clientY = e.clientY, n.deltaX = e.movementX, n.deltaY = e.movementY, this._state = 0, e.pointerType === "touch") switch (this._activePointers.length) {
case 1:
this._state = this.touches.one;
break;
case 2:
this._state = this.touches.two;
break;
case 3:
this._state = this.touches.three;
break;
}
else (!this._isDragging && this._lockedPointer || this._isDragging && (e.buttons & ws.LEFT) === ws.LEFT) && (this._state |= this.mouseButtons.left), this._isDragging && (e.buttons & ws.MIDDLE) === ws.MIDDLE && (this._state |= this.mouseButtons.middle), this._isDragging && (e.buttons & ws.RIGHT) === ws.RIGHT && (this._state |= this.mouseButtons.right);
p();
}
}, c = (e) => {
let t = this._findPointerById(e.pointerId);
if (!(t && t === this._lockedPointer)) {
if (t && this._disposePointer(t), e.pointerType === "touch") switch (this._activePointers.length) {
case 0:
this._state = J.NONE;
break;
case 1:
this._state = this.touches.one;
break;
case 2:
this._state = this.touches.two;
break;
case 3:
this._state = this.touches.three;
break;
}
else this._state = J.NONE;
m();
}
}, l = -1, u = (e) => {
if (!this._domElement || !this._enabled || this.mouseButtons.wheel === J.NONE) return;
if (this._interactiveArea.left !== 0 || this._interactiveArea.top !== 0 || this._interactiveArea.width !== 1 || this._interactiveArea.height !== 1) {
let t = this._domElement.getBoundingClientRect(), n = e.clientX / t.width, r = e.clientY / t.height;
if (n < this._interactiveArea.left || n > this._interactiveArea.right || r < this._interactiveArea.top || r > this._interactiveArea.bottom) return;
}
if (e.preventDefault(), this.dollyToCursor || (this.mouseButtons.wheel & J.ROTATE) !== 0 || this.mouseButtons.wheel === J.TRUCK) {
let e = performance.now();
l - e < 1e3 && this._getClientRect(this._elementRect), l = e;
}
let t = Ks ? -1 : -3, n = e.deltaMode === 1 && !e.ctrlKey ? e.deltaY / t : e.deltaY / (t * 10), r = this.dollyToCursor ? (e.clientX - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, i = this.dollyToCursor ? (e.clientY - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0, a = e.ctrlKey ? this.touches.two : this.mouseButtons.wheel;
switch (a) {
case J.ROTATE:
case J.ROTATE_AZIMUTH:
case J.ROTATE_POLAR:
this._rotateInternal(e.deltaX, e.deltaY, a), this._isUserControllingRotate = !0;
break;
case J.TRUCK:
this._truckInternal(e.deltaX, e.deltaY, !1, !1), this._isUserControllingTruck = !0;
break;
case J.SCREEN_PAN:
this._truckInternal(e.deltaX, e.deltaY, !1, !0), this._isUserControllingTruck = !0;
break;
case J.OFFSET:
this._truckInternal(e.deltaX, e.deltaY, !0, !1), this._isUserControllingOffset = !0;
break;
case J.DOLLY:
case J.TOUCH_DOLLY:
case J.TOUCH_DOLLY_ROTATE:
case J.TOUCH_DOLLY_TRUCK:
case J.TOUCH_DOLLY_SCREEN_PAN:
case J.TOUCH_DOLLY_OFFSET:
this._dollyInternal(-n, r, i), this._isUserControllingDolly = !0;
break;
case J.ZOOM:
case J.TOUCH_ZOOM:
case J.TOUCH_ZOOM_ROTATE:
case J.TOUCH_ZOOM_TRUCK:
case J.TOUCH_ZOOM_SCREEN_PAN:
case J.TOUCH_ZOOM_OFFSET:
this._zoomInternal(-n, r, i), this._isUserControllingZoom = !0;
break;
}
this.dispatchEvent({ type: "control" });
}, d = (t) => {
if (!(!this._domElement || !this._enabled)) {
if (this.mouseButtons.right === e.ACTION.NONE) {
let e = t instanceof PointerEvent ? t.pointerId : 0, n = this._findPointerById(e);
n && this._disposePointer(n), this._domElement.ownerDocument.removeEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", c);
return;
}
t.preventDefault();
}
}, f = (e) => {
if (this._enabled) {
if (Bs(this._activePointers, Zs), this._getClientRect(this._elementRect), r.copy(Zs), i.copy(Zs), this._activePointers.length >= 2) {
let e = Zs.x - this._activePointers[1].clientX, t = Zs.y - this._activePointers[1].clientY, n = Math.sqrt(e * e + t * t);
a.set(0, n);
let r = (this._activePointers[0].clientX + this._activePointers[1].clientX) * .5, o = (this._activePointers[0].clientY + this._activePointers[1].clientY) * .5;
i.set(r, o);
}
if (this._state = 0, !e) this._lockedPointer && (this._state |= this.mouseButtons.left);
else if ("pointerType" in e && e.pointerType === "touch") switch (this._activePointers.length) {
case 1:
this._state = this.touches.one;
break;
case 2:
this._state = this.touches.two;
break;
case 3:
this._state = this.touches.three;
break;
}
else !this._lockedPointer && (e.buttons & ws.LEFT) === ws.LEFT && (this._state |= this.mouseButtons.left), (e.buttons & ws.MIDDLE) === ws.MIDDLE && (this._state |= this.mouseButtons.middle), (e.buttons & ws.RIGHT) === ws.RIGHT && (this._state |= this.mouseButtons.right);
(this._state & (J.ROTATE | J.TOUCH_ROTATE)) !== 0 && (this._sphericalEnd.theta = this._spherical.theta, this._sphericalEnd.phi = this._spherical.phi, this._thetaVelocity.value = 0, this._phiVelocity.value = 0), (this._state & (J.TRUCK | J.SCREEN_PAN | J.TOUCH_TRUCK | J.TOUCH_SCREEN_PAN)) !== 0 && (this._targetEnd.copy(this._target), this._targetVelocity.set(0, 0, 0)), (this._state & (J.DOLLY | J.TOUCH_DOLLY)) !== 0 && (this._sphericalEnd.radius = this._spherical.radius, this._radiusVelocity.value = 0), (this._state & (J.ZOOM | J.TOUCH_ZOOM)) !== 0 && (this._zoomEnd = this._zoom, this._zoomVelocity.value = 0), (this._state & (J.OFFSET | J.TOUCH_OFFSET)) !== 0 && (this._focalOffsetEnd.copy(this._focalOffset), this._focalOffsetVelocity.set(0, 0, 0)), this.dispatchEvent({ type: "controlstart" });
}
}, p = () => {
if (!this._enabled || !this._dragNeedsUpdate) return;
this._dragNeedsUpdate = !1, Bs(this._activePointers, Zs);
let e = this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement ? this._lockedPointer || this._activePointers[0] : null, t = e ? -e.deltaX : i.x - Zs.x, n = e ? -e.deltaY : i.y - Zs.y;
if (i.copy(Zs), (this._state & (J.ROTATE | J.TOUCH_ROTATE)) !== 0 && (this._rotateInternal(t, n, this._state), this._isUserControllingRotate = !0), (this._state & J.DOLLY) === J.DOLLY || (this._state & J.ZOOM) === J.ZOOM) {
let e = this.dollyToCursor ? (r.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, t = this.dollyToCursor ? (r.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0, i = this.dollyDragInverted ? -1 : 1;
(this._state & J.DOLLY) === J.DOLLY ? (this._dollyInternal(i * n * Ws, e, t), this._isUserControllingDolly = !0) : (this._zoomInternal(i * n * Ws, e, t), this._isUserControllingZoom = !0);
}
if ((this._state & (J.TOUCH_DOLLY | J.TOUCH_ZOOM)) !== 0) {
let e = Zs.x - this._activePointers[1].clientX, t = Zs.y - this._activePointers[1].clientY, n = Math.sqrt(e * e + t * t), r = a.y - n;
a.set(0, n);
let o = this.dollyToCursor ? (i.x - this._elementRect.x) / this._elementRect.width * 2 - 1 : 0, s = this.dollyToCursor ? (i.y - this._elementRect.y) / this._elementRect.height * -2 + 1 : 0;
(this._state & J.TOUCH_DOLLY) === 0 ? (this._zoomInternal(r * Ws, o, s), this._isUserControllingZoom = !0) : (this._dollyInternal(r * Ws, o, s), this._isUserControllingDolly = !0);
}
(this._state & (J.TRUCK | J.TOUCH_TRUCK)) !== 0 && (this._truckInternal(t, n, !1, !1), this._isUserControllingTruck = !0), (this._state & (J.SCREEN_PAN | J.TOUCH_SCREEN_PAN)) !== 0 && (this._truckInternal(t, n, !1, !0), this._isUserControllingTruck = !0), (this._state & (J.OFFSET | J.TOUCH_OFFSET)) !== 0 && (this._truckInternal(t, n, !0, !1), this._isUserControllingOffset = !0), this.dispatchEvent({ type: "control" });
}, m = () => {
Bs(this._activePointers, Zs), i.copy(Zs), this._dragNeedsUpdate = !1, (this._activePointers.length === 0 || this._activePointers.length === 1 && this._activePointers[0] === this._lockedPointer) && (this._isDragging = !1), this._activePointers.length === 0 && this._domElement && (this._domElement.ownerDocument.removeEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", c), this.dispatchEvent({ type: "controlend" }));
};
this.lockPointer = () => {
!this._enabled || !this._domElement || (this.cancel(), this._lockedPointer = {
pointerId: -1,
clientX: 0,
clientY: 0,
deltaX: 0,
deltaY: 0,
mouseButton: null
}, this._activePointers.push(this._lockedPointer), this._domElement.ownerDocument.removeEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", c), this._domElement.requestPointerLock(), this._domElement.ownerDocument.addEventListener("pointerlockchange", h), this._domElement.ownerDocument.addEventListener("pointerlockerror", g), this._domElement.ownerDocument.addEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.addEventListener("pointerup", c), f());
}, this.unlockPointer = () => {
var e, t, n;
this._lockedPointer !== null && (this._disposePointer(this._lockedPointer), this._lockedPointer = null), (e = this._domElement) == null || e.ownerDocument.exitPointerLock(), (t = this._domElement) == null || t.ownerDocument.removeEventListener("pointerlockchange", h), (n = this._domElement) == null || n.ownerDocument.removeEventListener("pointerlockerror", g), this.cancel();
};
let h = () => {
this._domElement && this._domElement.ownerDocument.pointerLockElement === this._domElement || this.unlockPointer();
}, g = () => {
this.unlockPointer();
};
this._addAllEventListeners = (e) => {
this._domElement = e, this._domElement.style.touchAction = "none", this._domElement.style.userSelect = "none", this._domElement.style.webkitUserSelect = "none", this._domElement.addEventListener("pointerdown", o), this._domElement.addEventListener("pointercancel", c), this._domElement.addEventListener("wheel", u, { passive: !1 }), this._domElement.addEventListener("contextmenu", d);
}, this._removeAllEventListeners = () => {
this._domElement && (this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = "", this._domElement.removeEventListener("pointerdown", o), this._domElement.removeEventListener("pointercancel", c), this._domElement.removeEventListener("wheel", u, { passive: !1 }), this._domElement.removeEventListener("contextmenu", d), this._domElement.ownerDocument.removeEventListener("pointermove", s, { passive: !1 }), this._domElement.ownerDocument.removeEventListener("pointerup", c), this._domElement.ownerDocument.removeEventListener("pointerlockchange", h), this._domElement.ownerDocument.removeEventListener("pointerlockerror", g));
}, this.cancel = () => {
this._state !== J.NONE && (this._state = J.NONE, this._activePointers.length = 0, m());
}, n && this.connect(n), this.update(0);
}
get camera() {
return this._camera;
}
set camera(e) {
this._camera = e, this.updateCameraUp(), this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0;
}
get enabled() {
return this._enabled;
}
set enabled(e) {
this._enabled = e, this._domElement && (e ? (this._domElement.style.touchAction = "none", this._domElement.style.userSelect = "none", this._domElement.style.webkitUserSelect = "none") : (this.cancel(), this._domElement.style.touchAction = "", this._domElement.style.userSelect = "", this._domElement.style.webkitUserSelect = ""));
}
get active() {
return !this._hasRested;
}
get currentAction() {
return this._state;
}
get distance() {
return this._spherical.radius;
}
set distance(e) {
this._spherical.radius === e && this._sphericalEnd.radius === e || (this._spherical.radius = e, this._sphericalEnd.radius = e, this._needsUpdate = !0);
}
get azimuthAngle() {
return this._spherical.theta;
}
set azimuthAngle(e) {
this._spherical.theta === e && this._sphericalEnd.theta === e || (this._spherical.theta = e, this._sphericalEnd.theta = e, this._needsUpdate = !0);
}
get polarAngle() {
return this._spherical.phi;
}
set polarAngle(e) {
this._spherical.phi === e && this._sphericalEnd.phi === e || (this._spherical.phi = e, this._sphericalEnd.phi = e, this._needsUpdate = !0);
}
get boundaryEnclosesCamera() {
return this._boundaryEnclosesCamera;
}
set boundaryEnclosesCamera(e) {
this._boundaryEnclosesCamera = e, this._needsUpdate = !0;
}
set interactiveArea(e) {
this._interactiveArea.width = Ms(e.width, 0, 1), this._interactiveArea.height = Ms(e.height, 0, 1), this._interactiveArea.x = Ms(e.x, 0, 1 - this._interactiveArea.width), this._interactiveArea.y = Ms(e.y, 0, 1 - this._interactiveArea.height);
}
addEventListener(e, t) {
super.addEventListener(e, t);
}
removeEventListener(e, t) {
super.removeEventListener(e, t);
}
rotate(e, t, n = !1) {
return this.rotateTo(this._sphericalEnd.theta + e, this._sphericalEnd.phi + t, n);
}
rotateAzimuthTo(e, t = !1) {
return this.rotateTo(e, this._sphericalEnd.phi, t);
}
rotatePolarTo(e, t = !1) {
return this.rotateTo(this._sphericalEnd.theta, e, t);
}
rotateTo(e, t, n = !1) {
this._isUserControllingRotate = this._userTransitions > 0;
let r = Ms(e, this.minAzimuthAngle, this.maxAzimuthAngle), i = Ms(t, this.minPolarAngle, this.maxPolarAngle);
this._sphericalEnd.theta = r, this._sphericalEnd.phi = i, this._sphericalEnd.makeSafe(), this._needsUpdate = !0, n || (this._spherical.theta = this._sphericalEnd.theta, this._spherical.phi = this._sphericalEnd.phi);
let a = !n || Ps(this._spherical.theta, this._sphericalEnd.theta, this.restThreshold) && Ps(this._spherical.phi, this._sphericalEnd.phi, this.restThreshold);
return this._createOnRestPromise(a);
}
dolly(e, t = !1) {
return this.dollyTo(this._sphericalEnd.radius - e, t);
}
dollyTo(e, t = !1) {
this._isUserControllingDolly = this._userTransitions > 0, this._lastDollyDirection = Ts.NONE, this._changedDolly = 0;
let n = this._sphericalEnd.radius, r = this._dollyToNoClamp(Ms(e, this.minDistance, this.maxDistance), t);
return this._recordUserTransitionRadius(n), r;
}
_dollyToNoClamp(e, t = !1) {
let n = this._sphericalEnd.radius;
if (this.colliderMeshes.length >= 1) {
let t = this._collisionTest(), r = Ps(t, this._spherical.radius);
if (!(n > e) && r) return Promise.resolve();
this._sphericalEnd.radius = Math.min(e, t);
} else this._sphericalEnd.radius = e;
this._needsUpdate = !0, t || (this._spherical.radius = this._sphericalEnd.radius);
let r = !t || Ps(this._spherical.radius, this._sphericalEnd.radius, this.restThreshold);
return this._createOnRestPromise(r);
}
dollyInFixed(e, t = !1) {
this._targetEnd.add(this._getCameraDirection(ec).multiplyScalar(e)), t || this._target.copy(this._targetEnd);
let n = !t || Ps(this._target.x, this._targetEnd.x, this.restThreshold) && Ps(this._target.y, this._targetEnd.y, this.restThreshold) && Ps(this._target.z, this._targetEnd.z, this.restThreshold);
return this._createOnRestPromise(n);
}
zoom(e, t = !1) {
return this.zoomTo(this._zoomEnd + e, t);
}
zoomTo(e, t = !1) {
this._isUserControllingZoom = this._userTransitions > 0;
let n = this._zoomEnd;
this._zoomEnd = Ms(e, this.minZoom, this.maxZoom), this._userTransitions > 0 && !Ps(this._zoomEnd, n) && (this._userTransitionZoomEnd = this._zoomEnd), this._needsUpdate = !0, t || (this._zoom = this._zoomEnd);
let r = !t || Ps(this._zoom, this._zoomEnd, this.restThreshold);
return this._changedZoom = 0, this._createOnRestPromise(r);
}
pan(e, t, n = !1) {
return console.warn("`pan` has been renamed to `truck`"), this.truck(e, t, n);
}
truck(e, t, n = !1) {
this._camera.updateMatrix(), tc.setFromMatrixColumn(this._camera.matrix, 0), nc.setFromMatrixColumn(this._camera.matrix, 1), tc.multiplyScalar(e), nc.multiplyScalar(-t);
let r = X.copy(tc).add(nc), i = Qs.copy(this._targetEnd).add(r);
return this.moveTo(i.x, i.y, i.z, n);
}
forward(e, t = !1) {
X.setFromMatrixColumn(this._camera.matrix, 0), X.crossVectors(this._camera.up, X), X.multiplyScalar(e);
let n = Qs.copy(this._targetEnd).add(X);
return this.moveTo(n.x, n.y, n.z, t);
}
elevate(e, t = !1) {
return X.copy(this._camera.up).multiplyScalar(e), this.moveTo(this._targetEnd.x + X.x, this._targetEnd.y + X.y, this._targetEnd.z + X.z, t);
}
moveTo(e, t, n, r = !1) {
this._isUserControllingTruck = this._userTransitions > 0;
let i = X.set(e, t, n).sub(this._targetEnd);
this._encloseToBoundary(this._targetEnd, i, this.boundaryFriction), this._needsUpdate = !0, r || this._target.copy(this._targetEnd);
let a = !r || Ps(this._target.x, this._targetEnd.x, this.restThreshold) && Ps(this._target.y, this._targetEnd.y, this.restThreshold) && Ps(this._target.z, this._targetEnd.z, this.restThreshold);
return this._createOnRestPromise(a);
}
lookInDirectionOf(e, t, n, r = !1) {
let i = X.set(e, t, n).sub(this._targetEnd).normalize().multiplyScalar(-this._sphericalEnd.radius).add(this._targetEnd);
return this.setPosition(i.x, i.y, i.z, r);
}
fitToBox(e, t, { cover: n = !1, paddingLeft: r = 0, paddingRight: i = 0, paddingBottom: a = 0, paddingTop: o = 0 } = {}) {
let s = [], c = e.isBox3 ? cc.copy(e) : cc.setFromObject(e);
c.isEmpty() && (console.warn("camera-controls: fitTo() cannot be used with an empty box. Aborting"), Promise.resolve());
let l = Fs(this._sphericalEnd.theta, ks), u = Fs(this._sphericalEnd.phi, ks);
s.push(this.rotateTo(l, u, t));
let d = X.setFromSpherical(this._sphericalEnd).normalize(), f = dc.setFromUnitVectors(d, Xs), p = Ps(Math.abs(d.y), 1);
p && f.multiply(fc.setFromAxisAngle(Ys, l)), f.multiply(this._yAxisUpSpaceInverse);
let m = lc.makeEmpty();
Qs.copy(c.min).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.min).setX(c.max.x).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.min).setY(c.max.y).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.max).setZ(c.min.z).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.min).setZ(c.max.z).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.max).setY(c.min.y).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.max).setX(c.min.x).applyQuaternion(f), m.expandByPoint(Qs), Qs.copy(c.max).applyQuaternion(f), m.expandByPoint(Qs), m.min.x -= r, m.min.y -= a, m.max.x += i, m.max.y += o, f.setFromUnitVectors(Xs, d), p && f.premultiply(fc.invert()), f.premultiply(this._yAxisUpSpace);
let h = m.getSize(X), g = m.getCenter(Qs).applyQuaternion(f);
if (Es(this._camera)) {
let e = this.getDistanceToFitBox(h.x, h.y, h.z, n);
s.push(this.moveTo(g.x, g.y, g.z, t)), s.push(this.dollyTo(e, t)), s.push(this.setFocalOffset(0, 0, 0, t));
} else if (Ds(this._camera)) {
let e = this._camera, r = e.right - e.left, i = e.top - e.bottom, a = n ? Math.max(r / h.x, i / h.y) : Math.min(r / h.x, i / h.y);
s.push(this.moveTo(g.x, g.y, g.z, t)), s.push(this.zoomTo(a, t)), s.push(this.setFocalOffset(0, 0, 0, t));
}
return Promise.all(s);
}
fitToSphere(t, n) {
let r = [], i = "isObject3D" in t ? e.createBoundingSphere(t, uc) : uc.copy(t);
if (r.push(this.moveTo(i.center.x, i.center.y, i.center.z, n)), Es(this._camera)) {
let e = this.getDistanceToFitSphere(i.radius);
r.push(this.dollyTo(e, n));
} else if (Ds(this._camera)) {
let e = this._camera.right - this._camera.left, t = this._camera.top - this._camera.bottom, a = 2 * i.radius, o = Math.min(e / a, t / a);
r.push(this.zoomTo(o, n));
}
return r.push(this.setFocalOffset(0, 0, 0, n)), Promise.all(r);
}
setLookAt(e, t, n, r, i, a, o = !1) {
let s = this._userTransitions > 0;
this._isUserControllingRotate = s, this._isUserControllingDolly = s, this._isUserControllingTruck = s, this._lastDollyDirection = Ts.NONE, this._changedDolly = 0;
let c = this._sphericalEnd.radius, l = Qs.set(r, i, a), u = X.set(e, t, n);
this._targetEnd.copy(l), u.sub(l), Ns(u.x) && (u.x = 0), Ns(u.y) && (u.y = 0), Ns(u.z) && (u.z = 0), this._sphericalEnd.setFromVector3(u.applyQuaternion(this._yAxisUpSpace)), this._recordUserTransitionRadius(c), this._needsUpdate = !0, o || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
let d = !o || Ps(this._target.x, this._targetEnd.x, this.restThreshold) && Ps(this._target.y, this._targetEnd.y, this.restThreshold) && Ps(this._target.z, this._targetEnd.z, this.restThreshold) && Ps(this._spherical.theta, this._sphericalEnd.theta, this.restThreshold) && Ps(this._spherical.phi, this._sphericalEnd.phi, this.restThreshold) && Ps(this._spherical.radius, this._sphericalEnd.radius, this.restThreshold);
return this._createOnRestPromise(d);
}
lerp(e, t, n, r = !1) {
let i = this._userTransitions > 0;
this._isUserControllingRotate = i, this._isUserControllingDolly = i, this._isUserControllingTruck = i, this._lastDollyDirection = Ts.NONE, this._changedDolly = 0;
let a = this._sphericalEnd.radius, o = X.set(...e.target);
if ("spherical" in e) oc.set(...e.spherical);
else {
let t = Qs.set(...e.position);
oc.setFromVector3(t.sub(o).applyQuaternion(this._yAxisUpSpace));
}
let s = $s.set(...t.target);
if ("spherical" in t) sc.set(...t.spherical);
else {
let e = Qs.set(...t.position);
sc.setFromVector3(e.sub(s).applyQuaternion(this._yAxisUpSpace));
}
this._targetEnd.copy(o.lerp(s, n));
let c = sc.theta - oc.theta, l = sc.phi - oc.phi, u = sc.radius - oc.radius;
this._sphericalEnd.set(oc.radius + u * n, oc.phi + l * n, oc.theta + c * n), this._recordUserTransitionRadius(a), this._needsUpdate = !0, r || (this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd));
let d = !r || Ps(this._target.x, this._targetEnd.x, this.restThreshold) && Ps(this._target.y, this._targetEnd.y, this.restThreshold) && Ps(this._target.z, this._targetEnd.z, this.restThreshold) && Ps(this._spherical.theta, this._sphericalEnd.theta, this.restThreshold) && Ps(this._spherical.phi, this._sphericalEnd.phi, this.restThreshold) && Ps(this._spherical.radius, this._sphericalEnd.radius, this.restThreshold);
return this._createOnRestPromise(d);
}
async userTransition(e) {
this._userTransitions++, this.dispatchEvent({ type: "control" });
try {
return await e();
} finally {
this._userTransitions--, this._userTransitions === 0 && (this._userTransitionRadiusEnd = null, this._userTransitionZoomEnd = null);
}
}
_recordUserTransitionRadius(e) {
this._userTransitions === 0 || Ps(this._sphericalEnd.radius, e) || (this._userTransitionRadiusEnd = this._sphericalEnd.radius);
}
lerpLookAt(e, t, n, r, i, a, o, s, c, l, u, d, f, p = !1) {
return this.lerp({
position: [
e,
t,
n
],
target: [
r,
i,
a
]
}, {
position: [
o,
s,
c
],
target: [
l,
u,
d
]
}, f, p);
}
setPosition(e, t, n, r = !1) {
return this.setLookAt(e, t, n, this._targetEnd.x, this._targetEnd.y, this._targetEnd.z, r);
}
setTarget(e, t, n, r = !1) {
let i = this.getPosition(X), a = this.setLookAt(i.x, i.y, i.z, e, t, n, r);
return this._sphericalEnd.phi = Ms(this._sphericalEnd.phi, this.minPolarAngle, this.maxPolarAngle), a;
}
setFocalOffset(e, t, n, r = !1) {
this._isUserControllingOffset = this._userTransitions > 0, this._focalOffsetEnd.set(e, t, n), this._needsUpdate = !0, r || this._focalOffset.copy(this._focalOffsetEnd);
let i = !r || Ps(this._focalOffset.x, this._focalOffsetEnd.x, this.restThreshold) && Ps(this._focalOffset.y, this._focalOffsetEnd.y, this.restThreshold) && Ps(this._focalOffset.z, this._focalOffsetEnd.z, this.restThreshold);
return this._createOnRestPromise(i);
}
setOrbitPoint(e, t, n) {
this._camera.updateMatrixWorld(), tc.setFromMatrixColumn(this._camera.matrixWorldInverse, 0), nc.setFromMatrixColumn(this._camera.matrixWorldInverse, 1), rc.setFromMatrixColumn(this._camera.matrixWorldInverse, 2);
let r = X.set(e, t, n), i = r.distanceTo(this._camera.position), a = r.sub(this._camera.position);
tc.multiplyScalar(a.x), nc.multiplyScalar(a.y), rc.multiplyScalar(a.z), X.copy(tc).add(nc).add(rc), X.z += i, this.dollyTo(i, !1), this.setFocalOffset(-X.x, X.y, -X.z, !1), this.moveTo(e, t, n, !1);
}
setBoundary(e) {
if (!e) {
this._boundary.min.set(-Infinity, -Infinity, -Infinity), this._boundary.max.set(Infinity, Infinity, Infinity), this._needsUpdate = !0;
return;
}
this._boundary.copy(e), this._boundary.clampPoint(this._targetEnd, this._targetEnd), this._needsUpdate = !0;
}
setViewport(e, t, n, r) {
if (e === null) {
this._viewport = null;
return;
}
this._viewport = this._viewport || new Y.Vector4(), typeof e == "number" ? this._viewport.set(e, t, n, r) : this._viewport.copy(e);
}
getDistanceToFitBox(e, t, n, r = !1) {
if (Vs(this._camera, "getDistanceToFitBox")) return this._spherical.radius;
let i = e / t, a = this._camera.getEffectiveFOV() * js, o = this._camera.aspect;
return ((r ? i > o : i < o) ? t : e / o) * .5 / Math.tan(a * .5) + n * .5;
}
getDistanceToFitSphere(e) {
if (Vs(this._camera, "getDistanceToFitSphere")) return this._spherical.radius;
let t = this._camera.getEffectiveFOV() * js, n = Math.atan(Math.tan(t * .5) * this._camera.aspect) * 2, r = 1 < this._camera.aspect ? t : n;
return e / Math.sin(r * .5);
}
getTarget(e, t = !0) {
return (e && e.isVector3 ? e : new Y.Vector3()).copy(t ? this._targetEnd : this._target);
}
getPosition(e, t = !0) {
return (e && e.isVector3 ? e : new Y.Vector3()).setFromSpherical(t ? this._sphericalEnd : this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(t ? this._targetEnd : this._target);
}
getSpherical(e, t = !0) {
return (e || new Y.Spherical()).copy(t ? this._sphericalEnd : this._spherical);
}
getFocalOffset(e, t = !0) {
return (e && e.isVector3 ? e : new Y.Vector3()).copy(t ? this._focalOffsetEnd : this._focalOffset);
}
normalizeRotations() {
return this._sphericalEnd.theta = (this._sphericalEnd.theta % Os + Os) % Os, this._sphericalEnd.theta > Math.PI && (this._sphericalEnd.theta -= Os), this._spherical.theta += Os * Math.round((this._sphericalEnd.theta - this._spherical.theta) / Os), this;
}
stop() {
this._focalOffset.copy(this._focalOffsetEnd), this._target.copy(this._targetEnd), this._spherical.copy(this._sphericalEnd), this._zoom = this._zoomEnd;
}
reset(e = !1) {
if (!Ps(this._camera.up.x, this._cameraUp0.x) || !Ps(this._camera.up.y, this._cameraUp0.y) || !Ps(this._camera.up.z, this._cameraUp0.z)) {
this._camera.up.copy(this._cameraUp0);
let e = this.getPosition(X);
this.updateCameraUp(), this.setPosition(e.x, e.y, e.z);
}
let t = [
this.setLookAt(this._position0.x, this._position0.y, this._position0.z, this._target0.x, this._target0.y, this._target0.z, e),
this.setFocalOffset(this._focalOffset0.x, this._focalOffset0.y, this._focalOffset0.z, e),
this.zoomTo(this._zoom0, e)
];
return Promise.all(t);
}
saveState() {
this._cameraUp0.copy(this._camera.up), this.getTarget(this._target0), this.getPosition(this._position0), this._zoom0 = this._zoom, this._focalOffset0.copy(this._focalOffset);
}
updateCameraUp() {
this._yAxisUpSpace.setFromUnitVectors(this._camera.up, Ys), this._yAxisUpSpaceInverse.copy(this._yAxisUpSpace).invert();
}
applyCameraUp() {
let e = X.subVectors(this._target, this._camera.position).normalize(), t = Qs.crossVectors(e, this._camera.up);
this._camera.up.crossVectors(t, e).normalize(), this._camera.updateMatrixWorld();
let n = this.getPosition(X);
this.updateCameraUp(), this.setPosition(n.x, n.y, n.z);
}
update(e) {
let t = this._sphericalEnd.theta - this._spherical.theta, n = this._sphericalEnd.phi - this._spherical.phi, r = this._sphericalEnd.radius - this._spherical.radius, i = ic.subVectors(this._targetEnd, this._target), a = ac.subVectors(this._focalOffsetEnd, this._focalOffset), o = this._zoomEnd - this._zoom;
if (Ns(t)) this._thetaVelocity.value = 0, this._spherical.theta = this._sphericalEnd.theta;
else {
let t = this._isUserControllingRotate ? this._controlSmoothTime.rotateAzimuth : this._smoothTime.rotateAzimuth;
this._spherical.theta = Rs(this._spherical.theta, this._sphericalEnd.theta, this._thetaVelocity, t, Infinity, e), this._needsUpdate = !0;
}
if (Ns(n)) this._phiVelocity.value = 0, this._spherical.phi = this._sphericalEnd.phi;
else {
let t = this._isUserControllingRotate ? this._controlSmoothTime.rotatePolar : this._smoothTime.rotatePolar;
this._spherical.phi = Rs(this._spherical.phi, this._sphericalEnd.phi, this._phiVelocity, t, Infinity, e), this._needsUpdate = !0;
}
if (Ns(r)) this._radiusVelocity.value = 0, this._spherical.radius = this._sphericalEnd.radius;
else {
let t = this._isUserControllingDolly ? this._controlSmoothTime.dolly : this._smoothTime.dolly;
this._spherical.radius = Rs(this._spherical.radius, this._sphericalEnd.radius, this._radiusVelocity, t, this.maxSpeed, e), this._needsUpdate = !0;
}
if (Ns(i.x) && Ns(i.y) && Ns(i.z) ? (this._targetVelocity.set(0, 0, 0), this._target.copy(this._targetEnd)) : (zs(this._target, this._targetEnd, this._targetVelocity, this._getTargetSmoothTime(), this.maxSpeed, e, this._target), this._needsUpdate = !0), Ns(a.x) && Ns(a.y) && Ns(a.z)) this._focalOffsetVelocity.set(0, 0, 0), this._focalOffset.copy(this._focalOffsetEnd);
else {
let t = this._isUserControllingOffset ? this._controlSmoothTime.offset : this._smoothTime.offset;
zs(this._focalOffset, this._focalOffsetEnd, this._focalOffsetVelocity, t, this.maxSpeed, e, this._focalOffset), this._needsUpdate = !0;
}
if (Ns(o)) this._zoomVelocity.value = 0, this._zoom = this._zoomEnd;
else {
let t = this._isUserControllingZoom ? this._controlSmoothTime.zoom : this._smoothTime.zoom;
this._zoom = Rs(this._zoom, this._zoomEnd, this._zoomVelocity, t, Infinity, e);
}
if (this.dollyToCursor) {
if (Es(this._camera) && this._changedDolly !== 0) {
let e = this._spherical.radius - this._lastDistance, t = this._camera, n = this._getCameraDirection(ec), r = X.copy(n).cross(t.up).normalize();
r.lengthSq() === 0 && (r.x = 1);
let i = Qs.crossVectors(r, n), a = this._sphericalEnd.radius * Math.tan(t.getEffectiveFOV() * js * .5), o = (this._sphericalEnd.radius - e - this._sphericalEnd.radius) / this._sphericalEnd.radius, s = $s.copy(this._targetEnd).add(r.multiplyScalar(this._dollyControlCoord.x * a * t.aspect)).add(i.multiplyScalar(this._dollyControlCoord.y * a)), c = X.copy(this._targetEnd).lerp(s, o), l = this._lastDollyDirection === Ts.IN && this._spherical.radius <= this.minDistance, u = this._lastDollyDirection === Ts.OUT && this.maxDistance <= this._spherical.radius;
if (this.infinityDolly && (l || u)) {
this._sphericalEnd.radius -= e, this._spherical.radius -= e;
let t = Qs.copy(n).multiplyScalar(-e);
c.add(t);
}
this._boundary.clampPoint(c, c);
let d = Qs.subVectors(c, this._targetEnd);
this._targetEnd.copy(c), this._target.add(d), this._changedDolly -= e, Ns(this._changedDolly) && (this._changedDolly = 0);
} else if (Ds(this._camera) && this._changedZoom !== 0) {
let e = this._zoom - this._lastZoom, t = this._camera, n = X.set(this._dollyControlCoord.x, this._dollyControlCoord.y, (t.near + t.far) / (t.near - t.far)).unproject(t), r = Qs.set(0, 0, -1).applyQuaternion(t.quaternion), i = $s.copy(n).add(r.multiplyScalar(-n.dot(t.up))), a = -(this._zoom - e - this._zoom) / this._zoom, o = this._getCameraDirection(ec), s = this._targetEnd.dot(o), c = X.copy(this._targetEnd).lerp(i, a), l = c.dot(o), u = o.multiplyScalar(l - s);
c.sub(u), this._boundary.clampPoint(c, c);
let d = Qs.subVectors(c, this._targetEnd);
this._targetEnd.copy(c), this._target.add(d), this._changedZoom -= e, Ns(this._changedZoom) && (this._changedZoom = 0);
}
}
this._camera.zoom !== this._zoom && (this._camera.zoom = this._zoom, this._camera.updateProjectionMatrix(), this._updateNearPlaneCorners(), this._needsUpdate = !0), this._dragNeedsUpdate = !0;
let s = this._collisionTest();
this._spherical.radius = Math.min(this._spherical.radius, s), this._spherical.makeSafe(), this._camera.position.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse).add(this._target), X.copy(this._target), this._camera.parent && this._camera.parent.localToWorld(X), this._camera.lookAt(X), (!Ns(this._focalOffset.x) || !Ns(this._focalOffset.y) || !Ns(this._focalOffset.z)) && (this._camera.matrix.compose(this._camera.position, this._camera.quaternion, this._camera.scale), tc.setFromMatrixColumn(this._camera.matrix, 0), nc.setFromMatrixColumn(this._camera.matrix, 1), rc.setFromMatrixColumn(this._camera.matrix, 2), tc.multiplyScalar(this._focalOffset.x), nc.multiplyScalar(-this._focalOffset.y), rc.multiplyScalar(this._focalOffset.z), X.copy(tc).add(nc).add(rc), this._camera.position.add(X), this._camera.updateMatrixWorld()), this._boundaryEnclosesCamera && this._encloseToBoundary(this._camera.position.copy(this._target), X.setFromSpherical(this._spherical).applyQuaternion(this._yAxisUpSpaceInverse), 1);
let c = this._needsUpdate;
return c && !this._updatedLastTime ? (this._hasRested = !1, this.dispatchEvent({ type: "wake" }), this.dispatchEvent({ type: "update" })) : c ? (this.dispatchEvent({ type: "update" }), Ns(t, this.restThreshold) && Ns(n, this.restThreshold) && Ns(r, this.restThreshold) && Ns(i.x, this.restThreshold) && Ns(i.y, this.restThreshold) && Ns(i.z, this.restThreshold) && Ns(a.x, this.restThreshold) && Ns(a.y, this.restThreshold) && Ns(a.z, this.restThreshold) && Ns(o, this.restThreshold) && !this._hasRested && (this._hasRested = !0, this.dispatchEvent({ type: "rest" }))) : !c && this._updatedLastTime && this.dispatchEvent({ type: "sleep" }), this._lastDistance = this._spherical.radius, this._lastZoom = this._zoom, this._updatedLastTime = c, this._needsUpdate = !1, c;
}
toJSON() {
return JSON.stringify({
enabled: this._enabled,
minDistance: this.minDistance,
maxDistance: Is(this.maxDistance),
minZoom: this.minZoom,
maxZoom: Is(this.maxZoom),
minPolarAngle: this.minPolarAngle,
maxPolarAngle: Is(this.maxPolarAngle),
minAzimuthAngle: Is(this.minAzimuthAngle),
maxAzimuthAngle: Is(this.maxAzimuthAngle),
smoothTime: this._smoothTime,
controlSmoothTime: this._controlSmoothTime,
dollySpeed: this.dollySpeed,
truckSpeed: this.truckSpeed,
dollyToCursor: this.dollyToCursor,
target: this._targetEnd.toArray(),
position: X.setFromSpherical(this._sphericalEnd).add(this._targetEnd).toArray(),
zoom: this._zoomEnd,
focalOffset: this._focalOffsetEnd.toArray(),
target0: this._target0.toArray(),
position0: this._position0.toArray(),
zoom0: this._zoom0,
focalOffset0: this._focalOffset0.toArray()
});
}
fromJSON(e, t = !1) {
let n = JSON.parse(e);
this.enabled = n.enabled, this.minDistance = n.minDistance, this.maxDistance = Ls(n.maxDistance), this.minZoom = n.minZoom, this.maxZoom = Ls(n.maxZoom), this.minPolarAngle = n.minPolarAngle, this.maxPolarAngle = Ls(n.maxPolarAngle), this.minAzimuthAngle = Ls(n.minAzimuthAngle), this.maxAzimuthAngle = Ls(n.maxAzimuthAngle), this.smoothTime = n.smoothTime, this.controlSmoothTime = n.controlSmoothTime, this.dollySpeed = n.dollySpeed, this.truckSpeed = n.truckSpeed, this.dollyToCursor = n.dollyToCursor, this._target0.fromArray(n.target0), this._position0.fromArray(n.position0), this._zoom0 = n.zoom0, this._focalOffset0.fromArray(n.focalOffset0), this.moveTo(n.target[0], n.target[1], n.target[2], t), oc.setFromVector3(X.fromArray(n.position).sub(this._targetEnd).applyQuaternion(this._yAxisUpSpace)), this.rotateTo(oc.theta, oc.phi, t), this.dollyTo(oc.radius, t), this.zoomTo(n.zoom, t), this.setFocalOffset(n.focalOffset[0], n.focalOffset[1], n.focalOffset[2], t), this._needsUpdate = !0;
}
connect(e) {
if (this._domElement) {
console.warn("camera-controls is already connected.");
return;
}
e.setAttribute("data-camera-controls-version", Us), this._addAllEventListeners(e), this._getClientRect(this._elementRect);
}
disconnect() {
this.cancel(), this._removeAllEventListeners(), this._domElement && (this._domElement.removeAttribute("data-camera-controls-version"), this._domElement = void 0);
}
dispose() {
this.removeAllEventListeners(), this.disconnect();
}
_getTargetDirection(e) {
return e.setFromSpherical(this._spherical).divideScalar(this._spherical.radius).applyQuaternion(this._yAxisUpSpaceInverse);
}
_getCameraDirection(e) {
return this._getTargetDirection(e).negate();
}
_findPointerById(e) {
return this._activePointers.find((t) => t.pointerId === e);
}
_findPointerByMouseButton(e) {
return this._activePointers.find((t) => t.mouseButton === e);
}
_disposePointer(e) {
this._activePointers.splice(this._activePointers.indexOf(e), 1);
}
_encloseToBoundary(e, t, n) {
let r = t.lengthSq();
if (r === 0) return e;
let i = Qs.copy(t).add(e), a = this._boundary.clampPoint(i, $s).sub(i), o = a.lengthSq();
if (o === 0) return e.add(t);
if (o === r) return e;
if (n === 0) return e.add(t).add(a);
{
let r = 1 + n * o / t.dot(a);
return e.add(Qs.copy(t).multiplyScalar(r)).add(a.multiplyScalar(1 - n));
}
}
_updateNearPlaneCorners() {
if (Es(this._camera)) {
let e = this._camera, t = e.near, n = e.getEffectiveFOV() * js, r = Math.tan(n * .5) * t, i = r * e.aspect;
this._nearPlaneCorners[0].set(-i, -r, 0), this._nearPlaneCorners[1].set(i, -r, 0), this._nearPlaneCorners[2].set(i, r, 0), this._nearPlaneCorners[3].set(-i, r, 0);
} else if (Ds(this._camera)) {
let e = this._camera, t = 1 / e.zoom, n = e.left * t, r = e.right * t, i = e.top * t, a = e.bottom * t;
this._nearPlaneCorners[0].set(n, i, 0), this._nearPlaneCorners[1].set(r, i, 0), this._nearPlaneCorners[2].set(r, a, 0), this._nearPlaneCorners[3].set(n, a, 0);
}
}
_collisionTest() {
let e = Infinity;
if (!(this.colliderMeshes.length >= 1) || Vs(this._camera, "_collisionTest")) return e;
let t = this._getTargetDirection(ec);
pc.lookAt(Js, t, this._camera.up);
for (let n = 0; n < 4; n++) {
let r = Qs.copy(this._nearPlaneCorners[n]);
r.applyMatrix4(pc);
let i = $s.addVectors(this._target, r);
mc.set(i, t), mc.far = this._spherical.radius + 1;
let a = mc.intersectObjects(this.colliderMeshes);
a.length !== 0 && a[0].distance < e && (e = a[0].distance);
}
return e;
}
_getClientRect(e) {
if (!this._domElement) return;
let t = this._domElement.getBoundingClientRect();
return e.x = t.left, e.y = t.top, this._viewport ? (e.x += this._viewport.x, e.y += t.height - this._viewport.w - this._viewport.y, e.width = this._viewport.z, e.height = this._viewport.w) : (e.width = t.width, e.height = t.height), e;
}
_createOnRestPromise(e) {
return e ? Promise.resolve() : (this._hasRested = !1, this.dispatchEvent({ type: "transitionstart" }), new Promise((e) => {
let t = () => {
this.removeEventListener("rest", t), e();
};
this.addEventListener("rest", t);
}));
}
_addAllEventListeners(e) {}
_removeAllEventListeners() {}
get smoothTime() {
return this._smoothTime;
}
set smoothTime(e) {
this._applySmoothTime(this._smoothTime, e);
}
get controlSmoothTime() {
return this._controlSmoothTime;
}
set controlSmoothTime(e) {
this._applySmoothTime(this._controlSmoothTime, e);
}
get draggingSmoothTime() {
return console.warn(".draggingSmoothTime has been deprecated. use controlSmoothTime instead."), this._controlSmoothTime;
}
set draggingSmoothTime(e) {
console.warn(".draggingSmoothTime has been deprecated. use controlSmoothTime instead."), this._applySmoothTime(this._controlSmoothTime, e);
}
_getTargetSmoothTime() {
return this._isUserControllingTruck ? this._controlSmoothTime.truck : this._smoothTime.truck;
}
_applySmoothTime(e, t) {
if (t != null) if (typeof t == "number") e.rotateAzimuth = e.rotatePolar = e.truck = e.dolly = e.zoom = e.offset = t;
else {
t.rotate !== void 0 && (e.rotateAzimuth = e.rotatePolar = t.rotate);
for (let n of Gs) t[n] !== void 0 && (e[n] = t[n]);
}
}
get dampingFactor() {
return console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead."), 0;
}
set dampingFactor(e) {
console.warn(".dampingFactor has been deprecated. use smoothTime (in seconds) instead.");
}
get draggingDampingFactor() {
return console.warn(".draggingDampingFactor has been deprecated. use controlSmoothTime (in seconds) instead."), 0;
}
set draggingDampingFactor(e) {
console.warn(".draggingDampingFactor has been deprecated. use controlSmoothTime (in seconds) instead.");
}
static createBoundingSphere(e, t = new Y.Sphere()) {
let n = t, r = n.center;
cc.makeEmpty(), e.traverseVisible((e) => {
e.isMesh && cc.expandByObject(e);
}), cc.getCenter(r);
let i = 0;
return e.traverseVisible((e) => {
if (!e.isMesh) return;
let t = e;
if (!t.geometry) return;
let n = t.geometry.clone();
n.applyMatrix4(t.matrixWorld);
let a = n.attributes.position;
for (let e = 0, t = a.count; e < t; e++) X.fromBufferAttribute(a, e), i = Math.max(i, r.distanceToSquared(X));
}), n.radius = Math.sqrt(i), n;
}
};
function gc(e, t, n, r, i, a, o, s, c, l) {
let u = r * o + i * s + a * c;
return Math.abs(u) < 1e-12 ? null : (l - (e * o + t * s + n * c)) / u;
}
var _c = 1e-7, vc = /Mac/.test((Cs = globalThis) == null || (Cs = Cs.navigator) == null ? void 0 : Cs.platform);
function yc(e, t, n) {
if (e === t) return n < e ? 0 : 1;
let r = Ms((n - e) / (t - e), 0, 1);
return r * r * (3 - 2 * r);
}
var bc = class extends hc {
constructor(e, t) {
super(e, t), q(this, "dollyToCursorHorizonAngle", 6 * js), q(this, "_targetPlaneNormal", void 0), q(this, "_targetPlaneConstant", 0), q(this, "_warnedTruck", !1), q(this, "_targetFollowsDolly", !1), q(this, "_normal", void 0), q(this, "_endCamera", void 0), q(this, "_forward", void 0), q(this, "_right", void 0), q(this, "_up", void 0), q(this, "_cursorDir", void 0), q(this, "_movedCamera", void 0), q(this, "_rayOrigin", void 0), q(this, "_bearing", void 0), q(this, "_truckShift", void 0), q(this, "_anchorShift", void 0), q(this, "_newTarget", void 0);
let n = qs();
this._targetPlaneNormal = new n.Vector3(), this._normal = new n.Vector3(), this._endCamera = new n.Vector3(), this._forward = new n.Vector3(), this._right = new n.Vector3(), this._up = new n.Vector3(), this._cursorDir = new n.Vector3(), this._movedCamera = new n.Vector3(), this._rayOrigin = new n.Vector3(), this._bearing = new n.Vector3(), this._truckShift = new n.Vector3(), this._anchorShift = new n.Vector3(), this._newTarget = new n.Vector3(), this._updateTargetPlaneNormal(), this._targetPlaneConstant = this._targetEnd.dot(this._targetPlaneNormal);
let r = this._truckInternal;
this._truckInternal = (e, t, n, i) => {
!n && !i && (this._warnedTruck || (console.warn("MapControls: TRUCK panning drifts the target off the plane; coercing to SCREEN_PAN. Bind SCREEN_PAN instead of TRUCK."), this._warnedTruck = !0), i = !0), n || (this._targetFollowsDolly = !1), r(e, t, n, i);
};
let i = this._dollyInternal;
this._dollyInternal = (e, t, n) => {
let r = this._camera;
if (this.dollyToCursor && !this.infinityDolly && Es(r)) {
let i = .95 ** (-e * this.dollySpeed), a = this._sphericalEnd.radius, o = Ms(a * i, this.minDistance, this.maxDistance) / a;
this._updateTargetPlaneNormal();
let s = this._normal.copy(this._targetPlaneNormal), c = this._targetPlaneConstant, l = this._endCamera.setFromSpherical(this._sphericalEnd).applyQuaternion(this._yAxisUpSpaceInverse).add(this._targetEnd), u = this._forward.subVectors(this._targetEnd, l).normalize(), d = u.dot(s);
if (d > -1e-7) this._dollyToNoClamp(Ms(a * i, this.minDistance, this.maxDistance), !0);
else {
let i = this._right.crossVectors(u, r.up);
i.lengthSq() < _c && i.setFromMatrixColumn(r.matrixWorld, 0), i.normalize();
let f = this._up.crossVectors(i, u).normalize(), p = Math.tan(r.getEffectiveFOV() * js * .5), m = p * r.aspect, h = this._cursorDir.copy(u).addScaledVector(i, t * m).addScaledVector(f, n * p).normalize(), g = -h.dot(s), _ = Math.sin(this.dollyToCursorHorizonAngle), v = yc(Math.sin(.5 * this.dollyToCursorHorizonAngle), _, g), y = this._bearing.copy(h).addScaledVector(s, g);
y.lengthSq() > _c && y.normalize();
let b = Math.abs(e) * (vc ? 10 : 30), x = a * p, S = this.truckSpeed * b * x / this._elementRect.height, C = this._truckShift.copy(y).multiplyScalar(Math.sign(1 - o) * S), w = this._anchorShift.set(0, 0, 0), T = a;
if (v > 0) {
let e = gc(l.x, l.y, l.z, h.x, h.y, h.z, s.x, s.y, s.z, c);
if (e !== null && e > 0) {
let t = this._movedCamera.copy(l).addScaledVector(h, e * (1 - o));
T = (c - t.dot(s)) / d, w.copy(t).addScaledVector(u, T).sub(this._targetEnd);
} else v = 0;
}
let E = this._truckShift, D;
v >= 1 ? (E.copy(w), D = T) : v <= 0 ? (E.copy(C), D = a) : (E.copy(C).lerp(w, v), D = a + (T - a) * v);
let O = this._newTarget.copy(this._targetEnd).add(E);
this._boundary.clampPoint(O, O), this._dollyToNoClamp(Ms(D, this.minDistance, this.maxDistance), !0), this._targetEnd.copy(O);
}
this._isUserControllingTruck = !0, this._targetFollowsDolly = !0, this._changedDolly = 0, this._lastDollyDirection = Math.sign(-e), this._needsUpdate = !0;
return;
}
this._targetFollowsDolly = !1, i(e, t, n);
};
let a = this._zoomInternal;
this._zoomInternal = (e, t, n) => {
let r = this._camera;
if (this.dollyToCursor && !this.infinityDolly && Ds(r)) {
let i = .95 ** (e * this.dollySpeed), a = this._zoomEnd, o = Ms(a * i, this.minZoom, this.maxZoom);
this._updateTargetPlaneNormal();
let s = this._normal.copy(this._targetPlaneNormal), c = this._targetPlaneConstant, l = this._endCamera.setFromSpherical(this._sphericalEnd).applyQuaternion(this._yAxisUpSpaceInverse).add(this._targetEnd), u = this._forward.subVectors(this._targetEnd, l).normalize(), d = this._right.crossVectors(u, r.up);
d.lengthSq() < _c && d.setFromMatrixColumn(r.matrixWorld, 0), d.normalize();
let f = this._up.crossVectors(d, u).normalize(), p = -u.dot(s), m = Math.sin(this.dollyToCursorHorizonAngle), h = yc(Math.sin(.5 * this.dollyToCursorHorizonAngle), m, p), g = (r.top - r.bottom) / a, _ = 1 - a / o, v = this._bearing.copy(u).addScaledVector(s, p);
v.lengthSq() > _c && v.normalize();
let y = Math.abs(e) * (vc ? 10 : 30), b = this.truckSpeed * y * g / this._elementRect.height, x = this._truckShift.copy(v).multiplyScalar(Math.sign(_) * b), S = this._anchorShift.set(0, 0, 0);
if (h > 0) {
let e = (r.right + r.left) * .5, i = (r.top + r.bottom) * .5, o = (r.right - r.left) * .5 / a, p = g * .5, m = this._rayOrigin.copy(l).addScaledVector(d, e + t * o).addScaledVector(f, i + n * p), v = gc(m.x, m.y, m.z, u.x, u.y, u.z, s.x, s.y, s.z, c);
v === null ? h = 0 : S.copy(m).addScaledVector(u, v).sub(this._targetEnd).multiplyScalar(_);
}
let C = this._truckShift;
h >= 1 ? C.copy(S) : h <= 0 ? C.copy(x) : C.copy(x).lerp(S, h);
let w = this._newTarget.copy(this._targetEnd).add(C);
this._boundary.clampPoint(w, w), this.zoomTo(o, !0), this._targetEnd.copy(w), this._isUserControllingTruck = !0, this._targetFollowsDolly = !0, this._needsUpdate = !0;
return;
}
this._targetFollowsDolly = !1, a(e, t, n);
};
}
_getTargetSmoothTime() {
return (this._targetFollowsDolly || this._isZoomingInUserTransition()) && this._isUserControllingTruck ? Ds(this._camera) ? this._isUserControllingZoom ? this._controlSmoothTime.zoom : this._smoothTime.zoom : this._isUserControllingDolly ? this._controlSmoothTime.dolly : this._smoothTime.dolly : super._getTargetSmoothTime();
}
_isZoomingInUserTransition() {
return this._userTransitions === 0 ? !1 : Ds(this._camera) ? this._zoomEnd === this._userTransitionZoomEnd && !Ps(this._zoom, this._zoomEnd) : this._sphericalEnd.radius === this._userTransitionRadiusEnd && !Ps(this._spherical.radius, this._sphericalEnd.radius);
}
_updateTargetPlaneNormal() {
this._targetPlaneNormal.copy(this._camera.up).normalize();
}
setTargetPlane(e) {
this._targetPlaneConstant = e;
}
getTargetPlane() {
return this._targetPlaneConstant;
}
}, Z = ie(), xc = {
Box3: ze,
MathUtils: { clamp: zt.clamp },
Matrix4: W,
Quaternion: yt,
Raycaster: Ze,
Sphere: vn,
Spherical: Bt,
Vector2: V,
Vector3: U,
Vector4: _n
};
bc.install({ THREE: xc }), le({ CameraControlsImpl: bc });
function Sc(e) {
var t, n;
let r = (0, Z.c)(50), i, a, o, s, c, l, u, d, f, p, m, h, g, _;
r[0] === e ? (i = r[1], a = r[2], o = r[3], s = r[4], c = r[5], l = r[6], u = r[7], d = r[8], f = r[9], p = r[10], m = r[11], h = r[12], g = r[13], _ = r[14]) : ({ref: h, camera: i, domElement: a, makeDefault: o, onControlStart: l, onControl: s, onControlEnd: c, onTransitionStart: f, onUpdate: p, onWake: m, onRest: u, onSleep: d, regress: g, ..._} = e, r[0] = e, r[1] = i, r[2] = a, r[3] = o, r[4] = s, r[5] = c, r[6] = l, r[7] = u, r[8] = d, r[9] = f, r[10] = p, r[11] = m, r[12] = h, r[13] = g, r[14] = _);
let v = I(Mc), y = I(jc), b = I(Ac), x = I(kc), S = I(Oc), C = I(Dc), w = _e(), T = (t = i) == null ? v : t, E = (n = a) == null ? y.domElement : n, D;
r[15] === T ? D = r[16] : (D = () => Nc(T), r[15] = T, r[16] = D);
let [O, k] = (0, G.useState)(D), [A, j] = (0, G.useState)(T);
A !== T && (j(T), k((e) => Object.assign(e, { camera: T })));
let M;
r[17] !== O || r[18] !== T || r[19] !== y || r[20] !== w ? (M = (e, t) => {
if (O.update(Math.min(t, Fc)) || y.info.render.frame == 0) {
let e = T.position.toArray().map(Ec), t = O.getTarget(Ic).toArray().map(Tc), { theta: n, phi: r, radius: i } = O.getSpherical(Lc), a = [
Tn(n),
Tn(r),
i
].map(wc), o = [T.near, T.far].map(Cc);
w("camera", {
position: e,
target: t,
spherical: a,
clippingPlanes: o
});
}
}, r[17] = O, r[18] = T, r[19] = y, r[20] = w, r[21] = M) : M = r[21], ue(M, -1);
let N, P;
r[22] !== O || r[23] !== E ? (N = () => {
O.connect(E);
let e = () => O.cancel();
return E.addEventListener("touchcancel", e), () => {
E.removeEventListener("touchcancel", e), O.disconnect();
};
}, P = [E, O], r[22] = O, r[23] = E, r[24] = N, r[25] = P) : (N = r[24], P = r[25]), (0, G.useEffect)(N, P);
let ee, te;
r[26] !== O || r[27] !== b || r[28] !== s || r[29] !== c || r[30] !== l || r[31] !== u || r[32] !== d || r[33] !== f || r[34] !== p || r[35] !== m || r[36] !== C || r[37] !== g ? (ee = () => {
let e = function() {
b(), g && C.regress();
}, t = (t) => {
e(), l == null || l(t);
}, n = (t) => {
e(), s == null || s(t);
}, r = (e) => {
c == null || c(e);
}, i = (t) => {
e(), f == null || f(t);
}, a = (t) => {
e(), p == null || p(t);
}, o = (t) => {
e(), m == null || m(t);
}, h = (e) => {
u == null || u(e);
}, _ = (e) => {
d == null || d(e);
};
return O.addEventListener("controlstart", t), O.addEventListener("control", n), O.addEventListener("controlend", r), O.addEventListener("transitionstart", i), O.addEventListener("update", a), O.addEventListener("wake", o), O.addEventListener("rest", h), O.addEventListener("sleep", _), () => {
O.removeEventListener("controlstart", t), O.removeEventListener("control", n), O.removeEventListener("controlend", r), O.removeEventListener("transitionstart", i), O.removeEventListener("update", a), O.removeEventListener("wake", o), O.removeEventListener("rest", h), O.removeEventListener("sleep", _);
};
}, te = [
O,
b,
g,
C,
l,
s,
c,
f,
p,
m,
u,
d
], r[26] = O, r[27] = b, r[28] = s, r[29] = c, r[30] = l, r[31] = u, r[32] = d, r[33] = f, r[34] = p, r[35] = m, r[36] = C, r[37] = g, r[38] = ee, r[39] = te) : (ee = r[38], te = r[39]), (0, G.useEffect)(ee, te);
let ne, re;
r[40] !== O || r[41] !== S || r[42] !== o || r[43] !== x ? (ne = () => {
if (o) {
let e = S().controls;
return x({ controls: O }), () => x({ controls: e });
}
}, re = [
o,
O,
x,
S
], r[40] = O, r[41] = S, r[42] = o, r[43] = x, r[44] = ne, r[45] = re) : (ne = r[44], re = r[45]), (0, G.useEffect)(ne, re);
let F;
return r[46] !== O || r[47] !== h || r[48] !== _ ? (F = /* @__PURE__ */ (0, K.jsx)("primitive", {
ref: h,
object: O,
..._
}), r[46] = O, r[47] = h, r[48] = _, r[49] = F) : F = r[49], F;
}
function Cc(e) {
return +e.toFixed(2);
}
function wc(e) {
return +e.toFixed(2);
}
function Tc(e) {
return +e.toFixed(2);
}
function Ec(e) {
return +e.toFixed(2);
}
function Dc(e) {
return e.performance;
}
function Oc(e) {
return e.get;
}
function kc(e) {
return e.set;
}
function Ac(e) {
return e.invalidate;
}
function jc(e) {
return e.gl;
}
function Mc(e) {
return e.camera;
}
function Nc(e) {
let t = new bc(e), { NONE: n } = Pc;
return t.mouseButtons = {
left: n,
middle: n,
right: n,
wheel: n
}, t.touches = {
one: n,
two: n,
three: n
}, t;
}
var Pc = bc.ACTION, Fc = 1 / 30, Ic = new U(), Lc = new Bt();
//#endregion
//#region ../renderer/src/types/guards.ts
function Rc(e) {
return e.shape !== void 0;
}
function zc(e) {
return e.source !== void 0;
}
function Bc(e) {
return e.lines !== void 0;
}
function Vc(e) {
return e.points !== void 0;
}
function Hc(e) {
return e.url !== void 0;
}
function Uc(e) {
return e.children !== void 0;
}
function Wc(e) {
let t = e;
return t.placement !== void 0 && t.screenSpace === !0;
}
function Gc(e) {
return e[0] !== void 0 && Uc(e[0]);
}
function Kc(e) {
return e[0] !== void 0 && Rc(e[0]);
}
function qc(e) {
return e[0] !== void 0 && zc(e[0]);
}
function Jc(e) {
return e[0] !== void 0 && Bc(e[0]);
}
function Yc(e) {
return e[0] !== void 0 && Vc(e[0]);
}
function Xc(e) {
return e[0] !== void 0 && Hc(e[0]);
}
//#endregion
//#region ../renderer/src/utils/logging.ts
var Zc = /* @__PURE__ */ e(y(), 1), Qc = "efp:renderer";
function $c(e) {
let t = (0, Zc.default)(e ? `${Qc}:${e}` : Qc);
t.log = (...e) => console.info(...e);
let n = t.extend("debug");
n.log = (...e) => console.debug(...e);
let r = t.extend("warn");
r.log = (...e) => console.warn(...e);
let i = t.extend("error");
return i.log = (...e) => console.error(...e), {
debug: n,
info: t,
warn: r,
error: i
};
}
function el(e, t) {
function n(e) {
let r = e.name;
Gc(e.children) ? (console.groupCollapsed(r), e.children.forEach((e) => n(e)), console.groupEnd()) : t(r);
}
t.enabled && n(e.rootLayer);
}
//#endregion
//#region ../renderer/src/space/camera-kind.ts
function tl(e) {
return e.isPerspectiveCamera === !0;
}
function nl(e) {
return e.isOrthographicCamera === !0;
}
function rl(e) {
return tl(e) || nl(e);
}
//#endregion
//#region ../renderer/src/space/Space.ts
var il = $c("space");
function al() {
return (0, G.use)(cl);
}
var ol = class {
constructor(e) {
this.matrix = new W(), this.matrixInverse = new W(), this._scale = 1, this._isExternal = !1, this.width = 0, this.height = 0, e && this.refit(e);
}
get scale() {
return this._scale;
}
get isExternal() {
return this._isExternal;
}
refit(e) {
if (this.width = e.width, this.height = e.height, this._isExternal = this.validateStaticTransform(e.staticTransform), this._isExternal) this.matrix.fromArray(e.staticTransform);
else {
let t = sl(e.viewbox, this.width * e.dpr, this.height * e.dpr), { x: n, y: r } = e.viewbox.center;
this.matrix.makeTranslation(-n * t, -r * t, 0).scale(new U(t, t, t));
}
this.matrix.premultiply(ul), this.matrixInverse.copy(this.matrix).invert(), this._scale = Math.sqrt(Go(this.matrix, 0) * Go(this.matrix, 1));
}
planToWorld(e, t = new U()) {
var n;
return t.set(e.x, e.y, (n = e.z) == null ? 0 : n).applyMatrix4(this.matrix);
}
worldToPlan(e, t = new An()) {
return _l.set(e.x, e.y, e.z).applyMatrix4(this.matrixInverse), t.set(_l.x, _l.y, _l.z), t;
}
canvasToNdc(e, t = new V()) {
if (this.width <= 0 || this.height <= 0) return il.warn("canvasToNdc: the canvas has no size"), t.set(0, 0);
let n = e.x / this.width * 2 - 1, r = -(e.y / this.height) * 2 + 1;
return t.set(Uo(n, -1, 1), Uo(r, -1, 1));
}
ndcToCanvas(e, t = new An()) {
return t.set((e.x + 1) / 2 * this.width, (1 - e.y) / 2 * this.height, 0);
}
rayToPlan(e, t = new An()) {
if (ml.copy(e).applyMatrix4(this.matrixInverse), ml.intersectPlane(fl, _l)) return t.set(_l.x, _l.y, 0);
}
ndcToPlan(e, t, n) {
return ll(pl, e, t), this.rayToPlan(pl.ray, n);
}
planToNdc(e, t, n = new V()) {
if (this.planToWorld(e, vl), yl.set(vl.x, vl.y, vl.z, 1).applyMatrix4(t.matrixWorldInverse).applyMatrix4(t.projectionMatrix), !(yl.w <= 0)) return n.set(yl.x / yl.w, yl.y / yl.w);
}
canvasToPlan(e, t, n) {
return this.ndcToPlan(this.canvasToNdc(e, hl), t, n);
}
planToCanvas(e, t, n) {
let r = this.planToNdc(e, t, bl);
if (r) return this.ndcToCanvas(r, n);
}
validateStaticTransform(e) {
return e === void 0 ? !1 : e.length === 16 ? !0 : (il.warn(`staticTransform must be 16 elements long, got ${e.length}`), !1);
}
};
function sl(e, t, n) {
let { width: r, height: i } = e.size;
return r <= 0 || i <= 0 || t <= 0 || n <= 0 ? 1 : Math.min(t / r, n / i);
}
var cl = (0, G.createContext)(new ol());
function ll(e, t, n) {
if (rl(n)) {
e.setFromCamera(gl.set(t.x, t.y), n);
return;
}
e.ray.origin.set(t.x, t.y, -1).unproject(n), e.ray.direction.set(t.x, t.y, 1).unproject(n).sub(e.ray.origin).normalize();
}
var ul = new W().makeScale(1, 1, -1), dl = new W().makeScale(1, -1, 1), fl = new en(new U(0, 0, 1), 0), pl = new Ze(), ml = new H(), hl = new V(), gl = new V(), _l = new U(), vl = new U(), yl = new _n(), bl = new V(), xl;
(function(e) {
e[e.Start = 1] = "Start", e[e.Move = 2] = "Move", e[e.End = 4] = "End", e[e.Cancel = 8] = "Cancel";
})(xl || (xl = {}));
var Sl;
(function(e) {
e[e.None = 0] = "None", e[e.Left = 1] = "Left", e[e.Right = 2] = "Right", e[e.Up = 4] = "Up", e[e.Down = 8] = "Down", e[e.Horizontal = 3] = "Horizontal", e[e.Vertical = 12] = "Vertical", e[e.All = 15] = "All";
})(Sl || (Sl = {}));
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/recognizer/recognizer-state.js
var Q;
(function(e) {
e[e.Possible = 1] = "Possible", e[e.Began = 2] = "Began", e[e.Changed = 4] = "Changed", e[e.Ended = 8] = "Ended", e[e.Recognized = 8] = "Recognized", e[e.Cancelled = 16] = "Cancelled", e[e.Failed = 32] = "Failed";
})(Q || (Q = {}));
var Cl = "auto", wl = "manipulation", Tl = "none", El = "pan-x", Dl = "pan-y";
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/touchaction/clean-touch-actions.js
function Ol(e) {
if (e.includes("none")) return Tl;
let t = e.includes(El), n = e.includes(Dl);
return t && n ? Tl : t || n ? t ? El : Dl : e.includes("manipulation") ? wl : Cl;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/touchaction/touchaction.js
var kl = class {
constructor(e, t) {
this.actions = "", this.manager = e, this.set(t);
}
set(e) {
e === "compute" && (e = this.compute()), this.manager.element && (this.manager.element.style.touchAction = e, this.actions = e);
}
update() {
this.set(this.manager.options.touchAction);
}
compute() {
let e = [];
for (let t of this.manager.recognizers) t.options.enable && (e = e.concat(t.getTouchAction()));
return Ol(e.join(" "));
}
};
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/utils/split-str.js
function Al(e) {
return e.trim().split(/\s+/g);
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/utils/event-listeners.js
function jl(e, t, n) {
if (e) for (let r of Al(t)) e.addEventListener(r, n, !1);
}
function Ml(e, t, n) {
if (e) for (let r of Al(t)) e.removeEventListener(r, n, !1);
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/utils/get-window-for-element.js
function Nl(e) {
return (e.ownerDocument || e).defaultView;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/utils/has-parent.js
function Pl(e, t) {
let n = e;
for (; n;) {
if (n === t) return !0;
n = n.parentNode;
}
return !1;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-center.js
function Fl(e) {
let t = e.length;
if (t === 1) return {
x: Math.round(e[0].clientX),
y: Math.round(e[0].clientY)
};
let n = 0, r = 0, i = 0;
for (; i < t;) n += e[i].clientX, r += e[i].clientY, i++;
return {
x: Math.round(n / t),
y: Math.round(r / t)
};
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/simple-clone-input-data.js
function Il(e) {
let t = [], n = 0;
for (; n < e.pointers.length;) t[n] = {
clientX: Math.round(e.pointers[n].clientX),
clientY: Math.round(e.pointers[n].clientY)
}, n++;
return {
timeStamp: Date.now(),
pointers: t,
center: Fl(t),
deltaX: e.deltaX,
deltaY: e.deltaY
};
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-distance.js
function Ll(e, t) {
let n = t.x - e.x, r = t.y - e.y;
return Math.sqrt(n * n + r * r);
}
function Rl(e, t) {
let n = t.clientX - e.clientX, r = t.clientY - e.clientY;
return Math.sqrt(n * n + r * r);
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-angle.js
function zl(e, t) {
let n = t.x - e.x, r = t.y - e.y;
return Math.atan2(r, n) * 180 / Math.PI;
}
function Bl(e, t) {
let n = t.clientX - e.clientX, r = t.clientY - e.clientY;
return Math.atan2(r, n) * 180 / Math.PI;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-direction.js
function Vl(e, t) {
return e === t ? Sl.None : Math.abs(e) >= Math.abs(t) ? e < 0 ? Sl.Left : Sl.Right : t < 0 ? Sl.Up : Sl.Down;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-delta-xy.js
function Hl(e, t) {
let n = t.center, r = e.offsetDelta, i = e.prevDelta, a = e.prevInput;
return (t.eventType === xl.Start || (a == null ? void 0 : a.eventType) === xl.End) && (i = e.prevDelta = {
x: (a == null ? void 0 : a.deltaX) || 0,
y: (a == null ? void 0 : a.deltaY) || 0
}, r = e.offsetDelta = {
x: n.x,
y: n.y
}), {
deltaX: i.x + (n.x - r.x),
deltaY: i.y + (n.y - r.y)
};
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-velocity.js
function Ul(e, t, n) {
return {
x: t / e || 0,
y: n / e || 0
};
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-scale.js
function Wl(e, t) {
return Rl(t[0], t[1]) / Rl(e[0], e[1]);
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/get-rotation.js
function Gl(e, t) {
return Bl(t[1], t[0]) - Bl(e[1], e[0]);
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/compute-interval-input-data.js
function Kl(e, t) {
let n = e.lastInterval || t, r = t.timeStamp - n.timeStamp, i, a, o, s;
if (t.eventType !== xl.Cancel && (r > 25 || n.velocity === void 0)) {
let c = t.deltaX - n.deltaX, l = t.deltaY - n.deltaY, u = Ul(r, c, l);
a = u.x, o = u.y, i = Math.abs(u.x) > Math.abs(u.y) ? u.x : u.y, s = Vl(c, l), e.lastInterval = t;
} else i = n.velocity, a = n.velocityX, o = n.velocityY, s = n.direction;
t.velocity = i, t.velocityX = a, t.velocityY = o, t.direction = s;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/compute-input-data.js
function ql(e, t) {
let { session: n } = e, { pointers: r } = t, { length: i } = r;
n.firstInput || (n.firstInput = Il(t)), i > 1 && !n.firstMultiple ? n.firstMultiple = Il(t) : i === 1 && (n.firstMultiple = !1);
let { firstInput: a, firstMultiple: o } = n, s = o ? o.center : a.center, c = t.center = Fl(r);
t.timeStamp = Date.now(), t.deltaTime = t.timeStamp - a.timeStamp, t.angle = zl(s, c), t.distance = Ll(s, c);
let { deltaX: l, deltaY: u } = Hl(n, t);
t.deltaX = l, t.deltaY = u, t.offsetDirection = Vl(t.deltaX, t.deltaY);
let d = Ul(t.deltaTime, t.deltaX, t.deltaY);
t.overallVelocityX = d.x, t.overallVelocityY = d.y, t.overallVelocity = Math.abs(d.x) > Math.abs(d.y) ? d.x : d.y, t.scale = o ? Wl(o.pointers, r) : 1, t.rotation = o ? Gl(o.pointers, r) : 0, t.maxPointers = n.prevInput ? t.pointers.length > n.prevInput.maxPointers ? t.pointers.length : n.prevInput.maxPointers : t.pointers.length;
let f = e.element;
return Pl(t.srcEvent.target, f) && (f = t.srcEvent.target), t.target = f, Kl(n, t), t;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/input-handler.js
function Jl(e, t, n) {
let r = n.pointers.length, i = n.changedPointers.length, a = t & xl.Start && r - i === 0, o = t & (xl.End | xl.Cancel) && r - i === 0;
n.isFirst = !!a, n.isFinal = !!o, a && (e.session = {}), n.eventType = t;
let s = ql(e, n);
e.emit("hammer.input", s), e.recognize(s), e.session.prevInput = s;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/input/input.js
var Yl = class {
constructor(e) {
this.evEl = "", this.evWin = "", this.evTarget = "", this.domHandler = (e) => {
this.manager.options.enable && this.handler(e);
}, this.manager = e, this.element = e.element, this.target = e.options.inputTarget || e.element;
}
callback(e, t) {
Jl(this.manager, e, t);
}
init() {
jl(this.element, this.evEl, this.domHandler), jl(this.target, this.evTarget, this.domHandler), jl(Nl(this.element), this.evWin, this.domHandler);
}
destroy() {
Ml(this.element, this.evEl, this.domHandler), Ml(this.target, this.evTarget, this.domHandler), Ml(Nl(this.element), this.evWin, this.domHandler);
}
}, Xl = {
pointerdown: xl.Start,
pointermove: xl.Move,
pointerup: xl.End,
pointercancel: xl.Cancel,
pointerout: xl.Cancel
}, Zl = "pointerdown", Ql = "pointermove pointerup pointercancel", $l = class extends Yl {
constructor(e) {
super(e), this.evEl = Zl, this.evWin = Ql, this.store = this.manager.session.pointerEvents = [], this.init();
}
handler(e) {
let { store: t } = this, n = !1, r = Xl[e.type], i = e.pointerType, a = i === "touch", o = t.findIndex((t) => t.pointerId === e.pointerId);
r & xl.Start && (e.buttons || a) ? o < 0 && (t.push(e), o = t.length - 1) : r & (xl.End | xl.Cancel) && (n = !0), !(o < 0) && (t[o] = e, this.callback(r, {
pointers: t,
changedPointers: [e],
eventType: r,
pointerType: i,
srcEvent: e
}), n && t.splice(o, 1));
}
}, eu = [
"",
"webkit",
"Moz",
"MS",
"ms",
"o"
];
function tu(e, t) {
let n = t[0].toUpperCase() + t.slice(1);
for (let r of eu) {
let i = r ? r + n : t;
if (i in e) return i;
}
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/manager.js
var nu = 1, ru = 2, iu = {
touchAction: "compute",
enable: !0,
inputTarget: null,
cssProps: {
userSelect: "none",
userDrag: "none",
touchCallout: "none",
tapHighlightColor: "rgba(0,0,0,0)"
}
}, au = class {
constructor(e, t) {
this.options = {
...iu,
...t,
cssProps: {
...iu.cssProps,
...t.cssProps
},
inputTarget: t.inputTarget || e
}, this.handlers = {}, this.session = {}, this.recognizers = [], this.oldCssProps = {}, this.element = e, this.input = new $l(this), this.touchAction = new kl(this, this.options.touchAction), this.toggleCssProps(!0);
}
set(e) {
return Object.assign(this.options, e), e.touchAction && this.touchAction.update(), e.inputTarget && (this.input.destroy(), this.input.target = e.inputTarget, this.input.init()), this;
}
stop(e) {
this.session.stopped = e ? ru : nu;
}
recognize(e) {
let { session: t } = this;
if (t.stopped) return;
this.session.prevented && e.srcEvent.preventDefault();
let n, { recognizers: r } = this, { curRecognizer: i } = t;
(!i || i && i.state & Q.Recognized) && (i = t.curRecognizer = null);
let a = 0;
for (; a < r.length;) n = r[a], t.stopped !== ru && (!i || n === i || n.canRecognizeWith(i)) ? n.recognize(e) : n.reset(), !i && n.state & (Q.Began | Q.Changed | Q.Ended) && (i = t.curRecognizer = n), a++;
}
get(e) {
let { recognizers: t } = this;
for (let n = 0; n < t.length; n++) if (t[n].options.event === e) return t[n];
return null;
}
add(e) {
if (Array.isArray(e)) {
for (let t of e) this.add(t);
return this;
}
let t = this.get(e.options.event);
return t && this.remove(t), this.recognizers.push(e), e.manager = this, this.touchAction.update(), e;
}
remove(e) {
if (Array.isArray(e)) {
for (let t of e) this.remove(t);
return this;
}
let t = typeof e == "string" ? this.get(e) : e;
if (t) {
let { recognizers: e } = this, n = e.indexOf(t);
n !== -1 && (e.splice(n, 1), this.touchAction.update());
}
return this;
}
on(e, t) {
if (!e || !t) return;
let { handlers: n } = this;
for (let r of Al(e)) n[r] = n[r] || [], n[r].push(t);
}
off(e, t) {
if (!e) return;
let { handlers: n } = this;
for (let r of Al(e)) t ? n[r] && n[r].splice(n[r].indexOf(t), 1) : delete n[r];
}
emit(e, t) {
let n = this.handlers[e] && this.handlers[e].slice();
if (!n || !n.length) return;
let r = t;
r.type = e, r.preventDefault = function() {
t.srcEvent.preventDefault();
};
let i = 0;
for (; i < n.length;) n[i](r), i++;
}
destroy() {
this.toggleCssProps(!1), this.handlers = {}, this.session = {}, this.input.destroy(), this.element = null;
}
toggleCssProps(e) {
let { element: t } = this;
if (t) {
for (let [n, r] of Object.entries(this.options.cssProps)) {
let i = tu(t.style, n);
e ? (this.oldCssProps[i] = t.style[i], t.style[i] = r) : t.style[i] = this.oldCssProps[i] || "";
}
e || (this.oldCssProps = {});
}
}
}, ou = 1;
function su() {
return ou++;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/recognizer/state-str.js
function cu(e) {
return e & Q.Cancelled ? "cancel" : e & Q.Ended ? "end" : e & Q.Changed ? "move" : e & Q.Began ? "start" : "";
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/hammerjs/recognizer/recognizer.js
var lu = class {
constructor(e) {
this.options = e, this.id = su(), this.state = Q.Possible, this.simultaneous = {}, this.requireFail = [];
}
set(e) {
return Object.assign(this.options, e), this.manager.touchAction.update(), this;
}
recognizeWith(e) {
if (Array.isArray(e)) {
for (let t of e) this.recognizeWith(t);
return this;
}
let t;
if (typeof e == "string") {
if (t = this.manager.get(e), !t) throw Error(`Cannot find recognizer ${e}`);
} else t = e;
let { simultaneous: n } = this;
return n[t.id] || (n[t.id] = t, t.recognizeWith(this)), this;
}
dropRecognizeWith(e) {
if (Array.isArray(e)) {
for (let t of e) this.dropRecognizeWith(t);
return this;
}
let t;
return t = typeof e == "string" ? this.manager.get(e) : e, t && delete this.simultaneous[t.id], this;
}
requireFailure(e) {
if (Array.isArray(e)) {
for (let t of e) this.requireFailure(t);
return this;
}
let t;
if (typeof e == "string") {
if (t = this.manager.get(e), !t) throw Error(`Cannot find recognizer ${e}`);
} else t = e;
let { requireFail: n } = this;
return n.indexOf(t) === -1 && (n.push(t), t.requireFailure(this)), this;
}
dropRequireFailure(e) {
if (Array.isArray(e)) {
for (let t of e) this.dropRequireFailure(t);
return this;
}
let t;
if (t = typeof e == "string" ? this.manager.get(e) : e, t) {
let e = this.requireFail.indexOf(t);
e > -1 && this.requireFail.splice(e, 1);
}
return this;
}
hasRequireFailures() {
return !!this.requireFail.find((e) => e.options.enable);
}
canRecognizeWith(e) {
return !!this.simultaneous[e.id];
}
emit(e) {
if (!e) return;
let { state: t } = this;
t < Q.Ended && this.manager.emit(this.options.event + cu(t), e), this.manager.emit(this.options.event, e), e.additionalEvent && this.manager.emit(e.additionalEvent, e), t >= Q.Ended && this.manager.emit(this.options.event + cu(t), e);
}
tryEmit(e) {
this.canEmit() ? this.emit(e) : this.state = Q.Failed;
}
canEmit() {
let e = 0;
for (; e < this.requireFail.length;) {
if (!(this.requireFail[e].state & (Q.Failed | Q.Possible))) return !1;
e++;
}
return !0;
}
recognize(e) {
let t = { ...e };
if (!this.options.enable) {
this.reset(), this.state = Q.Failed;
return;
}
this.state & (Q.Recognized | Q.Cancelled | Q.Failed) && (this.state = Q.Possible), this.state = this.process(t), this.state & (Q.Began | Q.Changed | Q.Ended | Q.Cancelled) && this.tryEmit(t);
}
getEventNames() {
return [this.options.event];
}
reset() {}
}, uu = class extends lu {
attrTest(e) {
let t = this.options.pointers;
return t === 0 || e.pointers.length === t;
}
process(e) {
let { state: t } = this, { eventType: n } = e, r = t & (Q.Began | Q.Changed), i = this.attrTest(e);
return r && (n & xl.Cancel || !i) ? t | Q.Cancelled : r || i ? n & xl.End ? t | Q.Ended : t & Q.Began ? t | Q.Changed : Q.Began : Q.Failed;
}
}, du = class extends lu {
constructor(e = {}) {
super({
enable: !0,
event: "tap",
pointers: 1,
taps: 1,
interval: 300,
time: 250,
threshold: 9,
posThreshold: 10,
...e
}), this.pTime = null, this.pCenter = null, this._timer = null, this._input = null, this.count = 0;
}
getTouchAction() {
return [wl];
}
process(e) {
let { options: t } = this, n = e.pointers.length === t.pointers, r = e.distance < t.threshold, i = e.deltaTime < t.time;
if (this.reset(), e.eventType & xl.Start && this.count === 0) return this.failTimeout();
if (r && i && n) {
if (e.eventType !== xl.End) return this.failTimeout();
let n = !this.pTime || e.timeStamp - this.pTime < t.interval, r = !this.pCenter || Ll(this.pCenter, e.center) < t.posThreshold;
if (this.pTime = e.timeStamp, this.pCenter = e.center, !r || !n ? this.count = 1 : this.count += 1, this._input = e, this.count % t.taps === 0) return this.hasRequireFailures() ? (this._timer = setTimeout(() => {
this.state = Q.Recognized, this.tryEmit(this._input);
}, t.interval), Q.Began) : Q.Recognized;
}
return Q.Failed;
}
failTimeout() {
return this._timer = setTimeout(() => {
this.state = Q.Failed;
}, this.options.interval), Q.Failed;
}
reset() {
clearTimeout(this._timer);
}
emit(e) {
this.state === Q.Recognized && (e.tapCount = this.count, this.manager.emit(this.options.event, e));
}
}, fu = class extends uu {
constructor() {
super(...arguments), this.wheelSession = null, this.wheelSessionUnsubscribe = null, this.handleWheelSessionEvent = (e) => {
e.device === "trackpad" && this.handleTrackpadEvent(e);
};
}
set(e) {
let { wheelSession: t, ...n } = e;
if (t && t !== this.wheelSession) {
var r;
(r = this.wheelSessionUnsubscribe) == null || r.call(this), this.wheelSessionUnsubscribe = null, this.wheelSession = t;
}
return super.set(n), this.updateWheelSessionSubscription(), this;
}
getTrackpadInput(e, t = {}) {
var n, r;
let { srcEvent: i } = e, a = (n = t.deltaX) == null ? e.deltaX : n, o = (r = t.deltaY) == null ? e.deltaY : r, s = Vl(a, o), c = i;
return {
pointers: [c, c],
changedPointers: [c, c],
pointerType: "trackpad",
srcEvent: c,
eventType: e.eventType,
timeStamp: e.timeStamp,
deltaTime: e.deltaTime,
center: e.center,
deltaX: a,
deltaY: o,
angle: Math.atan2(o, a) * 180 / Math.PI,
distance: Math.sqrt(a * a + o * o),
scale: 1,
rotation: 0,
direction: s,
offsetDirection: s,
velocity: e.velocity,
velocityX: e.velocityX,
velocityY: e.velocityY,
overallVelocity: e.overallVelocity,
overallVelocityX: e.overallVelocityX,
overallVelocityY: e.overallVelocityY,
maxPointers: 2,
target: i.target || this.manager.element,
additionalEvent: "",
...t
};
}
updateWheelSessionSubscription() {
let e = !!(this.wheelSession && this.options.enable && this.options.trackpad && this.options.pointers === 2);
e && !this.wheelSessionUnsubscribe ? this.wheelSessionUnsubscribe = this.wheelSession.on(this.handleWheelSessionEvent) : !e && this.wheelSessionUnsubscribe && (this.wheelSessionUnsubscribe(), this.wheelSessionUnsubscribe = null);
}
}, pu = [
"",
"start",
"move",
"end",
"cancel",
"up",
"down",
"left",
"right"
], mu = class extends fu {
constructor(e = {}) {
super({
enable: !0,
pointers: 1,
event: "pan",
threshold: 10,
direction: Sl.All,
trackpad: !1,
...e
}), this.trackpadGesture = !1, this.pX = null, this.pY = null;
}
getTouchAction() {
let { options: { direction: e } } = this, t = [];
return e & Sl.Horizontal && t.push(Dl), e & Sl.Vertical && t.push(El), t;
}
getEventNames() {
return pu.map((e) => this.options.event + e);
}
directionTest(e) {
let { options: t } = this, n = !0, { distance: r } = e, { direction: i } = e, a = e.deltaX, o = e.deltaY;
return i & t.direction || (t.direction & Sl.Horizontal ? (i = a === 0 ? Sl.None : a < 0 ? Sl.Left : Sl.Right, n = a !== this.pX, r = Math.abs(e.deltaX)) : (i = o === 0 ? Sl.None : o < 0 ? Sl.Up : Sl.Down, n = o !== this.pY, r = Math.abs(e.deltaY))), e.direction = i, n && r > t.threshold && !!(i & t.direction);
}
attrTest(e) {
return super.attrTest(e) && (!!(this.state & Q.Began) || !(this.state & Q.Began) && this.directionTest(e));
}
emit(e) {
this.pX = e.deltaX, this.pY = e.deltaY;
let t = Sl[e.direction].toLowerCase();
t && (e.additionalEvent = this.options.event + t), super.emit(e);
}
handleTrackpadEvent(e) {
e.isFirst && (this.trackpadGesture = !e.srcEvent.ctrlKey), this.trackpadGesture && (this.recognize(this.getTrackpadInput(e, {
deltaX: -e.deltaX,
deltaY: -e.deltaY,
velocity: -e.velocity,
velocityX: -e.velocityX,
velocityY: -e.velocityY,
overallVelocity: -e.overallVelocity,
overallVelocityX: -e.overallVelocityX,
overallVelocityY: -e.overallVelocityY
})), e.isFinal && (this.trackpadGesture = !1));
}
}, hu = [
"",
"start",
"move",
"end",
"cancel"
], gu = class extends uu {
constructor(e = {}) {
super({
enable: !0,
event: "rotate",
threshold: 0,
pointers: 2,
...e
});
}
getTouchAction() {
return [Tl];
}
getEventNames() {
return hu.map((e) => this.options.event + e);
}
attrTest(e) {
return super.attrTest(e) && (Math.abs(e.rotation) > this.options.threshold || !!(this.state & Q.Began));
}
}, _u = class {
constructor(e, t, n) {
this.element = e, this.callback = t, this.options = n;
}
listen(e, t) {
t ? this.element.addEventListener(e, this.handleEvent, { passive: !1 }) : this.element.removeEventListener(e, this.handleEvent);
}
}, vu = (typeof navigator < "u" && navigator.userAgent ? navigator.userAgent.toLowerCase() : "").indexOf("firefox") !== -1, yu = 40, bu = .25, xu = class extends _u {
constructor(e, t, n) {
var r;
if (n.enable = (r = n.enable) != null && r, super(e, t, n), this.handleEvent = (e) => {
var t, n;
if (!this.options.enable) return;
let r = e.deltaY;
globalThis.WheelEvent && (vu && e.deltaMode === globalThis.WheelEvent.DOM_DELTA_PIXEL && (r /= globalThis.devicePixelRatio), e.deltaMode === globalThis.WheelEvent.DOM_DELTA_LINE && (r *= yu)), e.shiftKey && r && (r *= bu), this.callback({
type: "wheel",
center: {
x: e.clientX,
y: e.clientY
},
delta: -r,
device: (t = (n = this.options.wheelSession) == null ? void 0 : n.device) == null ? "unknown" : t,
srcEvent: e,
pointerType: "mouse",
target: e.target
});
}, n.enable) {
var i;
this.wheelSessionUnsubscribe = (i = this.options.wheelSession) == null ? void 0 : i.on(() => {}), this.listen("wheel", !0);
}
}
destroy() {
var e;
this.listen("wheel", !1), (e = this.wheelSessionUnsubscribe) == null || e.call(this), this.wheelSessionUnsubscribe = void 0;
}
enableEventType(e, t) {
if (e === "wheel" && this.options.enable !== t) {
if (this.options.enable = t, t && !this.wheelSessionUnsubscribe) {
var n;
this.wheelSessionUnsubscribe = (n = this.options.wheelSession) == null ? void 0 : n.on(() => {});
}
if (this.listen("wheel", t), !t) {
var r;
(r = this.wheelSessionUnsubscribe) == null || r.call(this), this.wheelSessionUnsubscribe = void 0;
}
}
}
}, Su = 4.000244140625, Cu = 40, wu = 0, Tu = 1, Eu = 40, Du = 40, Ou = 120, ku = {
classificationDelay: 32,
endDelay: 80
}, Au = class {
constructor(e, t = {}) {
var n;
this.subscriptions = /* @__PURE__ */ new Map(), this.session = null, this.classificationTimer = null, this.endTimer = null, this.pressedControlKeys = /* @__PURE__ */ new Set(), this.listeningForControlKeys = !1, this.handleEvent = (e) => {
if (!this.hasSubscribers) return "unknown";
let t = Mu(e, this.pressedControlKeys.size > 0), n = this.session;
if (n && t.timeStamp - n.lastTimeStamp >= this.options.endDelay) {
if (this.end(), !this.hasSubscribers) return "unknown";
n = null;
}
n ? (this.scheduleEnd(), this.addSample(n, t)) : (n = this.startPendingSession(t), this.scheduleEnd());
let { device: r } = n;
return r === "unknown" && (r = Nu(n.samples, !1), r !== "unknown" && this.begin(n, r)), r;
}, this.finishClassification = () => {
if (this.classificationTimer = null, !this.session || this.session.device !== "unknown") return;
let e = this.session, t = Nu(e.samples, !0);
this.begin(e, t === "unknown" ? "mouse" : t);
}, this.end = () => {
if (!this.session) return;
if (this.session.device === "unknown") {
let e = this.session, t = Nu(e.samples, !0);
this.begin(e, t === "unknown" ? "mouse" : t);
}
if (!this.session) return;
let e = this.session;
this.emit(xl.End, e.lastEvent), this.reset();
}, this.handleKeyDown = (e) => {
e.key === "Control" && this.pressedControlKeys.add(e.code || e.key);
}, this.handleKeyUp = (e) => {
e.key === "Control" && (e.code ? this.pressedControlKeys.delete(e.code) : this.pressedControlKeys.clear());
}, this.handleWindowBlur = () => {
this.pressedControlKeys.clear();
}, this.element = e, this.options = {
...ku,
...t
}, (n = this.element) == null || n.addEventListener("wheel", this.handleEvent, { passive: !0 });
}
get hasSubscribers() {
return this.subscriptions.size > 0;
}
get device() {
var e, t;
return (e = (t = this.session) == null ? void 0 : t.device) == null ? "unknown" : e;
}
on(e) {
let t = { listener: e };
return this.subscriptions.set(e, t), this.updateControlKeyEventListeners(), () => {
this.subscriptions.get(e) === t && this.off(e);
};
}
off(e) {
this.subscriptions.delete(e), this.updateControlKeyEventListeners(), this.hasSubscribers || this.reset();
}
cancel() {
let e = this.session;
e && e.device !== "unknown" && this.emit(xl.Cancel, e.lastEvent), this.reset();
}
destroy() {
var e;
this.cancel(), this.subscriptions.clear(), this.updateControlKeyEventListeners(), (e = this.element) == null || e.removeEventListener("wheel", this.handleEvent);
}
startPendingSession(e) {
let t = {
samples: [e],
device: "unknown",
firstTimeStamp: e.timeStamp,
lastTimeStamp: e.timeStamp,
totalDeltaX: e.deltaX,
totalDeltaY: e.deltaY,
velocityX: 0,
velocityY: 0,
lastEvent: e.event
};
return this.session = t, this.classificationTimer = globalThis.setTimeout(this.finishClassification, this.options.classificationDelay), t;
}
addSample(e, t) {
if (e.samples.push(t), e.lastTimeStamp = t.timeStamp, e.lastEvent = t.event, e.totalDeltaX += t.deltaX, e.totalDeltaY += t.deltaY, e.device !== "unknown") {
let n = e.samples[e.samples.length - 2], r = t.timeStamp - n.timeStamp;
e.velocityX = r > 0 ? t.deltaX / r : 0, e.velocityY = r > 0 ? t.deltaY / r : 0, this.emit(xl.Move, t.event, {
velocityX: e.velocityX,
velocityY: e.velocityY
});
}
}
begin(e, t) {
e.device = t, this.clearClassificationTimer(), this.emit(xl.Start, e.samples[0].event);
let n = e.lastTimeStamp - e.firstTimeStamp;
e.velocityX = n > 0 ? e.totalDeltaX / n : 0, e.velocityY = n > 0 ? e.totalDeltaY / n : 0, this.emit(xl.Move, e.lastEvent, {
velocityX: e.velocityX,
velocityY: e.velocityY
});
}
scheduleEnd() {
this.clearEndTimer(), this.endTimer = globalThis.setTimeout(this.end, this.options.endDelay);
}
emit(e, t, n) {
var r, i;
let a = this.session;
if (!a || a.device === "unknown") return;
let o = e === xl.Start, s = e === xl.End || e === xl.Cancel, c = o ? a.firstTimeStamp : a.lastTimeStamp, l = o ? 0 : Math.max(0, c - a.firstTimeStamp), u = o ? 0 : a.totalDeltaX, d = o ? 0 : a.totalDeltaY, f = l > 0 ? u / l : 0, p = l > 0 ? d / l : 0, m = o ? 0 : (r = n == null ? void 0 : n.velocityX) == null ? a.velocityX : r, h = o ? 0 : (i = n == null ? void 0 : n.velocityY) == null ? a.velocityY : i, g = {
eventType: e,
device: a.device,
srcEvent: t,
timeStamp: c,
center: {
x: t.clientX,
y: t.clientY
},
deltaX: u,
deltaY: d,
deltaTime: l,
velocity: Math.abs(m) > Math.abs(h) ? m : h,
velocityX: m,
velocityY: h,
overallVelocity: Math.abs(f) > Math.abs(p) ? f : p,
overallVelocityX: f,
overallVelocityY: p,
isFirst: o,
isFinal: s
};
for (let { listener: e } of [...this.subscriptions.values()]) e(g);
}
reset() {
this.clearClassificationTimer(), this.clearEndTimer(), this.session = null;
}
clearClassificationTimer() {
this.classificationTimer !== null && (globalThis.clearTimeout(this.classificationTimer), this.classificationTimer = null);
}
clearEndTimer() {
this.endTimer !== null && (globalThis.clearTimeout(this.endTimer), this.endTimer = null);
}
updateControlKeyEventListeners() {
let e = this.hasSubscribers, t = ju();
!t || e === this.listeningForControlKeys || (this.listeningForControlKeys = e, e ? (t.addEventListener("keydown", this.handleKeyDown, !0), t.addEventListener("keyup", this.handleKeyUp, !0), t.addEventListener("blur", this.handleWindowBlur)) : (t.removeEventListener("keydown", this.handleKeyDown, !0), t.removeEventListener("keyup", this.handleKeyUp, !0), t.removeEventListener("blur", this.handleWindowBlur), this.pressedControlKeys.clear()));
}
};
function ju() {
var e;
return typeof window < "u" ? window : (e = globalThis.document) == null ? void 0 : e.defaultView;
}
function Mu(e, t) {
let n = e.deltaX, r = e.deltaY;
return e.deltaMode === Tu && (n *= Cu, r *= Cu), {
event: e,
timeStamp: e.timeStamp,
deltaX: n,
deltaY: r,
isControlKeyDown: t
};
}
function Nu(e, t) {
return e.some(({ event: e, isControlKeyDown: t }) => e.ctrlKey && !t) ? "trackpad" : e.some(({ event: e }) => e.deltaMode !== wu) || e.some(Pu) || e.every(({ event: e }) => {
let t = e.wheelDelta;
return t !== void 0 && Math.abs(t) % 40 == 0;
}) ? "mouse" : e.some(({ deltaX: e }) => e !== 0) || e.length > 1 && Fu(e) ? "trackpad" : t ? "mouse" : "unknown";
}
function Pu({ event: e, deltaX: t, deltaY: n }) {
if (t !== 0 || n === 0) return !1;
let r = Math.abs(n / Su);
if (Number.isInteger(r)) return !0;
let i = e.wheelDelta;
return typeof i == "number" && i !== 0 && i % Ou === 0;
}
function Fu(e) {
for (let t = 0; t < e.length; t++) {
let n = e[t];
if (Math.abs(n.deltaX) > Du || Math.abs(n.deltaY) > Du || t > 0 && n.timeStamp - e[t - 1].timeStamp > Eu) return !1;
}
return !0;
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/inputs/move-input.js
var Iu = [
"mousedown",
"mousemove",
"mouseup",
"mouseover",
"mouseout",
"mouseenter",
"mouseleave"
], Lu = class extends _u {
constructor(e, t, n) {
super(e, t, {
enable: !0,
...n
}), this.handleEvent = (e) => {
this.handleOverEvent(e), this.handleOutEvent(e), this.handleEnterEvent(e), this.handleLeaveEvent(e), this.handleMoveEvent(e);
}, this.pressed = !1;
let { enable: r = !1 } = this.options;
this.enableMoveEvent = r, this.enableLeaveEvent = r, this.enableEnterEvent = r, this.enableOutEvent = r, this.enableOverEvent = r, r && Iu.forEach((e) => this.listen(e, !0));
}
destroy() {
Iu.forEach((e) => this.listen(e, !1));
}
enableEventType(e, t) {
switch (e) {
case "pointermove":
this.enableMoveEvent !== t && (this.enableMoveEvent = t, this.listen("mousedown", t), this.listen("mousemove", t), this.listen("mouseup", t));
break;
case "pointerover":
this.enableOverEvent !== t && (this.enableOverEvent = t, this.listen("mouseover", t));
break;
case "pointerout":
this.enableOutEvent !== t && (this.enableOutEvent = t, this.listen("mouseout", t));
break;
case "pointerenter":
this.enableEnterEvent !== t && (this.enableEnterEvent = t, this.listen("mouseenter", t));
break;
case "pointerleave":
this.enableLeaveEvent !== t && (this.enableLeaveEvent = t, this.listen("mouseleave", t));
break;
default:
}
}
handleOverEvent(e) {
this.enableOverEvent && e.type === "mouseover" && this._emit("pointerover", e);
}
handleOutEvent(e) {
this.enableOutEvent && e.type === "mouseout" && this._emit("pointerout", e);
}
handleEnterEvent(e) {
this.enableEnterEvent && e.type === "mouseenter" && this._emit("pointerenter", e);
}
handleLeaveEvent(e) {
this.enableLeaveEvent && e.type === "mouseleave" && this._emit("pointerleave", e);
}
handleMoveEvent(e) {
if (this.enableMoveEvent) switch (e.type) {
case "mousedown":
e.button >= 0 && (this.pressed = !0);
break;
case "mousemove":
e.buttons === 0 && (this.pressed = !1), this.pressed || this._emit("pointermove", e);
break;
case "mouseup":
this.pressed = !1;
break;
default:
}
}
_emit(e, t) {
this.callback({
type: e,
center: {
x: t.clientX,
y: t.clientY
},
srcEvent: t,
pointerType: "mouse",
target: t.target
});
}
}, Ru = ["keydown", "keyup"], zu = class extends _u {
constructor(e, t, n) {
super(e, t, {
enable: !0,
tabIndex: 0,
...n
}), this.handleEvent = (e) => {
let t = e.target || e.srcElement;
t.tagName === "INPUT" && t.type === "text" || t.tagName === "TEXTAREA" || (this.enableDownEvent && e.type === "keydown" && this.callback({
type: "keydown",
srcEvent: e,
key: e.key,
target: e.target
}), this.enableUpEvent && e.type === "keyup" && this.callback({
type: "keyup",
srcEvent: e,
key: e.key,
target: e.target
}));
};
let { enable: r = !1 } = this.options;
this.enableDownEvent = r, this.enableUpEvent = r, e.tabIndex = this.options.tabIndex, e.style.outline = "none", r && Ru.forEach((e) => this.listen(e, !0));
}
destroy() {
Ru.forEach((e) => this.listen(e, !1));
}
enableEventType(e, t) {
e === "keydown" && this.enableDownEvent !== t && (this.enableDownEvent = t, this.listen(e, t)), e === "keyup" && this.enableUpEvent !== t && (this.enableUpEvent = t, this.listen(e, t));
}
}, Bu = class extends _u {
constructor(e, t, n) {
var r;
n.enable = (r = n.enable) != null && r, super(e, t, n), this.handleEvent = (e) => {
this.options.enable && this.callback({
type: "contextmenu",
center: {
x: e.clientX,
y: e.clientY
},
srcEvent: e,
pointerType: "mouse",
target: e.target
});
}, n.enable && this.listen("contextmenu", !0);
}
destroy() {
this.listen("contextmenu", !1);
}
enableEventType(e, t) {
e === "contextmenu" && this.options.enable !== t && (this.options.enable = t, this.listen("contextmenu", t));
}
}, Vu = 1, Hu = 2, Uu = 4, Wu = {
pointerdown: Vu,
pointermove: Hu,
pointerup: Uu,
mousedown: Vu,
mousemove: Hu,
mouseup: Uu
}, Gu = 0, Ku = 1, qu = 2, Ju = 1, Yu = 2, Xu = 4;
function Zu(e) {
let t = Wu[e.srcEvent.type];
if (!t) return null;
let { buttons: n, button: r } = e.srcEvent, i = !1, a = !1, o = !1;
return t === Hu ? (i = !!(n & Ju), a = !!(n & Xu), o = !!(n & Yu)) : (i = r === Gu, a = r === Ku, o = r === qu), {
leftButton: i,
middleButton: a,
rightButton: o
};
}
function Qu(e, t) {
let n = e.center;
if (!n) return null;
let r = t.getBoundingClientRect(), i = r.width / t.offsetWidth || 1, a = r.height / t.offsetHeight || 1;
return {
center: n,
offsetCenter: {
x: (n.x - r.left - t.clientLeft) / i,
y: (n.y - r.top - t.clientTop) / a
}
};
}
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/utils/event-registrar.js
var $u = {
srcElement: "root",
priority: 0
}, ed = class {
constructor(e, t) {
this.handleEvent = (e) => {
if (this.isEmpty()) return;
let t = this._normalizeEvent(e), n = e.srcEvent.target;
for (; n && n !== t.rootElement;) {
if (this._emit(t, n), t.handled) return;
n = n.parentNode;
}
this._emit(t, "root");
}, this.eventManager = e, this.recognizerName = t, this.handlers = [], this.handlersByElement = /* @__PURE__ */ new Map(), this._active = !1;
}
isEmpty() {
return !this._active;
}
add(e, t, n, r = !1, i = !1) {
let { handlers: a, handlersByElement: o } = this, s = {
...$u,
...n
}, c = o.get(s.srcElement);
c || (c = [], o.set(s.srcElement, c));
let l = {
type: e,
handler: t,
srcElement: s.srcElement,
priority: s.priority
};
r && (l.once = !0), i && (l.passive = !0), a.push(l), this._active = this._active || !l.passive;
let u = c.length - 1;
for (; u >= 0 && !(c[u].priority >= l.priority);) u--;
c.splice(u + 1, 0, l);
}
remove(e, t) {
let { handlers: n, handlersByElement: r } = this;
for (let i = n.length - 1; i >= 0; i--) {
let a = n[i];
if (a.type === e && a.handler === t) {
n.splice(i, 1);
let e = r.get(a.srcElement);
e.splice(e.indexOf(a), 1), e.length === 0 && r.delete(a.srcElement);
}
}
this._active = n.some((e) => !e.passive);
}
_emit(e, t) {
let n = this.handlersByElement.get(t);
if (n) {
let t = !1, r = () => {
e.handled = !0;
}, i = () => {
e.handled = !0, t = !0;
}, a = [];
for (let o = 0; o < n.length; o++) {
let { type: s, handler: c, once: l } = n[o];
if (c({
...e,
type: s,
stopPropagation: r,
stopImmediatePropagation: i
}), l && a.push(n[o]), t) break;
}
for (let e = 0; e < a.length; e++) {
let { type: t, handler: n } = a[e];
this.remove(t, n);
}
}
}
_normalizeEvent(e) {
let t = this.eventManager.getElement();
return {
...e,
...Zu(e),
...Qu(e, t),
preventDefault: () => {
e.srcEvent.preventDefault();
},
stopImmediatePropagation: null,
stopPropagation: null,
handled: !1,
rootElement: t
};
}
};
//#endregion
//#region ../../node_modules/.pnpm/mjolnir.js@3.1.0/node_modules/mjolnir.js/dist/event-manager.js
function td(e) {
if ("recognizer" in e) return e;
let t, n = Array.isArray(e) ? [...e] : [e];
return t = typeof n[0] == "function" ? new (n.shift())(n.shift() || {}) : n.shift(), {
recognizer: t,
recognizeWith: typeof n[0] == "string" ? [n[0]] : n[0],
requireFailure: typeof n[1] == "string" ? [n[1]] : n[1]
};
}
var nd = class {
constructor(e = null, t = {}) {
if (this._onBasicInput = (e) => {
this.manager.emit(e.srcEvent.type, e);
}, this._onOtherEvent = (e) => {
this.manager.emit(e.type, e);
}, this.options = {
recognizers: [],
events: {},
touchAction: "compute",
tabIndex: 0,
cssProps: {},
...t
}, this.events = /* @__PURE__ */ new Map(), this.element = e, this.wheelSession = new Au(e), e) {
this.manager = new au(e, this.options);
for (let e of this.options.recognizers) {
let { recognizer: t, recognizeWith: n, requireFailure: r } = td(e);
this.manager.add(t), n && t.recognizeWith(n), r && t.requireFailure(r);
}
this.manager.on("hammer.input", this._onBasicInput), this.wheelInput = new xu(e, this._onOtherEvent, {
enable: !1,
wheelSession: this.wheelSession
}), this.moveInput = new Lu(e, this._onOtherEvent, { enable: !1 }), this.keyInput = new zu(e, this._onOtherEvent, {
enable: !1,
tabIndex: t.tabIndex
}), this.contextmenuInput = new Bu(e, this._onOtherEvent, { enable: !1 }), this.on(this.options.events);
}
}
getElement() {
return this.element;
}
destroy() {
if (!this.element) {
this.wheelSession.destroy();
return;
}
this.wheelInput.destroy(), this.wheelSession.destroy(), this.moveInput.destroy(), this.keyInput.destroy(), this.contextmenuInput.destroy(), this.manager.destroy();
}
on(e, t, n) {
this._addEventHandler(e, t, n, !1);
}
once(e, t, n) {
this._addEventHandler(e, t, n, !0);
}
watch(e, t, n) {
this._addEventHandler(e, t, n, !1, !0);
}
off(e, t) {
this._removeEventHandler(e, t);
}
emit(e) {
var t;
(t = this.manager) == null || t.emit(e.type, e);
}
_toggleRecognizer(e, t) {
var n, r, i, a;
let { manager: o } = this;
if (!o) return;
let s = o.get(e);
s && (s.set({
enable: t,
wheelSession: this.wheelSession
}), o.touchAction.update()), (n = this.wheelInput) == null || n.enableEventType(e, t), (r = this.moveInput) == null || r.enableEventType(e, t), (i = this.keyInput) == null || i.enableEventType(e, t), (a = this.contextmenuInput) == null || a.enableEventType(e, t);
}
_addEventHandler(e, t, n, r, i) {
if (typeof e != "string") {
n = t;
for (let [t, a] of Object.entries(e)) this._addEventHandler(t, a, n, r, i);
return;
}
let { manager: a, events: o } = this;
if (!a) return;
let s = o.get(e);
if (!s) {
let t = this._getRecognizerName(e) || e;
s = new ed(this, t), o.set(e, s), a && a.on(e, s.handleEvent);
}
s.add(e, t, n, r, i), s.isEmpty() || this._toggleRecognizer(s.recognizerName, !0);
}
_removeEventHandler(e, t) {
if (typeof e != "string") {
for (let [t, n] of Object.entries(e)) this._removeEventHandler(t, n);
return;
}
let { events: n } = this, r = n.get(e);
if (r && (r.remove(e, t), r.isEmpty())) {
let { recognizerName: e } = r, t = !1;
for (let r of n.values()) if (r.recognizerName === e && !r.isEmpty()) {
t = !0;
break;
}
t || this._toggleRecognizer(e, !1);
}
}
_getRecognizerName(e) {
var t;
return (t = this.manager.recognizers.find((t) => t.getEventNames().includes(e))) == null ? void 0 : t.options.event;
}
};
//#endregion
//#region ../renderer/src/utils/hot-state.ts
function rd(e, t, n) {
let r = e == null ? void 0 : e.data;
return r ? (t in r || (r[t] = n()), r[t]) : n();
}
//#endregion
//#region ../renderer/src/controls/gestures.ts
function id(e, t) {
let n = (0, Z.c)(5), r = I(ad), i, a;
n[0] !== r || n[1] !== t || n[2] !== e ? (i = () => {
let n = od(r);
return n.on(e, t), () => {
n.off(e, t), sd(r);
};
}, a = [
r,
e,
t
], n[0] = r, n[1] = t, n[2] = e, n[3] = i, n[4] = a) : (i = n[3], a = n[4]), (0, G.useEffect)(i, a);
}
function ad(e) {
return e.gl.domElement;
}
function od(e) {
let t = ld.get(e);
if (t) return t.refs++, t.manager;
let n = new nd(e, { recognizers: [
gu,
[
mu,
{
event: "pitch",
pointers: 2
},
"rotate"
],
[du, {
event: "doubletap",
taps: 2,
interval: 500,
time: 500,
posThreshold: 30
}]
] });
return ld.set(e, {
manager: n,
refs: 1
}), n;
}
function sd(e) {
let t = ld.get(e);
t && (--t.refs > 0 || (ld.delete(e), t.manager.destroy()));
}
function cd(e) {
return {
x: e.offsetX,
y: e.offsetY
};
}
var ld = rd(void 0, "managers", () => /* @__PURE__ */ new WeakMap());
//#endregion
//#region ../renderer/src/update/store.ts
function ud(...e) {
for (let t of e) md(t);
}
function dd(e, t) {
return pd(e).listeners.add(t), () => {
let n = hd.get(e);
n && n.listeners.delete(t);
};
}
function fd(e) {
var t;
let n = pd(e);
return ((t = n.childrenSnapshot) == null ? void 0 : t.version) !== n.version && (n.childrenSnapshot = {
version: n.version,
snapshot: [...e.children]
}), n.childrenSnapshot.snapshot;
}
function pd(e) {
let t = hd.get(e);
return t || (t = {
version: 0,
listeners: /* @__PURE__ */ new Set()
}, hd.set(e, t)), t;
}
function md(e) {
let t = hd.get(e);
if (t) {
t.version++;
for (let e of t.listeners) e();
}
}
var hd = rd(void 0, "subscriptions", () => /* @__PURE__ */ new WeakMap());
//#endregion
//#region ../renderer/src/update/slot-writers.ts
function gd(e, t, n) {
var r;
function i() {
t(), n();
}
let a = (r = yd.get(e)) == null ? /* @__PURE__ */ new Set() : r;
return a.add(i), yd.set(e, a), () => {
a.delete(i);
};
}
function _d(e) {
let t = yd.get(e);
if (t) for (let e of [...t]) e();
}
function vd(e) {
if (e) for (let t of e) Uc(t) ? ud(t) : _d(t);
}
var yd = rd(void 0, "slotWriters", () => /* @__PURE__ */ new WeakMap());
//#endregion
//#region ../renderer/src/events/def-culling.ts
function bd(e, t, n) {
var r, i;
let a = (r = t == null ? void 0 : t[0]) == null ? .5 : r, o = (i = t == null ? void 0 : t[1]) == null ? .5 : i, s = Math.max(a, 1 - a) * e.size.x, c = Math.max(o, 1 - o) * e.size.y;
return Cd.set(e.center.x, e.center.y, e.elevation), n.set(Cd, Math.hypot(s, c)), n;
}
function xd(e, t) {
return Bc(e) ? !t.intersectsSphere(bd(e.bounds, void 0, wd)) : zc(e) ? !t.intersectsSphere(bd(e.bounds, e.origin, wd)) : !1;
}
function Sd(e, t, n = new Xe()) {
return Td.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse).multiply(t), n.setFromProjectionMatrix(Td, e.coordinateSystem);
}
var Cd = new U(), wd = new vn(), Td = new W();
//#endregion
//#region ../renderer/src/events/placement/box.ts
function Ed(e, t, n, r, i) {
let a = r;
if (!Number.isFinite(a) || a <= 0) return;
let o = e.bounds, s = zc(e) ? e.origin : void 0;
return Dd(o.center.x, o.center.y, o.elevation, o.size.x / a, o.size.y / a, s, o.rotation, t, n, i);
}
function Dd(e, t, n, r, i, a, o, s, c, l) {
var u, d;
if (!(r > 0) || !(i > 0)) return;
let f = s.planToCanvas(Ad.set(e, t, n), c, jd);
if (!f || !Number.isFinite(f.x) || !Number.isFinite(f.y)) return;
Md.set((.5 - ((u = a == null ? void 0 : a[0]) == null ? .5 : u)) * r, (.5 - ((d = a == null ? void 0 : a[1]) == null ? .5 : d)) * i), Fn(Md, o, kd, Md), Nd.set(f.x + Md.x, f.y + Md.y, r, i, o, 0);
let { min: p, max: m } = Qn(Nd, Pd);
return l.minX = p.x, l.maxX = m.x, l.minY = p.y, l.maxY = m.y, l;
}
function Od(e, t, n) {
var r, i;
let a = (r = (i = e.placement) == null ? void 0 : i.padding) == null ? 0 : r, o = typeof a == "number" ? a : a[0], s = typeof a == "number" ? a : a[1];
return n.minX = t.minX - o, n.maxX = t.maxX + o, n.minY = t.minY - s, n.maxY = t.maxY + s, n;
}
var kd = {
x: 0,
y: 0
}, Ad = new An(), jd = new An(), Md = new An(), Nd = new Xn({
x: 0,
y: 0
}, {
x: 0,
y: 0
}), Pd = new cr();
//#endregion
//#region ../renderer/src/events/placement/grid.ts
function Fd(e, t) {
return e === "always";
}
function Id(e, t) {
return e.minX < t.maxX && e.maxX > t.minX && e.minY < t.maxY && e.maxY > t.minY;
}
var Ld = class {
constructor(e, t) {
this.cells = [], this.filled = [], this.boxes = [], this.modes = [], this.count = 0, this.xCells = 0, this.yCells = 0, this.width = -1, this.height = -1, this.reset(e, t);
}
reset(e, t) {
this.count = 0;
for (let e of this.filled) this.cells[e].length = 0;
if (this.filled.length = 0, e !== this.width || t !== this.height) {
this.width = e, this.height = t, this.xCells = Math.max(1, Math.ceil((e + 200) / 32)), this.yCells = Math.max(1, Math.ceil((t + 200) / 32)), this.cells = [];
for (let e = 0; e < this.xCells * this.yCells; e++) this.cells.push([]);
}
}
intersects(e) {
return e.maxX >= -100 && e.minX <= this.width + 100 && e.maxY >= -100 && e.minY <= this.height + 100;
}
blockerOf(e, t) {
if (t === "always") return;
let n = this.cellX(e.minX), r = this.cellX(e.maxX), i = this.cellY(e.minY), a = this.cellY(e.maxY), o = -1;
for (let s = i; s <= a; s++) for (let i = n; i <= r; i++) for (let n of this.cells[s * this.xCells + i]) {
if (o !== -1 && n >= o || Fd(t, this.modes[n])) continue;
let r = n * 4;
e.minX < this.boxes[r + 2] && e.maxX > this.boxes[r] && e.minY < this.boxes[r + 3] && e.maxY > this.boxes[r + 1] && (o = n);
}
return o === -1 ? void 0 : o;
}
insert(e, t) {
let n = this.count++, r = n * 4;
this.boxes[r] = e.minX, this.boxes[r + 1] = e.minY, this.boxes[r + 2] = e.maxX, this.boxes[r + 3] = e.maxY, this.modes[n] = t;
let i = this.cellX(e.minX), a = this.cellX(e.maxX), o = this.cellY(e.minY), s = this.cellY(e.maxY);
for (let e = o; e <= s; e++) for (let t = i; t <= a; t++) {
let r = e * this.xCells + t, i = this.cells[r];
i.length === 0 && this.filled.push(r), i.push(n);
}
return n;
}
boxOf(e, t) {
let n = e * 4;
return t.minX = this.boxes[n], t.minY = this.boxes[n + 1], t.maxX = this.boxes[n + 2], t.maxY = this.boxes[n + 3], t;
}
cellX(e) {
let t = Math.floor((e + 100) / 32);
return Math.min(Math.max(t, 0), this.xCells - 1);
}
cellY(e) {
let t = Math.floor((e + 100) / 32);
return Math.min(Math.max(t, 0), this.yCells - 1);
}
};
//#endregion
//#region ../renderer/src/events/placement/pass.ts
function Rd() {
let e = new Ld(0, 0), t = /* @__PURE__ */ new Map(), n = 0, r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new Map();
return {
run(a, o, s, c = Yd) {
let l = performance.now(), u = ++n, d = 0, f = 0, p = (e, n) => {
let r = t.get(e);
t.set(e, 2 * u + +!!n), !(r !== void 0 && r % 2 == +!!n) && (f++, s(e, n));
}, m = zd(a);
for (let [t, n] of m) {
var h;
e.reset(o.width, o.height);
let a = n.layers.some((e) => e.clustering !== void 0), s = /* @__PURE__ */ new Map(), l = [], u = /* @__PURE__ */ new Map(), f = (t, n, r, i) => {
let o = n === void 0 ? void 0 : e.blockerOf(n, i);
if (o === void 0) {
if (n !== void 0 && i !== "always") {
let n = e.insert(r, i);
a && (l[n] = t);
}
for (let e of t) s.set(e, !0);
return;
}
for (let e of t) s.set(e, !1);
if (!a) return;
let c = u.get(o);
if (c === void 0) {
c = [...l[o]];
for (let e of c) s.set(e, !1);
u.set(o, c);
}
for (let e of t) c.push(e);
}, m = /* @__PURE__ */ new Set(), _;
for (let t of n.defs) for (let i of t) {
var g;
let t = i.placement;
if (t === void 0) continue;
if (!Wc(i)) {
r.has(i) || (r.add(i), Qd.warn("placement is not supported for a flat def yet; set screenSpace to place it %O", i));
continue;
}
let a = t.group;
if (a !== void 0) {
if (m.has(a)) continue;
m.add(a), _ != null || (_ = Bd(n.defs));
let t = _.get(a);
if (t === void 0) continue;
d += t.length, f(t, Vd(t, e, o) ? rf : void 0, nf, "never");
continue;
}
d++;
let s = (g = t.overlap) == null ? "never" : g, c = Ed(i, o.space, o.camera, o.pixelSize, ef), l = c === void 0 ? void 0 : Od(i, c, tf), u = l !== void 0 && e.intersects(l) ? l : void 0;
f([i], u, ef, s);
}
let v = a ? Hd(u, l, e, Ud(n), o, s) : [], y = i.get(t), b = a && !qd(v, (h = y == null ? void 0 : y.members) == null ? $d : h);
for (let [e, t] of s) p(e, t);
if (y !== void 0 && y.members.length > 0) for (let [e, t] of y.told) (e.clustering === void 0 || !n.layers.includes(e)) && c(e, [], t);
if (!a) {
i.delete(t);
continue;
}
if (!b && (y === void 0 || y.members.length === 0)) continue;
let x, S = [];
for (let e of n.layers) {
let t = e.clustering;
t !== void 0 && (S.push([e, t]), !(!b && y.told.some(([t]) => t === e)) && (x != null || (x = v.map(Gd)), c(e, [...x], t)));
}
i.set(t, {
members: v,
told: S
});
}
if (i.size > 0) {
for (let [e, { members: t, told: n }] of i) if (!m.has(e) && (i.delete(e), t.length !== 0)) for (let [e, t] of n) c(e, [], t);
}
if (t.size > d) for (let [e, n] of t) n < 2 * u && t.delete(e);
if (f > 0 && Qd.debug.enabled) {
let e = (performance.now() - l).toFixed(2);
Qd.debug(`placed ${d} defs, ${f} flipped, in ${e}ms`);
}
},
forget(e) {
t.delete(e);
}
};
}
function zd(e) {
let t = /* @__PURE__ */ new Map();
for (let [r, i] of e) {
var n;
let e = (n = i.collisionGroup) == null ? i : n, a = t.get(e);
if (a === void 0) {
t.set(e, {
layers: [i],
defs: [r]
});
continue;
}
a.layers.includes(i) || a.layers.push(i), a.defs.push(r);
}
return t;
}
function Bd(e) {
let t = /* @__PURE__ */ new Map();
for (let r of e) for (let e of r) {
var n;
let r = (n = e.placement) == null ? void 0 : n.group;
if (r === void 0 || !Wc(e)) continue;
let i = t.get(r);
i === void 0 ? t.set(r, [e]) : i.push(e);
}
return t;
}
function Vd(e, t, n) {
let r = 0;
for (let o of e) {
var i, a;
if (((i = (a = o.placement) == null ? void 0 : a.overlap) == null ? "never" : i) === "always") continue;
let e = Ed(o, n.space, n.camera, n.pixelSize, ef);
if (e === void 0) continue;
let s = Od(o, e, tf);
if (t.intersects(s)) {
if (r++ === 0) {
Xd(e, nf), Xd(s, rf);
continue;
}
Zd(e, nf), Zd(s, rf);
}
}
return r > 0;
}
function Hd(e, t, n, r, i, a) {
let o = [...e.keys()].sort(Jd), s = o.map((t) => e.get(t));
if (s.length === 0) return s;
for (let e of o) t[e] = void 0;
let c = [], l = [], u = [], d = [];
for (let e of s) {
let t = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
};
c.push(t), l.push(Wd(e, r, i, t) !== void 0), u.push(!0), d.push(!0);
}
let f = (e) => {
if (d[e] = !0, l[e]) for (let t = 0; t < s.length; t++) t !== e && u[t] && l[t] && Id(c[e], c[t]) && (d[t] = !0);
};
for (let e = !0; e;) {
e = !1;
for (let o = 0; o < s.length; o++) if (!(!u[o] || !d[o])) {
d[o] = !1;
for (let u = 0; u < t.length && l[o]; u++) {
let d = t[u];
if (!(d === void 0 || !Id(c[o], n.boxOf(u, af)))) {
t[u] = void 0;
for (let e of d) a.set(e, !1), s[o].push(e);
l[o] = Wd(s[o], r, i, c[o]) !== void 0, f(o), e = !0;
}
}
for (let t = 0; t < s.length && l[o]; t++) {
if (t === o || !u[t] || !l[t] || !Id(c[o], c[t])) continue;
let n = Math.min(o, t), a = Math.max(o, t);
for (let e of s[a]) s[n].push(e);
if (u[a] = !1, l[n] = Wd(s[n], r, i, c[n]) !== void 0, f(n), e = !0, a === o) break;
}
}
}
return s.filter((e, t) => u[t]);
}
function Ud(e) {
var t;
return (t = e.layers.find((e) => e.clustering !== void 0)) == null || (t = t.clustering) == null ? void 0 : t.marker;
}
function Wd(e, t, n, r) {
let { x: i, y: a, elevation: o } = Kd(e, of), { space: s, camera: c, pixelSize: l } = n;
if (t !== void 0) {
let { width: e, height: n, origin: l } = t;
return Dd(i, a, o, e, n, l, 0, s, c, r);
}
if (!(!Number.isFinite(l) || l <= 0)) for (let t of e) {
var u, d;
if (((u = (d = t.placement) == null ? void 0 : d.overlap) == null ? "never" : u) === "always") continue;
let { size: e, rotation: n } = t.bounds, f = e.x / l, p = e.y / l;
if (!(!(f > 0) || !(p > 0))) return Dd(i, a, o, f, p, zc(t) ? t.origin : void 0, n, s, c, r);
}
}
function Gd(e) {
return Kd(e, {
unitCount: 0,
x: 0,
y: 0,
elevation: 0
});
}
function Kd(e, t) {
let n = 0, r = 0, i = 0, a = -Infinity;
for (let t = 0; t < e.length;) {
var o, s;
let c = (o = e[t].placement) == null ? void 0 : o.group, l = 0, u = 0, d = 0;
do {
let { bounds: n } = e[t];
l += n.center.x, u += n.center.y, a = Math.max(a, n.elevation), d++, t++;
} while (c !== void 0 && t < e.length && ((s = e[t].placement) == null ? void 0 : s.group) === c);
n++, r += l / d, i += u / d;
}
return t.unitCount = n, t.x = r / n, t.y = i / n, t.elevation = a, t;
}
function qd(e, t) {
if (e.length !== t.length) return !1;
for (let n = 0; n < e.length; n++) {
let r = e[n], i = t[n];
if (r.length !== i.length) return !1;
for (let e = 0; e < r.length; e++) if (r[e] !== i[e]) return !1;
}
return !0;
}
function Jd(e, t) {
return e - t;
}
function Yd() {}
function Xd(e, t) {
t.minX = e.minX, t.minY = e.minY, t.maxX = e.maxX, t.maxY = e.maxY;
}
function Zd(e, t) {
t.minX = Math.min(t.minX, e.minX), t.minY = Math.min(t.minY, e.minY), t.maxX = Math.max(t.maxX, e.maxX), t.maxY = Math.max(t.maxY, e.maxY);
}
var Qd = $c("placement"), $d = [], ef = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
}, tf = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
}, nf = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
}, rf = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
}, af = {
minX: 0,
minY: 0,
maxX: 0,
maxY: 0
}, of = {
unitCount: 0,
x: 0,
y: 0,
elevation: 0
}, sf = $c("layout"), cf = (0, G.createContext)(void 0);
function lf(e, t) {
let n = (0, Z.c)(5), r = (0, G.use)(cf), i, a;
n[0] !== t || n[1] !== e || n[2] !== r ? (i = () => {
if (!r) return;
let n = t.filter(uf);
if ((e.onScale || e.onRoll) && n.push(e), n.length) return r.register(e, n);
}, a = [
r,
e,
t
], n[0] = t, n[1] = e, n[2] = r, n[3] = i, n[4] = a) : (i = n[3], a = n[4]), (0, G.useEffect)(i, a);
}
function uf(e) {
return (e.onScale !== void 0 || e.onRoll !== void 0 || ff(e)) && !Uc(e);
}
function df(e, t, n = 0) {
let r = /* @__PURE__ */ new Map(), i = Rd(), a = !1, o = !1, s = /* @__PURE__ */ new WeakMap(), c = /* @__PURE__ */ new WeakMap(), l = /* @__PURE__ */ new WeakMap(), u = /* @__PURE__ */ new Set(), d = /* @__PURE__ */ new Set(), f = /* @__PURE__ */ new Set(), p, m = t, h = n, g = {
pixelSize: m,
roll: h
};
function _(e, t) {
if (e.onScale && s.get(e) !== m) {
let n = e.onScale(g);
s.set(e, m), n != null && n.length && t(n);
}
if (e.onRoll && c.get(e) !== h) {
let n = e.onRoll(g);
c.set(e, h), n != null && n.length && t(n);
}
}
function v(e) {
l.set(e, e.hidden === !0), vd([e]);
}
function y(e) {
for (let t of e) {
if (Uc(t)) {
v(t);
continue;
}
let e = l.get(t);
e !== void 0 && e !== (t.hidden === !0) ? (d.delete(t), f.delete(t), u.add(t)) : (u.delete(t), f.delete(t), d.add(t));
}
}
function b(e, t) {
let n = performance.now(), i = u.size + d.size + f.size, a = 0;
for (let e of r.keys()) for (let n of e) n[t] && (a++, _(n, y));
let o = u.size + d.size + f.size;
o > i && (p != null || (p = {
defs: 0,
drains: 0,
writeMs: 0
}), p.defs += o - i), sf.debug(`${e}: ran ${a} ${t} handlers in ${(performance.now() - n).toFixed(2)}ms, ${o} defs to write (${u.size} visibility flips)`);
}
return {
get pixelSize() {
return m;
},
get roll() {
return h;
},
get hasWork() {
return u.size > 0 || d.size > 0 || f.size > 0;
},
get needsPlacement() {
return a;
},
get placementDrifted() {
return o;
},
register(t, n) {
r.set(n, t);
let s = !1;
for (let e of n) l.has(e) || l.set(e, e.hidden === !0), _(e, (e) => {
for (let t of e) v(t);
s = !0;
});
n.some(ff) && (a = !0, s = !0), s && e();
let c = n.filter(Wc).map((t) => {
let n = pf(t);
return dd(t, () => {
mf(t, n) && (o = !0, e());
});
});
return () => {
for (let e of c) e();
r.delete(n), n.some(Wc) && (a = !0, e());
for (let e of n) u.delete(e), d.delete(e), f.delete(e), i.forget(e);
};
},
applyScale(e) {
m = e, g.pixelSize = e, b(`pxToSvgScale ${+e.toFixed(3)}`, "onScale");
},
applyRoll(e) {
h = e, g.roll = e, b(`roll ${+e.toFixed(3)}`, "onRoll");
},
applyPlacement(e) {
a = !1, o = !1, i.run(r, e, (e, t) => {
var n;
let r = (n = e.placement) == null ? void 0 : n.onPlace(t, g);
r != null && r.length && y(r);
}, (e, t, n) => {
let r = n.onCluster(t, g);
r != null && r.length && y(r);
});
},
drain(e, t = -1) {
if (u.size === 0 && d.size === 0 && f.size === 0) return !1;
let n = performance.now(), r = 0, i = () => r > 0 && t > 0 && performance.now() - n >= t;
for (let t of [u, d]) for (let n of t) {
if (i()) break;
if (r++, t.delete(n), e !== void 0 && xd(n, e)) {
f.add(n);
continue;
}
v(n);
}
for (let e of f) {
if (i()) break;
r++, f.delete(e), v(e);
}
let a = u.size + d.size + f.size;
return p && (p.drains++, p.writeMs += performance.now() - n, a === 0 && (sf.debug(`wrote ${p.defs} defs over ${p.drains} frames in ${p.writeMs.toFixed(2)}ms`), p = void 0)), a > 0;
}
};
}
function ff(e) {
return e.placement !== void 0;
}
function pf(e) {
let t = {
numbers: /* @__PURE__ */ new Float64Array(9),
padding: void 0
};
return mf(e, t), t;
}
function mf(e, t) {
var n, r, i;
let { bounds: a } = e, o = zc(e) ? e.origin : void 0, s = (n = e.placement) == null ? void 0 : n.padding, c = hf;
c[0] = a.center.x, c[1] = a.center.y, c[2] = a.size.x, c[3] = a.size.y, c[4] = a.rotation, c[5] = a.elevation, c[6] = (r = o == null ? void 0 : o[0]) == null ? .5 : r, c[7] = (i = o == null ? void 0 : o[1]) == null ? .5 : i;
let l = s !== t.padding;
for (let e = 0; e < 8; e++) c[e] !== t.numbers[e] && (l = !0), t.numbers[e] = c[e];
return t.padding = s, l;
}
var hf = /* @__PURE__ */ new Float64Array(9), gf = (0, G.createContext)(void 0);
function _f() {
return (0, G.use)(gf);
}
function vf(e, t) {
let n = yf(e, bf), r = (e) => n > 0 && e > 0 ? n / e : 1;
return {
get zoomFactor() {
return r(t());
},
zoomFactorToDistance(e) {
return e > 0 ? n / e : n;
},
distanceToZoomFactor: r
};
}
function yf(e, t) {
return e <= 0 ? 0 : e / 2 / Math.tan(wn(t) / 2);
}
var bf = 36.87;
//#endregion
//#region ../renderer/src/space/canvas-size.ts
function xf() {
let e = (0, Z.c)(4), t = I(wf), n = I(Cf), r = I(Sf), i;
return e[0] !== r || e[1] !== n || e[2] !== t ? (i = {
width: t,
height: n,
dpr: r
}, e[0] = r, e[1] = n, e[2] = t, e[3] = i) : i = e[3], i;
}
function Sf(e) {
return e.viewport.dpr;
}
function Cf(e) {
return e.size.height;
}
function wf(e) {
return e.size.width;
}
//#endregion
//#region ../renderer/src/controls/hooks.ts
function Tf() {
var e;
return (e = I(Ef)) == null ? void 0 : e;
}
function Ef(e) {
return e.controls;
}
function Df(e) {
let t = (0, Z.c)(7), n = I(kf), r = I(Of), i;
t[0] !== e || t[1] !== n ? (i = () => {
var t;
let r = n().controls;
if (r) return (t = e(r)) == null ? void 0 : t;
}, t[0] = e, t[1] = n, t[2] = i) : i = t[2];
let a;
t[3] !== e || t[4] !== n || t[5] !== r ? (a = [
e,
n,
r
], t[3] = e, t[4] = n, t[5] = r, t[6] = a) : a = t[6], (0, G.useEffect)(i, a);
}
function Of(e) {
return e.controls;
}
function kf(e) {
return e.get;
}
function Af(e) {
let t = (0, Z.c)(2), n;
t[0] === e ? n = t[1] : (n = (t) => (t.addEventListener("sleep", e), () => t.removeEventListener("sleep", e)), t[0] = e, t[1] = n), Df(n);
}
function jf(e) {
let t = (0, Z.c)(2), n;
t[0] === e ? n = t[1] : (n = (t) => (t.addEventListener("control", e), () => t.removeEventListener("control", e)), t[0] = e, t[1] = n), Df(n);
}
function Mf() {
let e = (0, Z.c)(5), t = Tf(), n = _f(), r = al(), i = (0, G.use)(cf), a;
return e[0] !== n || e[1] !== t || e[2] !== r || e[3] !== i ? (a = () => Nf({
controls: t,
camera: n,
space: r,
targets: i
}), e[0] = n, e[1] = t, e[2] = r, e[3] = i, e[4] = a) : a = e[4], a;
}
function Nf(e) {
var t, n;
let { controls: r, camera: i, space: a, targets: o } = e, s = (t = o == null ? void 0 : o.pixelSize) == null ? 1 : t;
return r ? (r.getTarget(Ff), {
center: a.worldToPlan(Ff, new An()),
zoom: (n = i == null ? void 0 : i.zoomFactor) == null ? 1 : n,
roll: Tn(ns(r)),
pitch: Tn(r.polarAngle),
pixelSize: s
}) : {
...Pf(),
pixelSize: s
};
}
function Pf() {
return {
center: new An(),
zoom: 1,
roll: 0,
pitch: 0,
pixelSize: 1
};
}
var Ff = new U();
function If() {
let e = (0, Z.c)(11), t = I(Rf), n = I(Lf), r = Tf(), i = _f(), a = al(), { width: o, height: s, dpr: c } = xf(), l;
e[0] === t ? l = e[1] : (l = () => t().camera.view, e[0] = t, e[1] = l);
let u;
return e[2] !== i || e[3] !== r || e[4] !== c || e[5] !== s || e[6] !== n || e[7] !== a || e[8] !== l || e[9] !== o ? (u = new ts({
controls: r,
camera: i,
space: a,
view: l,
width: o,
height: s,
dpr: c,
invalidate: n
}), e[2] = i, e[3] = r, e[4] = c, e[5] = s, e[6] = n, e[7] = a, e[8] = l, e[9] = o, e[10] = u) : u = e[10], u;
}
function Lf(e) {
return e.invalidate;
}
function Rf(e) {
return e.get;
}
//#endregion
//#region ../renderer/src/controls/handlers/Inertia.tsx
function zf(e) {
var t, n, r, i;
let a = (0, Z.c)(21), o = (t = e.minSampleMs) == null ? Kf : t, s = (n = e.durationMs) == null ? qf : n, c = (r = e.speedThreshold) == null ? Jf : r, l = (i = e.ease) == null ? Vf : i, { sample: u, apply: d } = e, f = I(Bf), p;
a[0] !== d || a[1] !== s || a[2] !== l || a[3] !== o || a[4] !== u || a[5] !== c ? (p = () => new Hf({
minSampleMs: o,
durationMs: s,
speedThreshold: c,
ease: l
}, u, d), a[0] = d, a[1] = s, a[2] = l, a[3] = o, a[4] = u, a[5] = c, a[6] = p) : p = a[6];
let [m] = (0, G.useState)(p), h, g;
a[7] !== d || a[8] !== s || a[9] !== l || a[10] !== m || a[11] !== o || a[12] !== u || a[13] !== c ? (h = () => {
m.configure({
minSampleMs: o,
durationMs: s,
speedThreshold: c,
ease: l
}, u, d);
}, g = [
m,
o,
s,
c,
l,
u,
d
], a[7] = d, a[8] = s, a[9] = l, a[10] = m, a[11] = o, a[12] = u, a[13] = c, a[14] = h, a[15] = g) : (h = a[14], g = a[15]), (0, G.useEffect)(h, g);
let _;
a[16] === m ? _ = a[17] : (_ = (e) => (m.connect(e), () => m.disconnect()), a[16] = m, a[17] = _), Df(_);
let v;
return a[18] !== m || a[19] !== f ? (v = (e, t) => {
m.update(t) && f();
}, a[18] = m, a[19] = f, a[20] = v) : v = a[20], ue(v, Uf), null;
}
function Bf(e) {
return e.invalidate;
}
function Vf(e) {
return 2 ** (10 * (e - 1));
}
var Hf = class {
constructor(e, t, n) {
this.minSampleMs = void 0, this.durationMs = void 0, this.speedThreshold = void 0, this.ease = void 0, this.sample = void 0, this.apply = void 0, this.controls = void 0, this.total = [], this.records = [], this.velocity = [], this.step = [], this.active = !1, this.elapsedMs = 0, this.prevFactor = 1, this.onControlStart = () => {
this.active = !1, this.records.length = 0, this.total.fill(0);
}, this.onControl = () => {
let e = this.sample(), t = performance.now();
if (e) {
var n;
for (let t = 0; t < e.length; t++) this.total[t] = ((n = this.total[t]) == null ? 0 : n) + e[t];
}
this.records.push({
t,
total: this.total.slice()
});
let r = t - Wf;
for (; this.records.length && this.records[0].t < r;) this.records.shift();
}, this.onControlEnd = () => {
let e = performance.now(), t = e - this.minSampleMs;
for (let r = this.records.length - 1; r >= 0; r--) {
let i = this.records[r];
if (i.t >= t && r !== 0) continue;
let a = e - i.t;
if (a <= 0) return;
let o = 0;
this.velocity.length = this.total.length, this.step.length = this.total.length;
for (let e = 0; e < this.total.length; e++) {
var n;
this.velocity[e] = (this.total[e] - ((n = i.total[e]) == null ? 0 : n)) / a, o += this.velocity[e] * this.velocity[e];
}
if (Math.sqrt(o) <= this.speedThreshold) return;
this.elapsedMs = 0, this.prevFactor = 1, this.active = !0;
return;
}
}, this.minSampleMs = e.minSampleMs, this.durationMs = e.durationMs, this.speedThreshold = e.speedThreshold, this.ease = e.ease, this.sample = t, this.apply = n;
}
configure(e, t, n) {
this.minSampleMs = e.minSampleMs, this.durationMs = e.durationMs, this.speedThreshold = e.speedThreshold, this.ease = e.ease, this.sample = t, this.apply = n;
}
connect(e) {
this.controls && this.disconnect(), this.controls = e, e.addEventListener("controlstart", this.onControlStart), e.addEventListener("control", this.onControl), e.addEventListener("controlend", this.onControlEnd);
}
disconnect() {
let e = this.controls;
e && (this.active = !1, this.records.length = 0, e.removeEventListener("controlstart", this.onControlStart), e.removeEventListener("control", this.onControl), e.removeEventListener("controlend", this.onControlEnd), this.controls = void 0);
}
update(e) {
if (!this.active) return !1;
let t = e * 1e3;
this.elapsedMs += t;
let n = Math.min(1, this.elapsedMs / this.durationMs), r = this.ease(1 - n), i = (r + this.prevFactor) * .5;
this.prevFactor = r;
for (let e = 0; e < this.velocity.length; e++) this.step[e] = this.velocity[e] * i * t;
return this.apply(this.step) ? ((r <= Gf || n >= 1) && (this.active = !1), !0) : (this.active = !1, !1);
}
}, Uf = -2, Wf = 300, Gf = .02, Kf = 50, qf = 1e3, Jf = .08;
//#endregion
//#region ../renderer/src/controls/handlers/Pan.tsx
function Yf(e) {
var t;
let n = (0, Z.c)(4), r = (t = e.inertia) == null || t;
if (Df(Xf), r === !1) return null;
let i;
n[0] === r ? i = n[1] : (i = r === !0 ? {} : r, n[0] = r, n[1] = i);
let a;
return n[2] === i ? a = n[3] : (a = /* @__PURE__ */ (0, K.jsx)(Zf, { ...i }), n[2] = i, n[3] = a), a;
}
function Xf(e) {
return e.mouseButtons.left = Pc.SCREEN_PAN, e.touches.one = Pc.TOUCH_SCREEN_PAN, () => {
e.mouseButtons.left = Pc.NONE, e.touches.one = Pc.NONE;
};
}
function Zf(e) {
let t = (0, Z.c)(16), n = I(ep), r = I($f), i = al(), a = Tf(), [o] = (0, G.useState)(Qf), s, c;
t[0] !== n || t[1] !== o ? (s = () => (o.connect(n), () => o.disconnect()), c = [o, n], t[0] = n, t[1] = o, t[2] = s, t[3] = c) : (s = t[2], c = t[3]), (0, G.useEffect)(s, c);
let l;
t[4] !== a || t[5] !== o ? (l = () => {
let e = o.sample();
return a && (a.currentAction & rp) !== 0 ? e : void 0;
}, t[4] = a, t[5] = o, t[6] = l) : l = t[6];
let u = l, d;
t[7] !== a || t[8] !== r || t[9] !== o.anchor || t[10] !== i ? (d = (e) => a !== void 0 && np(a, i, r().camera, o.anchor, e), t[7] = a, t[8] = r, t[9] = o.anchor, t[10] = i, t[11] = d) : d = t[11];
let f = d, p;
return t[12] !== f || t[13] !== e || t[14] !== u ? (p = /* @__PURE__ */ (0, K.jsx)(zf, {
...e,
sample: u,
apply: f
}), t[12] = f, t[13] = e, t[14] = u, t[15] = p) : p = t[15], p;
}
function Qf() {
return new tp();
}
function $f(e) {
return e.get;
}
function ep(e) {
return e.gl.domElement;
}
var tp = class {
constructor() {
this.anchor = new An(), this.element = void 0, this.positions = /* @__PURE__ */ new Map(), this.last = /* @__PURE__ */ new Map(), this.delta = [0, 0], this.onDown = (e) => {
let { x: t, y: n } = cd(e);
this.positions.set(e.pointerId, {
x: t,
y: n,
toCanvasX: t - e.clientX,
toCanvasY: n - e.clientY
}), this.last.set(e.pointerId, {
x: t,
y: n
});
}, this.onMove = (e) => {
let t = this.positions.get(e.pointerId);
t && (t.x = e.clientX + t.toCanvasX, t.y = e.clientY + t.toCanvasY);
}, this.onUp = (e) => {
this.positions.delete(e.pointerId), this.last.delete(e.pointerId);
};
}
connect(e) {
this.element && this.disconnect(), this.element = e;
let t = e.ownerDocument;
e.addEventListener("pointerdown", this.onDown), t.addEventListener("pointermove", this.onMove), t.addEventListener("pointerup", this.onUp), t.addEventListener("pointercancel", this.onUp);
}
disconnect() {
let e = this.element;
if (!e) return;
let t = e.ownerDocument;
e.removeEventListener("pointerdown", this.onDown), t.removeEventListener("pointermove", this.onMove), t.removeEventListener("pointerup", this.onUp), t.removeEventListener("pointercancel", this.onUp), this.positions.clear(), this.last.clear(), this.element = void 0;
}
sample() {
let e = 0, t = 0, n = 0, r = 0, i = 0;
for (let [a, o] of this.positions) {
r += o.x, i += o.y;
let s = this.last.get(a);
s && (e += o.x - s.x, t += o.y - s.y, s.x = o.x, s.y = o.y, n++);
}
return this.positions.size && this.anchor.set(r / this.positions.size, i / this.positions.size, 0), this.delta[0] = n ? e / n : 0, this.delta[1] = n ? t / n : 0, this.delta;
}
};
function np(e, t, n, r, i) {
let a = t.canvasToPlan(r, n, ip), o = t.canvasToPlan({
x: r.x + i[0],
y: r.y + i[1]
}, n, ap);
if (!a || !o) return !1;
t.planToWorld(a, op), t.planToWorld(o, sp);
let s = e.getTarget(cp, !1).add(op).sub(sp);
return e.moveTo(s.x, s.y, s.z, !1), !0;
}
var rp = Pc.TRUCK | Pc.SCREEN_PAN | Pc.TOUCH_TRUCK | Pc.TOUCH_SCREEN_PAN, ip = new An(), ap = new An(), op = new U(), sp = new U(), cp = new U();
//#endregion
//#region ../renderer/src/controls/handlers/Pitch.tsx
function lp() {
let e = (0, Z.c)(10), t = Tf(), [n] = (0, G.useState)(up), r;
e[0] === n ? r = e[1] : (r = (e) => (e.mouseButtons.right = e.mouseButtons.right | Pc.ROTATE_POLAR, () => {
e.mouseButtons.right = e.mouseButtons.right & ~Pc.ROTATE_POLAR, n.end(e);
}), e[0] = n, e[1] = r), Df(r);
let i;
e[2] === n ? i = e[3] : (i = (e) => n.start(e), e[2] = n, e[3] = i);
let a = i, o;
e[4] !== t || e[5] !== n ? (o = (e) => {
t && n.move(e, t);
}, e[4] = t, e[5] = n, e[6] = o) : o = e[6];
let s = o, c;
e[7] !== t || e[8] !== n ? (c = () => n.end(t), e[7] = t, e[8] = n, e[9] = c) : c = e[9];
let l = c;
return id("pitchstart", a), id("pitch", s), id("pitchend", l), null;
}
function up() {
return new dp();
}
var dp = class {
constructor() {
this.verdict = {}, this.lastPoints = void 0, this.prevTwoFingerAction = void 0, this.p0 = new V(), this.p1 = new V();
}
start(e) {
let t = hp(e);
t.length === 2 && (this.p0.copy(cd(t[0])), this.p1.copy(cd(t[1])), this.lastPoints = [new V().copy(this.p0), new V().copy(this.p1)], pp(this.p0.sub(this.p1)) && (this.verdict.isValid = !1));
}
move(e, t) {
let n = this.lastPoints;
if (!n) return;
let r = hp(e);
if (r.length !== 2 || (this.p0.copy(cd(r[0])).sub(n[0]), this.p1.copy(cd(r[1])).sub(n[1]), !fp(this.p0, this.p1, e.timeStamp, this.verdict))) return;
this.prevTwoFingerAction === void 0 && (this.prevTwoFingerAction = t.touches.two, t.touches.two = Pc.NONE, t.dispatchEvent({ type: "controlstart" })), n[0].add(this.p0), n[1].add(this.p1);
let i = wn((this.p0.y + this.p1.y) / 2 * gp);
t.rotatePolarTo(t.polarAngle + i, !1), t.dispatchEvent({ type: "control" });
}
end(e) {
this.prevTwoFingerAction !== void 0 && (e == null || e.dispatchEvent({ type: "controlend" })), e && this.prevTwoFingerAction && (e.touches.two = this.prevTwoFingerAction), this.prevTwoFingerAction = void 0, this.verdict = {}, this.lastPoints = void 0;
}
};
function fp(e, t, n, r) {
return r.isValid = mp(e, t, n, r), r.isValid === !0;
}
function pp(e) {
return Math.abs(e.y) > Math.abs(e.x);
}
function mp(e, t, n, r) {
if (r.isValid !== void 0) return r.isValid;
let i = e.length() >= _p, a = t.length() >= _p;
if (!i && !a) return;
if (!i || !a) return r.firstMove != null || (r.firstMove = n), n - r.firstMove < vp && void 0;
let o = e.y > 0 == t.y > 0;
return pp(e) && pp(t) && o;
}
function hp(e) {
return e.pointers.slice().sort((e, t) => e.pointerId - t.pointerId);
}
var gp = -.5, _p = 2, vp = 100;
//#endregion
//#region ../renderer/src/controls/handlers/Roll.tsx
function yp(e) {
var t;
let n = (0, Z.c)(13), r = (t = e.threshold) == null ? Tp : t, i = I(xp), a = Tf(), o = al(), [s] = (0, G.useState)(bp), c;
n[0] === s ? c = n[1] : (c = (e) => (e.mouseButtons.right = e.mouseButtons.right | Pc.ROTATE_AZIMUTH, () => {
e.mouseButtons.right = e.mouseButtons.right & ~Pc.ROTATE_AZIMUTH, s.end(e);
}), n[0] = s, n[1] = c), Df(c);
let l;
n[2] === s ? l = n[3] : (l = (e) => s.start(e), n[2] = s, n[3] = l);
let u = l, d;
n[4] !== a || n[5] !== s || n[6] !== i || n[7] !== o || n[8] !== r ? (d = (e) => {
a && s.move(e, r, {
controls: a,
camera: i().camera,
space: o
});
}, n[4] = a, n[5] = s, n[6] = i, n[7] = o, n[8] = r, n[9] = d) : d = n[9];
let f = d, p;
n[10] !== a || n[11] !== s ? (p = () => s.end(a), n[10] = a, n[11] = s, n[12] = p) : p = n[12];
let m = p;
return id("rotatestart", u), id("rotate", f), id("rotateend", m), null;
}
function bp() {
return new Sp();
}
function xp(e) {
return e.get;
}
var Sp = class {
constructor() {
this.isRolling = !1, this.startVector = void 0, this.minDiameter = 0, this.prevAngle = 0, this.vector = new V(), this.p0 = new V(), this.p1 = new V(), this.pivotPlan = new An(), this.pivotWorld = new U(), this.targetWorld = new U(), this.cameraPosition = new U(), this.cameraForward = new U(), this.rotation = new W();
}
start(e) {
let { pointers: t } = e;
this.p0.copy(cd(t[0])), this.p1.copy(cd(t[1])), this.startVector = new V().copy(this.p0).sub(this.p1), this.minDiameter = this.startVector.length();
}
move(e, t, n) {
let { controls: r } = n, { pointers: i } = e;
if (!this.isRolling) {
if (i.length !== 2 || (this.p0.copy(cd(i[0])), this.p1.copy(cd(i[1])), this.vector.copy(this.p0).sub(this.p1), this.belowThreshold(t))) return;
this.isRolling = !0, this.prevAngle = e.rotation, r.dispatchEvent({ type: "controlstart" });
}
let a = -wn(e.rotation - this.prevAngle);
this.prevAngle = e.rotation, !(Math.abs(a) < wp) && this.setPivot(e.offsetCenter, n) && (this.rotation.makeRotationZ(a), this.cameraPosition.sub(this.pivotWorld).applyMatrix4(this.rotation).add(this.pivotWorld), this.cameraForward.applyMatrix4(this.rotation), this.targetWorld.copy(this.cameraPosition).add(this.cameraForward), r.setLookAt(this.cameraPosition.x, this.cameraPosition.y, this.cameraPosition.z, this.targetWorld.x, this.targetWorld.y, this.targetWorld.z, !1), r.dispatchEvent({ type: "control" }));
}
end(e) {
this.isRolling && (e == null || e.dispatchEvent({ type: "controlend" })), this.isRolling = !1, this.startVector = void 0, this.minDiameter = 0;
}
belowThreshold(e) {
this.minDiameter = Math.min(this.minDiameter, this.vector.length());
let t = this.startVector;
return t ? Tn(this.vector.angleTo(t)) < Cp(this.minDiameter, e) : !1;
}
setPivot(e, t) {
let { controls: n, camera: r, space: i } = t;
return i.canvasToPlan(e, r, this.pivotPlan) ? (i.planToWorld(this.pivotPlan, this.pivotWorld), n.getPosition(this.cameraPosition), n.getTarget(this.targetWorld), this.cameraForward.copy(this.targetWorld).sub(this.cameraPosition), !0) : !1;
}
};
function Cp(e, t) {
return t / (Math.PI * e) * 360;
}
var wp = .001, Tp = 25;
//#endregion
//#region ../renderer/src/controls/handlers/DoubleTapZoom.tsx
function Ep(e) {
let t = (0, Z.c)(6), { factor: n } = e, r = I(Op), i = I(Dp), a = al(), o = Tf(), s;
return t[0] !== o || t[1] !== n || t[2] !== r || t[3] !== i || t[4] !== a ? (s = (e) => {
if (!o) return;
let t = a.canvasToPlan(e.offsetCenter, r().camera);
t && (o.userTransition(() => kp(o, a, n, t)), i());
}, t[0] = o, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = s) : s = t[5], id("doubletap", s), null;
}
function Dp(e) {
return e.invalidate;
}
function Op(e) {
return e.get;
}
function kp(e, t, n, r) {
let i = e.distance, a = Uo(e.getSpherical(Mp, !0).radius / n, e.minDistance, e.maxDistance), o = t.planToWorld(r, Ap), s = e.getTarget(jp, !1).sub(o).multiplyScalar(a / i).add(o);
return Promise.all([e.moveTo(s.x, s.y, s.z, !0), e.dollyTo(a, !0)]);
}
var Ap = new U(), jp = new U(), Mp = new Bt();
//#endregion
//#region ../renderer/src/controls/handlers/Zoom.tsx
function Np(e) {
let t = (0, Z.c)(2);
if (Df(Pp), e.dblclick === void 0) return null;
let n;
return t[0] === e.dblclick ? n = t[1] : (n = /* @__PURE__ */ (0, K.jsx)(Ep, { factor: e.dblclick }), t[0] = e.dblclick, t[1] = n), n;
}
function Pp(e) {
return e.mouseButtons.wheel = Pc.DOLLY, e.touches.two = Pc.TOUCH_DOLLY_SCREEN_PAN, () => {
e.mouseButtons.wheel = Pc.NONE, e.touches.two = Pc.NONE;
};
}
//#endregion
//#region ../renderer/src/controls/Controls.tsx
function Fp(e) {
var t, n, r, i;
let a = (0, Z.c)(18), o = (0, G.useRef)(null), s;
if (a[0] !== e.config) {
var c;
s = (c = e.config) == null ? {} : c, a[0] = e.config, a[1] = s;
} else s = a[1];
let l = s, u = (t = l.pan) == null || t, d = (n = l.zoom) == null || n, f = (r = l.roll) == null ? Lp : r, p = (i = l.pitch) == null ? Lp : i, m, h;
a[2] === Symbol.for("react.memo_cache_sentinel") ? (m = () => {
o.current.rotateTo(0, 0);
}, h = [], a[2] = m, a[3] = h) : (m = a[2], h = a[3]), (0, G.useEffect)(m, h);
let g;
a[4] === Symbol.for("react.memo_cache_sentinel") ? (g = /* @__PURE__ */ (0, K.jsx)(Sc, {
ref: o,
makeDefault: !0,
events: !0,
dollyToCursor: !0,
controlSmoothTime: {
rotate: 0,
truck: 0
}
}), a[4] = g) : g = a[4];
let _;
a[5] === u ? _ = a[6] : (_ = u !== !1 && /* @__PURE__ */ (0, K.jsx)(Yf, { ...Ip(u) }), a[5] = u, a[6] = _);
let v;
a[7] === d ? v = a[8] : (v = d !== !1 && /* @__PURE__ */ (0, K.jsx)(Np, { ...Ip(d) }), a[7] = d, a[8] = v);
let y;
a[9] === f ? y = a[10] : (y = f !== !1 && /* @__PURE__ */ (0, K.jsx)(yp, { ...Ip(f) }), a[9] = f, a[10] = y);
let b;
a[11] === p ? b = a[12] : (b = p !== !1 && /* @__PURE__ */ (0, K.jsx)(lp, {}), a[11] = p, a[12] = b);
let x;
return a[13] !== _ || a[14] !== v || a[15] !== y || a[16] !== b ? (x = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [
g,
_,
v,
y,
b
] }), a[13] = _, a[14] = v, a[15] = y, a[16] = b, a[17] = x) : x = a[17], x;
}
function Ip(e) {
return typeof e == "object" ? e : {};
}
var Lp = !1;
//#endregion
//#region ../renderer/src/debug/debug-chunk.ts
function Rp() {
return Bp != null || (Bp = import("./DebugTools-CSGF0Uqi.js")), Bp;
}
async function zp() {
await Rp();
}
var Bp, Vp = (0, G.lazy)(() => import("./DebugTools-CSGF0Uqi.js").then((e) => ({ default: e.DebugTools })));
function Hp(e) {
let t = (0, Z.c)(7), n, r, i;
t[0] === e ? (n = t[1], r = t[2], i = t[3]) : ({debugEnabled: i, children: r, ...n} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i), i && (0, G.use)(Rp());
let a;
return t[4] !== n || t[5] !== r ? (a = /* @__PURE__ */ (0, K.jsx)(vs, {
...n,
children: r
}), t[4] = n, t[5] = r, t[6] = a) : a = t[6], a;
}
function Up(e) {
let t = (0, Z.c)(2), { enabled: n, children: r } = e;
if (!n) return r;
let i;
return t[0] === r ? i = t[1] : (i = /* @__PURE__ */ (0, K.jsx)(G.Suspense, {
fallback: null,
children: /* @__PURE__ */ (0, K.jsx)(Vp, { children: r })
}), t[0] = r, t[1] = i), i;
}
function Wp(e, t) {
if (e <= 0) return;
let n = Kp(t) * Zp, r = e * e / (Xp * n);
return Math.min(Math.max(r, e * (1 - Jp)), e * (1 - Yp));
}
function Gp(e) {
return Math.max(e, .1) * 2;
}
function Kp(e) {
return qp * e;
}
var qp = .1, Jp = .98, Yp = .5, Xp = 2 ** 24, Zp = Math.cos(wn(85));
//#endregion
//#region ../renderer/src/events/pointer.ts
function Qp(e, t) {
let n = (0, Z.c)(19), r = al(), i = t && e.onClick !== void 0, a = t && e.onPointerMove !== void 0, o = t && e.onPointerOut !== void 0, s;
n[0] !== e || n[1] !== r ? (s = function(t) {
return (n) => tm(e, t, n, r);
}, n[0] = e, n[1] = r, n[2] = s) : s = n[2];
let c = s, l;
n[3] === t ? l = n[4] : (l = () => t ? void 0 : !1, n[3] = t, n[4] = l);
let u;
n[5] !== c || n[6] !== i ? (u = i ? c("onClick") : void 0, n[5] = c, n[6] = i, n[7] = u) : u = n[7];
let d;
n[8] !== c || n[9] !== a ? (d = a ? c("onPointerMove") : void 0, n[8] = c, n[9] = a, n[10] = d) : d = n[10];
let f;
n[11] !== c || n[12] !== o ? (f = o ? c("onPointerOut") : void 0, n[11] = c, n[12] = o, n[13] = f) : f = n[13];
let p;
return n[14] !== l || n[15] !== u || n[16] !== d || n[17] !== f ? (p = {
raycast: l,
onClick: u,
onPointerMove: d,
onPointerOut: f
}, n[14] = l, n[15] = u, n[16] = d, n[17] = f, n[18] = p) : p = n[18], p;
}
function $p() {
let e = (0, Z.c)(4), t = I(em), n = al(), r, i;
e[0] !== t || e[1] !== n ? (r = () => {
t({ filter: (e, t) => om(am(e, t, n), n) });
}, i = [t, n], e[0] = t, e[1] = n, e[2] = r, e[3] = i) : (r = e[2], i = e[3]), (0, G.useEffect)(r, i);
}
function em(e) {
return e.setEvents;
}
function tm(e, t, n, r) {
let i = e[t];
if (!i || t === "onClick" && cm(n)) return;
let a = rm(n);
a && i({
def: a,
point: r.worldToPlan(n.point),
stopPropagation: () => n.stopPropagation(),
nativeEvent: n.nativeEvent
});
}
function nm(e, t) {
return pm.set(e, t), () => {
pm.get(e) === t && pm.delete(e);
};
}
function rm(e) {
var t;
return (t = pm.get(e.object)) == null ? void 0 : t.defAt(e.instanceId);
}
function im(e, t, n) {
let [r] = e.intersectObject(t, !0);
return r ? n.worldToPlan(r.point) : sm(e.ray, n);
}
function am(e, t, n) {
if (e.length === 0) return e;
let { interaction: r } = t.internal, i = t.raycaster.intersectObject(t.scene, !0).find((e) => !dm(e.object, r));
if (!i) return e;
let a = i.distance + Kp(n.scale);
return e.filter((e) => e.distance <= a);
}
function om(e, t) {
if (e.length < 2) return e;
let n = Kp(t.scale), r = [];
for (let t = 0; t < e.length;) {
let i = t + 1;
for (; i < e.length;) {
let r = e[i].distance - e[t].distance;
if (r < 0 || r > n) break;
i++;
}
let a = e.slice(t, i);
a.length > 1 && a.sort((e, t) => lm(t, e)), r.push(...a), t = i;
}
return r;
}
function sm(e, t) {
var n;
return (n = t.rayToPlan(e)) == null ? t.worldToPlan(e.origin) : n;
}
function cm(e) {
return e.delta * e.delta > fm;
}
function lm(e, t) {
if (e.object !== t.object) return um(e.object) - um(t.object) || e.object.renderOrder - t.object.renderOrder;
let n = pm.get(e.object);
if (!n) return 0;
let r = n.defAt(e.instanceId), i = n.defAt(t.instanceId);
return (r ? n.paintOrderOf(r) : 0) - (i ? n.paintOrderOf(i) : 0);
}
function um(e) {
for (let t = e.parent; t; t = t.parent) if (t.isGroup) return t.renderOrder;
return 0;
}
function dm(e, t) {
for (let n = e; n; n = n.parent) if (t.includes(n)) return !0;
return !1;
}
var fm = 15, pm = rd(void 0, "sources", () => /* @__PURE__ */ new WeakMap());
//#endregion
//#region ../renderer/src/events/PointerMissed.tsx
function mm(e) {
let t = (0, Z.c)(12), { onPointerMissed: n } = e, r = I(_m), i = I(gm), a = I(hm), o = al(), s;
t[0] !== n || t[1] !== r || t[2] !== i || t[3] !== o ? (s = (e) => {
e.type === "click" && (n == null || n({
point: im(r, i, o),
nativeEvent: e
}));
}, t[0] = n, t[1] = r, t[2] = i, t[3] = o, t[4] = s) : s = t[4];
let c = (0, G.useEffectEvent)(s), l = n !== void 0, u;
t[5] !== c || t[6] !== l || t[7] !== a ? (u = () => (a({ onPointerMissed: l ? c : void 0 }), () => a({ onPointerMissed: void 0 })), t[5] = c, t[6] = l, t[7] = a, t[8] = u) : u = t[8];
let d;
return t[9] !== l || t[10] !== a ? (d = [l, a], t[9] = l, t[10] = a, t[11] = d) : d = t[11], (0, G.useEffect)(u, d), null;
}
function hm(e) {
return e.set;
}
function gm(e) {
return e.scene;
}
function _m(e) {
return e.raycaster;
}
//#endregion
//#region ../renderer/src/external/external-camera.ts
function vm(e, t) {
let n = ym.fromArray(t).multiply(ul), r = n.elements;
xm.set(r[0], r[4], r[8], r[1], r[5], r[9], r[3], r[7], r[11]), Sm.set(-r[12], -r[13], -r[15]).applyMatrix3(xm.invert()), bm.copy(n).invert(), Cm.set(0, 0, 1).applyMatrix4(bm), wm.set(0, 0, -1).applyMatrix4(bm);
let i = Cm.distanceToSquared(Sm) <= wm.distanceToSquared(Sm) ? 1 : -1;
i === 1 ? Tm.copy(wm).sub(Cm).normalize() : Tm.copy(Cm).sub(wm).normalize(), Em.set(0, 1, i).applyMatrix4(bm), Dm.set(0, -1, i).applyMatrix4(bm), km.copy(Em).sub(Dm).normalize(), Om.copy(Sm).add(Tm), e.matrixWorld.lookAt(Sm, Om, km), e.matrixWorld.setPosition(Sm), e.matrixWorldInverse.copy(e.matrixWorld).invert(), e.projectionMatrix.multiplyMatrices(n, e.matrixWorld), e.projectionMatrixInverse.copy(e.projectionMatrix).invert();
}
var ym = new W(), bm = new W(), xm = new on(), Sm = new U(), Cm = new U(), wm = new U(), Tm = new U(), Em = new U(), Dm = new U(), Om = new U(), km = new U();
//#endregion
//#region ../renderer/src/external/external-events.ts
function Am(e) {
let t = ye(e);
return {
...t,
connect(e) {
var n, r;
(n = t.connect) == null || n.call(t, (r = e.parentElement) == null ? e : r);
},
compute(e, t) {
t.pointer.set(e.offsetX / t.size.width * 2 - 1, -(e.offsetY / t.size.height) * 2 + 1), ll(t.raycaster, t.pointer, t.camera), t.raycaster.camera = t.camera;
}
};
}
//#endregion
//#region ../renderer/src/external/ExternalCanvas.tsx
var jm = $c("external");
function Mm(e) {
let t = (0, Z.c)(15), { gl: n, requestFrame: r, onFrame: i, children: a } = e, o = (0, G.useRef)(void 0), s;
t[0] === r ? s = t[1] : (s = () => r(), t[0] = r, t[1] = s);
let c = (0, G.useEffectEvent)(s), l;
t[2] === i ? l = t[3] : (l = (e) => i(e), t[2] = i, t[3] = l);
let u = (0, G.useEffectEvent)(l), d;
t[4] !== c || t[5] !== n || t[6] !== u ? (d = () => {
let e = Nm(n, c, u);
return o.current = e, () => {
o.current = void 0, e == null || e.dispose();
};
}, t[4] = c, t[5] = n, t[6] = u, t[7] = d) : d = t[7];
let f;
t[8] === n ? f = t[9] : (f = [n], t[8] = n, t[9] = f), (0, G.useEffect)(d, f);
let p;
t[10] === a ? p = t[11] : (p = () => {
var e;
(e = o.current) == null || e.render(/* @__PURE__ */ (0, K.jsx)(G.StrictMode, { children: a }));
}, t[10] = a, t[11] = p);
let m;
return t[12] !== a || t[13] !== n ? (m = [n, a], t[12] = a, t[13] = n, t[14] = m) : m = t[14], (0, G.useEffect)(p, m), null;
}
function Nm(e, t, n) {
let r = e.canvas;
if (!(r instanceof HTMLCanvasElement)) {
jm.warn("external mode needs a context bound to an HTMLCanvasElement");
return;
}
le(fe);
let i = new Ve();
i.matrixAutoUpdate = !1, i.matrixWorldAutoUpdate = !1, i.manual = !0;
let a = new ne({
canvas: r,
context: e
});
a.autoClear = !1;
let o = a.setSize.bind(a);
a.setSize = (e, t) => o(e, t, !1), a.forceContextLoss = () => void 0;
let s = () => {
let e = r.getBoundingClientRect();
return {
width: e.width,
height: e.height,
top: e.top,
left: e.left
};
}, c = ce(r), l = !1, u = !1, d, f, p;
return c.configure({
gl: a,
flat: !0,
camera: i,
frameloop: "never",
events: Am,
size: s(),
dpr: window.devicePixelRatio
}).then(() => {
var e, o, m;
if (l) return;
let h = (e = ve.get(r)) == null ? void 0 : e.store;
h && (h.setState({ invalidate: () => {
l || t();
} }), (o = (m = h.getState().events).connect) == null || o.call(m, r), f = n((e) => {
l || (vm(i, e), a.resetState(), pe(performance.now(), !0, h.getState()));
}), typeof ResizeObserver == "function" && (p = new ResizeObserver(() => {
if (l) return;
let e = s();
h.getState().setSize(e.width, e.height, e.top, e.left), h.getState().setDpr(window.devicePixelRatio);
}), p.observe(r)), u = !0, d !== void 0 && c.render(d), t());
}), {
render(e) {
d = e, u && c.render(e);
},
dispose() {
l = !0, p == null || p.disconnect(), f == null || f(), c.unmount();
}
};
}
//#endregion
//#region ../renderer/src/space/layout-measure.ts
function Pm(e, t, n, r) {
var i;
if (!(n > 0) || !(t.scale > 0)) return;
if (r) {
let i = Rm(e, r.distance);
return i > 0 ? i / n / t.scale : void 0;
}
let a = Lm(e, t);
if (!a) return;
let o = (i = t.planToNdc(a, e, Wm)) == null ? void 0 : i.y;
if (o === void 0) return;
let s = t.ndcToPlan(Wm.set(-1, o), e, Hm), c = t.ndcToPlan(Wm.set(1, o), e, Um);
if (!s || !c) return;
let l = Math.hypot(c.x - s.x, c.y - s.y);
if (l > 0) return l / n;
}
function Fm(e, t, n, r, i) {
if (i) return ns(i);
let a = Lm(e, t);
if (!a) return;
Gm.multiplyMatrices(e.projectionMatrix, e.matrixWorldInverse).multiply(t.matrix);
let o = Gm.elements, s = Km.set(a.x, a.y, 0, 1).applyMatrix4(Gm), c = (o[0] * s.w - s.x * o[3]) * n, l = -(o[1] * s.w - s.y * o[3]) * r;
if (!(c === 0 && l === 0)) return Wo(-Math.atan2(l, c), 2 * Math.PI);
}
function Im(e, t) {
return Math.abs(e - t) >= zm;
}
function Lm(e, t) {
return Bm.origin.setFromMatrixPosition(e.matrixWorld), e.getWorldDirection(Bm.direction), t.rayToPlan(Bm, Vm);
}
function Rm(e, t) {
let n = e.projectionMatrix.elements[0];
return n > 0 ? tl(e) ? 2 * t / n : nl(e) ? 2 / n : NaN : NaN;
}
var zm = 1e-4, Bm = new H(), Vm = new An(), Hm = new An(), Um = new An(), Wm = new V(), Gm = new W(), Km = new _n();
//#endregion
//#region ../renderer/src/events/LayoutDriver.tsx
function qm(e) {
let t = (0, Z.c)(14), { children: n } = e, r = I(Xm), i = I(Ym), a = I(Jm), o = Tf(), s = al(), c;
t[0] !== r || t[1] !== i || t[2] !== a || t[3] !== s ? (c = () => {
var e, t;
return df(a, (e = Pm(r, s, i.domElement.width / i.getPixelRatio())) == null ? 1 : e, (t = Fm(r, s, i.domElement.width / i.getPixelRatio(), i.domElement.height / i.getPixelRatio())) == null ? 0 : t);
}, t[0] = r, t[1] = i, t[2] = a, t[3] = s, t[4] = c) : c = t[4];
let [l] = (0, G.useState)(c), u;
t[5] === Symbol.for("react.memo_cache_sentinel") ? (u = {
seen: new W(),
size: new V(),
frameAt: -Infinity,
changedAt: -Infinity,
placedAt: -Infinity
}, t[5] = u) : u = t[5];
let d = (0, G.useRef)(u), f;
t[6] !== o || t[7] !== a || t[8] !== s || t[9] !== l ? (f = (e) => {
let { camera: t, gl: n, viewport: r } = e, { width: i, height: c } = n.domElement, u = i / r.dpr, f = c / r.dpr, p = Pm(t, s, u, o);
p !== void 0 && Im(p, l.pixelSize) && l.applyScale(p);
let m = Fm(t, s, u, f, o);
m !== void 0 && m !== l.roll && l.applyRoll(m);
let h = {
space: s,
camera: t,
pixelSize: l.pixelSize,
width: u,
height: f
};
if (Zm(l, d.current, h, performance.now()) && a(), !l.hasWork) return;
let g = Sd(t, s.matrix, ih);
l.drain(g, $m) && a();
}, t[6] = o, t[7] = a, t[8] = s, t[9] = l, t[10] = f) : f = t[10], ue(f);
let p;
return t[11] !== n || t[12] !== l ? (p = /* @__PURE__ */ (0, K.jsx)(cf, {
value: l,
children: n
}), t[11] = n, t[12] = l, t[13] = p) : p = t[13], p;
}
function Jm(e) {
return e.invalidate;
}
function Ym(e) {
return e.gl;
}
function Xm(e) {
return e.camera;
}
function Zm(e, t, n, r) {
let { space: i, camera: a, width: o, height: s } = n, c = Math.min(r - t.frameAt, nh), l = Qm(i, a, t.seen, o, s);
(t.size.x !== o || t.size.y !== s || l > th * c / 1e3) && (t.changedAt = r), t.seen.multiplyMatrices(a.projectionMatrix, a.matrixWorldInverse), t.size.set(o, s), t.frameAt = r;
let u = t.changedAt > t.placedAt;
return !(e.needsPlacement || e.placementDrifted) && !(u && r - t.changedAt >= eh) ? u : (t.placedAt = r, e.applyPlacement(n), !1);
}
function Qm(e, t, n, r, i) {
if (ah.multiplyMatrices(t.projectionMatrix, t.matrixWorldInverse), ah.equals(n)) return 0;
let a = -1;
for (let o of rh) for (let s of rh) {
let c = e.ndcToPlan(oh.set(o, s), t, sh);
if (!c || (ch.set(c.x, c.y, 0, 1).applyMatrix4(e.matrix).applyMatrix4(n), ch.w <= 0)) continue;
let l = (ch.x / ch.w - o) * (r / 2), u = (ch.y / ch.w - s) * (i / 2);
a = Math.max(a, Math.hypot(l, u));
}
return a < 0 ? Infinity : a;
}
var $m = 3, eh = 60, th = 60, nh = 1e3 / 30, rh = [
-.96,
0,
.96
], ih = new Xe(), ah = new W(), oh = new V(), sh = new An(), ch = new _n();
//#endregion
//#region ../renderer/src/core/shader-source.ts
function lh(e, t) {
return ph(e, (e) => `${t}\n${e}`);
}
function uh(e, t) {
return ph(e, (e) => `${e}\n${t}`);
}
function dh(e, t, n) {
let r = e.indexOf(t);
if (r < 0) throw Error(`shader-source: the shader has no "${t}" to rewrite.`);
return e.slice(0, r) + n + e.slice(r + t.length);
}
function fh(e) {
let t = "#include <tonemapping_fragment>", n = "#if defined( TONE_MAPPING )";
return e.includes(t) ? t : e.includes(n) ? n : void 0;
}
function ph(e, t) {
let n = mh.exec(e);
if (!n) throw Error("shader-source: the shader has no \"void main()\" to inject into.");
let r = n[0];
return e.slice(0, n.index) + t(r) + e.slice(n.index + r.length);
}
var mh = /void\s+main\s*\(\s*(?:void)?\s*\)\s*\{/;
//#endregion
//#region ../renderer/src/objects/layer/layer-context.ts
function hh() {
return (0, G.use)(yh);
}
function gh() {
return (0, G.use)(bh);
}
function _h(e) {
for (let t of e) if (t.dim !== void 0) return t.dim;
return 0;
}
function vh(e, t) {
let n = e.map((e) => dd(e, t));
return () => {
for (let e of n) e();
};
}
var yh = (0, G.createContext)([]), bh = (0, G.createContext)(!1);
//#endregion
//#region ../renderer/src/objects/materials/effects/ao/ambient-occlusion-pass.ts
function xh() {
return {
uDepth: { value: null },
uNoise: { value: Sh() },
uProjection: { value: new W() },
uUnprojection: { value: new W() },
uTexel: { value: new V(1, 1) },
uNoiseScale: { value: new V(1, 1) },
uRadius: { value: 1 },
uTaps: { value: 16 },
uKernel: { value: Ch() }
};
}
function Sh() {
let e = new Float32Array(16 * Dh);
for (let t = 0; t < 16; t++) {
let n = 2 * Math.PI * wh(t * Oh);
e[t * Dh] = Math.cos(n), e[t * Dh + 1] = Math.sin(n), e[t * Dh + 2] = 0, e[t * Dh + 3] = 1;
}
let t = new Ut(e, 4, 4, dt, pt);
return t.minFilter = Gt, t.magFilter = Gt, t.wrapS = Je, t.wrapT = Je, t.needsUpdate = !0, t;
}
function Ch() {
let e = [];
for (let t = 0; t < 16; t++) {
let n = 2 * Math.PI * wh(kh + t * Ah), r = wh(kh + t * jh), i = Math.sqrt(1 - r * r), a = Mh + (1 - Mh) * ((t + 1) / 16) ** 2;
e.push(new U(Math.cos(n) * i * a, Math.sin(n) * i * a, r * a));
}
return e;
}
function wh(e) {
return e - Math.floor(e);
}
var Th = "\n varying vec2 vUv;\n\n void main() {\n vUv = uv;\n gl_Position = vec4(position.xy, 0.0, 1.0);\n }\n", Eh = "\n uniform sampler2D uDepth;\n uniform sampler2D uNoise;\n uniform mat4 uProjection;\n uniform mat4 uUnprojection;\n uniform vec2 uTexel;\n uniform vec2 uNoiseScale;\n uniform float uRadius;\n uniform int uTaps;\n uniform vec3 uKernel[16];\n varying vec2 vUv;\n\n const float AO_BIAS = 0.02;\n\n // Where the grazing fade starts and ends, as the absolute dot of the normal against the view\n // direction: fully faded about seventeen degrees from edge on, fully open by about forty. See the\n // fade at the end of main.\n const float AO_GRAZING_MIN = 0.30;\n const float AO_GRAZING_MAX = 0.64;\n\n // How far apart the two neighbors of an axis have to be before blendAxis takes the nearer one\n // outright. Measured as a share of their sum. Larger crosses over more gently and softens a\n // silhouette. Smaller sharpens the silhouette and brings the normal jump back.\n const float AO_CROSSOVER = 0.45;\n\n float depthAt(vec2 uv) {\n return texture2D(uDepth, uv).x;\n }\n\n vec3 viewAt(vec2 uv, float depth) {\n vec4 clip = vec4(uv * 2. - 1., depth * 2. - 1., 1.);\n vec4 view = uUnprojection * clip;\n return view.xyz / view.w;\n }\n\n vec3 blendAxis(vec3 back, vec3 forward, float backApart, float forwardApart) {\n // Positive when the backward neighbor is the worse of the two, which moves the result toward\n // the forward one. Normalized by the sum, so AO_CROSSOVER is a share rather than a depth.\n float ratio = (backApart - forwardApart) / max(backApart + forwardApart, 1e-6);\n return mix(back, forward, smoothstep(-AO_CROSSOVER, AO_CROSSOVER, ratio));\n }\n\n vec3 normalAt(vec2 uv, vec3 here, float depth) {\n vec2 stepX = vec2(uTexel.x, 0.);\n vec2 stepY = vec2(0., uTexel.y);\n float left = depthAt(uv - stepX);\n float right = depthAt(uv + stepX);\n float down = depthAt(uv - stepY);\n float up = depthAt(uv + stepY);\n\n // blendAxis leans toward the neighbor that stays on this surface rather than switching to it. A\n // hard pick makes a face turned side on jump: both depth differences are large and nearly equal\n // there, so a small camera rotation crosses the comparison and the normal jumps with it. The\n // smoothstep over their difference crosses that middle continuously.\n vec3 alongX = blendAxis(here - viewAt(uv - stepX, left), viewAt(uv + stepX, right) - here,\n abs(depth - left), abs(right - depth));\n vec3 alongY = blendAxis(here - viewAt(uv - stepY, down), viewAt(uv + stepY, up) - here,\n abs(depth - down), abs(up - depth));\n\n vec3 normal = normalize(cross(alongX, alongY));\n // A surface the camera sees faces the camera, and view space looks down -z. The flip matters in\n // external mode, where the host's projection can mirror an axis and turn the cross product with\n // it. The wrong side samples the hemisphere behind the surface.\n return normal.z < 0. ? -normal : normal;\n }\n\n float occlusionTap(vec3 here, vec3 at) {\n vec4 clip = uProjection * vec4(at, 1.);\n // At or behind the eye, where the perspective divide has no answer. Orthographic keeps w at 1,\n // so this costs a comparison there and nothing else.\n if (clip.w <= 0.) return 0.;\n vec2 uv = clip.xy / clip.w * .5 + .5;\n // Screen space sees only what is on screen. A tap off the edge has no depth of its own, and\n // clamped sampling answers with the border texel's depth, so the tap contributes nothing.\n if (uv.x < 0. || uv.x > 1. || uv.y < 0. || uv.y > 1.) return 0.;\n float stored = depthAt(uv);\n // The prepass clears to the far plane, so a tap over open background lands there. This rejects\n // that tap rather than darkening an edge.\n if (stored >= 1.) return 0.;\n float storedZ = viewAt(uv, stored).z;\n // Nothing in front of the tap: this surface is open in that direction.\n if (storedZ < at.z + uRadius * AO_BIAS) return 0.;\n return smoothstep(0., 1., uRadius / abs(here.z - storedZ));\n }\n\n void main() {\n float depth = depthAt(vUv);\n // Nothing here, or nothing to reach with. The prepass clears to the far plane. A radius of zero\n // puts every tap on the fragment itself, where the divide by its distance has no answer.\n if (depth >= 1. || uRadius <= 0.) {\n gl_FragColor = vec4(0., 0., 0., 1.);\n return;\n }\n\n vec3 here = viewAt(vUv, depth);\n vec3 normal = normalAt(vUv, here, depth);\n\n // The tile's own rotation, turned into a basis around the normal. One kernel becomes a\n // different kernel per pixel, with no second kernel to upload.\n vec3 rotation = vec3(texture2D(uNoise, vUv * uNoiseScale).xy, 0.);\n vec3 tangent = cross(normal, rotation);\n // Degenerate only where the rotation lies along the normal, which is a wall seen edge on. The\n // fallback is degenerate only where the normal is the view axis, the case this one covers, so\n // between them there is always a tangent.\n if (dot(tangent, tangent) < 1e-6) tangent = cross(normal, vec3(0., 0., 1.));\n tangent = normalize(tangent);\n mat3 orient = mat3(tangent, cross(normal, tangent), normal);\n\n float occluded = 0.;\n for (int tap = 0; tap < 16; tap++) {\n // GLSL ES 1.00 on the old Android WebViews this SDK reaches needs a constant loop bound, and\n // the break is what skips the taps.\n if (tap >= uTaps) break;\n occluded += occlusionTap(here, here + orient * uKernel[tap] * uRadius);\n }\n\n // The average divides by what the loop walked, not by what the kernel holds. The floor stops a\n // tap count of zero from dividing by nothing. No control offers zero, and a stale upload can\n // still hold it.\n float term = occluded / max(float(uTaps), 1.);\n\n // The fade drops the term where the surface turns edge on to the camera, because the normal\n // that oriented this kernel stops being reliable there. A face turned nearly side on gives\n // normalAt two neighbors that disagree by almost the same amount. A small camera rotation then\n // still moves the normal, and the term moves with it.\n //\n // The fragment sits in view space here, where the camera is the origin, so its own direction is\n // the view vector. The dot of that against the normal says how square on the surface is: one\n // face on, zero edge on. Taken as an absolute value, since a normal reconstructed at a depth\n // discontinuity can come back pointing away.\n //\n // An ordinary wall under this plan's camera reads about 0.82 square on at a 55 degree pitch.\n // That is well clear of the band, so walls keep their full term.\n float facing = abs(dot(normal, normalize(here)));\n gl_FragColor = vec4(term * smoothstep(AO_GRAZING_MIN, AO_GRAZING_MAX, facing), 0., 0., 1.);\n }\n", Dh = 4, Oh = .6180339887498949, kh = .5, Ah = .7548776662466927, jh = .5698402909980532, Mh = .1;
//#endregion
//#region ../renderer/src/objects/materials/effects/ao/blur-pass.ts
function Nh(e) {
return {
uOcclusion: { value: null },
uDepth: { value: null },
uTexel: { value: new V(1, 1) },
uBlur: e.aoBlur
};
}
var Ph = .05, Fh = `
uniform sampler2D uOcclusion;
uniform sampler2D uDepth;
uniform vec2 uTexel;
uniform int uBlur;
varying vec2 vUv;
const float AO_EDGE = ${Ph};
void main() {
float depth = texture2D(uDepth, vUv).x;
// Symmetric at any side, and this texel alone at side 1.
float center = float(uBlur - 1) * .5;
float occluded = 0.;
float total = 0.;
// GLSL ES 1.00 on the old Android WebViews this SDK reaches needs constant loop bounds, and the
// break is what skips the fetches.
for (int y = 0; y < 4; y++) {
if (y >= uBlur) break;
for (int x = 0; x < 4; x++) {
if (x >= uBlur) break;
vec2 at = vUv + (vec2(float(x), float(y)) - center) * uTexel;
// Depth-aware, so occlusion does not bleed across the edge between a wall and whatever
// stands behind it. Stored depth is not linear, so the difference is a share of the range
// still ahead of this texel.
float stored = texture2D(uDepth, at).x;
float apart = abs(stored - depth) / max(1. - depth, 1e-6);
float weight = 1. - smoothstep(0., AO_EDGE, apart);
occluded += texture2D(uOcclusion, at).r * weight;
total += weight;
}
}
// Nothing around this texel describes the surface it is on, so there is no term to write and no
// total to divide by. Open, which a lit read of it leaves alone.
if (total <= 0.) {
gl_FragColor = vec4(0., 0., 0., 1.);
return;
}
gl_FragColor = vec4(occluded / total, 0., 0., 1.);
}
`;
//#endregion
//#region ../renderer/src/objects/materials/effects/ao/ambient-occlusion-patch.ts
function Ih(e, t) {
if (e.fragmentShader.includes(Wh)) return;
let n = fh(e.fragmentShader);
if (!n) throw Error("applyAmbientOcclusion: the shader has no output chain to darken before.");
let r = lh(e.fragmentShader, Gh).replace(n, `${Kh}\n${n}`);
e.uniforms[Lh] = t.aoMap, e.uniforms[Rh] = t.aoDepth, e.uniforms[zh] = t.aoActive, e.uniforms[Bh] = t.aoGuard, e.uniforms[Vh] = t.aoStrength, e.uniforms[Hh] = t.aoViewport, e.uniforms[Uh] = t.shadowColor, e.fragmentShader = r;
}
var Lh = "uAoMap", Rh = "uAoDepth", zh = "uAoActive", Bh = "uAoGuard", Vh = "uAoStrength", Hh = "uAoViewport", Uh = "uAoColor", Wh = "vec3 ambientOcclusion(", Gh = `
uniform sampler2D ${Lh};
uniform sampler2D ${Rh};
uniform float ${zh};
uniform float ${Bh};
uniform float ${Vh};
uniform vec2 ${Hh};
uniform vec3 ${Uh};
const float AO_EDGE = ${Ph};
${Wh}vec3 rgb, float depth) {
// A frame that skipped the passes shades correctly rather than sampling a stale texture.
if (${zh} < .5) return rgb;
// The guard band undone. Every pass ran on a frustum (1 + g) wider than this one. This
// fragment's place in the AO texture is its ndc shrunk by that factor.
vec2 uv = ((gl_FragCoord.xy / ${Hh}) * 2. - 1.) / (1. + ${Bh}) * .5 + .5;
// Whether the term measured the surface this fragment shades. Stored depth is not linear, so
// the difference is a share of the range still ahead of this fragment.
float stored = texture2D(${Rh}, uv).x;
float apart = abs(stored - depth) / max(1. - depth, 1e-6);
float weight = 1. - smoothstep(0., AO_EDGE, apart);
// Nothing here describes the surface this fragment is on, a translucent one most of all. There
// is no term to apply and no second fetch worth taking.
if (weight <= 0.) return rgb;
return mix(rgb, ${Uh}, ${Vh} * texture2D(${Lh}, uv).r * weight);
}
`, Kh = "\n gl_FragColor.rgb = ambientOcclusion(gl_FragColor.rgb, gl_FragCoord.z);\n";
//#endregion
//#region ../renderer/src/objects/materials/effects/ao/index.ts
function qh() {
return {
aoMap: { value: null },
aoDepth: { value: null },
aoActive: { value: 0 },
aoGuard: { value: Jh.guard },
aoStrength: { value: Jh.strength },
aoBlur: { value: Jh.blur },
aoViewport: { value: new V(1, 1) },
enabled: Jh.enabled,
radius: Jh.radius,
taps: Jh.taps,
occluders: /* @__PURE__ */ new Set()
};
}
var Jh = {
enabled: !1,
radius: 8,
strength: .35,
blur: 4,
taps: 16,
guard: .15
};
//#endregion
//#region ../renderer/src/objects/materials/effects/color-dim.ts
function Yh() {
let e = (0, Z.c)(6), t = hh(), n = I(Xh), r;
e[0] === Symbol.for("react.memo_cache_sentinel") ? (r = { value: 0 }, e[0] = r) : r = e[0];
let i = (0, G.useRef)(r), a;
e[1] === Symbol.for("react.memo_cache_sentinel") ? (a = () => (e) => Zh(e, i.current), e[1] = a) : a = e[1];
let [o] = (0, G.useState)(a), s, c;
return e[2] !== t || e[3] !== n ? (s = () => {
let e = function() {
let e = tg(_h(t));
i.current.value !== e && (i.current.value = e, n());
};
return e(), vh(t, e);
}, c = [t, n], e[2] = t, e[3] = n, e[4] = s, e[5] = c) : (s = e[4], c = e[5]), (0, G.useEffect)(s, c), o;
}
function Xh(e) {
return e.invalidate;
}
function Zh(e, t) {
let n = e.fragmentShader;
if (!n.includes("instanceDim") || n.includes(ag)) return !1;
let r = fh(n);
if (!r) throw Error("applyDim: the shader has no output chain to dim before.");
return e.uniforms[ig] = t, e.fragmentShader = lh(n, og).replace(r, `${sg}\n${r}`), !0;
}
function Qh(e, t) {
let n = [], r = [];
for (let i of e) ($h(i.dim, t) ? n : r).push(i);
return n.length === 0 || r.length === 0 ? e : [...n, ...r];
}
function $h(e, t) {
return e === void 0 ? t : e > 0;
}
function eg(e) {
return e === void 0 ? -1 : tg(e);
}
function tg(e) {
return Math.min(Math.max(e, 0), 1);
}
var ng = "instanceDim", rg = { vertex: { [ng]: "float" } }, ig = "uDim", ag = "vec4 dimColor(", og = `
uniform float ${ig};
const vec3 grayWeights = vec3(0.299, 0.587, 0.114);
const float darkenFactor = pow(2., 2.2); // Gamma corrected
${ag}vec4 col, float amount) {
vec3 gray = vec3(dot(grayWeights, col.rgb));
return vec4(mix(col.rgb, gray / darkenFactor, amount), col.a);
}
`, sg = `
gl_FragColor = dimColor(gl_FragColor, ${ng} < 0. ? ${ig} : ${ng});
`;
//#endregion
//#region ../renderer/src/objects/materials/effects/contact-shadow.ts
function cg(e, t) {
if (e.fragmentShader.includes(gg)) return;
let n = fh(e.fragmentShader);
if (!n) throw Error("applyContactShadow: the shader has no output chain to darken before.");
let r = dh(lh(e.vertexShader, bg), yg, `${yg}\n${xg}`), i = lh(e.fragmentShader, Sg).replace(n, `${Cg}\n${n}`);
e.uniforms[fg] = t.shadowDistance, e.uniforms[pg] = t.shadowStrength, e.uniforms[mg] = t.shadowColor, e.uniforms[hg] = t.planFromWorld, e.vertexShader = r, e.fragmentShader = i;
}
function lg(e) {
e.shadowStrength.value = e.contactEnabled ? e.contactStrength : 0;
}
function ug() {
return {
shadowDistance: { value: dg.distance },
shadowStrength: { value: dg.strength },
contactEnabled: !0,
contactStrength: dg.strength,
shadowColor: { value: new gt(dg.color) },
shadowHex: dg.color,
planFromWorld: { value: new W() }
};
}
var dg = {
distance: 1.5,
strength: .2,
color: "#4a5260"
}, fg = "uShadowDistance", pg = "uShadowStrength", mg = "uShadowColor", hg = "uPlanFromWorld", gg = "vec3 contactShadow(", _g = "vHeight", vg = "worldPosition", yg = "#include <worldpos_vertex>", bg = `
#define DISTANCE
uniform mat4 ${hg};
varying float ${_g};
`, xg = `
${_g} = (${hg} * ${vg}).z;
`, Sg = `
uniform float ${fg};
uniform float ${pg};
uniform vec3 ${mg};
varying float ${_g};
${gg}vec3 rgb, float height) {
float lit = clamp(height / max(${fg}, 1e-4), 0., 1.);
return mix(rgb, ${mg}, ${pg} * (1. - lit));
}
`, Cg = `
gl_FragColor.rgb = contactShadow(gl_FragColor.rgb, ${_g});
`;
//#endregion
//#region ../renderer/src/objects/materials/effects/effects-context.ts
function wg() {
return {
...qh(),
...ug()
};
}
function Tg() {
return (0, G.use)(Eg);
}
var Eg = (0, G.createContext)(wg()), Dg = { value: 0 }, Og = { value: new W() };
function kg(e) {
return e.vertexShader.includes(Pg) ? !0 : e.vertexShader.includes(Fg) ? (e.uniforms[Pg] = Og, e.vertexShader = dh(lh(e.vertexShader, `uniform mat4 ${Pg};`), Fg, `${Fg}\n${Ig}`), e.fragmentShader = lh(e.fragmentShader, Lg), !0) : !1;
}
function Ag(e, t) {
if (e.fragmentShader.includes(Mg)) return;
let n = fh(e.fragmentShader);
n && kg(e) && (e.uniforms[Mg] = Dg, e.uniforms[Ng] = t.shadowColor, e.fragmentShader = lh(e.fragmentShader, `uniform float ${Mg};\nuniform vec3 ${Ng};`).replace("#include <lights_fragment_begin>", zg).replace(n, `${Rg}\n${n}`));
}
function jg(e) {
kg(e) && (e.fragmentShader = e.fragmentShader.replace("getShadowMask()", "sunShadowLit()"));
}
var Mg = "uSunShadowStrength", Ng = "uSunShadowColor", Pg = "uShadowFromView", Fg = "#include <shadowmap_vertex>", Ig = `
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
vDirectionalShadowCoord[ 0 ] = ${Pg} * vec4( mvPosition.xyz + normalize( transformedNormal ) * directionalLightShadows[ 0 ].shadowNormalBias, 1.0 );
#endif
`, Lg = "\n#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0 && defined( SHADOWMAP_TYPE_PCF )\n float sunShadowLit() {\n vec4 coord = vDirectionalShadowCoord[ 0 ];\n coord.z += directionalLightShadows[ 0 ].shadowBias;\n if ( coord.x < 0.0 || coord.x > 1.0 || coord.y < 0.0 || coord.y > 1.0 || coord.z > 1.0 ) return 1.0;\n // Four taps half a radius apart, each a hardware 2x2 compare: a fixed 4x4 footprint.\n vec2 offset = directionalLightShadows[ 0 ].shadowRadius * 0.5 / directionalLightShadows[ 0 ].shadowMapSize;\n return 0.25 * (\n texture( directionalShadowMap[ 0 ], vec3( coord.xy + vec2( -offset.x, -offset.y ), coord.z ) ) +\n texture( directionalShadowMap[ 0 ], vec3( coord.xy + vec2( offset.x, -offset.y ), coord.z ) ) +\n texture( directionalShadowMap[ 0 ], vec3( coord.xy + vec2( -offset.x, offset.y ), coord.z ) ) +\n texture( directionalShadowMap[ 0 ], vec3( coord.xy + vec2( offset.x, offset.y ), coord.z ) )\n );\n }\n#else\n float sunShadowLit() { return 1.0; }\n#endif\n", Rg = `
#if defined( USE_SHADOWMAP ) && NUM_DIR_LIGHT_SHADOWS > 0
if ( receiveShadow ) {
// Shadow-casting lights sort first, so the sun is directional light 0 as well.
float sunFacing = max( dot( normalize( normal ), directionalLights[ 0 ].direction ), 0.0 );
// A face turned from the sun keeps its color, so it skips the lookup.
float sunLit = sunFacing > 0.0 ? sunShadowLit() : 1.0;
gl_FragColor.rgb = mix( gl_FragColor.rgb, ${Ng}, min( ${Mg} * sunFacing, 1.0 ) * ( 1.0 - sunLit ) );
}
#endif
`, zg = xe.lights_fragment_begin.replace("( UNROLLED_LOOP_INDEX < NUM_DIR_LIGHT_SHADOWS )", "( UNROLLED_LOOP_INDEX < 0 )"), Bg = {
blending: 5,
blendSrc: 204,
blendSrcAlpha: 201,
blendDst: 205,
blendDstAlpha: 205,
side: 2,
depthFunc: 3,
depthWrite: !1,
polygonOffset: !0,
polygonOffsetFactor: -1,
polygonOffsetUnits: -4,
forceSinglePass: !0
}, Vg = {
depthTest: !1,
transparent: !0
}, Hg = $c("color-material");
function Ug(e) {
var t;
let n = (0, Z.c)(18), r = (t = e.color) == null ? "white" : t, i = e.solid === !0, a = gh(), o, s;
n[0] !== a || n[1] !== i ? (o = () => {
i && a && Hg.warn("overlay has no effect on a solid batch, so it is ignored.");
}, s = [i, a], n[0] = a, n[1] = i, n[2] = o, n[3] = s) : (o = n[2], s = n[3]), (0, G.useEffect)(o, s);
let c = Yh(), l = Tg(), u;
n[4] !== c || n[5] !== l || n[6] !== e.onBeforeCompile || n[7] !== i ? (u = () => {
let t = e.onBeforeCompile;
return (e) => {
t == null || t(e), i && (cg(e, l), Ih(e, l), Ag(e, l)), c(e);
};
}, n[4] = c, n[5] = l, n[6] = e.onBeforeCompile, n[7] = i, n[8] = u) : u = n[8];
let [d] = (0, G.useState)(u);
if (i) {
var f;
let t = (f = e.translucent) != null && f, i = !t, a;
return n[9] !== r || n[10] !== d || n[11] !== i || n[12] !== t ? (a = /* @__PURE__ */ (0, K.jsx)("meshLambertMaterial", {
...Bg,
color: r,
depthWrite: !0,
polygonOffset: !1,
transparent: t,
forceSinglePass: i,
onBeforeCompile: d
}), n[9] = r, n[10] = d, n[11] = i, n[12] = t, n[13] = a) : a = n[13], a;
}
let p = a ? Vg : null, m;
return n[14] !== r || n[15] !== d || n[16] !== p ? (m = /* @__PURE__ */ (0, K.jsx)("meshBasicMaterial", {
...Bg,
...p,
color: r,
onBeforeCompile: d
}), n[14] = r, n[15] = d, n[16] = p, n[17] = m) : m = n[17], m;
}
//#endregion
//#region ../renderer/src/objects/Background.tsx
function Wg(e) {
let t = (0, Z.c)(4), [n] = (0, G.useState)(Gg), r;
t[0] === Symbol.for("react.memo_cache_sentinel") ? (r = /* @__PURE__ */ (0, K.jsx)("planeGeometry", { args: [2, 2] }), t[0] = r) : r = t[0];
let i;
return t[1] !== n || t[2] !== e.color ? (i = /* @__PURE__ */ (0, K.jsxs)("mesh", {
name: "background",
renderOrder: 0,
frustumCulled: !1,
children: [r, /* @__PURE__ */ (0, K.jsx)(Ug, {
color: e.color,
onBeforeCompile: n
})]
}), t[1] = n, t[2] = e.color, t[3] = i) : i = t[3], i;
}
function Gg() {
return Kg;
}
function Kg(e) {
e.vertexShader = e.vertexShader.replace("#include <project_vertex>", "gl_Position = vec4(transformed.xy, 1.0, 1.0);"), e.fragmentShader = lh(e.fragmentShader, `const float ${ng} = -1.0;`);
}
//#endregion
//#region ../renderer/src/objects/images/texture-budget.ts
var qg = $c("texture-budget"), Jg = 4, Yg = 4 / 3, Xg = 1024 * 1024, Zg = .001;
function Qg(e, t) {
return e * t * Jg * Yg;
}
var $g = class {
constructor(e) {
this.memoryLimitMb = void 0, this.atlases = /* @__PURE__ */ new Set(), this.listeners = /* @__PURE__ */ new Set(), this.factor = 1, this.memoryLimitMb = e;
}
isActive() {
return !!this.memoryLimitMb;
}
setMemoryLimit(e) {
if (e === this.memoryLimitMb) return;
let t = this.isActive();
this.memoryLimitMb = e, this.isActive() === t ? this.recompute() : (this.factor = this.computeResizeFactor(), this.notify());
}
register(e) {
this.atlases.add(e), this.recompute();
}
unregister(e) {
this.atlases.delete(e) && this.recompute();
}
getResizeFactor() {
return this.factor;
}
subscribe(e) {
return this.listeners.add(e), () => {
this.listeners.delete(e);
};
}
recompute() {
let e = this.computeResizeFactor();
Math.abs(e - this.factor) < Zg || (this.factor = e, this.notify());
}
notify() {
for (let e of this.listeners) e();
}
computeResizeFactor() {
if (!this.memoryLimitMb) return 1;
let e = 0, t = 0;
for (let n of this.atlases) {
let r = Qg(n.width, n.height);
n.resizable ? e += r : t += r;
}
if (e === 0) return qg.debug("no resizable atlases, atlases will not be scaled"), 1;
let n = this.memoryLimitMb * Xg - t;
if (n <= 0) return qg.debug("memory limit too low to resize textures, atlases will not be scaled"), 1;
let r = Math.sqrt(n / e);
return r >= 1 ? 1 : (qg.debug("resize factor: %s (budget %d bytes, resizable %d bytes)", r.toFixed(3), n, e), r);
}
}, e_ = (0, G.createContext)(new $g());
function t_(e, t) {
let n = (0, Z.c)(15), r, i;
n[0] === e ? (r = n[1], i = n[2]) : (r = (t) => e.subscribe(t), i = () => e.isActive(), n[0] = e, n[1] = r, n[2] = i);
let a = (0, G.useSyncExternalStore)(r, i), o, s;
n[3] === e ? (o = n[4], s = n[5]) : (o = (t) => e.subscribe(t), s = () => e.getResizeFactor(), n[3] = e, n[4] = o, n[5] = s);
let c = (0, G.useSyncExternalStore)(o, s), l;
n[6] !== a || n[7] !== t.image || n[8] !== t.resizable || n[9] !== e ? (l = () => {
if (!a) return;
let n = {
width: t.image.width,
height: t.image.height,
resizable: t.resizable
};
return e.register(n), () => e.unregister(n);
}, n[6] = a, n[7] = t.image, n[8] = t.resizable, n[9] = e, n[10] = l) : l = n[10];
let u;
return n[11] !== a || n[12] !== t || n[13] !== e ? (u = [
e,
t,
a
], n[11] = a, n[12] = t, n[13] = e, n[14] = u) : u = n[14], (0, G.useEffect)(l, u), t.resizable ? c : 1;
}
//#endregion
//#region ../renderer/src/core/typed-array.ts
function n_(e, t) {
let n = e.constructor, r = new n(t);
return r.set(e.subarray(0, t)), r;
}
//#endregion
//#region ../renderer/src/core/SquareDataTexture.ts
var r_ = $c("square-data-texture");
function i_(e, t) {
return Math.max(t, Math.ceil(Math.sqrt(e / t)) * t);
}
function a_(e, t, n, r) {
t === 3 && (r_.warn("\"channels\" cannot be 3. Set to 4. More info: https://github.com/mrdoob/three.js/pull/23228"), t = 4);
let i = i_(r, n), a = new e(i * i * t), o = e.name.includes("Float"), s = e.name.includes("Uint"), c = o ? pt : s ? Tt : Lt, l;
switch (t) {
case 1:
l = o ? ft : Sn;
break;
case 2:
l = o ? rt : at;
break;
default:
l = o ? dt : Ae;
break;
}
return {
array: a,
size: i,
type: c,
format: l
};
}
var o_ = class extends Ut {
get data() {
return this._data;
}
constructor(e, t, n, r, i, a) {
t === 3 && (t = 4);
let { array: o, format: s, size: c, type: l } = a_(e, t, n, r);
super(o, c, c, s, l), this.partialUpdate = !0, this.maxUpdateCalls = Infinity, this._utils = null, this._needsUpdate = !1, this._lastWidth = null, this._data = void 0, this._channels = void 0, this._pixelsPerInstance = void 0, this._stride = void 0, this._rowToUpdate = void 0, this._rowRanges = [], this._uniformMap = void 0, this._fetchUniformsInFragmentShader = void 0, this._data = o, this._channels = t, this._pixelsPerInstance = n, this._stride = n * t, this._rowToUpdate = Array(c), this._uniformMap = i, this._fetchUniformsInFragmentShader = a, this.needsUpdate = !0;
}
resize(e) {
let t = i_(e, this._pixelsPerInstance);
if (t === this.image.width) return;
this._rowToUpdate.length = t;
let n = n_(this._data, t * t * this._channels);
this.dispose(), this.image = {
data: n,
height: t,
width: t
}, this._data = n;
}
enqueueUpdate(e) {
if (this._needsUpdate = !0, !this.partialUpdate) return;
let t = this.image.width / this._pixelsPerInstance, n = Math.floor(e / t);
this._rowToUpdate[n] = !0;
}
update(e) {
let t = e.properties.get(this), n = this.version > 0 && t.__version !== this.version, r = this._lastWidth !== null && this._lastWidth !== this.image.width;
if (!this._needsUpdate || !t.__webglTexture || n || r) {
this._lastWidth = this.image.width, this._needsUpdate = !1;
return;
}
if (this._needsUpdate = !1, !this.partialUpdate) {
this.needsUpdate = !0;
return;
}
let i = this.collectDirtyRanges();
i !== 0 && (i > this.maxUpdateCalls ? this.needsUpdate = !0 : this.updateRows(t.__webglTexture, e, i), this._rowToUpdate.fill(!1));
}
setUniformAt(e, t, n) {
let { offset: r, size: i } = this._uniformMap.get(t), a = this._stride;
i === 1 ? this._data[e * a + r] = n : n.toArray(this._data, e * a + r);
}
getUniformAt(e, t, n) {
let { offset: r, size: i } = this._uniformMap.get(t), a = this._stride;
return i === 1 ? this._data[e * a + r] : n.fromArray(this._data, e * a + r);
}
getUniformsGLSL(e, t) {
return {
vertex: this.getUniformsVertexGLSL(e, t),
fragment: this.getUniformsFragmentGLSL(e, t)
};
}
copy(e) {
super.copy(e), this.partialUpdate = e.partialUpdate, this.maxUpdateCalls = e.maxUpdateCalls, this._channels = e._channels, this._pixelsPerInstance = e._pixelsPerInstance, this._stride = e._stride, this._rowToUpdate = [...e._rowToUpdate], this._uniformMap = e._uniformMap, this._fetchUniformsInFragmentShader = e._fetchUniformsInFragmentShader;
let t = e._data.slice(), { width: n, height: r } = e.image;
return this.source = new tn({
data: t,
width: n,
height: r
}), this._data = t, this.needsUpdate = !0, this;
}
clone() {
let e = this.image.width, t = this.constructor;
return new t(this._data.constructor, this._channels, this._pixelsPerInstance, e * e / this._pixelsPerInstance, this._uniformMap, this._fetchUniformsInFragmentShader).copy(this);
}
collectDirtyRanges() {
let e = this._rowToUpdate, t = this._rowRanges, n = 0;
for (let a = 0, o = e.length; a < o; a++) {
var r, i;
if (!e[a]) continue;
let s = a;
for (; a < o && e[a];) a++;
let c = (i = t[r = n]) == null ? t[r] = {
row: 0,
count: 0
} : i;
c.row = s, c.count = a - s, n++;
}
return n;
}
updateRows(e, t, n) {
var r;
let i = t.state, a = t.getContext();
this._utils != null || (this._utils = new F(a, t.extensions));
let o = this._utils.convert(this.format), s = this._utils.convert(this.type), { data: c, width: l } = this.image, u = this._channels;
i.bindTexture(a.TEXTURE_2D, e);
let d = Ge.getPrimaries(Ge.workingColorSpace), f = this.colorSpace === "" ? null : Ge.getPrimaries(this.colorSpace), p = this.colorSpace === "" || d === f ? a.NONE : a.BROWSER_DEFAULT_WEBGL;
a.pixelStorei(a.UNPACK_FLIP_Y_WEBGL, this.flipY), a.pixelStorei(a.UNPACK_PREMULTIPLY_ALPHA_WEBGL, this.premultiplyAlpha), a.pixelStorei(a.UNPACK_ALIGNMENT, this.unpackAlignment), a.pixelStorei(a.UNPACK_COLORSPACE_CONVERSION_WEBGL, p);
for (let e = 0; e < n; e++) {
let { row: t, count: n } = this._rowRanges[e];
a.texSubImage2D(a.TEXTURE_2D, 0, 0, t, l, n, o, s, c, t * l * u);
}
(r = this.onUpdate) == null || r.call(this, this);
}
getUniformsVertexGLSL(e, t) {
if (this._fetchUniformsInFragmentShader) return {
declarations: `varying float ${s_}${t};`,
body: `${s_}${t} = ${t};`
};
let n = this.texelsFetchGLSL(e, t), r = this.getFromTexelsGLSL(), { assignVarying: i, declareVarying: a } = this.getVarying();
return {
declarations: `
uniform highp sampler2D ${e};
${a}`,
body: `
${n}
${r}
${i}`
};
}
getUniformsFragmentGLSL(e, t) {
if (!this._fetchUniformsInFragmentShader) {
let { declareVarying: e, getVarying: t } = this.getVarying();
return {
declarations: e,
body: t
};
}
let n = this.texelsFetchGLSL(e, `${s_}${t}`), r = this.getFromTexelsGLSL();
return {
declarations: `
uniform highp sampler2D ${e};
varying float ${s_}${t};`,
body: `
${n}
${r}`
};
}
texelsFetchGLSL(e, t) {
let n = this._pixelsPerInstance, r = `
int size = textureSize(${e}, 0).x;
int j = int(${t}) * ${n};
int x = j % size;
int y = j / size;
`;
for (let t = 0; t < n; t++) r += `vec4 ${c_}${t} = texelFetch(${e}, ivec2(x + ${t}, y), 0);\n`;
return r;
}
getFromTexelsGLSL() {
let e = this._uniformMap, t = "";
for (let [n, { type: r, offset: i, size: a }] of e) {
let e = Math.floor(i / this._channels), o = (t = 0) => `${c_}${e + t}`;
if (r === "mat3") t += `mat3 ${n} = mat3(${o()}.rgb, vec3(${o()}.a, ${o(1)}.rg), vec3(${o(1)}.ba, ${o(2)}.r));`;
else if (r === "mat4") t += `mat4 ${n} = mat4(${o()}, ${o(1)}, ${o(2)}, ${o(3)});`;
else {
let e = this.getUniformComponents(i, a);
t += `${r} ${n} = ${o()}.${e};`;
}
t += "\n";
}
return t;
}
getVarying() {
let e = this._uniformMap, t = "", n = "", r = "";
for (let [i, { type: a }] of e) t += `varying ${a} ${s_}${i};\n`, n += `${s_}${i} = ${i};\n`, r += `${a} ${i} = ${s_}${i};\n`;
return {
declareVarying: t,
assignVarying: n,
getVarying: r
};
}
getUniformComponents(e, t) {
let n = e % this._channels, r = "";
for (let e = 0; e < t; e++) r += l_[n + e];
return r;
}
}, s_ = "efp_f", c_ = "efp_texel", l_ = [
"r",
"g",
"b",
"a"
], u_ = class {
constructor() {
this.texture = null, this.declared = {}, this.key = "";
}
get shaderKey() {
return this.key;
}
add(e, t) {
let n = {
...this.declared.vertex,
...e.vertex
}, r = {
...this.declared.fragment,
...e.fragment
}, i = d_({
vertex: n,
fragment: r
}), a = new o_(Float32Array, i.channels, i.pixelsPerInstance, t, i.uniformMap, i.fetchInFragmentShader), o = this.texture;
o && (g_(o, a, h_(this.declared), t), o.dispose()), this.texture = a, this.declared = {
vertex: n,
fragment: r
}, this.key = m_(this.declared);
}
get(e, t, n) {
return this.require().getUniformAt(e, t, n);
}
set(e, t, n) {
let r = this.require();
r.setUniformAt(e, t, n), r.enqueueUpdate(e);
}
resize(e) {
var t;
(t = this.texture) == null || t.resize(e);
}
patchShader(e, t, n = "") {
let r = this.texture;
if (!r) return !1;
let i = r.getUniformsGLSL(v_, t);
return e.uniforms[v_] = { value: r }, e.vertexShader = uh(lh(e.vertexShader, i.vertex.declarations), `${i.vertex.body}\n${n}`), e.fragmentShader = uh(lh(e.fragmentShader, i.fragment.declarations), `${i.fragment.body}\n${n}`), !0;
}
copyFrom(e) {
this.declared = {
vertex: { ...e.declared.vertex },
fragment: { ...e.declared.fragment }
}, this.key = e.key, this.texture = e.texture ? e.texture.clone() : null;
}
dispose() {
var e;
(e = this.texture) == null || e.dispose();
}
require() {
if (!this.texture) throw Error("InstanceUniforms: declare uniforms with \"addUniforms\" before reading or writing them.");
return this.texture;
}
};
function d_(e) {
var t, n;
let r = (t = e.vertex) == null ? {} : t, i = (n = e.fragment) == null ? {} : n, a = [], o = 0, s = !0;
for (let e in r) {
let t = r[e], n = p_(t);
o += n, a.push({
name: e,
type: t,
size: n
}), s = !1;
}
for (let e in i) {
if (r[e]) continue;
let t = i[e], n = p_(t);
o += n, a.push({
name: e,
type: t,
size: n
});
}
a.sort((e, t) => t.size - e.size);
let c = /* @__PURE__ */ new Map(), l = [];
for (let { name: e, size: t, type: n } of a) c.set(e, {
offset: f_(t, l),
size: t,
type: n
});
return {
channels: Math.min(o, 4),
pixelsPerInstance: Math.ceil(o / 4),
uniformMap: c,
fetchInFragmentShader: s
};
}
function f_(e, t) {
if (e < 4) {
for (let n = 0; n < t.length; n++) if (t[n] + e <= 4) {
let r = n * 4 + t[n];
return t[n] += e, r;
}
}
let n = t.length * 4;
for (let n = e; n > 0; n -= 4) t.push(n);
return n;
}
function p_(e) {
switch (e) {
case "float": return 1;
case "vec2": return 2;
case "vec3": return 3;
case "vec4": return 4;
case "mat3": return 9;
case "mat4": return 16;
default: throw Error(`InstanceUniforms: invalid uniform type "${String(e)}".`);
}
}
function m_(e) {
let t = (e, t = {}) => Object.entries(t).map(([t, n]) => `${e}${t}:${n}`);
return [...t("v", e.vertex), ...t("f", e.fragment)].join(",");
}
function h_(e) {
return {
...e.vertex,
...e.fragment
};
}
function g_(e, t, n, r) {
for (let i in n) {
let a = __(n[i]);
for (let n = 0; n < r; n++) t.setUniformAt(n, i, e.getUniformAt(n, i, a));
}
}
function __(e) {
switch (e) {
case "vec2": return new V();
case "vec3": return new U();
case "vec4": return new _n();
case "mat3": return new on();
case "mat4": return new W();
default: return;
}
}
var v_ = "uniformsTexture", y_ = class {
constructor() {
this.list = {
ids: /* @__PURE__ */ new Float32Array(),
count: 0
}, this.frustum = new Xe(), this.cameraPos = new U(), this.forward = new U();
}
performFrustumCulling(e, t, n, r) {
return this.list.ids.length < t.capacity && (this.list.ids = new Float32Array(t.capacity)), this.list.count = 0, t.addedInstancesCount === 0 || this.frustumCulling(e, t, n, r), this.list;
}
frustumCulling(e, t, n, r) {
let i = e.sortObjects, a = e.perObjectFrustumCulled;
if (!a && !i) {
this.updateIndexArray(t);
return;
}
if (i && (w_.copy(e.matrixWorld).invert(), this.cameraPos.setFromMatrixPosition(n.matrixWorld).applyMatrix4(w_), this.forward.set(0, 0, -1).transformDirection(n.matrixWorld).transformDirection(w_)), a ? (C_.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse).multiply(e.matrixWorld), this.frustum.setFromProjectionMatrix(C_), this.linearCulling(e, t, n)) : this.updateRenderList(e, t, n), i) {
let t = e.customSort, n = D_;
t === null ? n.sort(r.transparent ? S_ : x_) : t(n);
let i = this.list.ids, a = n.length;
for (let e = 0; e < a; e++) i[e] = n[e].index;
this.list.count = a, n.length = 0;
}
}
updateIndexArray(e) {
let t = this.list.ids, n = e.addedInstancesCount, r = 0;
for (let i = 0; i < n; i++) e.getVisibleAt(i) && (t[r++] = i);
this.list.count = r;
}
updateRenderList(e, t, n) {
let r = t.addedInstancesCount;
for (let i = 0; i < r; i++) t.getVisibleAt(i) && b_(this.depthOf(this.instanceSphere(e, i, n, E_)), i);
}
linearCulling(e, t, n) {
let r = this.list.ids, i = t.addedInstancesCount, a = e.sortObjects, o = 0;
for (let s = 0; s < i; s++) {
if (!t.getVisibleAt(s)) continue;
let i = this.instanceSphere(e, s, n, E_);
this.frustum.intersectsSphere(i) && (a ? b_(this.depthOf(i), s) : r[o++] = s);
}
a || (this.list.count = o);
}
instanceSphere(e, t, n, r) {
return e.getBoundingSphereAt(t, r);
}
depthOf(e) {
return T_.subVectors(e.center, this.cameraPos).dot(this.forward);
}
};
function b_(e, t) {
var n, r;
let i = (r = O_[n = D_.length]) == null ? O_[n] = {
depth: e,
index: t
} : r;
i.depth = e, i.index = t, D_.push(i);
}
function x_(e, t) {
return e.depth - t.depth;
}
function S_(e, t) {
return t.depth - e.depth;
}
var C_ = new W(), w_ = new W(), T_ = new U(), E_ = new vn(), D_ = [], O_ = [], k_ = "\n uniform highp sampler2D indexTexture;\n\n // The id this draw’s instance holds. A mutable global rather than a local of main, so the\n // fetches below can read it; main assigns it before anything else runs.\n float instanceIndex;\n\n // Resolves a draw to the instance it should read. The culling pass writes the surviving ids into\n // indexTexture in draw order, so gl_InstanceID addresses it directly.\n float getIndirectIndex( int id ) {\n int size = textureSize( indexTexture, 0 ).x;\n return texelFetch( indexTexture, ivec2( id % size, id / size ), 0 ).r;\n }\n\n #ifdef USE_INSTANCING_MATRIX_INDIRECT\n\n uniform highp sampler2D matricesTexture;\n\n mat4 getInstancedMatrix() {\n int size = textureSize( matricesTexture, 0 ).x;\n int j = int( instanceIndex ) * 4;\n int x = j % size;\n int y = j / size;\n vec4 v1 = texelFetch( matricesTexture, ivec2( x, y ), 0 );\n vec4 v2 = texelFetch( matricesTexture, ivec2( x + 1, y ), 0 );\n vec4 v3 = texelFetch( matricesTexture, ivec2( x + 2, y ), 0 );\n vec4 v4 = texelFetch( matricesTexture, ivec2( x + 3, y ), 0 );\n return mat4( v1, v2, v3, v4 );\n }\n\n #else\n\n // No transforms written, so nothing to sample: a mesh placing its instances some other way — a\n // line batch, by two endpoints — allocates no matrices texture at all, and the transform chunks\n // that read this go on compiling.\n mat4 getInstancedMatrix() {\n return mat4( 1.0 );\n }\n\n #endif\n", A_ = "\n instanceIndex = getIndirectIndex( gl_InstanceID );\n mat4 instanceMatrix = getInstancedMatrix();\n", j_ = "\n uniform highp sampler2D colorsTexture;\n\n vec4 getColorTexture() {\n int size = textureSize( colorsTexture, 0 ).x;\n int j = int( instanceIndex );\n int x = j % size;\n int y = j / size;\n return texelFetch( colorsTexture, ivec2( x, y ), 0 );\n }\n", M_ = "\n vColor = vec4( 1.0 );\n\n #ifdef USE_COLOR\n vColor *= color;\n #endif\n\n vColor *= getColorTexture();\n", N_ = !1;
function P_() {
if (N_) return;
N_ = !0;
let e = xe;
e.instanced_color_vertex = M_, e.project_vertex = R_(e.project_vertex), e.worldpos_vertex = R_(e.worldpos_vertex), e.defaultnormal_vertex = R_(e.defaultnormal_vertex);
}
function F_(e, t) {
let n = e.onBeforeCompile, r = e.customProgramCacheKey, i = () => `${!!t.matricesTexture}_${!!t.colorsTexture}_${t.uniforms.shaderKey}`;
return e.customProgramCacheKey = () => `efp_${i()}_${r.call(e)}`, e.onBeforeCompile = (r, i) => {
I_(r, t), n.call(e, r, i);
}, () => {
e.onBeforeCompile = n, e.customProgramCacheKey = r;
};
}
function I_(e, t) {
e.defines = {
...e.defines,
USE_INSTANCING_INDIRECT: ""
}, e.uniforms.indexTexture = { value: t.indexTexture }, t.matricesTexture && (e.defines.USE_INSTANCING_MATRIX_INDIRECT = "", e.uniforms.matricesTexture = { value: t.matricesTexture }), t.uniforms.patchShader(e, "instanceIndex"), e.vertexShader = lh(e.vertexShader, k_), e.vertexShader = uh(e.vertexShader, A_), L_(e, t.colorsTexture);
}
function L_(e, t) {
var n;
let r = e.vertexShader.includes("<color_vertex>") && e.fragmentShader.includes("<color_pars_fragment>");
if (!t || !r) return;
let i = (n = e.defines) == null ? e.defines = {} : n;
i.USE_INSTANCING_COLOR_INDIRECT = "", i.USE_COLOR_ALPHA = "", e.uniforms.colorsTexture = { value: t }, e.vertexShader = lh(e.vertexShader, j_), e.vertexShader = e.vertexShader.replace("<color_vertex>", "<instanced_color_vertex>");
}
function R_(e) {
return e.replace("#ifdef USE_INSTANCING", "#if defined USE_INSTANCING || defined USE_INSTANCING_INDIRECT");
}
//#endregion
//#region ../renderer/src/core/instanced/Instances.ts
var z_ = /*#__PURE__*/ function(e) {
return e[e.Free = 0] = "Free", e[e.Hidden = 1] = "Hidden", e[e.Visible = 2] = "Visible", e;
}(z_ || {}), B_ = class {
constructor(e, t) {
this.instanceStates = void 0, this.freeIds = [], this.onResize = void 0, this._activeInstancesCount = 0, this._addedInstancesCount = 0, this.onResize = t, this.instanceStates = Array(e).fill(z_.Free);
}
get capacity() {
return this.instanceStates.length;
}
get instancesCount() {
return this._activeInstancesCount;
}
get addedInstancesCount() {
return this._addedInstancesCount;
}
addInstances(e, t) {
let n = this.freeIds;
if (n.length > 0) {
let r = -1, i = Math.min(n.length, e), a = n.length - i;
for (let e = n.length - 1; e >= a; e--) {
let i = n[e];
i > r && (r = i), this.addInstance(i, t);
}
n.length -= i, e -= i, this._addedInstancesCount = Math.max(r + 1, this._addedInstancesCount);
}
let r = this._addedInstancesCount, i = r + e;
this.setAddedInstancesCount(i);
for (let e = r; e < i; e++) this.addInstance(e, t);
}
removeInstances(...e) {
let t = this.freeIds;
for (let n of e) n < this._addedInstancesCount && this.getActiveAt(n) && (this.instanceStates[n] = z_.Free, t.push(n), this._activeInstancesCount--);
for (let e = this._addedInstancesCount - 1; e >= 0 && !this.getActiveAt(e); e--) this._addedInstancesCount--;
}
getVisibleAt(e) {
return this.instanceStates[e] === z_.Visible;
}
setVisibleAt(e, t) {
this.instanceStates[e] !== z_.Free && (this.instanceStates[e] = t ? z_.Visible : z_.Hidden);
}
getActiveAt(e) {
return this.instanceStates[e] !== z_.Free;
}
copyFrom(e) {
this._activeInstancesCount = e._activeInstancesCount, this._addedInstancesCount = e._addedInstancesCount, this.instanceStates = e.instanceStates.slice(), this.freeIds.length = 0, this.freeIds.push(...e.freeIds);
}
setAddedInstancesCount(e) {
if (e < this._addedInstancesCount) {
this._addedInstancesCount = e;
return;
}
let t = this.capacity;
if (e > t) {
let n = t + (t >> 1) + 512;
for (; n < e;) n += (n >> 1) + 512;
this.resize(n);
}
this._addedInstancesCount = e;
}
addInstance(e, t) {
this._activeInstancesCount++, this.instanceStates[e] = z_.Visible, t == null || t(e);
}
resize(e) {
let t = this.instanceStates.length;
this.instanceStates.length = e, this.instanceStates.fill(z_.Free, t), this.onResize(e);
}
}, V_ = class {
constructor() {
this.raycastOnlyFrustum = !0;
}
raycast(e, t, n, r, i) {
!e.material || t.addedInstancesCount === 0 || this.intersectsMesh(e, r) && this.raycastInstances(e, t, n, r, i);
}
intersectsMesh(e, t) {
return e.boundingSphere === null && e.computeBoundingSphere(), W_.copy(e.boundingSphere).applyMatrix4(e.matrixWorld), t.ray.intersectsSphere(W_);
}
raycastInstances(e, t, n, r, i) {
let a = this.raycastOnlyFrustum && e.perObjectFrustumCulled && n !== null, o = a ? n.count : t.addedInstancesCount;
for (let s = 0; s < o; s++) this.checkObjectIntersection(e, t, a ? n.ids[s] : s, r, i);
}
prepareInstance(e, t) {
return H_.geometry = e.geometry, H_.material = e.material, H_.matrixWorld.multiplyMatrices(e.matrixWorld, e.getMatrixAt(t, U_)), H_;
}
checkObjectIntersection(e, t, n, r, i) {
if (!t.getVisibleAt(n)) return;
let a = i.length;
this.prepareInstance(e, n).raycast(r, i);
for (let t = a; t < i.length; t++) i[t].object = e, i[t].instanceId = n;
}
}, H_ = new Yt(), U_ = new W(), W_ = new vn();
//#endregion
//#region ../renderer/src/core/instanced/InstancedMesh.ts
P_();
var G_ = class extends Yt {
constructor(e = {}) {
super(), this.count = 0, this.isInstancedMesh = !0, this.instanceMatrix = new Jt(/* @__PURE__ */ new Float32Array(), 16), this.instanceColor = null, this.morphTexture = null, this.customSort = null, this.perObjectFrustumCulled = !0, this.sortObjects = !1, this.boundingBox = null, this.boundingSphere = null, this.raycasting = new V_(), this.culling = new y_(), this.indexTexture = void 0, this.matricesTexture = null, this.colorsTexture = null, this.uniforms = new u_(), this.instances = void 0, this.drawList = null, this._unpatchMaterial = null;
let t = e.capacity && e.capacity > 0 ? e.capacity : q_;
this.instances = new B_(t, (e) => this.resizeCapacity(e)), this.indexTexture = new o_(Float32Array, 1, 1, t);
}
get capacity() {
return this.instances.capacity;
}
get instancesCount() {
return this.instances.instancesCount;
}
addUniforms(e) {
this.uniforms.add(e, this.capacity), this.materialsNeedUpdate();
}
getUniformAt(e, t, n) {
return this.uniforms.get(e, t, n);
}
setUniformAt(e, t, n) {
this.uniforms.set(e, t, n);
}
addInstances(e, t) {
return this.instances.addInstances(e, (e) => {
this.resetInstance(e), t == null || t(e);
}), this;
}
removeInstances(...e) {
return this.instances.removeInstances(...e), this.invalidateBounds(), this;
}
getVisibleAt(e) {
return this.instances.getVisibleAt(e);
}
setVisibleAt(e, t) {
this.instances.setVisibleAt(e, t), this.drawList = null;
}
getMatrixAt(e, t = J_) {
return this.matricesTexture ? t.fromArray(this.matricesTexture.data, e * 16) : t.identity();
}
setMatrixAt(e, t) {
this.matricesTexture || this.initMatricesTexture();
let n = this.matricesTexture;
return t.toArray(n.data, e * 16), n.enqueueUpdate(e), this.invalidateBounds(), this;
}
getColorAt(e, t = Y_) {
if (!this.colorsTexture) return t.setScalar(1);
let n = this.colorsTexture.data;
return t.fromArray(n, e * 4);
}
setColorAt(e, t) {
this.colorsTexture || this.initColorsTexture();
let n = this.colorsTexture.data;
return (typeof t == "object" ? t : Y_.set(t)).toArray(n, e * 4), this.colorsTexture.enqueueUpdate(e), this;
}
computeBoundingBox() {
let e = this.instances.addedInstancesCount;
this.boundingBox != null || (this.boundingBox = new ze()), this.boundingBox.makeEmpty();
for (let t = 0; t < e; t++) this.instances.getActiveAt(t) && this.boundingBox.union(this.getBoundingBoxAt(t, X_));
}
computeBoundingSphere() {
let e = this.instances.addedInstancesCount;
this.boundingSphere != null || (this.boundingSphere = new vn()), this.boundingSphere.makeEmpty();
for (let t = 0; t < e; t++) this.instances.getActiveAt(t) && this.boundingSphere.union(this.getBoundingSphereAt(t, Z_));
}
getBoundingSphereAt(e, t) {
let n = this.geometry;
return n.boundingSphere || n.computeBoundingSphere(), t.copy(n.boundingSphere).applyMatrix4(this.getMatrixAt(e));
}
getBoundingBoxAt(e, t) {
let n = this.geometry;
return n.boundingBox || n.computeBoundingBox(), t.copy(n.boundingBox).applyMatrix4(this.getMatrixAt(e));
}
dispose() {
var e, t;
this.dispatchEvent({ type: "dispose" }), this.indexTexture.dispose(), (e = this.matricesTexture) == null || e.dispose(), (t = this.colorsTexture) == null || t.dispose(), this.uniforms.dispose();
}
resetInstance(e) {
this.matricesTexture && this.setMatrixAt(e, J_.identity());
}
patchMaterial(e) {
return F_(e, {
indexTexture: this.indexTexture,
matricesTexture: this.matricesTexture,
colorsTexture: this.colorsTexture,
uniforms: this.uniforms
});
}
invalidateBounds() {
this.boundingBox = null, this.boundingSphere = null, this.drawList = null;
}
onBeforeRender(e, t, n, r, i, a) {
var o, s, c;
super.onBeforeRender(e, t, n, r, i, a), this._unpatchMaterial = this.patchMaterial(i);
let l = this.culling.performFrustumCulling(this, this.instances, n, i);
this.indexTexture.data.set(l.ids.subarray(0, l.count));
let u = this.indexTexture.image.width;
for (let e = 0; e < l.count; e += u) this.indexTexture.enqueueUpdate(e);
this.drawList = l, this.count = l.count, this.count !== 0 && (this.indexTexture.update(e), (o = this.matricesTexture) == null || o.update(e), (s = this.colorsTexture) == null || s.update(e), (c = this.uniforms.texture) == null || c.update(e));
}
onAfterRender(e, t, n, r, i, a) {
var o;
super.onAfterRender(e, t, n, r, i, a), (o = this._unpatchMaterial) == null || o.call(this), this._unpatchMaterial = null;
}
onBeforeShadow(e, t, n, r, i, a, o) {
this.onBeforeRender(e, t, r, i, a, o);
}
onAfterShadow(e, t, n, r, i, a, o) {
this.onAfterRender(e, t, r, i, a, o), this.drawList = null;
}
clone(e) {
let t = this.constructor;
return new t({ capacity: this.capacity }).copy(this, e);
}
copy(e, t) {
return super.copy(e, t), this.geometry = e.geometry.clone(), this.instances.copyFrom(e.instances), this.drawList = null, this.indexTexture = e.indexTexture.clone(), this.matricesTexture = e.matricesTexture ? e.matricesTexture.clone() : null, this.colorsTexture = e.colorsTexture ? e.colorsTexture.clone() : null, this.uniforms.copyFrom(e.uniforms), e.boundingBox && (this.boundingBox = e.boundingBox.clone()), e.boundingSphere && (this.boundingSphere = e.boundingSphere.clone()), this;
}
raycast(e, t) {
this.raycasting.raycast(this, this.instances, this.drawList, e, t);
}
resizeCapacity(e) {
var t;
if (this.indexTexture.resize(e), (t = this.matricesTexture) == null || t.resize(e), this.colorsTexture) {
let t = this.colorsTexture.data.length;
this.colorsTexture.resize(e), this.colorsTexture.data.fill(1, t);
}
this.uniforms.resize(e);
}
initMatricesTexture() {
this.matricesTexture = new o_(Float32Array, 4, 4, this.capacity);
let e = this.matricesTexture.data;
for (let t = 0; t < e.length; t += 16) e[t] = 1, e[t + 5] = 1, e[t + 10] = 1, e[t + 15] = 1;
this.materialsNeedUpdate();
}
initColorsTexture() {
this.colorsTexture = new o_(Float32Array, 4, 1, this.capacity), this.colorsTexture.colorSpace = Ge.workingColorSpace, this.colorsTexture.data.fill(1), this.materialsNeedUpdate();
}
materialsNeedUpdate() {
let e = this.material;
if (Array.isArray(e)) for (let t of e) t.needsUpdate = !0;
else e.needsUpdate = !0;
}
}, K_ = le(G_), q_ = 1e3, J_ = new W(), Y_ = new gt(), X_ = new ze(), Z_ = new vn(), Q_ = class extends V_ {
prepareInstance(e, t) {
let n = e.getMatrixAt(t, tv), r = Go(e.matrixWorld, 0);
nv.setFromMatrixPosition(n).applyMatrix4(e.matrixWorld), ev.matrixWorld.makeScale(r * Go(n, 0), r * Go(n, 1), 1).setPosition(nv);
let i = n.elements;
$_.rotation = Math.atan2(i[1], i[0]);
let a = e.getAnchorAt(t, rv);
return ev.center.set(a.x + .5, .5 - a.y), ev;
}
}, $_ = new yn(), ev = new Ot($_), tv = new W(), nv = new U(), rv = new V(), iv = "anchorOffset", av = { vertex: { [iv]: "vec2" } };
function ov(e) {
let t = uv.get(e);
if (t) return t;
let n = { value: 0 };
return uv.set(e, n), n;
}
function sv(e) {
let t = e.onBeforeCompile, n = e.customProgramCacheKey;
return e.customProgramCacheKey = () => `efp_sprite_${n.call(e)}`, e.onBeforeCompile = (n, r) => {
n.uniforms[lv] = ov(e), cv(n), t.call(e, n, r);
}, () => {
e.onBeforeCompile = t, e.customProgramCacheKey = n;
};
}
function cv(e) {
let t = e.vertexShader;
return !t.includes("vec2 anchorOffset") || !t.includes(dv) ? !1 : (e.vertexShader = dh(`uniform float ${lv};\n${pv}\n${t}`, dv, fv), !0);
}
var lv = "spriteReferenceDepth", uv = /* @__PURE__ */ new WeakMap(), dv = "#include <project_vertex>", fv = `
vec4 mvPosition = modelViewMatrix * instanceMatrix[ 3 ];
vec3 local = vec3( position.xy - ${iv}, 0.0 );
vec2 offset = ( instanceMatrix * vec4( local, 0.0 ) ).xy;
float planToWorld = length( modelMatrix[ 0 ].xyz );
mvPosition.xy += offset.xy * planToWorld * spriteDepthScale( mvPosition.z );
gl_Position = projectionMatrix * mvPosition;
`, pv = `
float spriteDepthScale( const in float viewZ ) {
bool isPerspective = projectionMatrix[ 2 ][ 3 ] == -1.0;
if ( !isPerspective || ${lv} <= 0.0 ) return 1.0;
return -viewZ / ${lv};
}
`;
//#endregion
//#region ../renderer/src/core/sprites/BatchedSprites.ts
function mv(e) {
return e.isBatchedSprites === !0;
}
var hv = le(class extends G_ {
constructor(e = {}) {
super(e), this.isBatchedSprites = !0, this.geometry = _v, this.raycasting = new Q_(), this.addUniforms(av);
}
getAnchorAt(e, t = vv) {
return this.getUniformAt(e, iv, t);
}
setAnchorAt(e, t, n) {
this.setUniformAt(e, iv, vv.set(t, n)), this.invalidateBounds();
}
getBoundingSphereAt(e, t) {
let n = this.getMatrixAt(e, yv);
return t.center.setFromMatrixPosition(n), t.radius = gv(this.getAnchorAt(e, vv)) * n.getMaxScaleOnAxis(), t;
}
onBeforeRender(e, t, n, r, i, a) {
ov(i).value = Ko(n, this.matrixWorld), super.onBeforeRender(e, t, n, r, i, a);
}
patchMaterial(e) {
let t = sv(e), n = super.patchMaterial(e);
return () => {
n(), t();
};
}
resetInstance(e) {
super.resetInstance(e), this.setAnchorAt(e, 0, 0);
}
});
function gv(e) {
return Math.hypot(.5 + Math.abs(e.x), .5 + Math.abs(e.y));
}
var _v = new Fe(1, 1), vv = new V(), yv = new W();
//#endregion
//#region ../renderer/src/objects/containers/hooks.ts
function bv(e, t, n) {
let r = (0, Z.c)(20), [i] = (0, G.useState)(e), a = hh(), o = Cv(), s = (0, G.useRef)(t), c;
r[0] === t ? c = r[1] : (c = () => {
s.current = t;
}, r[0] = t, r[1] = c), (0, G.useEffect)(c);
let l, u;
r[2] !== a || r[3] !== i || r[4] !== t || r[5] !== o ? (l = () => {
i.setPaintOrder(t, _h(a) > 0), o();
}, u = [
i,
t,
a,
o
], r[2] = a, r[3] = i, r[4] = t, r[5] = o, r[6] = l, r[7] = u) : (l = r[6], u = r[7]), (0, G.useEffect)(l, u);
let d, f;
r[8] !== a || r[9] !== i || r[10] !== o ? (d = () => {
let e = _h(a) > 0;
return vh(a, () => {
let t = _h(a) > 0;
t !== e && (e = t, i.setPaintOrder(s.current, t), o());
});
}, f = [
i,
a,
o
], r[8] = a, r[9] = i, r[10] = o, r[11] = d, r[12] = f) : (d = r[11], f = r[12]), (0, G.useEffect)(d, f);
let p, m;
r[13] === i ? (p = r[14], m = r[15]) : (p = () => nm(i.mesh, i), m = [i], r[13] = i, r[14] = p, r[15] = m), (0, G.useEffect)(p, m);
let h, g;
return r[16] !== i || r[17] !== n ? (h = () => {
if (n) return i.setKindMismatchHandler(n), () => i.setKindMismatchHandler(void 0);
}, g = [i, n], r[16] = i, r[17] = n, r[18] = h, r[19] = g) : (h = r[18], g = r[19]), (0, G.useEffect)(h, g), i;
}
function xv(e, t, n) {
let r = (0, Z.c)(6), i = (0, G.useRef)(-1), a = Cv(), o, s;
return r[0] !== e || r[1] !== t || r[2] !== a || r[3] !== n ? (o = () => {
let r = e.claim(t, n);
return i.current = r, _d(t), a(), () => {
e.release(r), i.current = -1, a();
};
}, s = [
e,
t,
n,
a
], r[0] = e, r[1] = t, r[2] = a, r[3] = n, r[4] = o, r[5] = s) : (o = r[4], s = r[5]), (0, G.useEffect)(o, s), i;
}
function Sv(e, t, n, r) {
let i = (0, Z.c)(21), a = n == null ? wv : n, o = Cv(), s = (0, G.useRef)(Tv), c;
i[0] !== t || i[1] !== o ? (c = (e) => dd(t, () => {
s.current(), o(), e();
}), i[0] = t, i[1] = o, i[2] = c) : c = i[2];
let l = (0, G.useSyncExternalStore)(c, a), u = xv(e, t, l), d;
i[3] !== e || i[4] !== t || i[5] !== a || i[6] !== l || i[7] !== u || i[8] !== r ? (d = function() {
let n = u.current;
if (n < 0 || !Object.is(a(), l)) return;
let i = !t.hidden;
e.setVisibleAt(n, i), e.setDimAt(n, t.dim), i && r(n);
}, i[3] = e, i[4] = t, i[5] = a, i[6] = l, i[7] = u, i[8] = r, i[9] = d) : d = i[9];
let f = d, p;
i[10] === f ? p = i[11] : (p = () => {
s.current = f;
}, i[10] = f, i[11] = p), (0, G.useEffect)(p);
let m, h;
i[12] !== t || i[13] !== o ? (m = () => gd(t, () => s.current(), o), h = [t, o], i[12] = t, i[13] = o, i[14] = m, i[15] = h) : (m = i[14], h = i[15]), (0, G.useEffect)(m, h);
let g;
i[16] === t ? g = i[17] : (g = () => {
_d(t);
}, i[16] = t, i[17] = g);
let _;
i[18] !== t || i[19] !== l ? (_ = [t, l], i[18] = t, i[19] = l, i[20] = _) : _ = i[20], (0, G.useEffect)(g, _);
}
function Cv() {
let e = (0, Z.c)(2), t = R(), n;
e[0] === t ? n = e[1] : (n = () => () => t.getState().invalidate(), e[0] = t, e[1] = n);
let [r] = (0, G.useState)(n);
return r;
}
var wv = () => null, Tv = () => void 0, Ev = /* @__PURE__ */ new WeakMap(), Dv = 0;
function Ov(e) {
let t = Ev.get(e);
return t === void 0 && (t = `def-${Dv++}`, Ev.set(e, t)), t;
}
//#endregion
//#region ../../node_modules/.pnpm/colord@2.9.3/node_modules/colord/index.mjs
var kv = {
grad: .9,
turn: 360,
rad: 360 / (2 * Math.PI)
}, Av = function(e) {
return typeof e == "string" ? e.length > 0 : typeof e == "number";
}, jv = function(e, t, n) {
return t === void 0 && (t = 0), n === void 0 && (n = 10 ** t), Math.round(n * e) / n + 0;
}, Mv = function(e, t, n) {
return t === void 0 && (t = 0), n === void 0 && (n = 1), e > n ? n : e > t ? e : t;
}, Nv = function(e) {
return (e = isFinite(e) ? e % 360 : 0) > 0 ? e : e + 360;
}, Pv = function(e) {
return {
r: Mv(e.r, 0, 255),
g: Mv(e.g, 0, 255),
b: Mv(e.b, 0, 255),
a: Mv(e.a)
};
}, Fv = function(e) {
return {
r: jv(e.r),
g: jv(e.g),
b: jv(e.b),
a: jv(e.a, 3)
};
}, Iv = /^#([0-9a-f]{3,8})$/i, Lv = function(e) {
var t = e.toString(16);
return t.length < 2 ? "0" + t : t;
}, Rv = function(e) {
var t = e.r, n = e.g, r = e.b, i = e.a, a = Math.max(t, n, r), o = a - Math.min(t, n, r), s = o ? a === t ? (n - r) / o : a === n ? 2 + (r - t) / o : 4 + (t - n) / o : 0;
return {
h: 60 * (s < 0 ? s + 6 : s),
s: a ? o / a * 100 : 0,
v: a / 255 * 100,
a: i
};
}, zv = function(e) {
var t = e.h, n = e.s, r = e.v, i = e.a;
t = t / 360 * 6, n /= 100, r /= 100;
var a = Math.floor(t), o = r * (1 - n), s = r * (1 - (t - a) * n), c = r * (1 - (1 - t + a) * n), l = a % 6;
return {
r: 255 * [
r,
s,
o,
o,
c,
r
][l],
g: 255 * [
c,
r,
r,
s,
o,
o
][l],
b: 255 * [
o,
o,
c,
r,
r,
s
][l],
a: i
};
}, Bv = function(e) {
return {
h: Nv(e.h),
s: Mv(e.s, 0, 100),
l: Mv(e.l, 0, 100),
a: Mv(e.a)
};
}, Vv = function(e) {
return {
h: jv(e.h),
s: jv(e.s),
l: jv(e.l),
a: jv(e.a, 3)
};
}, Hv = function(e) {
return zv((n = (t = e).s, {
h: t.h,
s: (n *= ((r = t.l) < 50 ? r : 100 - r) / 100) > 0 ? 2 * n / (r + n) * 100 : 0,
v: r + n,
a: t.a
}));
var t, n, r;
}, Uv = function(e) {
return {
h: (t = Rv(e)).h,
s: (i = (200 - (n = t.s)) * (r = t.v) / 100) > 0 && i < 200 ? n * r / 100 / (i <= 100 ? i : 200 - i) * 100 : 0,
l: i / 2,
a: t.a
};
var t, n, r, i;
}, Wv = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Gv = /^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Kv = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, qv = /^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i, Jv = {
string: [
[function(e) {
var t = Iv.exec(e);
return t ? (e = t[1]).length <= 4 ? {
r: parseInt(e[0] + e[0], 16),
g: parseInt(e[1] + e[1], 16),
b: parseInt(e[2] + e[2], 16),
a: e.length === 4 ? jv(parseInt(e[3] + e[3], 16) / 255, 2) : 1
} : e.length === 6 || e.length === 8 ? {
r: parseInt(e.substr(0, 2), 16),
g: parseInt(e.substr(2, 2), 16),
b: parseInt(e.substr(4, 2), 16),
a: e.length === 8 ? jv(parseInt(e.substr(6, 2), 16) / 255, 2) : 1
} : null : null;
}, "hex"],
[function(e) {
var t = Kv.exec(e) || qv.exec(e);
return t ? t[2] !== t[4] || t[4] !== t[6] ? null : Pv({
r: Number(t[1]) / (t[2] ? 100 / 255 : 1),
g: Number(t[3]) / (t[4] ? 100 / 255 : 1),
b: Number(t[5]) / (t[6] ? 100 / 255 : 1),
a: t[7] === void 0 ? 1 : Number(t[7]) / (t[8] ? 100 : 1)
}) : null;
}, "rgb"],
[function(e) {
var t = Wv.exec(e) || Gv.exec(e);
if (!t) return null;
var n, r;
return Hv(Bv({
h: (n = t[1], r = t[2], r === void 0 && (r = "deg"), Number(n) * (kv[r] || 1)),
s: Number(t[3]),
l: Number(t[4]),
a: t[5] === void 0 ? 1 : Number(t[5]) / (t[6] ? 100 : 1)
}));
}, "hsl"]
],
object: [
[function(e) {
var t = e.r, n = e.g, r = e.b, i = e.a, a = i === void 0 ? 1 : i;
return Av(t) && Av(n) && Av(r) ? Pv({
r: Number(t),
g: Number(n),
b: Number(r),
a: Number(a)
}) : null;
}, "rgb"],
[function(e) {
var t = e.h, n = e.s, r = e.l, i = e.a, a = i === void 0 ? 1 : i;
return !Av(t) || !Av(n) || !Av(r) ? null : Hv(Bv({
h: Number(t),
s: Number(n),
l: Number(r),
a: Number(a)
}));
}, "hsl"],
[function(e) {
var t = e.h, n = e.s, r = e.v, i = e.a, a = i === void 0 ? 1 : i;
return !Av(t) || !Av(n) || !Av(r) ? null : zv(function(e) {
return {
h: Nv(e.h),
s: Mv(e.s, 0, 100),
v: Mv(e.v, 0, 100),
a: Mv(e.a)
};
}({
h: Number(t),
s: Number(n),
v: Number(r),
a: Number(a)
}));
}, "hsv"]
]
}, Yv = function(e, t) {
for (var n = 0; n < t.length; n++) {
var r = t[n][0](e);
if (r) return [r, t[n][1]];
}
return [null, void 0];
}, Xv = function(e) {
return typeof e == "string" ? Yv(e.trim(), Jv.string) : typeof e == "object" && e ? Yv(e, Jv.object) : [null, void 0];
}, Zv = function(e, t) {
var n = Uv(e);
return {
h: n.h,
s: Mv(n.s + 100 * t, 0, 100),
l: n.l,
a: n.a
};
}, Qv = function(e) {
return (299 * e.r + 587 * e.g + 114 * e.b) / 1e3 / 255;
}, $v = function(e, t) {
var n = Uv(e);
return {
h: n.h,
s: n.s,
l: Mv(n.l + 100 * t, 0, 100),
a: n.a
};
}, ey = function() {
function e(e) {
this.parsed = Xv(e)[0], this.rgba = this.parsed || {
r: 0,
g: 0,
b: 0,
a: 1
};
}
return e.prototype.isValid = function() {
return this.parsed !== null;
}, e.prototype.brightness = function() {
return jv(Qv(this.rgba), 2);
}, e.prototype.isDark = function() {
return Qv(this.rgba) < .5;
}, e.prototype.isLight = function() {
return Qv(this.rgba) >= .5;
}, e.prototype.toHex = function() {
return e = Fv(this.rgba), t = e.r, n = e.g, r = e.b, a = (i = e.a) < 1 ? Lv(jv(255 * i)) : "", "#" + Lv(t) + Lv(n) + Lv(r) + a;
var e, t, n, r, i, a;
}, e.prototype.toRgb = function() {
return Fv(this.rgba);
}, e.prototype.toRgbString = function() {
return e = Fv(this.rgba), t = e.r, n = e.g, r = e.b, (i = e.a) < 1 ? "rgba(" + t + ", " + n + ", " + r + ", " + i + ")" : "rgb(" + t + ", " + n + ", " + r + ")";
var e, t, n, r, i;
}, e.prototype.toHsl = function() {
return Vv(Uv(this.rgba));
}, e.prototype.toHslString = function() {
return e = Vv(Uv(this.rgba)), t = e.h, n = e.s, r = e.l, (i = e.a) < 1 ? "hsla(" + t + ", " + n + "%, " + r + "%, " + i + ")" : "hsl(" + t + ", " + n + "%, " + r + "%)";
var e, t, n, r, i;
}, e.prototype.toHsv = function() {
return e = Rv(this.rgba), {
h: jv(e.h),
s: jv(e.s),
v: jv(e.v),
a: jv(e.a, 3)
};
var e;
}, e.prototype.invert = function() {
return ty({
r: 255 - (e = this.rgba).r,
g: 255 - e.g,
b: 255 - e.b,
a: e.a
});
var e;
}, e.prototype.saturate = function(e) {
return e === void 0 && (e = .1), ty(Zv(this.rgba, e));
}, e.prototype.desaturate = function(e) {
return e === void 0 && (e = .1), ty(Zv(this.rgba, -e));
}, e.prototype.grayscale = function() {
return ty(Zv(this.rgba, -1));
}, e.prototype.lighten = function(e) {
return e === void 0 && (e = .1), ty($v(this.rgba, e));
}, e.prototype.darken = function(e) {
return e === void 0 && (e = .1), ty($v(this.rgba, -e));
}, e.prototype.rotate = function(e) {
return e === void 0 && (e = 15), this.hue(this.hue() + e);
}, e.prototype.alpha = function(e) {
return typeof e == "number" ? ty({
r: (t = this.rgba).r,
g: t.g,
b: t.b,
a: e
}) : jv(this.rgba.a, 3);
var t;
}, e.prototype.hue = function(e) {
var t = Uv(this.rgba);
return typeof e == "number" ? ty({
h: e,
s: t.s,
l: t.l,
a: t.a
}) : jv(t.h);
}, e.prototype.isEqual = function(e) {
return this.toHex() === ty(e).toHex();
}, e;
}(), ty = function(e) {
return e instanceof ey ? e : new ey(e);
}, ny = [], ry = function(e) {
e.forEach(function(e) {
ny.indexOf(e) < 0 && (e(ey, Jv), ny.push(e));
});
};
//#endregion
//#region ../../node_modules/.pnpm/colord@2.9.3/node_modules/colord/plugins/names.mjs
function iy(e, t) {
var n = {
white: "#ffffff",
bisque: "#ffe4c4",
blue: "#0000ff",
cadetblue: "#5f9ea0",
chartreuse: "#7fff00",
chocolate: "#d2691e",
coral: "#ff7f50",
antiquewhite: "#faebd7",
aqua: "#00ffff",
azure: "#f0ffff",
whitesmoke: "#f5f5f5",
papayawhip: "#ffefd5",
plum: "#dda0dd",
blanchedalmond: "#ffebcd",
black: "#000000",
gold: "#ffd700",
goldenrod: "#daa520",
gainsboro: "#dcdcdc",
cornsilk: "#fff8dc",
cornflowerblue: "#6495ed",
burlywood: "#deb887",
aquamarine: "#7fffd4",
beige: "#f5f5dc",
crimson: "#dc143c",
cyan: "#00ffff",
darkblue: "#00008b",
darkcyan: "#008b8b",
darkgoldenrod: "#b8860b",
darkkhaki: "#bdb76b",
darkgray: "#a9a9a9",
darkgreen: "#006400",
darkgrey: "#a9a9a9",
peachpuff: "#ffdab9",
darkmagenta: "#8b008b",
darkred: "#8b0000",
darkorchid: "#9932cc",
darkorange: "#ff8c00",
darkslateblue: "#483d8b",
gray: "#808080",
darkslategray: "#2f4f4f",
darkslategrey: "#2f4f4f",
deeppink: "#ff1493",
deepskyblue: "#00bfff",
wheat: "#f5deb3",
firebrick: "#b22222",
floralwhite: "#fffaf0",
ghostwhite: "#f8f8ff",
darkviolet: "#9400d3",
magenta: "#ff00ff",
green: "#008000",
dodgerblue: "#1e90ff",
grey: "#808080",
honeydew: "#f0fff0",
hotpink: "#ff69b4",
blueviolet: "#8a2be2",
forestgreen: "#228b22",
lawngreen: "#7cfc00",
indianred: "#cd5c5c",
indigo: "#4b0082",
fuchsia: "#ff00ff",
brown: "#a52a2a",
maroon: "#800000",
mediumblue: "#0000cd",
lightcoral: "#f08080",
darkturquoise: "#00ced1",
lightcyan: "#e0ffff",
ivory: "#fffff0",
lightyellow: "#ffffe0",
lightsalmon: "#ffa07a",
lightseagreen: "#20b2aa",
linen: "#faf0e6",
mediumaquamarine: "#66cdaa",
lemonchiffon: "#fffacd",
lime: "#00ff00",
khaki: "#f0e68c",
mediumseagreen: "#3cb371",
limegreen: "#32cd32",
mediumspringgreen: "#00fa9a",
lightskyblue: "#87cefa",
lightblue: "#add8e6",
midnightblue: "#191970",
lightpink: "#ffb6c1",
mistyrose: "#ffe4e1",
moccasin: "#ffe4b5",
mintcream: "#f5fffa",
lightslategray: "#778899",
lightslategrey: "#778899",
navajowhite: "#ffdead",
navy: "#000080",
mediumvioletred: "#c71585",
powderblue: "#b0e0e6",
palegoldenrod: "#eee8aa",
oldlace: "#fdf5e6",
paleturquoise: "#afeeee",
mediumturquoise: "#48d1cc",
mediumorchid: "#ba55d3",
rebeccapurple: "#663399",
lightsteelblue: "#b0c4de",
mediumslateblue: "#7b68ee",
thistle: "#d8bfd8",
tan: "#d2b48c",
orchid: "#da70d6",
mediumpurple: "#9370db",
purple: "#800080",
pink: "#ffc0cb",
skyblue: "#87ceeb",
springgreen: "#00ff7f",
palegreen: "#98fb98",
red: "#ff0000",
yellow: "#ffff00",
slateblue: "#6a5acd",
lavenderblush: "#fff0f5",
peru: "#cd853f",
palevioletred: "#db7093",
violet: "#ee82ee",
teal: "#008080",
slategray: "#708090",
slategrey: "#708090",
aliceblue: "#f0f8ff",
darkseagreen: "#8fbc8f",
darkolivegreen: "#556b2f",
greenyellow: "#adff2f",
seagreen: "#2e8b57",
seashell: "#fff5ee",
tomato: "#ff6347",
silver: "#c0c0c0",
sienna: "#a0522d",
lavender: "#e6e6fa",
lightgreen: "#90ee90",
orange: "#ffa500",
orangered: "#ff4500",
steelblue: "#4682b4",
royalblue: "#4169e1",
turquoise: "#40e0d0",
yellowgreen: "#9acd32",
salmon: "#fa8072",
saddlebrown: "#8b4513",
sandybrown: "#f4a460",
rosybrown: "#bc8f8f",
darksalmon: "#e9967a",
lightgoldenrodyellow: "#fafad2",
snow: "#fffafa",
lightgrey: "#d3d3d3",
lightgray: "#d3d3d3",
dimgray: "#696969",
dimgrey: "#696969",
olivedrab: "#6b8e23",
olive: "#808000"
}, r = {};
for (var i in n) r[n[i]] = i;
var a = {};
e.prototype.toName = function(t) {
if (!(this.rgba.a || this.rgba.r || this.rgba.g || this.rgba.b)) return "transparent";
var i, o, s = r[this.toHex()];
if (s) return s;
if (t != null && t.closest) {
var c = this.toRgb(), l = Infinity, u = "black";
if (!a.length) for (var d in n) a[d] = new e(n[d]).toRgb();
for (var f in n) {
var p = (i = c, o = a[f], (i.r - o.r) ** 2 + (i.g - o.g) ** 2 + (i.b - o.b) ** 2);
p < l && (l = p, u = f);
}
return u;
}
}, t.string.push([function(t) {
var r = t.toLowerCase(), i = r === "transparent" ? "#0000" : n[r];
return i ? new e(i).toRgb() : null;
}, "name"]);
}
//#endregion
//#region ../renderer/src/utils/colors.ts
ry([iy]);
function ay(e) {
let t = ty(typeof e == "string" ? e : `#${e.toString(16).padStart(6, "0")}`);
if (t.isValid()) return t.toRgb();
}
function oy(e) {
var t, n;
return ((t = (n = ay(e)) == null ? void 0 : n.a) == null ? 1 : t) < 1;
}
//#endregion
//#region ../renderer/src/objects/containers/mesh-writes.ts
function sy(e) {
if (!yr(e) && !br(e)) return py.makeTranslation(0, 0, "elevation" in e ? e.elevation : 0);
let t = "elevation" in e ? e.elevation : 0, n = "rotation" in e ? e.rotation : 0;
return uy.set(e.center.x, e.center.y, t), dy.setFromAxisAngle(vy, n), fy.set(e.size.x, e.size.y, 1), py.compose(uy, dy, fy);
}
function cy(e, t, n) {
return e.getMatrixAt(t, my), my.equals(n) ? !1 : (e.setMatrixAt(t, n), !0);
}
function ly(e, t, n, r) {
let i = ay(n.color);
return i ? (hy.setRGB(i.r / 255, i.g / 255, i.b / 255, wt), gy.set(hy.r, hy.g, hy.b, i.a), e.getColorAt(t, _y), _y.equals(gy) ? !1 : (e.setColorAt(t, gy), !0)) : (r.warn(`Invalid color: ${String(n.color)} %O`, n), !1);
}
var uy = new U(), dy = new yt(), fy = new U(), py = new W(), my = new W(), hy = new gt(), gy = new _n(), _y = new _n(), vy = new U(0, 0, 1), yy = class {
constructor(e = {}) {
var t;
this.customSort = (e) => {
let t = this.orderBySlot;
e.sort((e, n) => {
var r, i;
return this.sortDirection * (((r = t[e.index]) == null ? 0 : r) - ((i = t[n.index]) == null ? 0 : i));
});
}, this.layerDefs = [], this.layerDimmed = !1, this.dimmedBySlot = [], this.orderByDef = /* @__PURE__ */ new WeakMap(), this.orderBySlot = [], this.slotByDef = /* @__PURE__ */ new Map(), this.defBySlot = /* @__PURE__ */ new Map(), this.schema = void 0, this.sortDirection = void 0, this.boundMesh = void 0, this.kindMismatchHandler = void 0, this.schema = (t = e.schema) == null ? rg : t, this.sortDirection = e.reverse ? -1 : 1;
}
get mesh() {
return this.boundMesh;
}
bind(e) {
!e || this.boundMesh || (this.boundMesh = e, e.addUniforms(this.schema));
}
claim(e, t) {
var n;
let r = this.addInstance(t);
return this.slotByDef.set(e, r), this.defBySlot.set(r, e), this.orderBySlot[r] = (n = this.orderByDef.get(e)) == null ? 0 : n, this.dimmedBySlot[r] = $h(e.dim, this.layerDimmed), r;
}
release(e) {
this.removeInstance(e), this.orderBySlot[e] = 0, this.dimmedBySlot[e] = void 0;
let t = this.defBySlot.get(e);
t && (this.slotByDef.delete(t), this.defBySlot.delete(e));
}
defAt(e) {
return e === void 0 ? void 0 : this.defBySlot.get(e);
}
paintOrderOf(e) {
var t;
return (t = this.orderByDef.get(e)) == null ? 0 : t;
}
setKindMismatchHandler(e) {
this.kindMismatchHandler = e;
}
reportKindMismatch() {
var e;
(e = this.kindMismatchHandler) == null || e.call(this);
}
setVisibleAt(e, t) {
this.mesh.setVisibleAt(e, t);
}
setDimAt(e, t) {
this.writeDim(e, eg(t));
let n = $h(t, this.layerDimmed);
this.layerDefs.length === 0 || this.dimmedBySlot[e] === n || this.applyOrder();
}
writeDim(e, t) {
this.mesh.setUniformAt(e, ng, t);
}
setPaintOrder(e, t) {
this.layerDefs = e, this.layerDimmed = t, this.applyOrder();
}
orderedDefs() {
let e = Qh(this.layerDefs, this.layerDimmed);
for (let t = 0; t < e.length; t++) this.orderByDef.set(e[t], t);
return e;
}
applyOrder() {
let e = this.orderedDefs();
for (let t = 0; t < e.length; t++) {
let n = e[t], r = this.slotOf(n);
r !== void 0 && (this.orderBySlot[r] = t, this.dimmedBySlot[r] = $h(n.dim, this.layerDimmed));
}
}
slotOf(e) {
return this.slotByDef.get(e);
}
};
//#endregion
//#region ../renderer/src/objects/materials/TextureMaterial.tsx
function by(e) {
let t = (0, Z.c)(8), { map: n, uvOffset: r, opacityUniform: i } = e, a = Yh(), o = gh(), s;
t[0] !== a || t[1] !== i || t[2] !== r ? (s = function(e) {
a(e), r && (e.vertexShader = lh(e.vertexShader, xy).replace("#include <uv_vertex>", `
#include <uv_vertex>
vMapUv = uv * ${r}.zw + ${r}.xy;
vMapRegion = ${r};
`.trim()), e.fragmentShader = dh(lh(e.fragmentShader, `${xy}\n${Sy}`), Cy, wy)), i && (e.fragmentShader = e.fragmentShader.replace("#include <colorspace_fragment>", `
#include <colorspace_fragment>
gl_FragColor *= ${i};
`.trim()));
}, t[0] = a, t[1] = i, t[2] = r, t[3] = s) : s = t[3];
let c = s, l = o ? Vg : null, u;
return t[4] !== n || t[5] !== c || t[6] !== l ? (u = /* @__PURE__ */ (0, K.jsx)("meshBasicMaterial", {
...Bg,
...l,
blendSrc: 201,
map: n,
onBeforeCompile: c
}), t[4] = n, t[5] = c, t[6] = l, t[7] = u) : u = t[7], u;
}
var xy = "flat varying vec4 vMapRegion;", Sy = "\nvec4 sampleMapRegion( sampler2D atlas, vec2 uv, vec4 region ) {\n vec2 size = vec2( textureSize( atlas, 0 ) );\n vec2 gradX = dFdx( uv );\n vec2 gradY = dFdy( uv );\n vec2 texelsX = gradX * size;\n vec2 texelsY = gradY * size;\n float level = 0.5 * log2( max( dot( texelsX, texelsX ), dot( texelsY, texelsY ) ) );\n vec2 inset = 0.5 * exp2( ceil( max( level, 0.0 ) ) ) / size;\n // A region narrower than two insets clamps to its middle, because clamp() with a lower bound\n // above its upper bound is undefined in GLSL.\n vec2 middle = region.xy + 0.5 * region.zw;\n vec2 low = min( region.xy + inset, middle );\n vec2 high = max( region.xy + region.zw - inset, middle );\n return textureGrad( atlas, clamp( uv, low, high ), gradX, gradY );\n}\n", Cy = "#include <map_fragment>", wy = "\n#ifdef USE_MAP\n diffuseColor *= sampleMapRegion( map, vMapUv, vMapRegion );\n#endif\n", Ty = class {
constructor(e = 0, t = 0, n = 0, r = 0, i = !1, a = void 0) {
this.oversized = !1, this._rot = !1, this._allowRotation = void 0, this._dirty = 0, this._width = e, this._height = t, this._x = n, this._y = r, this._data = {}, this._rot = i, this._allowRotation = a;
}
static Collide(e, t) {
return e.collide(t);
}
static Contain(e, t) {
return e.contain(t);
}
area() {
return this.width * this.height;
}
collide(e) {
return e.x < this.x + this.width && e.x + e.width > this.x && e.y < this.y + this.height && e.y + e.height > this.y;
}
contain(e) {
return e.x >= this.x && e.y >= this.y && e.x + e.width <= this.x + this.width && e.y + e.height <= this.y + this.height;
}
get width() {
return this._width;
}
set width(e) {
e !== this._width && (this._width = e, this._dirty++);
}
get height() {
return this._height;
}
set height(e) {
e !== this._height && (this._height = e, this._dirty++);
}
get x() {
return this._x;
}
set x(e) {
e !== this._x && (this._x = e, this._dirty++);
}
get y() {
return this._y;
}
set y(e) {
e !== this._y && (this._y = e, this._dirty++);
}
get rot() {
return this._rot;
}
set rot(e) {
if (this._allowRotation !== !1 && this._rot !== e) {
let t = this.width;
this.width = this.height, this.height = t, this._rot = e, this._dirty++;
}
}
get allowRotation() {
return this._allowRotation;
}
set allowRotation(e) {
this._allowRotation !== e && (this._allowRotation = e, this._dirty++);
}
get data() {
return this._data;
}
set data(e) {
e === null || e === this._data || (this._data = e, typeof e == "object" && e.hasOwnProperty("allowRotation") && (this._allowRotation = e.allowRotation), this._dirty++);
}
get dirty() {
return this._dirty > 0;
}
setDirty(e = !0) {
this._dirty = e ? this._dirty + 1 : 0;
}
}, Ey = class {
constructor() {
this._dirty = 0;
}
get dirty() {
return this._dirty > 0 || this.rects.some((e) => e.dirty);
}
setDirty(e = !0) {
if (this._dirty = e ? this._dirty + 1 : 0, !e) for (let e of this.rects) e.setDirty && e.setDirty(!1);
}
}, Dy = class e extends Ey {
constructor(e = ky, t = ky, n = 0, r = {}) {
super(), this.maxWidth = e, this.maxHeight = t, this.padding = n, this.freeRects = [], this.rects = [], this.verticalExpand = !1, this.options = {
smart: !0,
pot: !0,
square: !0,
allowRotation: !1,
tag: !1,
exclusiveTag: !0,
border: 0,
logic: Ay.MAX_EDGE
}, this.options = Object.assign(Object.assign({}, this.options), r), this.width = this.options.smart ? 0 : e, this.height = this.options.smart ? 0 : t, this.border = this.options.border ? this.options.border : 0, this.freeRects.push(new Ty(this.maxWidth + this.padding - this.border * 2, this.maxHeight + this.padding - this.border * 2, this.border, this.border)), this.stage = new Ty(this.width, this.height);
}
add(...e) {
let t, n;
if (e.length === 1) {
if (typeof e[0] != "object") throw Error("MacrectsBin.add(): Wrong parameters");
n = e[0];
let t = n.data && n.data.tag ? n.data.tag : n.tag ? n.tag : void 0;
if (this.options.tag && this.options.exclusiveTag && this.tag !== t) return;
} else {
if (t = e.length > 2 ? e[2] : null, this.options.tag && this.options.exclusiveTag && (t && this.tag !== t.tag || !t && this.tag)) return;
n = new Ty(e[0], e[1]), n.data = t, n.setDirty(!1);
}
let r = this.place(n);
return r && this.rects.push(r), r;
}
repack() {
let e = [];
this.reset(), this.rects.sort((e, t) => {
let n = Math.max(t.width, t.height) - Math.max(e.width, e.height);
return n === 0 && e.hash && t.hash ? e.hash > t.hash ? -1 : 1 : n;
});
for (let t of this.rects) this.place(t) || e.push(t);
for (let t of e) this.rects.splice(this.rects.indexOf(t), 1);
return e.length > 0 ? e : void 0;
}
reset(e = !1, t = !1) {
e && (this.data && delete this.data, this.tag && delete this.tag, this.rects = [], t && (this.options = {
smart: !0,
pot: !0,
square: !0,
allowRotation: !1,
tag: !1,
border: 0
})), this.width = this.options.smart ? 0 : this.maxWidth, this.height = this.options.smart ? 0 : this.maxHeight, this.border = this.options.border ? this.options.border : 0, this.freeRects = [new Ty(this.maxWidth + this.padding - this.border * 2, this.maxHeight + this.padding - this.border * 2, this.border, this.border)], this.stage = new Ty(this.width, this.height), this._dirty = 0;
}
clone() {
let t = new e(this.maxWidth, this.maxHeight, this.padding, this.options);
for (let e of this.rects) t.add(e);
return t;
}
place(e) {
let t = e.data && e.data.tag ? e.data.tag : e.tag ? e.tag : void 0;
if (this.options.tag && this.options.exclusiveTag && this.tag !== t) return;
let n, r;
if (r = e.hasOwnProperty("_allowRotation") && e.allowRotation !== void 0 ? e.allowRotation : this.options.allowRotation, n = this.findNode(e.width + this.padding, e.height + this.padding, r), n) {
this.updateBinSize(n);
let t = this.freeRects.length, r = 0;
for (; r < t;) this.splitNode(this.freeRects[r], n) && (this.freeRects.splice(r, 1), t--, r--), r++;
return this.pruneFreeList(), this.verticalExpand = this.width > this.height, e.x = n.x, e.y = n.y, e.rot === void 0 && (e.rot = !1), e.rot = n.rot ? !e.rot : e.rot, this._dirty++, e;
} else if (!this.verticalExpand) {
if (this.updateBinSize(new Ty(e.width + this.padding, e.height + this.padding, this.width + this.padding - this.border, this.border)) || this.updateBinSize(new Ty(e.width + this.padding, e.height + this.padding, this.border, this.height + this.padding - this.border))) return this.place(e);
} else if (this.updateBinSize(new Ty(e.width + this.padding, e.height + this.padding, this.border, this.height + this.padding - this.border)) || this.updateBinSize(new Ty(e.width + this.padding, e.height + this.padding, this.width + this.padding - this.border, this.border))) return this.place(e);
}
findNode(e, t, n) {
let r = Number.MAX_VALUE, i, a, o;
for (let s in this.freeRects) a = this.freeRects[s], a.width >= e && a.height >= t && (i = this.options.logic === Ay.MAX_AREA ? a.width * a.height - e * t : Math.min(a.width - e, a.height - t), i < r && (o = new Ty(e, t, a.x, a.y), r = i)), n && a.width >= t && a.height >= e && (i = this.options.logic === Ay.MAX_AREA ? a.width * a.height - t * e : Math.min(a.height - e, a.width - t), i < r && (o = new Ty(t, e, a.x, a.y, !0), r = i));
return o;
}
splitNode(e, t) {
if (!e.collide(t)) return !1;
if (t.x < e.x + e.width && t.x + t.width > e.x) {
if (t.y > e.y && t.y < e.y + e.height) {
let n = new Ty(e.width, t.y - e.y, e.x, e.y);
this.freeRects.push(n);
}
if (t.y + t.height < e.y + e.height) {
let n = new Ty(e.width, e.y + e.height - (t.y + t.height), e.x, t.y + t.height);
this.freeRects.push(n);
}
}
if (t.y < e.y + e.height && t.y + t.height > e.y) {
if (t.x > e.x && t.x < e.x + e.width) {
let n = new Ty(t.x - e.x, e.height, e.x, e.y);
this.freeRects.push(n);
}
if (t.x + t.width < e.x + e.width) {
let n = new Ty(e.x + e.width - (t.x + t.width), e.height, t.x + t.width, e.y);
this.freeRects.push(n);
}
}
return !0;
}
pruneFreeList() {
let e = 0, t = 0, n = this.freeRects.length;
for (; e < n;) {
t = e + 1;
let r = this.freeRects[e];
for (; t < n;) {
let i = this.freeRects[t];
if (i.contain(r)) {
this.freeRects.splice(e, 1), e--, n--;
break;
}
r.contain(i) && (this.freeRects.splice(t, 1), t--, n--), t++;
}
e++;
}
}
updateBinSize(e) {
if (!this.options.smart || this.stage.contain(e)) return !1;
let t = Math.max(this.width, e.x + e.width - this.padding + this.border), n = Math.max(this.height, e.y + e.height - this.padding + this.border);
if (this.options.allowRotation) {
let r = Math.max(this.width, e.x + e.height - this.padding + this.border), i = Math.max(this.height, e.y + e.width - this.padding + this.border);
r * i < t * n && (t = r, n = i);
}
return this.options.pot && (t = 2 ** Math.ceil(Math.log(t) * Math.LOG2E), n = 2 ** Math.ceil(Math.log(n) * Math.LOG2E)), this.options.square && (t = n = Math.max(t, n)), t > this.maxWidth + this.padding || n > this.maxHeight + this.padding ? !1 : (this.expandFreeRects(t + this.padding, n + this.padding), this.width = this.stage.width = t, this.height = this.stage.height = n, !0);
}
expandFreeRects(e, t) {
this.freeRects.forEach((n, r) => {
n.x + n.width >= Math.min(this.width + this.padding - this.border, e) && (n.width = e - n.x - this.border), n.y + n.height >= Math.min(this.height + this.padding - this.border, t) && (n.height = t - n.y - this.border);
}, this), this.freeRects.push(new Ty(e - this.width - this.padding, t - this.border * 2, this.width + this.padding - this.border, this.border)), this.freeRects.push(new Ty(e - this.border * 2, t - this.height - this.padding, this.border, this.height + this.padding - this.border)), this.freeRects = this.freeRects.filter((e) => !(e.width <= 0 || e.height <= 0 || e.x < this.border || e.y < this.border)), this.pruneFreeList();
}
}, Oy = class e extends Ey {
constructor(...e) {
if (super(), this.rects = [], e.length === 1) {
if (typeof e[0] != "object") throw Error("OversizedElementBin: Wrong parameters");
let t = e[0];
this.rects = [t], this.width = t.width, this.height = t.height, this.data = t.data, t.oversized = !0;
} else {
this.width = e[0], this.height = e[1], this.data = e.length > 2 ? e[2] : null;
let t = new Ty(this.width, this.height);
t.oversized = !0, t.data = this.data, this.rects.push(t);
}
this.freeRects = [], this.maxWidth = this.width, this.maxHeight = this.height, this.options = {
smart: !1,
pot: !1,
square: !1
};
}
add() {}
reset(e = !1) {}
repack() {}
clone() {
return new e(this.rects[0]);
}
}, ky = 4096, Ay;
(function(e) {
e[e.MAX_AREA = 0] = "MAX_AREA", e[e.MAX_EDGE = 1] = "MAX_EDGE";
})(Ay || (Ay = {}));
var jy = class {
constructor(e = ky, t = ky, n = 0, r = {}) {
this.width = e, this.height = t, this.padding = n, this.options = {
smart: !0,
pot: !0,
square: !1,
allowRotation: !1,
tag: !1,
exclusiveTag: !0,
border: 0,
logic: Ay.MAX_EDGE
}, this._currentBinIndex = 0, this.bins = [], this.options = Object.assign(Object.assign({}, this.options), r);
}
add(...e) {
if (e.length === 1) {
if (typeof e[0] != "object") throw Error("MacrectsPacker.add(): Wrong parameters");
let t = e[0];
if (t.width > this.width || t.height > this.height) this.bins.push(new Oy(t));
else if (!this.bins.slice(this._currentBinIndex).find((e) => e.add(t) !== void 0)) {
let e = new Dy(this.width, this.height, this.padding, this.options), n = t.data && t.data.tag ? t.data.tag : t.tag ? t.tag : void 0;
this.options.tag && n && (e.tag = n), e.add(t), this.bins.push(e);
}
return t;
} else {
let t = new Ty(e[0], e[1]);
if (e.length > 2 && (t.data = e[2]), t.width > this.width || t.height > this.height) this.bins.push(new Oy(t));
else if (!this.bins.slice(this._currentBinIndex).find((e) => e.add(t) !== void 0)) {
let e = new Dy(this.width, this.height, this.padding, this.options);
this.options.tag && t.data.tag && (e.tag = t.data.tag), e.add(t), this.bins.push(e);
}
return t;
}
}
addArray(e) {
if (!this.options.tag || this.options.exclusiveTag) this.sort(e, this.options.logic).forEach((e) => this.add(e));
else {
if (e.length === 0) return;
e.sort((e, t) => {
let n = e.data && e.data.tag ? e.data.tag : e.tag ? e.tag : void 0, r = t.data && t.data.tag ? t.data.tag : t.tag ? t.tag : void 0;
return r === void 0 ? -1 : n === void 0 ? 1 : r > n ? -1 : 1;
});
let t, n = 0;
if (!this.bins.slice(this._currentBinIndex).find((r, i) => {
let a = r.clone();
for (let i = n; i < e.length; i++) {
let o = e[i], s = o.data && o.data.tag ? o.data.tag : o.tag ? o.tag : void 0;
if (i === 0 && (t = s), s !== t) return t = s, this.sort(e.slice(n, i), this.options.logic).forEach((e) => r.add(e)), n = i, this.addArray(e.slice(i)), !0;
if (s === void 0) return this.sort(e.slice(i), this.options.logic).forEach((e) => this.add(e)), n = e.length, !0;
if (a.add(o) === void 0) return this.sort(e.slice(n, i), this.options.logic).forEach((e) => r.add(e)), n = i, !1;
}
return this.sort(e.slice(n), this.options.logic).forEach((e) => r.add(e)), !0;
})) {
let t = e[n], r = new Dy(this.width, this.height, this.padding, this.options), i = t.data && t.data.tag ? t.data.tag : t.tag ? t.tag : void 0;
this.options.tag && this.options.exclusiveTag && i && (r.tag = i), this.bins.push(r), r.add(t), n++, this.addArray(e.slice(n));
}
}
}
reset() {
this.bins = [], this._currentBinIndex = 0;
}
repack(e = !0) {
if (e) {
let e = [];
for (let t of this.bins) if (t.dirty) {
let n = t.repack();
n && e.push(...n);
}
this.addArray(e);
return;
}
if (!this.dirty) return;
let t = this.rects;
this.reset(), this.addArray(t);
}
next() {
return this._currentBinIndex = this.bins.length, this._currentBinIndex;
}
load(e) {
e.forEach((e, t) => {
if (e.maxWidth > this.width || e.maxHeight > this.height) this.bins.push(new Oy(e.width, e.height, {}));
else {
let n = new Dy(this.width, this.height, this.padding, e.options);
n.freeRects.splice(0), e.freeRects.forEach((e, t) => {
n.freeRects.push(new Ty(e.width, e.height, e.x, e.y));
}), n.width = e.width, n.height = e.height, e.tag && (n.tag = e.tag), this.bins[t] = n;
}
}, this);
}
save() {
let e = [];
return this.bins.forEach(((t) => {
let n = {
width: t.width,
height: t.height,
maxWidth: t.maxWidth,
maxHeight: t.maxHeight,
freeRects: [],
rects: [],
options: t.options
};
t.tag && (n = Object.assign(Object.assign({}, n), { tag: t.tag })), t.freeRects.forEach((e) => {
n.freeRects.push({
x: e.x,
y: e.y,
width: e.width,
height: e.height
});
}), e.push(n);
})), e;
}
sort(e, t = Ay.MAX_EDGE) {
return e.slice().sort((e, n) => {
let r = t === Ay.MAX_EDGE ? Math.max(n.width, n.height) - Math.max(e.width, e.height) : n.width * n.height - e.width * e.height;
return r === 0 && e.hash && n.hash ? e.hash > n.hash ? -1 : 1 : r;
});
}
get currentBinIndex() {
return this._currentBinIndex;
}
get dirty() {
return this.bins.some((e) => e.dirty);
}
get rects() {
let e = [];
for (let t of this.bins) e.push(...t.rects);
return e;
}
};
//#endregion
//#region ../renderer/src/objects/images/pack-sources.ts
function My(e) {
return typeof e.slice == "function";
}
function Ny(e) {
return !("getContext" in e);
}
function Py(e, t) {
if (typeof OffscreenCanvas < "u") return new OffscreenCanvas(e, t);
let n = document.createElement("canvas");
return n.width = e, n.height = t, n;
}
function Fy(e, t, n = Py) {
let r = Math.max(1, Math.floor(t)), i = e.map((e) => e ? {
width: e.width,
height: e.height,
tiles: 0
} : {
width: 0,
height: 0,
tiles: 0
}), a = [], o = [];
for (let t = 0; t < e.length; t++) {
let n = e[t];
(!n || Ny(n) ? a : o).push(t);
}
let s = new jy(r, r, Iy, { pot: !1 });
return {
atlases: [...Ly(s, e, a, i, r, n, !0), ...Ly(s, e, o, i, r, n, !1)],
reports: i
};
}
var Iy = 16;
function Ly(e, t, n, r, i, a, o) {
let s = [];
for (let e of n) {
let { width: t, height: n } = r[e];
t <= 0 || n <= 0 || s.push({
width: t,
height: n,
x: 0,
y: 0,
hash: `${e}`,
data: { index: e }
});
}
e.reset(), e.addArray(s);
let c = s.filter((e) => e.oversized);
c.length > 0 && e.addArray(c.flatMap((e) => Ry(e, r[e.data.index], i)));
let l = e.bins.filter((e) => !e.rects.some((e) => e.oversized)), u = l.map((e) => ({
...zy(e, t, r, a),
resizable: o
}));
for (let e of l) for (let t of e.rects) r[t.data.index].tiles++;
return u;
}
function Ry(e, t, n) {
let r = Math.ceil(t.width / n), i = Math.ceil(t.height / n), a = [];
for (let o = 0; o < i; o++) {
let i = o * n, s = Math.min(n, t.height - i);
for (let c = 0; c < r; c++) {
let r = c * n, l = Math.min(n, t.width - r);
a.push({
width: l,
height: s,
x: 0,
y: 0,
hash: `${e.hash}:${c},${o}`,
data: {
index: e.data.index,
source: {
x: r,
y: i,
width: l,
height: s
}
}
});
}
}
return a;
}
function zy(e, t, n, r) {
let i = r(e.width, e.height), a = By(i);
if (!a) throw Error(`pack-sources: no 2d context for a ${e.width}x${e.height} atlas`);
let o = [];
for (let r of e.rects) {
let { index: i, source: s } = r.data, { width: c, height: l } = n[i], u = s == null ? {
x: 0,
y: 0,
width: c,
height: l
} : s, d = t[i];
if (!d) continue;
a.drawImage(d, u.x, u.y, u.width, u.height, r.x, r.y, r.width, r.height);
let f = {
u0: r.x / e.width,
v0: r.y / e.height,
u1: (r.x + r.width) / e.width,
v1: (r.y + r.height) / e.height
};
o.push(s ? {
index: i,
uv: f,
source: s
} : {
index: i,
uv: f
});
}
return {
canvas: i,
placements: o
};
}
function By(e) {
return "convertToBlob" in e, e.getContext("2d");
}
//#endregion
//#region ../renderer/src/objects/images/worker/atlas-worker.ts?worker&inline
var Vy = "(function(){var e=class{constructor(e=0,t=0,n=0,r=0,i=!1,a=void 0){this.oversized=!1,this._rot=!1,this._allowRotation=void 0,this._dirty=0,this._width=e,this._height=t,this._x=n,this._y=r,this._data={},this._rot=i,this._allowRotation=a}static Collide(e,t){return e.collide(t)}static Contain(e,t){return e.contain(t)}area(){return this.width*this.height}collide(e){return e.x<this.x+this.width&&e.x+e.width>this.x&&e.y<this.y+this.height&&e.y+e.height>this.y}contain(e){return e.x>=this.x&&e.y>=this.y&&e.x+e.width<=this.x+this.width&&e.y+e.height<=this.y+this.height}get width(){return this._width}set width(e){e!==this._width&&(this._width=e,this._dirty++)}get height(){return this._height}set height(e){e!==this._height&&(this._height=e,this._dirty++)}get x(){return this._x}set x(e){e!==this._x&&(this._x=e,this._dirty++)}get y(){return this._y}set y(e){e!==this._y&&(this._y=e,this._dirty++)}get rot(){return this._rot}set rot(e){if(this._allowRotation!==!1&&this._rot!==e){let t=this.width;this.width=this.height,this.height=t,this._rot=e,this._dirty++}}get allowRotation(){return this._allowRotation}set allowRotation(e){this._allowRotation!==e&&(this._allowRotation=e,this._dirty++)}get data(){return this._data}set data(e){e===null||e===this._data||(this._data=e,typeof e==`object`&&e.hasOwnProperty(`allowRotation`)&&(this._allowRotation=e.allowRotation),this._dirty++)}get dirty(){return this._dirty>0}setDirty(e=!0){this._dirty=e?this._dirty+1:0}},t=class{constructor(){this._dirty=0}get dirty(){return this._dirty>0||this.rects.some(e=>e.dirty)}setDirty(e=!0){if(this._dirty=e?this._dirty+1:0,!e)for(let e of this.rects)e.setDirty&&e.setDirty(!1)}},n=class n extends t{constructor(t=i,n=i,r=0,o={}){super(),this.maxWidth=t,this.maxHeight=n,this.padding=r,this.freeRects=[],this.rects=[],this.verticalExpand=!1,this.options={smart:!0,pot:!0,square:!0,allowRotation:!1,tag:!1,exclusiveTag:!0,border:0,logic:a.MAX_EDGE},this.options=Object.assign(Object.assign({},this.options),o),this.width=this.options.smart?0:t,this.height=this.options.smart?0:n,this.border=this.options.border?this.options.border:0,this.freeRects.push(new e(this.maxWidth+this.padding-this.border*2,this.maxHeight+this.padding-this.border*2,this.border,this.border)),this.stage=new e(this.width,this.height)}add(...t){let n,r;if(t.length===1){if(typeof t[0]!=`object`)throw Error(`MacrectsBin.add(): Wrong parameters`);r=t[0];let e=r.data&&r.data.tag?r.data.tag:r.tag?r.tag:void 0;if(this.options.tag&&this.options.exclusiveTag&&this.tag!==e)return}else{if(n=t.length>2?t[2]:null,this.options.tag&&this.options.exclusiveTag&&(n&&this.tag!==n.tag||!n&&this.tag))return;r=new e(t[0],t[1]),r.data=n,r.setDirty(!1)}let i=this.place(r);return i&&this.rects.push(i),i}repack(){let e=[];this.reset(),this.rects.sort((e,t)=>{let n=Math.max(t.width,t.height)-Math.max(e.width,e.height);return n===0&&e.hash&&t.hash?e.hash>t.hash?-1:1:n});for(let t of this.rects)this.place(t)||e.push(t);for(let t of e)this.rects.splice(this.rects.indexOf(t),1);return e.length>0?e:void 0}reset(t=!1,n=!1){t&&(this.data&&delete this.data,this.tag&&delete this.tag,this.rects=[],n&&(this.options={smart:!0,pot:!0,square:!0,allowRotation:!1,tag:!1,border:0})),this.width=this.options.smart?0:this.maxWidth,this.height=this.options.smart?0:this.maxHeight,this.border=this.options.border?this.options.border:0,this.freeRects=[new e(this.maxWidth+this.padding-this.border*2,this.maxHeight+this.padding-this.border*2,this.border,this.border)],this.stage=new e(this.width,this.height),this._dirty=0}clone(){let e=new n(this.maxWidth,this.maxHeight,this.padding,this.options);for(let t of this.rects)e.add(t);return e}place(t){let n=t.data&&t.data.tag?t.data.tag:t.tag?t.tag:void 0;if(this.options.tag&&this.options.exclusiveTag&&this.tag!==n)return;let r,i;if(i=t.hasOwnProperty(`_allowRotation`)&&t.allowRotation!==void 0?t.allowRotation:this.options.allowRotation,r=this.findNode(t.width+this.padding,t.height+this.padding,i),r){this.updateBinSize(r);let e=this.freeRects.length,n=0;for(;n<e;)this.splitNode(this.freeRects[n],r)&&(this.freeRects.splice(n,1),e--,n--),n++;return this.pruneFreeList(),this.verticalExpand=this.width>this.height,t.x=r.x,t.y=r.y,t.rot===void 0&&(t.rot=!1),t.rot=r.rot?!t.rot:t.rot,this._dirty++,t}else if(!this.verticalExpand){if(this.updateBinSize(new e(t.width+this.padding,t.height+this.padding,this.width+this.padding-this.border,this.border))||this.updateBinSize(new e(t.width+this.padding,t.height+this.padding,this.border,this.height+this.padding-this.border)))return this.place(t)}else if(this.updateBinSize(new e(t.width+this.padding,t.height+this.padding,this.border,this.height+this.padding-this.border))||this.updateBinSize(new e(t.width+this.padding,t.height+this.padding,this.width+this.padding-this.border,this.border)))return this.place(t)}findNode(t,n,r){let i=Number.MAX_VALUE,o,s,c;for(let l in this.freeRects)s=this.freeRects[l],s.width>=t&&s.height>=n&&(o=this.options.logic===a.MAX_AREA?s.width*s.height-t*n:Math.min(s.width-t,s.height-n),o<i&&(c=new e(t,n,s.x,s.y),i=o)),r&&s.width>=n&&s.height>=t&&(o=this.options.logic===a.MAX_AREA?s.width*s.height-n*t:Math.min(s.height-t,s.width-n),o<i&&(c=new e(n,t,s.x,s.y,!0),i=o));return c}splitNode(t,n){if(!t.collide(n))return!1;if(n.x<t.x+t.width&&n.x+n.width>t.x){if(n.y>t.y&&n.y<t.y+t.height){let r=new e(t.width,n.y-t.y,t.x,t.y);this.freeRects.push(r)}if(n.y+n.height<t.y+t.height){let r=new e(t.width,t.y+t.height-(n.y+n.height),t.x,n.y+n.height);this.freeRects.push(r)}}if(n.y<t.y+t.height&&n.y+n.height>t.y){if(n.x>t.x&&n.x<t.x+t.width){let r=new e(n.x-t.x,t.height,t.x,t.y);this.freeRects.push(r)}if(n.x+n.width<t.x+t.width){let r=new e(t.x+t.width-(n.x+n.width),t.height,n.x+n.width,t.y);this.freeRects.push(r)}}return!0}pruneFreeList(){let e=0,t=0,n=this.freeRects.length;for(;e<n;){t=e+1;let r=this.freeRects[e];for(;t<n;){let i=this.freeRects[t];if(i.contain(r)){this.freeRects.splice(e,1),e--,n--;break}r.contain(i)&&(this.freeRects.splice(t,1),t--,n--),t++}e++}}updateBinSize(e){if(!this.options.smart||this.stage.contain(e))return!1;let t=Math.max(this.width,e.x+e.width-this.padding+this.border),n=Math.max(this.height,e.y+e.height-this.padding+this.border);if(this.options.allowRotation){let r=Math.max(this.width,e.x+e.height-this.padding+this.border),i=Math.max(this.height,e.y+e.width-this.padding+this.border);r*i<t*n&&(t=r,n=i)}return this.options.pot&&(t=2**Math.ceil(Math.log(t)*Math.LOG2E),n=2**Math.ceil(Math.log(n)*Math.LOG2E)),this.options.square&&(t=n=Math.max(t,n)),t>this.maxWidth+this.padding||n>this.maxHeight+this.padding?!1:(this.expandFreeRects(t+this.padding,n+this.padding),this.width=this.stage.width=t,this.height=this.stage.height=n,!0)}expandFreeRects(t,n){this.freeRects.forEach((e,r)=>{e.x+e.width>=Math.min(this.width+this.padding-this.border,t)&&(e.width=t-e.x-this.border),e.y+e.height>=Math.min(this.height+this.padding-this.border,n)&&(e.height=n-e.y-this.border)},this),this.freeRects.push(new e(t-this.width-this.padding,n-this.border*2,this.width+this.padding-this.border,this.border)),this.freeRects.push(new e(t-this.border*2,n-this.height-this.padding,this.border,this.height+this.padding-this.border)),this.freeRects=this.freeRects.filter(e=>!(e.width<=0||e.height<=0||e.x<this.border||e.y<this.border)),this.pruneFreeList()}},r=class n extends t{constructor(...t){if(super(),this.rects=[],t.length===1){if(typeof t[0]!=`object`)throw Error(`OversizedElementBin: Wrong parameters`);let e=t[0];this.rects=[e],this.width=e.width,this.height=e.height,this.data=e.data,e.oversized=!0}else{this.width=t[0],this.height=t[1],this.data=t.length>2?t[2]:null;let n=new e(this.width,this.height);n.oversized=!0,n.data=this.data,this.rects.push(n)}this.freeRects=[],this.maxWidth=this.width,this.maxHeight=this.height,this.options={smart:!1,pot:!1,square:!1}}add(){}reset(e=!1){}repack(){}clone(){return new n(this.rects[0])}};let i=4096;var a;(function(e){e[e.MAX_AREA=0]=`MAX_AREA`,e[e.MAX_EDGE=1]=`MAX_EDGE`})(a||(a={}));var o=class{constructor(e=i,t=i,n=0,r={}){this.width=e,this.height=t,this.padding=n,this.options={smart:!0,pot:!0,square:!1,allowRotation:!1,tag:!1,exclusiveTag:!0,border:0,logic:a.MAX_EDGE},this._currentBinIndex=0,this.bins=[],this.options=Object.assign(Object.assign({},this.options),r)}add(...t){if(t.length===1){if(typeof t[0]!=`object`)throw Error(`MacrectsPacker.add(): Wrong parameters`);let e=t[0];if(e.width>this.width||e.height>this.height)this.bins.push(new r(e));else if(!this.bins.slice(this._currentBinIndex).find(t=>t.add(e)!==void 0)){let t=new n(this.width,this.height,this.padding,this.options),r=e.data&&e.data.tag?e.data.tag:e.tag?e.tag:void 0;this.options.tag&&r&&(t.tag=r),t.add(e),this.bins.push(t)}return e}else{let i=new e(t[0],t[1]);if(t.length>2&&(i.data=t[2]),i.width>this.width||i.height>this.height)this.bins.push(new r(i));else if(!this.bins.slice(this._currentBinIndex).find(e=>e.add(i)!==void 0)){let e=new n(this.width,this.height,this.padding,this.options);this.options.tag&&i.data.tag&&(e.tag=i.data.tag),e.add(i),this.bins.push(e)}return i}}addArray(e){if(!this.options.tag||this.options.exclusiveTag)this.sort(e,this.options.logic).forEach(e=>this.add(e));else{if(e.length===0)return;e.sort((e,t)=>{let n=e.data&&e.data.tag?e.data.tag:e.tag?e.tag:void 0,r=t.data&&t.data.tag?t.data.tag:t.tag?t.tag:void 0;return r===void 0?-1:n===void 0?1:r>n?-1:1});let t,r=0;if(!this.bins.slice(this._currentBinIndex).find((n,i)=>{let a=n.clone();for(let i=r;i<e.length;i++){let o=e[i],s=o.data&&o.data.tag?o.data.tag:o.tag?o.tag:void 0;if(i===0&&(t=s),s!==t)return t=s,this.sort(e.slice(r,i),this.options.logic).forEach(e=>n.add(e)),r=i,this.addArray(e.slice(i)),!0;if(s===void 0)return this.sort(e.slice(i),this.options.logic).forEach(e=>this.add(e)),r=e.length,!0;if(a.add(o)===void 0)return this.sort(e.slice(r,i),this.options.logic).forEach(e=>n.add(e)),r=i,!1}return this.sort(e.slice(r),this.options.logic).forEach(e=>n.add(e)),!0})){let t=e[r],i=new n(this.width,this.height,this.padding,this.options),a=t.data&&t.data.tag?t.data.tag:t.tag?t.tag:void 0;this.options.tag&&this.options.exclusiveTag&&a&&(i.tag=a),this.bins.push(i),i.add(t),r++,this.addArray(e.slice(r))}}}reset(){this.bins=[],this._currentBinIndex=0}repack(e=!0){if(e){let e=[];for(let t of this.bins)if(t.dirty){let n=t.repack();n&&e.push(...n)}this.addArray(e);return}if(!this.dirty)return;let t=this.rects;this.reset(),this.addArray(t)}next(){return this._currentBinIndex=this.bins.length,this._currentBinIndex}load(t){t.forEach((t,i)=>{if(t.maxWidth>this.width||t.maxHeight>this.height)this.bins.push(new r(t.width,t.height,{}));else{let r=new n(this.width,this.height,this.padding,t.options);r.freeRects.splice(0),t.freeRects.forEach((t,n)=>{r.freeRects.push(new e(t.width,t.height,t.x,t.y))}),r.width=t.width,r.height=t.height,t.tag&&(r.tag=t.tag),this.bins[i]=r}},this)}save(){let e=[];return this.bins.forEach((t=>{let n={width:t.width,height:t.height,maxWidth:t.maxWidth,maxHeight:t.maxHeight,freeRects:[],rects:[],options:t.options};t.tag&&(n=Object.assign(Object.assign({},n),{tag:t.tag})),t.freeRects.forEach(e=>{n.freeRects.push({x:e.x,y:e.y,width:e.width,height:e.height})}),e.push(n)})),e}sort(e,t=a.MAX_EDGE){return e.slice().sort((e,n)=>{let r=t===a.MAX_EDGE?Math.max(n.width,n.height)-Math.max(e.width,e.height):n.width*n.height-e.width*e.height;return r===0&&e.hash&&n.hash?e.hash>n.hash?-1:1:r})}get currentBinIndex(){return this._currentBinIndex}get dirty(){return this.bins.some(e=>e.dirty)}get rects(){let e=[];for(let t of this.bins)e.push(...t.rects);return e}};function s(e){return!(`getContext`in e)}function c(e,t){if(typeof OffscreenCanvas<`u`)return new OffscreenCanvas(e,t);let n=document.createElement(`canvas`);return n.width=e,n.height=t,n}function l(e,t,n=c){let r=Math.max(1,Math.floor(t)),i=e.map(e=>e?{width:e.width,height:e.height,tiles:0}:{width:0,height:0,tiles:0}),a=[],l=[];for(let t=0;t<e.length;t++){let n=e[t];(!n||s(n)?a:l).push(t)}let f=new o(r,r,u,{pot:!1});return{atlases:[...d(f,e,a,i,r,n,!0),...d(f,e,l,i,r,n,!1)],reports:i}}let u=16;function d(e,t,n,r,i,a,o){let s=[];for(let e of n){let{width:t,height:n}=r[e];t<=0||n<=0||s.push({width:t,height:n,x:0,y:0,hash:`${e}`,data:{index:e}})}e.reset(),e.addArray(s);let c=s.filter(e=>e.oversized);c.length>0&&e.addArray(c.flatMap(e=>f(e,r[e.data.index],i)));let l=e.bins.filter(e=>!e.rects.some(e=>e.oversized)),u=l.map(e=>({...p(e,t,r,a),resizable:o}));for(let e of l)for(let t of e.rects)r[t.data.index].tiles++;return u}function f(e,t,n){let r=Math.ceil(t.width/n),i=Math.ceil(t.height/n),a=[];for(let o=0;o<i;o++){let i=o*n,s=Math.min(n,t.height-i);for(let c=0;c<r;c++){let r=c*n,l=Math.min(n,t.width-r);a.push({width:l,height:s,x:0,y:0,hash:`${e.hash}:${c},${o}`,data:{index:e.data.index,source:{x:r,y:i,width:l,height:s}}})}}return a}function p(e,t,n,r){let i=r(e.width,e.height),a=m(i);if(!a)throw Error(`pack-sources: no 2d context for a ${e.width}x${e.height} atlas`);let o=[];for(let r of e.rects){let{index:i,source:s}=r.data,{width:c,height:l}=n[i],u=s==null?{x:0,y:0,width:c,height:l}:s,d=t[i];if(!d)continue;a.drawImage(d,u.x,u.y,u.width,u.height,r.x,r.y,r.width,r.height);let f={u0:r.x/e.width,v0:r.y/e.height,u1:(r.x+r.width)/e.width,v1:(r.y+r.height)/e.height};o.push(s?{index:i,uv:f,source:s}:{index:i,uv:f})}return{canvas:i,placements:o}}function m(e){return`convertToBlob`in e,e.getContext(`2d`)}async function h(e,t){let n=v(e);n.packing=!0;let r=await Promise.all(n.decoding);if(y.delete(e),n.canceled)return _(r),null;let{atlases:i,reports:a}=l(r,t),o=i.map(e=>({bitmap:e.canvas.transferToImageBitmap(),placements:e.placements,resizable:e.resizable}));return _(r),{type:`packed`,id:e,atlases:o,reports:a}}function g(e){let t=y.get(e);t&&(t.canceled=!0,!t.packing&&(y.delete(e),Promise.all(t.decoding).then(_)))}function _(e){for(let t of e)t&&`close`in t&&t.close()}function v(e){let t=y.get(e);return t||(t={decoding:[],canceled:!1,packing:!1},y.set(e,t)),t}let y=new Map,b=self;b.onmessage=e=>{let t=e.data;if(t.type===`sources`){let e=v(t.id);for(let n of t.sources)e.decoding.push(createImageBitmap(n).catch(()=>null));return}if(t.type===`cancel`){g(t.id);return}let{id:n}=t;h(n,t.maxDimension).then(e=>{e&&b.postMessage(e,e.atlases.map(e=>e.bitmap))},e=>{y.delete(n),b.postMessage({type:`failed`,id:n,message:String(e)})})}})();", Hy = typeof self < "u" && self.Blob && new Blob(["(self.URL || self.webkitURL).revokeObjectURL(self.location.href);", Vy], { type: "text/javascript;charset=utf-8" });
function Uy(e) {
let t;
try {
if (t = Hy && (self.URL || self.webkitURL).createObjectURL(Hy), !t) throw "";
let n = new Worker(t, { name: e == null ? void 0 : e.name });
return n.addEventListener("error", () => {
(self.URL || self.webkitURL).revokeObjectURL(t);
}), n;
} catch {
return new Worker("data:text/javascript;charset=utf-8," + encodeURIComponent(Vy), { name: e == null ? void 0 : e.name });
}
}
//#endregion
//#region ../renderer/src/objects/images/worker/client.ts
function Wy(e, t, n = {}) {
let { signal: r, createWorker: i = Xy } = n;
return new Promise((n, a) => {
if (r != null && r.aborted) {
a(Zy());
return;
}
let o;
try {
o = Gy(i);
} catch (e) {
a(Qy(e));
return;
}
let s = ++tb, c = (e) => {
r == null || r.removeEventListener("abort", l), $y.delete(s), e();
}, l = () => {
c(() => {
Jy(o, s), a(Zy());
});
};
$y.set(s, (e) => {
c(() => {
e.type === "failed" ? a(Error(e.message)) : n({
atlases: e.atlases,
reports: e.reports
});
});
}), r == null || r.addEventListener("abort", l);
try {
for (let t = 0; t < e.length; t += 25) Yy(o, {
type: "sources",
id: s,
sources: e.slice(t, t + 25)
});
Yy(o, {
type: "pack",
id: s,
maxDimension: t
});
} catch (e) {
c(() => {
Jy(o, s), a(Qy(e));
});
}
});
}
function Gy(e) {
if (eb) return eb.worker;
let t = {
worker: e(),
produced: !1
};
return t.worker.onmessage = (e) => {
let n = e.data, r = $y.get(n.id);
if (r) {
n.type === "packed" && n.atlases.length > 0 && (t.produced = !0), r(n);
return;
}
if (n.type === "packed") for (let e of n.atlases) e.bitmap.close();
}, t.worker.onerror = (e) => {
Ky(t), qy(e.message || "atlas-worker: failed to start");
}, t.worker.onmessageerror = () => {
Ky(t), qy("atlas-worker: a reply could not be read");
}, eb = t, t.worker;
}
function Ky(e) {
eb === e && (eb = null), e.produced || e.worker.terminate();
}
function qy(e) {
for (let [t, n] of [...$y]) n({
type: "failed",
id: t,
message: e
});
}
function Jy(e, t) {
try {
Yy(e, {
type: "cancel",
id: t
});
} catch {}
}
function Yy(e, t) {
e.postMessage(t);
}
function Xy() {
return new Uy();
}
function Zy() {
return /* @__PURE__ */ Error("atlas-worker: the pack was abandoned");
}
function Qy(e) {
return e instanceof Error ? e : Error(String(e));
}
var $y = /* @__PURE__ */ new Map(), eb = null, tb = 0, nb = $c("atlas-packer"), rb = 1e3;
async function ib(e, t, n = {}) {
let r = performance.now(), { createCanvas: i = Py, signal: a } = n, o = cb(e), s = o.map((e) => e.source), c = ab(s), l = null;
if (c === "worker") try {
l = await ob(o, s, t, a);
} catch (e) {
if (a != null && a.aborted) throw e;
nb.warn("the worker could not pack, packing inline instead %O", e), c = "inline";
}
l != null || (l = await sb(o, s, t, i, a));
let u = (performance.now() - r).toFixed(1);
return nb.debug("packed defs: %d, sources: %d, atlases: %d, tier: %s (%sms)", l.reduce((e, t) => e + t.images.length, 0), o.length, l.length, c, u), l;
}
function ab(e) {
return typeof Worker == "function" && typeof OffscreenCanvas < "u" && e.every(My) ? "worker" : "inline";
}
async function ob(e, t, n, r) {
let { atlases: i, reports: a } = await Wy(t, n, { signal: r });
if (r != null && r.aborted) {
for (let e of i) e.bitmap.close();
throw Error("atlas-packer: the pack was aborted");
}
return ub(e, a), i.map((t) => ({
image: t.bitmap,
resizable: t.resizable,
images: lb(t.placements, e, a)
}));
}
async function sb(e, t, n, r, i) {
let a = await db(t);
if (i != null && i.aborted) throw fb(t, a), Error("atlas-packer: the pack was aborted");
let { atlases: o, reports: s } = Fy(a, n, r);
return fb(t, a), ub(e, s), o.map((t) => ({
image: t.canvas,
resizable: t.resizable,
images: lb(t.placements, e, s)
}));
}
function cb(e) {
let t = /* @__PURE__ */ new Map();
for (let n of e) {
let e = t.get(n.source);
e || (e = {
source: n.source,
defs: [],
bounds: {
width: 0,
height: 0
}
}, t.set(n.source, e)), e.defs.push(n);
let { width: r, height: i } = n.bounds.size;
r * i > e.bounds.width * e.bounds.height && (e.bounds = {
width: r,
height: i
});
}
return [...t.values()];
}
function lb(e, t, n) {
let r = [];
for (let { index: i, uv: a, source: o } of e) {
let { width: e, height: s } = n[i], c = {
width: e,
height: s
};
for (let e of t[i].defs) r.push(o ? {
def: e,
uv: a,
source: o,
size: c
} : {
def: e,
uv: a,
size: c
});
}
return r;
}
function ub(e, t) {
for (let n = 0; n < e.length; n++) {
let r = e[n], { width: i, height: a, tiles: o } = t[n];
if (o === 0) {
nb.warn("skipping source with no pixels (%dx%d) %O", i, a, r.source);
continue;
}
o > 1 && nb.warn("source %dx%d exceeds the atlas limit, split into %d tiles", i, a, o);
let s = r.bounds.width * r.bounds.height;
if (s <= 0) continue;
let c = i * a / s;
c <= rb || nb.warn("over-sampled source: %dx%d px drawn into %sx%s units — %d px per unit², limit %d", i, a, Number(r.bounds.width.toFixed(2)), Number(r.bounds.height.toFixed(2)), Math.round(c), rb);
}
}
async function db(e) {
return Promise.all(e.map((e) => pb(e).catch(() => null)));
}
function fb(e, t) {
for (let n = 0; n < t.length; n++) {
let r = t[n];
r && My(e[n]) && "close" in r && r.close();
}
}
async function pb(e) {
return My(e) ? createImageBitmap(e) : e;
}
//#endregion
//#region ../renderer/src/objects/images/image-container.ts
var mb = "uvOffset", hb = "instanceOpacity", gb = class extends yy {
constructor(e) {
super({ schema: _b }), this.args = void 0, this.args = [{ capacity: Math.max(1, e) }];
}
get facesCamera() {
return mv(this.mesh);
}
setOpacityAt(e, t) {
let n = t === void 0 ? 1 : Math.min(Math.max(t, 0), 1);
this.mesh.setUniformAt(e, hb, n);
}
addInstance(e) {
let t = -1;
this.mesh.addInstances(1, (e) => {
t = e;
});
let { u0: n, v0: r, u1: i, v1: a } = e.uv;
return this.mesh.setUniformAt(t, mb, vb.set(n, r, i - n, a - r)), t;
}
removeInstance(e) {
this.mesh.removeInstances(e);
}
}, _b = { vertex: {
[mb]: "vec4",
[hb]: "float",
...rg.vertex
} }, vb = new _n(), yb = (0, G.memo)(function(e) {
let t = (0, Z.c)(6), { def: n, packed: r, container: i } = e, a;
t[0] === r ? a = t[1] : (a = () => r, t[0] = r, t[1] = a);
let o;
return t[2] !== i || t[3] !== n || t[4] !== r ? (o = (e) => {
let t = Sb(r);
bb(i, e, n, t), xb(i, e, n, t), i.setOpacityAt(e, n.opacity), !!n.screenSpace !== i.facesCamera && i.reportKindMismatch();
}, t[2] = i, t[3] = n, t[4] = r, t[5] = o) : o = t[5], Sv(i, n, a, o), null;
});
function bb(e, t, n, r) {
let i = sy(n.bounds);
if (e.facesCamera) {
r && i.scale(Eb.set(r.width, r.height, 1));
let e = i.elements[13];
i.premultiply(dl), i.elements[13] = e;
} else {
var a;
let [e, t] = (a = n.origin) == null ? Cb : a, o = e - .5, s = t - .5;
i.multiply(wb.makeTranslation(-o, -s, 0)), r && i.multiply(Tb.makeScale(r.width, r.height, 1).setPosition(r.x, r.y, 0));
}
cy(e.mesh, t, i);
}
function xb(e, t, n, r) {
var i;
let a = e.mesh;
if (!mv(a)) return;
let [o, s] = (i = n.origin) == null ? Cb : i, c = o - .5, l = s - .5;
r && (c = (c - r.x) / r.width, l = (l - r.y) / r.height), a.getAnchorAt(t, Db), !(Db.x === c && Db.y === l) && a.setAnchorAt(t, c, l);
}
function Sb(e) {
let { source: t, size: n } = e;
if (!t || n.width <= 0 || n.height <= 0) return;
let r = t.x / n.width, i = t.y / n.height, a = (t.x + t.width) / n.width, o = (t.y + t.height) / n.height;
return {
width: a - r,
height: o - i,
x: (r + a) / 2 - .5,
y: (i + o) / 2 - .5
};
}
var Cb = [.5, .5], wb = new W(), Tb = new W(), Eb = new U(), Db = new V(), Ob = $c("images");
function kb(e) {
var t;
let n = (0, Z.c)(21), { defs: r, maxAtlasSize: i, createCanvas: a } = e, o = (t = e.mounted) == null ? r.length : t, s = I(jb), c = I(Ab), l = i == null ? s.capabilities.maxTextureSize : i, [u, d] = (0, G.useState)(r);
Lb(u, r) || d(r);
let [f, p] = (0, G.useState)(Ub), m, h;
n[0] !== a || n[1] !== c || n[2] !== l || n[3] !== u ? (m = () => {
let e = new AbortController(), t = !1;
return ib(u, l, {
createCanvas: a,
signal: e.signal
}).then((n) => {
if (e.signal.aborted) {
zb(n);
return;
}
t = !0, p((e) => ({
defs: u,
atlases: n,
generation: e.generation + 1
})), c();
}, (t) => {
e.signal.aborted || Ob.error("atlas pack failed %O", t);
}), () => {
t || e.abort();
};
}, h = [
u,
l,
a,
c
], n[0] = a, n[1] = c, n[2] = l, n[3] = u, n[4] = m, n[5] = h) : (m = n[4], h = n[5]), (0, G.useEffect)(m, h);
let g;
n[6] === f.atlases ? g = n[7] : (g = () => () => zb(f.atlases), n[6] = f.atlases, n[7] = g);
let _;
n[8] === f ? _ = n[9] : (_ = [f], n[8] = f, n[9] = _), (0, G.useEffect)(g, _);
let v;
if (n[10] !== r || n[11] !== o || n[12] !== f.atlases || n[13] !== f.generation) {
let e;
n[15] !== r || n[16] !== o || n[17] !== f.generation ? (e = (e) => /* @__PURE__ */ (0, K.jsx)(Mb, {
atlas: e,
defs: r,
mounted: o
}, Rb(e, f.generation)), n[15] = r, n[16] = o, n[17] = f.generation, n[18] = e) : e = n[18], v = f.atlases.map(e), n[10] = r, n[11] = o, n[12] = f.atlases, n[13] = f.generation, n[14] = v;
} else v = n[14];
let y;
return n[19] === v ? y = n[20] : (y = /* @__PURE__ */ (0, K.jsx)(K.Fragment, { children: v }), n[19] = v, n[20] = y), y;
}
function Ab(e) {
return e.invalidate;
}
function jb(e) {
return e.gl;
}
function Mb(e) {
var t;
let n = (0, Z.c)(32), { atlas: r, defs: i } = e, a = (t = e.mounted) == null ? r.images.length : t, o;
n[0] === r.image ? o = n[1] : (o = () => Hb(r.image), n[0] = r.image, n[1] = o);
let [s] = (0, G.useState)(o), c = I(Nb), l = t_((0, G.use)(e_), r), u;
n[2] === Symbol.for("react.memo_cache_sentinel") ? (u = {}, n[2] = u) : u = n[2];
let d = (0, G.useRef)(u), f, p;
n[3] !== c || n[4] !== s ? (f = () => (c(), () => s.dispose()), p = [s, c], n[3] = c, n[4] = s, n[5] = f, n[6] = p) : (f = n[5], p = n[6]), (0, G.useEffect)(f, p);
let m;
n[7] !== r.image || n[8] !== l || n[9] !== c || n[10] !== s ? (m = () => {
Bb(s, r.image, d, l), c();
}, n[7] = r.image, n[8] = l, n[9] = c, n[10] = s, n[11] = m) : m = n[11];
let h;
n[12] !== r || n[13] !== l || n[14] !== c || n[15] !== s ? (h = [
s,
r,
l,
c
], n[12] = r, n[13] = l, n[14] = c, n[15] = s, n[16] = h) : h = n[16], (0, G.useEffect)(m, h);
let g, _;
n[17] === Symbol.for("react.memo_cache_sentinel") ? (g = () => {
let e = d.current;
return () => Vb(e);
}, _ = [], n[17] = g, n[18] = _) : (g = n[17], _ = n[18]), (0, G.useEffect)(g, _);
let v;
n[19] === r.images ? v = n[20] : (v = () => Fb(r.images), n[19] = r.images, n[20] = v);
let [y, b] = (0, G.useState)(v), x;
n[21] === r.images ? x = n[22] : (x = function() {
b(() => Fb(r.images));
}, n[21] = r.images, n[22] = x);
let S = x, C;
n[23] !== r.images || n[24] !== i || n[25] !== a || n[26] !== y || n[27] !== S || n[28] !== s ? (C = Ib.map((e, t) => {
let n = y[e];
return n.length === 0 ? null : /* @__PURE__ */ (0, K.jsx)(Pb, {
kind: e,
placements: n,
defs: i,
mounted: a,
capacity: r.images.length,
texture: s,
renderOrder: t,
onKindMismatch: S
}, e);
}), n[23] = r.images, n[24] = i, n[25] = a, n[26] = y, n[27] = S, n[28] = s, n[29] = C) : C = n[29];
let w;
return n[30] === C ? w = n[31] : (w = /* @__PURE__ */ (0, K.jsx)(K.Fragment, { children: C }), n[30] = C, n[31] = w), w;
}
function Nb(e) {
return e.invalidate;
}
function Pb(e) {
var t;
let n = (0, Z.c)(16), { kind: r, placements: i, defs: a, capacity: o, texture: s, renderOrder: c, onKindMismatch: l } = e, u = (t = e.mounted) == null ? i.length : t, d;
n[0] === o ? d = n[1] : (d = () => new gb(o), n[0] = o, n[1] = d);
let f = bv(d, a, l), p;
n[2] !== f || n[3] !== r || n[4] !== c || n[5] !== s ? (p = r === "sprite" ? /* @__PURE__ */ (0, K.jsx)(hv, {
args: f.args,
ref: (e) => f.bind(e),
sortObjects: !0,
customSort: f.customSort,
perObjectFrustumCulled: !0,
renderOrder: c,
children: /* @__PURE__ */ (0, K.jsx)(by, {
map: s,
uvOffset: mb,
opacityUniform: hb
})
}) : /* @__PURE__ */ (0, K.jsxs)(K_, {
args: f.args,
ref: (e) => f.bind(e),
sortObjects: !0,
customSort: f.customSort,
perObjectFrustumCulled: !0,
renderOrder: c,
children: [/* @__PURE__ */ (0, K.jsx)("planeGeometry", {}), /* @__PURE__ */ (0, K.jsx)(by, {
map: s,
uvOffset: mb,
opacityUniform: hb
})]
}), n[2] = f, n[3] = r, n[4] = c, n[5] = s, n[6] = p) : p = n[6];
let m = p, h;
if (n[7] !== f || n[8] !== u || n[9] !== i) {
let e;
n[11] === f ? e = n[12] : (e = (e) => /* @__PURE__ */ (0, K.jsx)(yb, {
def: e.def,
packed: e,
container: f
}, `${Ov(e.def)}:${e.uv.u0}:${e.uv.v0}`), n[11] = f, n[12] = e), h = i.slice(0, u).map(e), n[7] = f, n[8] = u, n[9] = i, n[10] = h;
} else h = n[10];
let g;
return n[13] !== m || n[14] !== h ? (g = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [m, h] }), n[13] = m, n[14] = h, n[15] = g) : g = n[15], g;
}
function Fb(e) {
let t = [], n = [];
for (let r of e) (r.def.screenSpace === !0 ? n : t).push(r);
return {
flat: t,
sprite: n
};
}
var Ib = ["flat", "sprite"];
function Lb(e, t) {
if (e.length !== t.length) return !1;
let n = new Set(e);
return t.every((e) => n.has(e));
}
function Rb(e, t) {
let n = e.images[0], r = n.source ? `:${n.source.x},${n.source.y}` : "";
return `${t}:${Ov(n.def)}:${n.uv.u0}:${n.uv.v0}${r}`;
}
function zb(e) {
for (let t of e) "close" in t.image && t.image.close();
}
function Bb(e, t, n, r) {
var i, a, o;
let s = n.current;
if (r >= 1) {
e.image !== t && (Vb(s), e.image = t, e.needsUpdate = !0);
return;
}
let c = Math.max(1, Math.round(t.width * r)), l = Math.max(1, Math.round(t.height * r)), u = (i = s.canvas) == null ? s.canvas = Py(c, l) : i;
u.width = c, u.height = l;
let d = By(u);
if (!d) {
Vb(s), e.image = t, e.needsUpdate = !0;
return;
}
d.drawImage(t, 0, 0, c, l), (a = s.bitmap) == null || a.close(), s.bitmap = "transferToImageBitmap" in u ? u.transferToImageBitmap() : void 0, e.image = (o = s.bitmap) == null ? u : o, e.needsUpdate = !0;
}
function Vb(e) {
var t;
(t = e.bitmap) == null || t.close(), e.bitmap = void 0;
}
function Hb(e) {
let t = new et(e);
return t.colorSpace = wt, t.flipY = !1, t.premultiplyAlpha = !0, t.generateMipmaps = !0, t;
}
var Ub = {
defs: [],
atlases: [],
generation: 0
};
re.line = {
worldUnits: { value: 1 },
linewidth: { value: 1 },
resolution: { value: new V() },
dashOffset: { value: 0 },
dashScale: { value: 1 },
dashSize: { value: 1 },
gapSize: { value: 1 }
}, ae.line = {
uniforms: St.merge([
re.common,
re.fog,
re.line
]),
vertexShader: "\n #include <common>\n #include <color_pars_vertex>\n #include <fog_pars_vertex>\n #include <logdepthbuf_pars_vertex>\n #include <clipping_planes_pars_vertex>\n\n uniform float linewidth;\n uniform vec2 resolution;\n\n attribute vec3 instanceStart;\n attribute vec3 instanceEnd;\n\n attribute vec3 instanceColorStart;\n attribute vec3 instanceColorEnd;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #ifdef USE_DASH\n\n uniform float dashScale;\n attribute float instanceDistanceStart;\n attribute float instanceDistanceEnd;\n varying float vLineDistance;\n\n #endif\n\n float trimSegmentAlpha( const in vec4 start, const in vec4 end ) {\n\n // compute the interpolation factor needed to trim the segment so it terminates\n // between the camera plane and the near plane\n\n // conservative estimate of the near plane\n float a = projectionMatrix[ 2 ][ 2 ]; // 3nd entry in 3th column\n float b = projectionMatrix[ 3 ][ 2 ]; // 3nd entry in 4th column\n\n // we need different nearEstimate formula for reversed and default depth buffer\n // a is positive with a reversed depth buffer so it can be used for controlling the code flow\n float nearEstimate = ( a > 0.0 ) ? ( - b / ( a + 1.0 ) ) : ( - 0.5 * b / a );\n\n return ( nearEstimate - start.z ) / ( end.z - start.z );\n\n }\n\n void main() {\n\n #ifdef USE_COLOR\n\n vColor.xyz = ( position.y < 0.5 ) ? instanceColorStart : instanceColorEnd;\n\n #endif\n\n float aspect = resolution.x / resolution.y;\n\n // camera space\n vec4 start = modelViewMatrix * vec4( instanceStart, 1.0 );\n vec4 end = modelViewMatrix * vec4( instanceEnd, 1.0 );\n\n #ifdef USE_DASH\n\n float lineDistanceStart = dashScale * instanceDistanceStart;\n float lineDistanceEnd = dashScale * instanceDistanceEnd;\n\n #endif\n\n #ifdef WORLD_UNITS\n\n worldStart = start.xyz;\n worldEnd = end.xyz;\n\n #else\n\n vUv = uv;\n\n #endif\n\n // special case for perspective projection, and segments that terminate either in, or behind, the camera plane\n // clearly the gpu firmware has a way of addressing this issue when projecting into ndc space\n // but we need to perform ndc-space calculations in the shader, so we must address this issue directly\n // perhaps there is a more elegant solution -- WestLangley\n\n bool perspective = ( projectionMatrix[ 2 ][ 3 ] == - 1.0 ); // 4th entry in the 3rd column\n\n if ( perspective ) {\n\n if ( start.z < 0.0 && end.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( start, end );\n end.xyz = mix( start.xyz, end.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceEnd = mix( lineDistanceStart, lineDistanceEnd, alpha );\n\n #endif\n\n } else if ( end.z < 0.0 && start.z >= 0.0 ) {\n\n float alpha = trimSegmentAlpha( end, start );\n start.xyz = mix( end.xyz, start.xyz, alpha );\n\n #ifdef USE_DASH\n\n lineDistanceStart = mix( lineDistanceEnd, lineDistanceStart, alpha );\n\n #endif\n\n }\n\n }\n\n #ifdef USE_DASH\n\n vLineDistance = ( position.y < 0.5 ) ? lineDistanceStart : lineDistanceEnd;\n vUv = uv;\n\n #endif\n\n // clip space\n vec4 clipStart = projectionMatrix * start;\n vec4 clipEnd = projectionMatrix * end;\n\n // ndc space\n vec3 ndcStart = clipStart.xyz / clipStart.w;\n vec3 ndcEnd = clipEnd.xyz / clipEnd.w;\n\n // direction\n vec2 dir = ndcEnd.xy - ndcStart.xy;\n\n // account for clip-space aspect ratio\n dir.x *= aspect;\n dir = normalize( dir );\n\n #ifdef WORLD_UNITS\n\n vec3 worldDir = normalize( end.xyz - start.xyz );\n vec3 tmpFwd = normalize( mix( start.xyz, end.xyz, 0.5 ) );\n vec3 worldUp = normalize( cross( worldDir, tmpFwd ) );\n vec3 worldFwd = cross( worldDir, worldUp );\n worldPos = position.y < 0.5 ? start: end;\n\n // height offset\n float hw = linewidth * 0.5;\n worldPos.xyz += position.x < 0.0 ? hw * worldUp : - hw * worldUp;\n\n // don't extend the line if we're rendering dashes because we\n // won't be rendering the endcaps\n #ifndef USE_DASH\n\n // cap extension\n worldPos.xyz += position.y < 0.5 ? - hw * worldDir : hw * worldDir;\n\n // add width to the box\n worldPos.xyz += worldFwd * hw;\n\n // endcaps\n if ( position.y > 1.0 || position.y < 0.0 ) {\n\n worldPos.xyz -= worldFwd * 2.0 * hw;\n\n }\n\n #endif\n\n // project the worldpos\n vec4 clip = projectionMatrix * worldPos;\n\n // shift the depth of the projected points so the line\n // segments overlap neatly\n vec3 clipPose = ( position.y < 0.5 ) ? ndcStart : ndcEnd;\n clip.z = clipPose.z * clip.w;\n\n #else\n\n vec2 offset = vec2( dir.y, - dir.x );\n // undo aspect ratio adjustment\n dir.x /= aspect;\n offset.x /= aspect;\n\n // sign flip\n if ( position.x < 0.0 ) offset *= - 1.0;\n\n // endcaps\n if ( position.y < 0.0 ) {\n\n offset += - dir;\n\n } else if ( position.y > 1.0 ) {\n\n offset += dir;\n\n }\n\n // adjust for linewidth\n offset *= linewidth;\n\n // adjust for clip-space to screen-space conversion // maybe resolution should be based on viewport ...\n offset /= resolution.y;\n\n // select end\n vec4 clip = ( position.y < 0.5 ) ? clipStart : clipEnd;\n\n // back to clip space\n offset *= clip.w;\n\n clip.xy += offset;\n\n #endif\n\n gl_Position = clip;\n\n vec4 mvPosition = ( position.y < 0.5 ) ? start : end; // this is an approximation\n\n #include <logdepthbuf_vertex>\n #include <clipping_planes_vertex>\n #include <fog_vertex>\n\n }\n ",
fragmentShader: "\n uniform vec3 diffuse;\n uniform float opacity;\n uniform float linewidth;\n\n #ifdef USE_DASH\n\n uniform float dashOffset;\n uniform float dashSize;\n uniform float gapSize;\n\n #endif\n\n varying float vLineDistance;\n\n #ifdef WORLD_UNITS\n\n varying vec4 worldPos;\n varying vec3 worldStart;\n varying vec3 worldEnd;\n\n #ifdef USE_DASH\n\n varying vec2 vUv;\n\n #endif\n\n #else\n\n varying vec2 vUv;\n\n #endif\n\n #include <common>\n #include <color_pars_fragment>\n #include <fog_pars_fragment>\n #include <logdepthbuf_pars_fragment>\n #include <clipping_planes_pars_fragment>\n\n vec2 closestLineToLine(vec3 p1, vec3 p2, vec3 p3, vec3 p4) {\n\n float mua;\n float mub;\n\n vec3 p13 = p1 - p3;\n vec3 p43 = p4 - p3;\n\n vec3 p21 = p2 - p1;\n\n float d1343 = dot( p13, p43 );\n float d4321 = dot( p43, p21 );\n float d1321 = dot( p13, p21 );\n float d4343 = dot( p43, p43 );\n float d2121 = dot( p21, p21 );\n\n float denom = d2121 * d4343 - d4321 * d4321;\n\n float numer = d1343 * d4321 - d1321 * d4343;\n\n mua = numer / denom;\n mua = clamp( mua, 0.0, 1.0 );\n mub = ( d1343 + d4321 * ( mua ) ) / d4343;\n mub = clamp( mub, 0.0, 1.0 );\n\n return vec2( mua, mub );\n\n }\n\n void main() {\n\n float alpha = opacity;\n vec4 diffuseColor = vec4( diffuse, alpha );\n\n #include <clipping_planes_fragment>\n\n #ifdef USE_DASH\n\n if ( vUv.y < - 1.0 || vUv.y > 1.0 ) discard; // discard endcaps\n\n if ( mod( vLineDistance + dashOffset, dashSize + gapSize ) > dashSize ) discard; // todo - FIX\n\n #endif\n\n #ifdef WORLD_UNITS\n\n // Find the closest points on the view ray and the line segment\n vec3 rayEnd = normalize( worldPos.xyz ) * 1e5;\n vec3 lineDir = worldEnd - worldStart;\n vec2 params = closestLineToLine( worldStart, worldEnd, vec3( 0.0, 0.0, 0.0 ), rayEnd );\n\n vec3 p1 = worldStart + lineDir * params.x;\n vec3 p2 = rayEnd * params.y;\n vec3 delta = p1 - p2;\n float len = length( delta );\n float norm = len / linewidth;\n\n #ifndef USE_DASH\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n float dnorm = fwidth( norm );\n alpha = 1.0 - smoothstep( 0.5 - dnorm, 0.5 + dnorm, norm );\n\n #else\n\n if ( norm > 0.5 ) {\n\n discard;\n\n }\n\n #endif\n\n #endif\n\n #else\n\n #ifdef USE_ALPHA_TO_COVERAGE\n\n // artifacts appear on some hardware if a derivative is taken within a conditional\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n float dlen = fwidth( len2 );\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n alpha = 1.0 - smoothstep( 1.0 - dlen, 1.0 + dlen, len2 );\n\n }\n\n #else\n\n if ( abs( vUv.y ) > 1.0 ) {\n\n float a = vUv.x;\n float b = ( vUv.y > 0.0 ) ? vUv.y - 1.0 : vUv.y + 1.0;\n float len2 = a * a + b * b;\n\n if ( len2 > 1.0 ) discard;\n\n }\n\n #endif\n\n #endif\n\n #include <logdepthbuf_fragment>\n #include <color_fragment>\n\n gl_FragColor = vec4( diffuseColor.rgb, alpha );\n\n #include <tonemapping_fragment>\n #include <colorspace_fragment>\n #include <fog_fragment>\n #include <premultiplied_alpha_fragment>\n\n }\n "
};
var Wb = class extends ke {
constructor(e) {
super({
type: "LineMaterial",
uniforms: St.clone(ae.line.uniforms),
vertexShader: ae.line.vertexShader,
fragmentShader: ae.line.fragmentShader,
clipping: !0
}), this.isLineMaterial = !0, this.setValues(e);
}
get color() {
return this.uniforms.diffuse.value;
}
set color(e) {
this.uniforms.diffuse.value = e;
}
get worldUnits() {
return "WORLD_UNITS" in this.defines;
}
set worldUnits(e) {
e === !0 !== this.worldUnits && (this.needsUpdate = !0), e === !0 ? this.defines.WORLD_UNITS = "" : delete this.defines.WORLD_UNITS;
}
get linewidth() {
return this.uniforms.linewidth.value;
}
set linewidth(e) {
this.uniforms.linewidth && (this.uniforms.linewidth.value = e);
}
get dashed() {
return "USE_DASH" in this.defines;
}
set dashed(e) {
e === !0 !== this.dashed && (this.needsUpdate = !0), e === !0 ? this.defines.USE_DASH = "" : delete this.defines.USE_DASH;
}
get dashScale() {
return this.uniforms.dashScale.value;
}
set dashScale(e) {
this.uniforms.dashScale.value = e;
}
get dashSize() {
return this.uniforms.dashSize.value;
}
set dashSize(e) {
this.uniforms.dashSize.value = e;
}
get dashOffset() {
return this.uniforms.dashOffset.value;
}
set dashOffset(e) {
this.uniforms.dashOffset.value = e;
}
get gapSize() {
return this.uniforms.gapSize.value;
}
set gapSize(e) {
this.uniforms.gapSize.value = e;
}
get opacity() {
return this.uniforms.opacity.value;
}
set opacity(e) {
this.uniforms && (this.uniforms.opacity.value = e);
}
get resolution() {
return this.uniforms.resolution.value;
}
set resolution(e) {
this.uniforms.resolution.value.copy(e);
}
get alphaToCoverage() {
return "USE_ALPHA_TO_COVERAGE" in this.defines;
}
set alphaToCoverage(e) {
this.defines && (e === !0 !== this.alphaToCoverage && (this.needsUpdate = !0), e === !0 ? this.defines.USE_ALPHA_TO_COVERAGE = "" : delete this.defines.USE_ALPHA_TO_COVERAGE);
}
}, Gb = new ze(), Kb = new U(), qb = class extends jt {
constructor() {
super(), this.isLineSegmentsGeometry = !0, this.type = "LineSegmentsGeometry", this.setIndex([
0,
2,
1,
2,
3,
1,
2,
4,
3,
4,
5,
3,
4,
6,
5,
6,
7,
5
]), this.setAttribute("position", new nt([
-1,
2,
0,
1,
2,
0,
-1,
1,
0,
1,
1,
0,
-1,
0,
0,
1,
0,
0,
-1,
-1,
0,
1,
-1,
0
], 3)), this.setAttribute("uv", new nt([
-1,
2,
1,
2,
-1,
1,
1,
1,
-1,
-1,
1,
-1,
-1,
-2,
1,
-2
], 2));
}
applyMatrix4(e) {
let t = this.attributes.instanceStart, n = this.attributes.instanceEnd;
return t !== void 0 && (t.applyMatrix4(e), n.applyMatrix4(e), t.needsUpdate = !0), this.boundingBox !== null && this.computeBoundingBox(), this.boundingSphere !== null && this.computeBoundingSphere(), this;
}
setPositions(e) {
let t;
e instanceof Float32Array ? t = e : Array.isArray(e) && (t = new Float32Array(e));
let n = new cn(t, 6, 1);
return this.setAttribute("instanceStart", new dn(n, 3, 0)), this.setAttribute("instanceEnd", new dn(n, 3, 3)), this.instanceCount = this.attributes.instanceStart.count, this.computeBoundingBox(), this.computeBoundingSphere(), this;
}
setColors(e) {
let t;
e instanceof Float32Array ? t = e : Array.isArray(e) && (t = new Float32Array(e));
let n = new cn(t, 6, 1);
return this.setAttribute("instanceColorStart", new dn(n, 3, 0)), this.setAttribute("instanceColorEnd", new dn(n, 3, 3)), this;
}
fromWireframeGeometry(e) {
return this.setPositions(e.attributes.position.array), this;
}
fromEdgesGeometry(e) {
return this.setPositions(e.attributes.position.array), this;
}
fromMesh(e) {
return this.fromWireframeGeometry(new Rt(e.geometry)), this;
}
fromLineSegments(e) {
let t = e.geometry;
return this.setPositions(t.attributes.position.array), this;
}
computeBoundingBox() {
this.boundingBox === null && (this.boundingBox = new ze());
let e = this.attributes.instanceStart, t = this.attributes.instanceEnd;
e !== void 0 && t !== void 0 && (this.boundingBox.setFromBufferAttribute(e), Gb.setFromBufferAttribute(t), this.boundingBox.union(Gb));
}
computeBoundingSphere() {
this.boundingSphere === null && (this.boundingSphere = new vn()), this.boundingBox === null && this.computeBoundingBox();
let e = this.attributes.instanceStart, t = this.attributes.instanceEnd;
if (e !== void 0 && t !== void 0) {
let n = this.boundingSphere.center;
this.boundingBox.getCenter(n);
let r = 0;
for (let i = 0, a = e.count; i < a; i++) Kb.fromBufferAttribute(e, i), r = Math.max(r, n.distanceToSquared(Kb)), Kb.fromBufferAttribute(t, i), r = Math.max(r, n.distanceToSquared(Kb));
this.boundingSphere.radius = Math.sqrt(r), isNaN(this.boundingSphere.radius) && console.error("THREE.LineSegmentsGeometry.computeBoundingSphere(): Computed radius is NaN. The instanced position data is likely to have NaN values.", this);
}
}
toJSON() {}
}, Jb = class extends y_ {
instanceSphere(e, t, n, r) {
let i = super.instanceSphere(e, t, n, r);
return i.radius += this.drawnMargin(e, t, n, i), i;
}
drawnMargin(e, t, n, r) {
var i;
let a = e.material, o = e.getWidthAt(t), s = o < 0 ? a.linewidth : o;
if (s <= 0) return 0;
if (a.worldUnits) return s / 2;
if (a.resolution.x === 0) return 0;
Xb.copy(r.center).applyMatrix4(e.matrixWorld);
let c = (i = n.near) == null ? 0 : i, l = Zb.setFromMatrixPosition(n.matrixWorld).distanceTo(Xb);
return Yb(n, Math.max(c, l + r.radius), s, a);
}
};
function Yb(e, t, n, r) {
let i = r.resolution;
return Qb.set(0, 0, -t, 1).applyMatrix4(e.projectionMatrix), Qb.multiplyScalar(1 / Qb.w), Qb.x = n / i.width, Qb.y = n / i.height, Qb.applyMatrix4(e.projectionMatrixInverse), Qb.multiplyScalar(1 / Qb.w), Math.abs(Math.max(Qb.x, Qb.y));
}
var Xb = new U(), Zb = new U(), Qb = new _n(), $b = "instanceStart", ex = "instanceEnd", tx = "lineWidth";
function nx(e) {
rx(e);
let t = e.onBeforeCompile, n = e.customProgramCacheKey;
return e.customProgramCacheKey = () => `efpLine_${n.call(e)}`, e.onBeforeCompile = (n, r) => {
ix(n), t.call(e, n, r);
}, () => {
e.onBeforeCompile = t, e.customProgramCacheKey = n;
};
}
function rx(e) {
e.vertexShader.includes(cx) || (e.vertexShader = uh(e.vertexShader, cx));
}
function ix(e) {
let t = e.vertexShader;
if (!t.includes("lineWidth")) return !1;
let n = `
float materialLineWidth = linewidth;
float linewidth = ${tx} < 0.0 ? materialLineWidth : ${tx};
`;
return e.vertexShader = dh(t.replace(ax, ""), ox, `${n}\n${ox}`), e.fragmentShader = dh(e.fragmentShader, sx, "gl_FragColor = vec4( diffuseColor.rgb, alpha * vColor.a );"), !0;
}
var ax = RegExp(`attribute\\s+vec3\\s+${$b}\\s*;\\s*attribute\\s+vec3\\s+${ex}\\s*;`), ox = "float aspect = resolution.x / resolution.y;", sx = "gl_FragColor = vec4( diffuseColor.rgb, alpha );", cx = "#include <color_vertex>", lx = new _n(), ux = new U(), dx = new U(), fx = new _n(), px = new _n(), mx = new _n(), hx = new U(), gx = new W(), _x = new Pe(), vx = new U(), yx = new ze(), bx = new vn(), xx = new _n(), Sx, Cx;
function wx(e, t, n) {
return xx.set(0, 0, -t, 1).applyMatrix4(e.projectionMatrix), xx.multiplyScalar(1 / xx.w), xx.x = Cx / n.width, xx.y = Cx / n.height, xx.applyMatrix4(e.projectionMatrixInverse), xx.multiplyScalar(1 / xx.w), Math.abs(Math.max(xx.x, xx.y));
}
function Tx(e, t) {
let n = e.matrixWorld, r = e.geometry, i = r.attributes.instanceStart, a = r.attributes.instanceEnd, o = Math.min(r.instanceCount, i.count);
for (let r = 0, s = o; r < s; r++) {
_x.start.fromBufferAttribute(i, r), _x.end.fromBufferAttribute(a, r), _x.applyMatrix4(n);
let o = new U(), s = new U();
Sx.distanceSqToSegment(_x.start, _x.end, s, o), s.distanceTo(o) < Cx * .5 && t.push({
point: s,
pointOnLine: o,
distance: Sx.origin.distanceTo(s),
object: e,
face: null,
faceIndex: r,
uv: null,
uv1: null
});
}
}
function Ex(e, t, n) {
let r = t.projectionMatrix, i = e.material.resolution, a = e.matrixWorld, o = e.geometry, s = o.attributes.instanceStart, c = o.attributes.instanceEnd, l = Math.min(o.instanceCount, s.count), u = -t.near;
Sx.at(1, mx), mx.w = 1, mx.applyMatrix4(t.matrixWorldInverse), mx.applyMatrix4(r), mx.multiplyScalar(1 / mx.w), mx.x *= i.x / 2, mx.y *= i.y / 2, mx.z = 0, hx.copy(mx), gx.multiplyMatrices(t.matrixWorldInverse, a);
for (let t = 0, o = l; t < o; t++) {
if (fx.fromBufferAttribute(s, t), px.fromBufferAttribute(c, t), fx.w = 1, px.w = 1, fx.applyMatrix4(gx), px.applyMatrix4(gx), fx.z > u && px.z > u) continue;
if (fx.z > u) {
let e = fx.z - px.z, t = (fx.z - u) / e;
fx.lerp(px, t);
} else if (px.z > u) {
let e = px.z - fx.z, t = (px.z - u) / e;
px.lerp(fx, t);
}
fx.applyMatrix4(r), px.applyMatrix4(r), fx.multiplyScalar(1 / fx.w), px.multiplyScalar(1 / px.w), fx.x *= i.x / 2, fx.y *= i.y / 2, px.x *= i.x / 2, px.y *= i.y / 2, _x.start.copy(fx), _x.start.z = 0, _x.end.copy(px), _x.end.z = 0;
let o = _x.closestPointToPointParameter(hx, !0);
_x.at(o, vx);
let l = zt.lerp(fx.z, px.z, o), d = l >= -1 && l <= 1, f = hx.distanceTo(vx) < Cx * .5;
if (d && f) {
_x.start.fromBufferAttribute(s, t), _x.end.fromBufferAttribute(c, t), _x.start.applyMatrix4(a), _x.end.applyMatrix4(a);
let r = new U(), i = new U();
Sx.distanceSqToSegment(_x.start, _x.end, i, r), n.push({
point: i,
pointOnLine: r,
distance: Sx.origin.distanceTo(i),
object: e,
face: null,
faceIndex: t,
uv: null,
uv1: null
});
}
}
}
var Dx = class extends Yt {
constructor(e = new qb(), t = new Wb({ color: Math.random() * 16777215 })) {
super(e, t), this.isLineSegments2 = !0, this.type = "LineSegments2";
}
computeLineDistances() {
let e = this.geometry, t = e.attributes.instanceStart, n = e.attributes.instanceEnd, r = new Float32Array(2 * t.count);
for (let e = 0, i = 0, a = t.count; e < a; e++, i += 2) ux.fromBufferAttribute(t, e), dx.fromBufferAttribute(n, e), r[i] = i === 0 ? 0 : r[i - 1], r[i + 1] = r[i] + ux.distanceTo(dx);
let i = new cn(r, 2, 1);
return e.setAttribute("instanceDistanceStart", new dn(i, 1, 0)), e.setAttribute("instanceDistanceEnd", new dn(i, 1, 1)), this;
}
raycast(e, t) {
let n = this.material.worldUnits, r = e.camera;
if (r === null && !n && console.error("LineSegments2: \"Raycaster.camera\" needs to be set in order to raycast against LineSegments2 while worldUnits is set to false."), n === !1 && (this.material.resolution.x === 0 || this.material.resolution.y === 0)) return;
let i = e.params.Line2 === void 0 ? 0 : e.params.Line2.threshold || 0;
Sx = e.ray;
let a = this.matrixWorld, o = this.geometry, s = this.material;
Cx = s.linewidth + i, o.boundingSphere === null && o.computeBoundingSphere(), bx.copy(o.boundingSphere).applyMatrix4(a);
let c;
if (c = n ? Cx * .5 : wx(r, Math.max(r.near, bx.distanceToPoint(Sx.origin)), s.resolution), bx.radius += c, Sx.intersectsSphere(bx) === !1) return;
o.boundingBox === null && o.computeBoundingBox(), yx.copy(o.boundingBox).applyMatrix4(a);
let l;
l = n ? Cx * .5 : wx(r, Math.max(r.near, yx.distanceToPoint(Sx.origin)), s.resolution), yx.expandByScalar(l), Sx.intersectsBox(yx) !== !1 && (n ? Tx(this, t) : Ex(this, r, t));
}
onBeforeRender(e) {
let t = this.material.uniforms;
t && t.resolution && (e.getViewport(lx), this.material.uniforms.resolution.value.set(lx.z, lx.w));
}
}, Ox = class extends V_ {
prepareInstance(e, t) {
e.getPointsAt(t, Ix, Lx), Fx.set([
Ix.x,
Ix.y,
Ix.z,
Lx.x,
Lx.y,
Lx.z
]), kx();
let n = e.getWidthAt(t);
return Px.linewidth = n < 0 ? e.material.linewidth : n, Px.worldUnits = e.material.worldUnits, Px.resolution.copy(e.material.resolution), Nx.matrixWorld.copy(e.matrixWorld), Nx;
}
};
function kx() {
var e, t;
let n = Nx.geometry, r = ((e = n.boundingBox) == null ? n.boundingBox = new ze() : e).makeEmpty();
r.expandByPoint(Ix).expandByPoint(Lx);
let i = (t = n.boundingSphere) == null ? n.boundingSphere = new vn() : t;
r.getCenter(i.center), i.radius = Ix.distanceTo(Lx) / 2;
}
function Ax() {
let e = new qb();
return e.setPositions(new Float32Array(Mx)), e;
}
function jx(e) {
return e.getAttribute("instanceStart").data.array;
}
var Mx = 6, Nx = new Dx(Ax(), new Wb()), Px = Nx.material, Fx = jx(Nx.geometry), Ix = new U(), Lx = new U(), Rx = le(class extends G_ {
constructor(e = {}) {
super(e), this.isBatchedLines = !0, this.geometry = new qb(), this.material = new Wb(), this.sortObjects = !0, this.raycasting = new Ox(), this.culling = new Jb(), this.addUniforms({ vertex: {
[$b]: "vec3",
[ex]: "vec3",
[tx]: "float"
} });
}
getPointsAt(e, t, n) {
this.getUniformAt(e, $b, t), this.getUniformAt(e, ex, n);
}
setPointsAt(e, t, n) {
this.setUniformAt(e, $b, Ux.set(t.x, t.y, t.z)), this.setUniformAt(e, ex, Wx.set(n.x, n.y, n.z)), this.invalidateBounds();
}
getWidthAt(e) {
return this.getUniformAt(e, tx);
}
setWidthAt(e, t) {
this.setUniformAt(e, tx, t);
}
getBoundingSphereAt(e, t) {
return this.getPointsAt(e, Ux, Wx), t.center.addVectors(Ux, Wx).multiplyScalar(.5), t.radius = Ux.distanceTo(Wx) / 2, t;
}
getBoundingBoxAt(e, t) {
return this.getPointsAt(e, Ux, Wx), t.makeEmpty().expandByPoint(Ux).expandByPoint(Wx);
}
dispose() {
super.dispose(), this.geometry.dispose();
}
resetInstance(e) {
super.resetInstance(e), this.setPointsAt(e, Hx, Hx), this.setWidthAt(e, Bx), this.setColorAt(e, Vx);
}
onBeforeRender(e, t, n, r, i, a) {
e.getViewport(Gx), this.material.resolution.set(Gx.z, Gx.w), super.onBeforeRender(e, t, n, r, i, a);
}
patchMaterial(e) {
if (!zx(e)) return super.patchMaterial(e);
let t = nx(e), n = super.patchMaterial(e);
return () => {
n(), t();
};
}
});
function zx(e) {
return e.isLineMaterial === !0;
}
var Bx = -1, Vx = new _n(1, 1, 1, 1), Hx = new U(), Ux = new U(), Wx = new U(), Gx = new _n(), Kx = 255, qx = le(Wb);
function Jx(e) {
var t, n;
let r = (0, Z.c)(6), i = (t = e.color) == null ? "white" : t, a = (n = e.width) == null ? 1 : n, o = Yh(), s = gh(), c;
r[0] === Symbol.for("react.memo_cache_sentinel") ? (c = function(e) {
e.clearStencil();
}, r[0] = c) : c = r[0];
let l = c, u = s ? Vg : null, d;
return r[1] !== i || r[2] !== o || r[3] !== u || r[4] !== a ? (d = /* @__PURE__ */ (0, K.jsx)(qx, {
...Bg,
...u,
color: i,
linewidth: a,
stencilWrite: !0,
stencilFunc: 517,
stencilZPass: _t,
stencilRef: Kx,
onBeforeRender: l,
onBeforeCompile: o
}), r[1] = i, r[2] = o, r[3] = u, r[4] = a, r[5] = d) : d = r[5], d;
}
//#endregion
//#region ../renderer/src/objects/lines/line-container.ts
var Yx = class extends yy {
constructor(e) {
super({ reverse: !0 }), this.args = void 0, this.args = [{ capacity: Math.max(e.length, 1) }];
}
addInstance() {
let e = -1;
return this.mesh.addInstances(1, (t) => {
e = t;
}), e;
}
removeInstance(e) {
this.mesh.removeInstances(e);
}
}, Xx = $c("line-instance"), Zx = (0, G.memo)(function(e) {
let t = (0, Z.c)(3), { def: n, container: r } = e, i;
return t[0] !== r || t[1] !== n ? (i = (e) => {
Qx(r, e, n), ly(r.mesh, e, n, Xx), $x(r, e, n);
}, t[0] = r, t[1] = n, t[2] = i) : i = t[2], Sv(r, n, null, i), null;
});
function Qx(e, t, n) {
let { p0: r, p1: i, elevation: a = 0 } = n.points;
eS.set(r.x, r.y, a), tS.set(i.x, i.y, a), e.mesh.getPointsAt(t, nS, rS), !(nS.equals(eS) && rS.equals(tS)) && e.mesh.setPointsAt(t, eS, tS);
}
function $x(e, t, n) {
let r = Math.max(n.width, 0);
e.mesh.getWidthAt(t) !== r && e.mesh.setWidthAt(t, r);
}
var eS = new U(), tS = new U(), nS = new U(), rS = new U();
//#endregion
//#region ../renderer/src/objects/lines/Lines.tsx
function iS(e) {
var t;
let n = (0, Z.c)(18), { defs: r } = e, i = (t = e.mounted) == null ? r.length : t, a;
n[0] === r ? a = n[1] : (a = () => new Yx(r), n[0] = r, n[1] = a);
let o = bv(a, r), s;
n[2] === o ? s = n[3] : (s = (e) => o.bind(e), n[2] = o, n[3] = s);
let c;
n[4] === Symbol.for("react.memo_cache_sentinel") ? (c = /* @__PURE__ */ (0, K.jsx)(Jx, {}), n[4] = c) : c = n[4];
let l;
n[5] !== o.args || n[6] !== o.customSort || n[7] !== s ? (l = /* @__PURE__ */ (0, K.jsx)(Rx, {
args: o.args,
ref: s,
customSort: o.customSort,
children: c
}), n[5] = o.args, n[6] = o.customSort, n[7] = s, n[8] = l) : l = n[8];
let u;
if (n[9] !== o || n[10] !== r || n[11] !== i) {
let e;
n[13] === o ? e = n[14] : (e = (e) => /* @__PURE__ */ (0, K.jsx)(Zx, {
def: e,
container: o
}, Ov(e)), n[13] = o, n[14] = e), u = r.slice(0, i).map(e), n[9] = o, n[10] = r, n[11] = i, n[12] = u;
} else u = n[12];
let d;
return n[15] !== l || n[16] !== u ? (d = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [l, u] }), n[15] = l, n[16] = u, n[17] = d) : d = n[17], d;
}
//#endregion
//#region ../renderer/src/utils/arrays.ts
function aS(e, t) {
if (e.length !== t.length) return !1;
for (let n = 0; n < e.length; n++) if (e[n] !== t[n]) return !1;
return !0;
}
//#endregion
//#region ../renderer/src/objects/lighting/occluder.ts
function oS() {
let e = (0, Z.c)(2), t = Tg(), n = (0, G.useRef)(null), r;
return e[0] === t.occluders ? r = e[1] : (r = (e) => sS(t.occluders, n, e), e[0] = t.occluders, e[1] = r), r;
}
function sS(e, t, n) {
t.current !== n && (t.current && e.delete(t.current), t.current = n, n && (n.layers.enable(1), e.add(n)));
}
//#endregion
//#region ../renderer/src/objects/models/model-opacity.ts
var cS = { value: 1 };
function lS() {
return (0, G.useSyncExternalStore)(fS, uS);
}
function uS() {
return cS.value;
}
function dS(e) {
if (e !== cS.value) {
cS.value = e;
for (let e of pS) e();
}
}
function fS(e) {
return pS.add(e), () => {
pS.delete(e);
};
}
var pS = /* @__PURE__ */ new Set();
//#endregion
//#region ../renderer/src/objects/materials/ModelMaterial.tsx
function mS(e) {
var t;
let n = (0, Z.c)(11), { source: r, opacityUniform: i } = e, a = Yh(), o = Tg(), s = (t = e.translucent) != null && t, c;
n[0] !== a || n[1] !== o || n[2] !== i || n[3] !== r || n[4] !== s ? (c = () => hS(r.clone(), i, a, o, s), n[0] = a, n[1] = o, n[2] = i, n[3] = r, n[4] = s, n[5] = c) : c = n[5];
let [l] = (0, G.useState)(c), u, d;
n[6] === l ? (u = n[7], d = n[8]) : (u = () => () => l.dispose(), d = [l], n[6] = l, n[7] = u, n[8] = d), (0, G.useEffect)(u, d);
let f;
return n[9] === l ? f = n[10] : (f = /* @__PURE__ */ (0, K.jsx)("primitive", {
object: l,
attach: "material"
}), n[9] = l, n[10] = f), f;
}
function hS(e, t, n, r, i) {
e.depthFunc = 3, e.polygonOffset = !1, e.transparent = e.transparent || i || e.opacity < 1, e.depthWrite = !0;
let a = e.onBeforeCompile.bind(e);
return e.onBeforeCompile = (e, ...i) => {
a(e, ...i), e.uniforms[gS] = cS, e.fragmentShader = lh(e.fragmentShader, `uniform float ${gS};`).replace("#include <dithering_fragment>", `
#include <dithering_fragment>
gl_FragColor.a *= ${t} < 0. ? ${gS} : ${t};
`.trim()), cg(e, r), Ih(e, r), Ag(e, r), n(e);
}, e.needsUpdate = !0, e;
}
var gS = "uDefaultModelOpacity", _S = (function() {
var e = "b9H79Tebbbe8Fv9Gbb9Gvuuuuueu9Giuuub9Geueu9Giuuueuixkbeeeddddillviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbeY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVbdE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbiL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtblK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WboY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbrl79IV9Rbwq:VZkdbk:XYi5ud9:du8Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaicefhxcj;abad9Uc;WFbGcjdadca0EhmaialfgPar9Rgoadfhsavaoadz:jjjjbgzceVhHcbhOdndninaeaO9nmeaPax9RaD6mdamaeaO9RaOamfgoae6EgAcsfglc9WGhCabaOad2fhXaAcethQaxaDfhiaOaeaoaeao6E9RhLalcl4cifcd4hKazcj;cbfaAfhYcbh8AazcjdfhEaHh3incbh5dnawTmbaxa8Acd4fRbbh5kcbh8Eazcj;cbfhqinaih8Fdndndndna5a8Ecet4ciGgoc9:fPdebdkaPa8F9RaA6mrazcj;cbfa8EaA2fa8FaAz:jjjjb8Aa8FaAfhixdkazcj;cbfa8EaA2fcbaAz:kjjjb8Aa8FhixekaPa8F9RaK6mva8FaKfhidnaCTmbaPai9RcK6mbaocdtc:q:G:cjbfcj:G:cjbawEhaczhrcbhlinargoc9Wfghaqfhrdndndndndndnaaa8Fahco4fRbbalcoG4ciGcdtfydbPDbedvivvvlvkar9cb83bwar9cb83bbxlkarcbaiRbdai8Xbb9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbaqaofgrcGfcbaicdfa8J9c8N1:NfghRbbag9cjjjjjw:dg8J9qE86bbarcVfcbaha8J9c8M1:NfghRbbag9cjjjjjl:dg8J9qE86bbarc7fcbaha8J9c8L1:NfghRbbag9cjjjjjd:dg8J9qE86bbarctfcbaha8J9c8K1:NfghRbbag9cjjjjje:dg8J9qE86bbarc91fcbaha8J9c8J1:NfghRbbag9cjjjj;ab:dg8J9qE86bbarc4fcbaha8J9cg1:NfghRbbag9cjjjja:dg8J9qE86bbarc93fcbaha8J9ch1:NfghRbbag9cjjjjz:dgg9qE86bbarc94fcbahag9ca1:NfghRbbai8Xbe9c:c:qj:bw9:9c:q;c1:I1e:d9c:b:c:e1z9:gg9cjjjjjz:dg8J9qE86bbarc95fcbaha8J9c8N1:NfgiRbbag9cjjjjjw:dg8J9qE86bbarc96fcbaia8J9c8M1:NfgiRbbag9cjjjjjl:dg8J9qE86bbarc97fcbaia8J9c8L1:NfgiRbbag9cjjjjjd:dg8J9qE86bbarc98fcbaia8J9c8K1:NfgiRbbag9cjjjjje:dg8J9qE86bbarc99fcbaia8J9c8J1:NfgiRbbag9cjjjj;ab:dg8J9qE86bbarc9:fcbaia8J9cg1:NfgiRbbag9cjjjja:dg8J9qE86bbarcufcbaia8J9ch1:NfgiRbbag9cjjjjz:dgg9qE86bbaiag9ca1:NfhixikaraiRblaiRbbghco4g8Ka8KciSg8KE86bbaqaofgrcGfaiclfa8Kfg8KRbbahcl4ciGg8La8LciSg8LE86bbarcVfa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc7fa8Ka8Lfg8KRbbahciGghahciSghE86bbarctfa8Kahfg8KRbbaiRbeghco4g8La8LciSg8LE86bbarc91fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc4fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc93fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc94fa8Kahfg8KRbbaiRbdghco4g8La8LciSg8LE86bbarc95fa8Ka8Lfg8KRbbahcl4ciGg8La8LciSg8LE86bbarc96fa8Ka8Lfg8KRbbahcd4ciGg8La8LciSg8LE86bbarc97fa8Ka8Lfg8KRbbahciGghahciSghE86bbarc98fa8KahfghRbbaiRbigico4g8Ka8KciSg8KE86bbarc99faha8KfghRbbaicl4ciGg8Ka8KciSg8KE86bbarc9:faha8KfghRbbaicd4ciGg8Ka8KciSg8KE86bbarcufaha8KfgrRbbaiciGgiaiciSgiE86bbaraifhixdkaraiRbwaiRbbghcl4g8Ka8KcsSg8KE86bbaqaofgrcGfaicwfa8Kfg8KRbbahcsGghahcsSghE86bbarcVfa8KahfghRbbaiRbeg8Kcl4g8La8LcsSg8LE86bbarc7faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarctfaha8KfghRbbaiRbdg8Kcl4g8La8LcsSg8LE86bbarc91faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc4faha8KfghRbbaiRbig8Kcl4g8La8LcsSg8LE86bbarc93faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc94faha8KfghRbbaiRblg8Kcl4g8La8LcsSg8LE86bbarc95faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc96faha8KfghRbbaiRbvg8Kcl4g8La8LcsSg8LE86bbarc97faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc98faha8KfghRbbaiRbog8Kcl4g8La8LcsSg8LE86bbarc99faha8LfghRbba8KcsGg8Ka8KcsSg8KE86bbarc9:faha8KfghRbbaiRbrgicl4g8Ka8KcsSg8KE86bbarcufaha8KfgrRbbaicsGgiaicsSgiE86bbaraifhixekarai8Pbw83bwarai8Pbb83bbaiczfhikdnaoaC9pmbalcdfhlaoczfhraPai9RcL0mekkaoaC6moaimexokaCmva8FTmvkaqaAfhqa8Ecefg8Ecl9hmbkdndndndnawTmbasa8Acd4fRbbgociGPlbedrbkaATmdaza8Afh8Fazcj;cbfhhcbh8EaEhaina8FRbbhraahocbhlinaoahalfRbbgqce4cbaqceG9R7arfgr86bbaoadfhoaAalcefgl9hmbkaacefhaa8Fcefh8FahaAfhha8Ecefg8Ecl9hmbxikkaATmeaza8Afhaazcj;cbfhhcbhoceh8EaYh8FinaEaofhlaa8Vbbhrcbhoinala8FaofRbbcwtahaofRbbgqVc;:FiGce4cbaqceG9R7arfgr87bbaladfhlaLaocefgofmbka8FaQfh8FcdhoaacdfhaahaQfhha8EceGhlcbh8EalmbxdkkaATmbaocl4h8Eaza8AfRbbhqcwhoa3hlinalRbbaotaqVhqalcefhlaocwfgoca9hmbkcbhhaEh8FaYhainazcj;cbfahfRbbhrcwhoaahlinalRbbaotarVhralaAfhlaocwfgoca9hmbkara8E94aq7hqcbhoa8Fhlinalaqao486bbalcefhlaocwfgoca9hmbka8Fadfh8FaacefhaahcefghaA9hmbkkaEclfhEa3clfh3a8Aclfg8Aad6mbkaXazcjdfaAad2z:jjjjb8AazazcjdfaAcufad2fadz:jjjjb8AaAaOfhOaihxaimbkc9:hoxdkcbc99aPax9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaok:ysezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecjez:kjjjb8Aav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk:Lvoeue99dud99eud99dndnadcl9hmbaeTmeindndnabcdfgd8Sbb:Yab8Sbbgi:Ygl:l:tabcefgv8Sbbgo:Ygr:l:tgwJbb;:9cawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai86bbdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad86bbdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad86bbabclfhbaecufgembxdkkaeTmbindndnabclfgd8Ueb:Yab8Uebgi:Ygl:l:tabcdfgv8Uebgo:Ygr:l:tgwJb;:FSawawNJbbbbawawJbbbb9GgDEgq:mgkaqaicb9iEalMgwawNakaqaocb9iEarMgqaqNMM:r:vglNJbbbZJbbb:;aDEMgr:lJbbb9p9DTmbar:Ohixekcjjjj94hikadai87ebdndnaqalNJbbbZJbbb:;aqJbbbb9GEMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkavad87ebdndnawalNJbbbZJbbb:;awJbbbb9GEMgw:lJbbb9p9DTmbaw:Ohdxekcjjjj94hdkabad87ebabcwfhbaecufgembkkk:4ioiue99dud99dud99dnaeTmbcbhiabhlindndnal8Uebgv:YgoJ:ji:1Salcof8UebgrciVgw:Y:vgDNJbbbZJbbb:;avcu9kEMgq:lJbbb9p9DTmbaq:Ohkxekcjjjj94hkkalclf8Uebhvalcdf8UebhxalarcefciGcetfak87ebdndnax:YgqaDNJbbbZJbbb:;axcu9kEMgm:lJbbb9p9DTmbam:Ohxxekcjjjj94hxkabaiarciGgkfcd7cetfax87ebdndnav:YgmaDNJbbbZJbbb:;avcu9kEMgP:lJbbb9p9DTmbaP:Ohvxekcjjjj94hvkalarcufciGcetfav87ebdndnawaw2:ZgPaPMaoaoN:taqaqN:tamamN:tgoJbbbbaoJbbbb9GE:raDNJbbbZMgD:lJbbb9p9DTmbaD:Ohrxekcjjjj94hrkalakcetfar87ebalcwfhlaiclfhiaecufgembkkk9mbdnadcd4ae2gdTmbinababydbgecwtcw91:Yaece91cjjj98Gcjjj;8if::NUdbabclfhbadcufgdmbkkk:Tvirud99eudndnadcl9hmbaeTmeindndnabRbbgiabcefgl8Sbbgvabcdfgo8Sbbgrf9R:YJbbuJabcifgwRbbgdce4adVgDcd4aDVgDcl4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax86bbdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao86bbdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai86bbdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad86bbabclfhbaecufgembxdkkaeTmbindndnab8Vebgiabcdfgl8Uebgvabclfgo8Uebgrf9R:YJbFu9habcofgw8Vebgdce4adVgDcd4aDVgDcl4aDVgDcw4aDVgD:Z:vgqNJbbbZMgk:lJbbb9p9DTmbak:Ohxxekcjjjj94hxkaoax87ebdndnaraif:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohoxekcjjjj94hokalao87ebdndnavaifar9R:YaqNJbbbZMgk:lJbbb9p9DTmbak:Ohixekcjjjj94hikabai87ebdndnaDadcetGadceGV:ZaqNJbbbZMgq:lJbbb9p9DTmbaq:Ohdxekcjjjj94hdkawad87ebabcwfhbaecufgembkkk9teiucbcbyd:K:G:cjbgeabcifc98GfgbBd:K:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaik;LeeeudndnaeabVciGTmbabhixekdndnadcz9pmbabhixekabhiinaiaeydbBdbaiclfaeclfydbBdbaicwfaecwfydbBdbaicxfaecxfydbBdbaeczfheaiczfhiadc9Wfgdcs0mbkkadcl6mbinaiaeydbBdbaeclfheaiclfhiadc98fgdci0mbkkdnadTmbinaiaeRbb86bbaicefhiaecefheadcufgdmbkkabk;aeedudndnabciGTmbabhixekaecFeGc:b:c:ew2hldndnadcz9pmbabhixekabhiinaialBdbaicxfalBdbaicwfalBdbaiclfalBdbaiczfhiadc9Wfgdcs0mbkkadcl6mbinaialBdbaiclfhiadc98fgdci0mbkkdnadTmbinaiae86bbaicefhiadcufgdmbkkabkk83dbcj:Gdk8Kbbbbdbbblbbbwbbbbbbbebbbdbbblbbbwbbbbc:K:Gdkl8W:qbb", t = "b9H79TebbbeKl9Gbb9Gvuuuuueu9Giuuub9Geueuixkbbebeeddddilve9Weeeviebeoweuecj:Gdkr;Neqo9TW9T9VV95dbH9F9F939H79T9F9J9H229F9Jt9VV7bb8A9TW79O9V9Wt9F9KW9J9V9KW9wWVtW949c919M9MWVbdY9TW79O9V9Wt9F9KW9J9V9KW69U9KW949c919M9MWVblE9TW79O9V9Wt9F9KW9J9V9KW69U9KW949tWG91W9U9JWbvL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9p9JtboK9TW79O9V9Wt9F9KW9J9V9KWS9P2tWV9r919HtbrL9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVT949WbwY9TW79O9V9Wt9F9KW9J9V9KWS9P2tWVJ9V29VVbDl79IV9Rbqq:W9Dklbzik94evu8Jjjjjbcz9Rhbcbheincbhdcbhiinabcwfadfaicjuaead4ceGglE86bbaialfhiadcefgdcw9hmbkaeai86b:q:W:cjbaecitab8Piw83i:q:G:cjbaecefgecjd9hmbkk:JBl8Aud97dur978Jjjjjbcj;kb9Rgv8Kjjjjbc9:hodnalTmbcuhoaiRbbgrc;WeGc:Ge9hmbarcsGgwce0mbc9:hoalcufadcd4cbawEgDadfgrcKcaawEgqaraq0Egk6mbaialfgxar9RhodnadTgmmbavaoad;8qbbkaicefhPcj;abad9Uc;WFbGcjdadca0EhsdndndnadTmbaoadfhzcbhHinaeaH9nmdaxaP9RaD6miabaHad2fhOaPaDfhAasaeaH9RaHasfae6EgCcsfgocl4cifcd4hXavcj;cbfaoc9WGgQcetfhLavcj;cbfaQci2fhKavcj;cbfaQfhYcbh8Aaoc;ab6hEincbh3dnawTmbaPa8Acd4fRbbh3kcbh5avcj;cbfh8Eindndndndna3a5cet4ciGgoc9:fPdebdkaxaA9RaQ6mwdnaQTmbavcj;cbfa5aQ2faAaQ;8qbbkaAaCfhAxdkaQTmeavcj;cbfa5aQ2fcbaQ;8kbxekaxaA9RaX6moaoclVcbawEhraAaXfhocbhidnaEmbaxao9Rc;Gb6mbcbhlina8EalfhidndndndndndnaAalco4fRbbgqciGarfPDbedibledibkaipxbbbbbbbbbbbbbbbbpklbxlkaiaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiaopbbbpklbaoczfhoxekaiaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcd4ciGarfPDbedibledibkaiczfpxbbbbbbbbbbbbbbbbpklbxlkaiczfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaiczfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaiczfaopbbbpklbaoczfhoxekaiczfaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqcl4ciGarfPDbedibledibkaicafpxbbbbbbbbbbbbbbbbpklbxlkaicafaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaoclffagRb:q:W:cjbfhoxikaicafaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbahaocwffagRb:q:W:cjbfhoxdkaicafaopbbbpklbaoczfhoxekaicafaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbahaocdffagRb:q:W:cjbfhokdndndndndndnaqco4arfPDbedibledibkaic8Wfpxbbbbbbbbbbbbbbbbpklbxlkaic8Wfaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaoclffaqRb:q:W:cjbfhoxikaic8Wfaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Ngicitpbi:q:G:cjbaiRb:q:W:cjbgipsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Ngqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spklbaiaocwffaqRb:q:W:cjbfhoxdkaic8Wfaopbbbpklbaoczfhoxekaic8WfaopbbdaoRbbgicitpbi:q:G:cjbaiRb:q:W:cjbgipsaoRbegqcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpklbaiaocdffaqRb:q:W:cjbfhokalc;abfhialcjefaQ0meaihlaxao9Rc;Fb0mbkkdnaiaQ9pmbaici4hlinaxao9RcK6mwa8EaifhqdndndndndndnaAaico4fRbbalcoG4ciGarfPDbedibledibkaqpxbbbbbbbbbbbbbbbbpkbbxlkaqaopbblaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLg8Fcdp:mea8FpmbzeHdOiAlCvXoQrLpxiiiiiiiiiiiiiiiip9ogapxiiiiiiiiiiiiiiiip8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaoclffagRb:q:W:cjbfhoxikaqaopbbwaopbbbg8Fclp:mea8FpmbzeHdOiAlCvXoQrLpxssssssssssssssssp9ogapxssssssssssssssssp8Jg8Fp5b9cjF;8;4;W;G;ab9:9cU1:Nghcitpbi:q:G:cjbahRb:q:W:cjbghpsa8Fp5e9cjF;8;4;W;G;ab9:9cU1:Nggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPaaa8Fp9spkbbahaocwffagRb:q:W:cjbfhoxdkaqaopbbbpkbbaoczfhoxekaqaopbbdaoRbbghcitpbi:q:G:cjbahRb:q:W:cjbghpsaoRbeggcitpbi:q:G:cjbp9UpmbedilvorzHOACXQLpPpkbbahaocdffagRb:q:W:cjbfhokalcdfhlaiczfgiaQ6mbkkaohAaoTmoka8EaQfh8Ea5cefg5cl9hmbkdndndndnawTmbaza8Acd4fRbbglciGPlbedwbkaQTmdavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep9Ta8Fpxeeeeeeeeeeeeeeeegap9op9Hp9rg8Fa8Jp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ug8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp9Ug8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep9Ta8Faap9op9Hp9rg8Fp9Ugap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp9Ugap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp9Ugap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp9Ug8Jp9AbbbaladfhlaoczfgoaQ6mbxikkaQTmeavcjdfa8Afhlava8Afpbdbh8Jcbhoinalavcj;cbfaofpblbg8KaYaofpblbg8LpmbzeHdOiAlCvXoQrLg8MaLaofpblbg8NaKaofpblbgypmbzeHdOiAlCvXoQrLg8PpmbezHdiOAlvCXorQLg8Fcep:nea8Fpxebebebebebebebebgap9op:bep9rg8Fa8Jp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ma8PpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwKDYq8AkEx3m5P8Es8Fg8Ka8NaypmwKDYq8AkEx3m5P8Es8Fg8LpmbezHdiOAlvCXorQLg8Fcep:nea8Faap9op:bep9rg8Fp:oeg8Jp9Abbbaladfgla8Ja8Fa8Fpmlvorlvorlvorlvorp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmwDqkwDqkwDqkwDqkp:oeg8Jp9Abbbaladfgla8Ja8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9Abbbaladfgla8Ja8Ka8LpmwDKYqk8AExm35Ps8E8Fg8Fcep:nea8Faap9op:bep9rg8Fp:oegap9Abbbaladfglaaa8Fa8Fpmlvorlvorlvorlvorp:oegap9Abbbaladfglaaa8Fa8FpmwDqkwDqkwDqkwDqkp:oegap9Abbbaladfglaaa8Fa8FpmxmPsxmPsxmPsxmPsp:oeg8Jp9AbbbaladfhlaoczfgoaQ6mbxdkkaQTmbcbhocbalcl4gl9Rc8FGhiavcjdfa8Afhrava8Afpbdbhainaravcj;cbfaofpblbg8JaYaofpblbg8KpmbzeHdOiAlCvXoQrLg8LaLaofpblbg8MaKaofpblbg8NpmbzeHdOiAlCvXoQrLgypmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Faap9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8LaypmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwKDYq8AkEx3m5P8Es8Fg8Ja8Ma8NpmwKDYq8AkEx3m5P8Es8Fg8KpmbezHdiOAlvCXorQLg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9Abbbaradfgraaa8Ja8KpmwDKYqk8AExm35Ps8E8Fg8Faip:Rea8Falp:Tep9qg8Fp9rgap9Abbbaradfgraaa8Fa8Fpmlvorlvorlvorlvorp9rgap9Abbbaradfgraaa8Fa8FpmwDqkwDqkwDqkwDqkp9rgap9Abbbaradfgraaa8Fa8FpmxmPsxmPsxmPsxmPsp9rgap9AbbbaradfhraoczfgoaQ6mbkka8Aclfg8Aad6mbkdnaCad2goTmbaOavcjdfao;8qbbkdnammbavavcjdfaCcufad2fad;8qbbkaCaHfhHc9:hoaAhPaAmbxlkkaeTmbaDalfhrcbhocuhlinaralaD9RglfaD6mdasaeao9Raoasfae6Eaofgoae6mbkaial9RhPkcbc99axaP9RakSEhoxekc9:hokavcj;kbf8Kjjjjbaokwbz:bjjjbkNsezu8Jjjjjbc;ae9Rgv8Kjjjjbc9:hodnalaeci9UgrcHf6mbcuhoaiRbbgwc;WeGc;Ge9hmbawcsGgDce0mbavc;abfcFecje;8kbav9cu83iUav9cu83i8Wav9cu83iyav9cu83iaav9cu83iKav9cu83izav9cu83iwav9cu83ibaialfc9WfhqaicefgwarfhldnaeTmbcmcsaDceSEhkcbhxcbhmcbhrcbhicbhoindnalaq9nmbc9:hoxikdndnawRbbgDc;Ve0mbavc;abfaoaDcu7gPcl4fcsGcitfgsydlhzasydbhHdndnaDcsGgsak9pmbavaiaPfcsGcdtfydbaxasEhDaxasTgOfhxxekdndnascsSmbcehOasc987asamffcefhDxekalcefhDal8SbbgscFeGhPdndnascu9mmbaDhlxekalcvfhlaPcFbGhPcrhsdninaD8SbbgOcFbGastaPVhPaOcu9kmeaDcefhDascrfgsc8J9hmbxdkkaDcefhlkcehOaPce4cbaPceG9R7amfhDkaDhmkavc;abfaocitfgsaDBdbasazBdlavaicdtfaDBdbavc;abfaocefcsGcitfgsaHBdbasaDBdlaocdfhoaOaifhidnadcd9hmbabarcetfgsaH87ebasclfaD87ebascdfaz87ebxdkabarcdtfgsaHBdbascwfaDBdbasclfazBdbxekdnaDcpe0mbavaiaqaDcsGfRbbgscl4gP9RcsGcdtfydbaxcefgOaPEhDavaias9RcsGcdtfydbaOaPTgzfgOascsGgPEhsaPThPdndnadcd9hmbabarcetfgHax87ebaHclfas87ebaHcdfaD87ebxekabarcdtfgHaxBdbaHcwfasBdbaHclfaDBdbkavaicdtfaxBdbavc;abfaocitfgHaDBdbaHaxBdlavaicefgicsGcdtfaDBdbavc;abfaocefcsGcitfgHasBdbaHaDBdlavaiazfgicsGcdtfasBdbavc;abfaocdfcsGcitfgDaxBdbaDasBdlaocifhoaiaPfhiaOaPfhxxekaxcbalRbbgsEgHaDc;:eSgDfhOascsGhAdndnascl4gCmbaOcefhzxekaOhzavaiaC9RcsGcdtfydbhOkdndnaAmbazcefhxxekazhxavaias9RcsGcdtfydbhzkdndnaDTmbalcefhDxekalcdfhDal8SbegPcFeGhsdnaPcu9kmbalcofhHascFbGhscrhldninaD8SbbgPcFbGaltasVhsaPcu9kmeaDcefhDalcrfglc8J9hmbkaHhDxekaDcefhDkasce4cbasceG9R7amfgmhHkdndnaCcsSmbaDhsxekaDcefhsaD8SbbglcFeGhPdnalcu9kmbaDcvfhOaPcFbGhPcrhldninas8SbbgDcFbGaltaPVhPaDcu9kmeascefhsalcrfglc8J9hmbkaOhsxekascefhskaPce4cbaPceG9R7amfgmhOkdndnaAcsSmbashlxekascefhlas8SbbgDcFeGhPdnaDcu9kmbascvfhzaPcFbGhPcrhDdninal8SbbgscFbGaDtaPVhPascu9kmealcefhlaDcrfgDc8J9hmbkazhlxekalcefhlkaPce4cbaPceG9R7amfgmhzkdndnadcd9hmbabarcetfgDaH87ebaDclfaz87ebaDcdfaO87ebxekabarcdtfgDaHBdbaDcwfazBdbaDclfaOBdbkavc;abfaocitfgDaOBdbaDaHBdlavaicdtfaHBdbavc;abfaocefcsGcitfgDazBdbaDaOBdlavaicefgicsGcdtfaOBdbavc;abfaocdfcsGcitfgDaHBdbaDazBdlavaiaCTaCcsSVfgicsGcdtfazBdbaiaATaAcsSVfhiaocifhokawcefhwaocsGhoaicsGhiarcifgrae6mbkkcbc99alaqSEhokavc;aef8Kjjjjbaok:clevu8Jjjjjbcz9Rhvdnalaecvf9pmbc9:skdnaiRbbc;:eGc;qeSmbcuskav9cb83iwaicefhoaialfc98fhrdnaeTmbdnadcdSmbcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcdtfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgiBdbalaiBdbawcefgwae9hmbxdkkcbhwindnaoar6mbc9:skaocefhlao8SbbgicFeGhddndnaicu9mmbalhoxekaocvfhoadcFbGhdcrhidninal8SbbgDcFbGaitadVhdaDcu9kmealcefhlaicrfgic8J9hmbxdkkalcefhokabawcetfadc8Etc8F91adcd47avcwfadceGcdtVglydbfgi87ebalaiBdbawcefgwae9hmbkkcbc99aoarSEk;Toio97eue97aec98Ghedndnadcl9hmbaeTmecbhdinababpbbbgicKp:RecKp:Sep;6eglaicwp:RecKp:Sep;6ealp;Geaiczp:RecKp:Sep;6egvp;Gep;Kep;Legopxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgwp9op9rp;Keglpxbb;:9cbb;:9cbb;:9cbb;:9calalp;Meaoaop;Meavaravawp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFbbbFbbbFbbbFbbbp9oaipxbbbFbbbFbbbFbbbFp9op9qalavp;Mearp;Kecwp:RepxbFbbbFbbbFbbbFbbp9op9qaoavp;Mearp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgDaDpbbbgipxbbbbbbFFbbbbbbFFgwp9oabpbbbgoaipmbediwDqkzHOAKY8AEgvczp:Reczp:Sep;6eglaoaipmlvorxmPsCXQL358E8FpxFubbFubbFubbFubbp9op;6eavczp:Sep;6egvp;Gealp;Gep;Kep;Legipxbbbbbbbbbbbbbbbbp:2egralpxbbbjbbbjbbbjbbbjgqp9op9rp;Keglpxb;:FSb;:FSb;:FSb;:FSalalp;Meaiaip;Meavaravaqp9op9rp;Keglalp;Mep;Kep;Kep;Jep;Negvp;Mepxbbn0bbn0bbn0bbn0grp;KepxFFbbFFbbFFbbFFbbp9oaiavp;Mearp;Keczp:Rep9qgialavp;Mearp;KepxFFbbFFbbFFbbFFbbp9oglpmwDKYqk8AExm35Ps8E8Fp9qpkbbabaoawp9oaialpmbezHdiOAlvCXorQLp9qpkbbabcafhbadclfgdae6mbkkk;2ileue97euo97dnaec98GgiTmbcbheinabcKfpx:ji:1S:ji:1S:ji:1S:ji:1SabpbbbglabczfgvpbbbgopmlvorxmPsCXQL358E8Fgrczp:Segwpxibbbibbbibbbibbbp9qp;6egDp;NegqaDaDp;MegDaDp;KealaopmbediwDqkzHOAKY8AEgDczp:Reczp:Sep;6eglalp;MeaDczp:Sep;6egoaop;Mearczp:Reczp:Sep;6egrarp;Mep;Kep;Kep;Lepxbbbbbbbbbbbbbbbbp:4ep;Jep;Mepxbbn0bbn0bbn0bbn0gDp;KepxFFbbFFbbFFbbFFbbgkp9oaqaop;MeaDp;Keczp:Rep9qgoaqalp;MeaDp;Keakp9oaqarp;MeaDp;Keczp:Rep9qgDpmwDKYqk8AExm35Ps8E8Fglp5eawclp:RegqpEi:T:j83ibavalp5baqpEd:T:j83ibabcwfaoaDpmbezHdiOAlvCXorQLgDp5eaqpEe:T:j83ibabaDp5baqpEb:T:j83ibabcafhbaeclfgeai6mbkkkuee97dnadcd4ae2c98GgeTmbcbhdinababpbbbgicwp:Recwp:Sep;6eaicep:SepxbbjFbbjFbbjFbbjFp9opxbbjZbbjZbbjZbbjZp:Uep;Mepkbbabczfhbadclfgdae6mbkkk:Sodw97euaec98Ghedndnadcl9hmbaeTmecbhdinabpxbbuJbbuJbbuJbbuJabpbbbgicKp:TeglaicYp:Tep9qgvcdp:Teavp9qgvclp:Teavp9qgop;6ep;Negvaicwp:RecKp:SegraipxFbbbFbbbFbbbFbbbgwp9ogDp:Uep;6ep;Mepxbbn0bbn0bbn0bbn0gqp;Kecwp:RepxbFbbbFbbbFbbbFbbp9oavaDarp:Xeaiczp:RecKp:Segip:Uep;6ep;Meaqp;Keawp9op9qavaDaraip:Uep:Xep;6ep;Meaqp;Keczp:RepxbbFbbbFbbbFbbbFbp9op9qavaoalcep:Rep9oalpxebbbebbbebbbebbbp9op9qp;6ep;Meaqp;KecKp:Rep9qpkbbabczfhbadclfgdae6mbxdkkaeTmbcbhdinabczfgkpxbFu9hbFu9hbFu9hbFu9habpbbbglakpbbbgrpmlvorxmPsCXQL358E8Fgvczp:TegqavcHp:Tep9qgicdp:Teaip9qgiclp:Teaip9qgicwp:Teaip9qgop;6ep;NegialarpmbediwDqkzHOAKY8AEgDpxFFbbFFbbFFbbFFbbglp9ograDczp:Segwp:Ueavczp:Reczp:SegDp:Xep;6ep;Mepxbbn0bbn0bbn0bbn0gvp;Kealp9oaiarawaDp:Uep:Xep;6ep;Meavp;Keczp:Rep9qgwaiaoaqcep:Rep9oaqpxebbbebbbebbbebbbp9op9qp;6ep;Meavp;Keczp:ReaiaDarp:Uep;6ep;Meavp;Kealp9op9qgipmwDKYqk8AExm35Ps8E8FpkbbabawaipmbezHdiOAlvCXorQLpkbbabcafhbadclfgdae6mbkkk9teiucbcbydj:G:cjbgeabcifc98GfgbBdj:G:cjbdndnabZbcztgd9nmbcuhiabad9RcFFifcz4nbcuSmekaehikaikkxebcj:Gdklz:zbb", n = new Uint8Array([
0,
97,
115,
109,
1,
0,
0,
0,
1,
4,
1,
96,
0,
0,
3,
3,
2,
0,
0,
5,
3,
1,
0,
1,
12,
1,
0,
10,
22,
2,
12,
0,
65,
0,
65,
0,
65,
0,
252,
10,
0,
0,
11,
7,
0,
65,
0,
253,
15,
26,
11
]), r = new Uint8Array([
32,
0,
65,
2,
1,
106,
34,
33,
3,
128,
11,
4,
13,
64,
6,
253,
10,
7,
15,
116,
127,
5,
8,
12,
40,
16,
19,
54,
20,
9,
27,
255,
113,
17,
42,
67,
24,
23,
146,
148,
18,
14,
22,
45,
70,
69,
56,
114,
101,
21,
25,
63,
75,
136,
108,
28,
118,
29,
73,
115
]);
if (typeof WebAssembly != "object") return { supported: !1 };
var i = WebAssembly.validate(n) ? s(t) : s(e), a, o = WebAssembly.instantiate(i, {}).then(function(e) {
a = e.instance, a.exports.__wasm_call_ctors();
});
function s(e) {
for (var t = new Uint8Array(e.length), n = 0; n < e.length; ++n) {
var i = e.charCodeAt(n);
t[n] = i > 96 ? i - 97 : i > 64 ? i - 39 : i + 4;
}
for (var a = 0, n = 0; n < e.length; ++n) t[a++] = t[n] < 60 ? r[t[n]] : (t[n] - 60) * 64 + t[++n];
return t.buffer.slice(0, a);
}
function c(e, t, n, r, i, a, o) {
var s = e.exports.sbrk, c = r + 3 & -4, l = s(c * i), u = s(a.length), d = new Uint8Array(e.exports.memory.buffer);
d.set(a, u);
var f = t(l, r, i, u, a.length);
if (f == 0 && o && o(l, c, i), n.set(d.subarray(l, l + r * i)), s(l - s(0)), f != 0) throw Error("Malformed buffer data: " + f);
}
var l = {
NONE: "",
OCTAHEDRAL: "meshopt_decodeFilterOct",
QUATERNION: "meshopt_decodeFilterQuat",
EXPONENTIAL: "meshopt_decodeFilterExp",
COLOR: "meshopt_decodeFilterColor"
}, u = {
ATTRIBUTES: "meshopt_decodeVertexBuffer",
TRIANGLES: "meshopt_decodeIndexBuffer",
INDICES: "meshopt_decodeIndexSequence"
}, d = [], f = 0;
function p(e) {
var t = {
object: new Worker(e),
pending: 0,
requests: {}
};
return t.object.onmessage = function(e) {
var n = e.data;
t.pending -= n.count, t.requests[n.id][n.action](n.value), delete t.requests[n.id];
}, t;
}
function m(e) {
for (var t = "self.ready = WebAssembly.instantiate(new Uint8Array([" + new Uint8Array(i) + "]), {}).then(function(result) { result.instance.exports.__wasm_call_ctors(); return result.instance; });self.onmessage = " + g.name + ";" + c.toString() + g.toString(), n = new Blob([t], { type: "text/javascript" }), r = URL.createObjectURL(n), a = d.length; a < e; ++a) d[a] = p(r);
for (var a = e; a < d.length; ++a) d[a].object.postMessage({});
d.length = e, URL.revokeObjectURL(r);
}
function h(e, t, n, r, i) {
for (var a = d[0], o = 1; o < d.length; ++o) d[o].pending < a.pending && (a = d[o]);
return new Promise(function(o, s) {
var c = new Uint8Array(n), l = ++f;
a.pending += e, a.requests[l] = {
resolve: o,
reject: s
}, a.object.postMessage({
id: l,
count: e,
size: t,
source: c,
mode: r,
filter: i
}, [c.buffer]);
});
}
function g(e) {
var t = e.data;
self.ready.then(function(e) {
if (!t.id) return self.close();
try {
var n = new Uint8Array(t.count * t.size);
c(e, e.exports[t.mode], n, t.count, t.size, t.source, e.exports[t.filter]), self.postMessage({
id: t.id,
count: t.count,
action: "resolve",
value: n
}, [n.buffer]);
} catch (e) {
self.postMessage({
id: t.id,
count: t.count,
action: "reject",
value: e
});
}
});
}
return {
ready: o,
supported: !0,
useWorkers: function(e) {
m(e);
},
decodeVertexBuffer: function(e, t, n, r, i) {
c(a, a.exports.meshopt_decodeVertexBuffer, e, t, n, r, a.exports[l[i]]);
},
decodeIndexBuffer: function(e, t, n, r) {
c(a, a.exports.meshopt_decodeIndexBuffer, e, t, n, r);
},
decodeIndexSequence: function(e, t, n, r) {
c(a, a.exports.meshopt_decodeIndexSequence, e, t, n, r);
},
decodeGltfBuffer: function(e, t, n, r, i, o) {
c(a, a.exports[u[i]], e, t, n, r, a.exports[l[o]]);
},
decodeGltfBufferAsync: function(e, t, n, r, i) {
return d.length > 0 ? h(e, t, n, u[r], l[i]) : o.then(function() {
var o = new Uint8Array(e * t);
return c(a, a.exports[u[r]], o, e, t, n, a.exports[l[i]]), o;
});
}
};
})();
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/examples/jsm/utils/BufferGeometryUtils.js
function vS(e, t = !1) {
let n = e[0].index !== null, r = new Set(Object.keys(e[0].attributes)), i = new Set(Object.keys(e[0].morphAttributes)), a = {}, o = {}, s = e[0].morphTargetsRelative, c = new Xt(), l = 0;
for (let u = 0; u < e.length; ++u) {
let d = e[u], f = 0;
if (n !== (d.index !== null)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."), null;
for (let e in d.attributes) {
if (!r.has(e)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". All geometries must have compatible attributes; make sure \"" + e + "\" attribute exists among all geometries, or in none of them."), null;
a[e] === void 0 && (a[e] = []), a[e].push(d.attributes[e]), f++;
}
if (f !== r.size) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". Make sure all geometries have the same number of attributes."), null;
if (s !== d.morphTargetsRelative) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphTargetsRelative must be consistent throughout all geometries."), null;
for (let e in d.morphAttributes) {
if (!i.has(e)) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". .morphAttributes must be consistent throughout all geometries."), null;
o[e] === void 0 && (o[e] = []), o[e].push(d.morphAttributes[e]);
}
if (t) {
let e;
if (n) e = d.index.count;
else if (d.attributes.position !== void 0) e = d.attributes.position.count;
else return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index " + u + ". The geometry must have either an index or a position attribute"), null;
c.addGroup(l, e, u), l += e;
}
}
if (n) {
let t = 0, n = [];
for (let r = 0; r < e.length; ++r) {
let i = e[r].index;
for (let e = 0; e < i.count; ++e) n.push(i.getX(e) + t);
t += e[r].attributes.position.count;
}
c.setIndex(n);
}
for (let e in a) {
let t = yS(a[e]);
if (!t) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + e + " attribute."), null;
c.setAttribute(e, t);
}
for (let e in o) {
let t = o[e][0].length;
if (t !== 0) {
c.morphAttributes = c.morphAttributes || {}, c.morphAttributes[e] = [];
for (let n = 0; n < t; ++n) {
let t = [];
for (let r = 0; r < o[e].length; ++r) t.push(o[e][r][n]);
let r = yS(t);
if (!r) return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the " + e + " morphAttribute."), null;
c.morphAttributes[e].push(r);
}
}
}
return c;
}
function yS(e) {
let t, n, r, i = -1, a = 0;
for (let o = 0; o < e.length; ++o) {
let s = e[o];
if (t === void 0 && (t = s.array.constructor), t !== s.array.constructor) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."), null;
if (n === void 0 && (n = s.itemSize), n !== s.itemSize) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."), null;
if (r === void 0 && (r = s.normalized), r !== s.normalized) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."), null;
if (i === -1 && (i = s.gpuType), i !== s.gpuType) return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."), null;
a += s.count * n;
}
let o = new t(a), s = new Me(o, n, r), c = 0;
for (let t = 0; t < e.length; ++t) {
let r = e[t];
if (r.isInterleavedBufferAttribute) {
let e = c / n;
for (let t = 0, i = r.count; t < i; t++) for (let i = 0; i < n; i++) {
let n = r.getComponent(t, i);
s.setComponent(t + e, i, n);
}
} else o.set(r.array, c);
c += r.count * n;
}
return i !== void 0 && (s.gpuType = i), s;
}
function bS(e, t) {
if (t === 0) return console.warn("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Geometry already defined as triangles."), e;
if (t === 2 || t === 1) {
let n = e.getIndex();
if (n === null) {
let t = [], r = e.getAttribute("position");
if (r !== void 0) {
for (let e = 0; e < r.count; e++) t.push(e);
e.setIndex(t), n = e.getIndex();
} else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Undefined position attribute. Processing not possible."), e;
}
let r = n.count - 2, i = [];
if (t === 2) for (let e = 1; e <= r; e++) i.push(n.getX(0)), i.push(n.getX(e)), i.push(n.getX(e + 1));
else for (let e = 0; e < r; e++) e % 2 == 0 ? (i.push(n.getX(e)), i.push(n.getX(e + 1)), i.push(n.getX(e + 2))) : (i.push(n.getX(e + 2)), i.push(n.getX(e + 1)), i.push(n.getX(e)));
i.length / 3 !== r && console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unable to generate correct amount of triangles.");
let a = e.clone();
return a.setIndex(i), a.clearGroups(), a;
} else return console.error("THREE.BufferGeometryUtils.toTrianglesDrawMode(): Unknown draw mode:", t), e;
}
function xS(e, t = Math.PI / 3) {
let n = e.index ? e.toNonIndexed() : e, r = n.attributes.position, i = r.count, a;
if (r.isBufferAttribute === !0 && r.itemSize === 3 && r.normalized === !1) a = r.array;
else {
a = new Float64Array(i * 3);
for (let e = 0; e < i; e++) a[3 * e + 0] = r.getX(e), a[3 * e + 1] = r.getY(e), a[3 * e + 2] = r.getZ(e);
}
let o = Math.cos(t), s = 1.0000000001 * 100, c = i / 3, l = new Float64Array(c * 3);
for (let e = 0; e < c; e++) {
let t = 9 * e, n = a[t + 0], r = a[t + 1], i = a[t + 2], o = a[t + 3], s = a[t + 4], c = a[t + 5], u = a[t + 6], d = a[t + 7], f = a[t + 8], p = u - o, m = d - s, h = f - c, g = n - o, _ = r - s, v = i - c, y = m * v - h * _, b = h * g - p * v, x = p * _ - m * g, S = 1 / (Math.sqrt(y * y + b * b + x * x) || 1);
l[3 * e + 0] = y * S, l[3 * e + 1] = b * S, l[3 * e + 2] = x * S;
}
let u = new Int32Array(i), d = new Int32Array(i * 3), f = 1;
for (; f < i * 2;) f <<= 1;
let p = f - 1, m = new Int32Array(f), h = 0;
for (let e = 0; e < i; e++) {
let t = 3 * e, n = ~~(a[t + 0] * s), r = ~~(a[t + 1] * s), i = ~~(a[t + 2] * s), o = (Math.imul(n, 73856093) ^ Math.imul(r, 19349663) ^ Math.imul(i, 83492791)) & p;
for (;;) {
let t = m[o];
if (t === 0) {
let t = 3 * h;
d[t + 0] = n, d[t + 1] = r, d[t + 2] = i, m[o] = h + 1, u[e] = h++;
break;
}
let a = 3 * (t - 1);
if (d[a + 0] === n && d[a + 1] === r && d[a + 2] === i) {
u[e] = t - 1;
break;
}
o = o + 1 & p;
}
}
let g = new Int32Array(h + 1);
for (let e = 0; e < i; e++) g[u[e] + 1]++;
for (let e = 0; e < h; e++) g[e + 1] += g[e];
let _ = new Int32Array(i), v = g.slice(0, h);
for (let e = 0; e < c; e++) {
let t = 3 * e;
_[v[u[t + 0]]++] = e, _[v[u[t + 1]]++] = e, _[v[u[t + 2]]++] = e;
}
let y = new Float32Array(i * 3);
for (let e = 0; e < c; e++) {
let t = 3 * e, n = l[t + 0], r = l[t + 1], i = l[t + 2];
for (let e = 0; e < 3; e++) {
let a = t + e, s = u[a], c = 0, d = 0, f = 0;
for (let e = g[s], t = g[s + 1]; e < t; e++) {
let t = 3 * _[e], a = l[t + 0], s = l[t + 1], u = l[t + 2];
n * a + r * s + i * u > o && (c += a, d += s, f += u);
}
let p = 1 / (Math.sqrt(c * c + d * d + f * f) || 1);
y[3 * a + 0] = c * p, y[3 * a + 1] = d * p, y[3 * a + 2] = f * p;
}
}
return n.setAttribute("normal", new Me(y, 3, !1)), n;
}
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/examples/jsm/utils/SkeletonUtils.js
function SS(e) {
let t = /* @__PURE__ */ new Map(), n = /* @__PURE__ */ new Map(), r = e.clone();
return CS(e, r, function(e, r) {
t.set(r, e), n.set(e, r);
}), r.traverse(function(e) {
if (!e.isSkinnedMesh) return;
let r = e, i = t.get(e), a = i.skeleton.bones;
r.skeleton = i.skeleton.clone(), r.bindMatrix.copy(i.bindMatrix), r.skeleton.bones = a.map(function(e) {
return n.get(e);
}), r.bind(r.skeleton, r.bindMatrix);
}), r;
}
function CS(e, t, n) {
n(e, t);
for (let r = 0; r < e.children.length; r++) CS(e.children[r], t.children[r], n);
}
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/examples/jsm/loaders/GLTFLoader.js
var wS = class extends qe {
constructor(e) {
super(e), this.dracoLoader = null, this.ktx2Loader = null, this.meshoptDecoder = null, this.pluginCallbacks = [], this.register(function(e) {
return new jS(e);
}), this.register(function(e) {
return new MS(e);
}), this.register(function(e) {
return new VS(e);
}), this.register(function(e) {
return new HS(e);
}), this.register(function(e) {
return new US(e);
}), this.register(function(e) {
return new PS(e);
}), this.register(function(e) {
return new FS(e);
}), this.register(function(e) {
return new IS(e);
}), this.register(function(e) {
return new LS(e);
}), this.register(function(e) {
return new AS(e);
}), this.register(function(e) {
return new RS(e);
}), this.register(function(e) {
return new NS(e);
}), this.register(function(e) {
return new BS(e);
}), this.register(function(e) {
return new zS(e);
}), this.register(function(e) {
return new OS(e);
}), this.register(function(e) {
return new WS(e, DS.EXT_MESHOPT_COMPRESSION);
}), this.register(function(e) {
return new WS(e, DS.KHR_MESHOPT_COMPRESSION);
}), this.register(function(e) {
return new GS(e);
});
}
load(e, t, n, r) {
let i = this, a;
if (this.resourcePath !== "") a = this.resourcePath;
else if (this.path !== "") {
let t = $e.extractUrlBase(e);
a = $e.resolveURL(t, this.path);
} else a = $e.extractUrlBase(e);
this.manager.itemStart(e);
let o = function(t) {
r ? r(t) : console.error(t), i.manager.itemError(e), i.manager.itemEnd(e);
}, s = new We(this.manager);
s.setPath(this.path), s.setResponseType("arraybuffer"), s.setRequestHeader(this.requestHeader), s.setWithCredentials(this.withCredentials), s.load(e, function(n) {
try {
i.parse(n, a, function(n) {
t(n), i.manager.itemEnd(e);
}, o);
} catch (e) {
o(e);
}
}, n, o);
}
setDRACOLoader(e) {
return this.dracoLoader = e, this;
}
setKTX2Loader(e) {
return this.ktx2Loader = e, this;
}
setMeshoptDecoder(e) {
return this.meshoptDecoder = e, this;
}
register(e) {
return this.pluginCallbacks.indexOf(e) === -1 && this.pluginCallbacks.push(e), this;
}
unregister(e) {
return this.pluginCallbacks.indexOf(e) !== -1 && this.pluginCallbacks.splice(this.pluginCallbacks.indexOf(e), 1), this;
}
parse(e, t, n, r) {
let i, a = {}, o = {}, s = new TextDecoder();
if (typeof e == "string") i = JSON.parse(e);
else if (e instanceof ArrayBuffer) if (s.decode(new Uint8Array(e, 0, 4)) === KS) {
try {
a[DS.KHR_BINARY_GLTF] = new YS(e);
} catch (e) {
r && r(e);
return;
}
i = JSON.parse(a[DS.KHR_BINARY_GLTF].content);
} else i = JSON.parse(s.decode(e));
else i = e;
if (i.asset === void 0 || i.asset.version[0] < 2) {
r && r(/* @__PURE__ */ Error("THREE.GLTFLoader: Unsupported asset. glTF versions >=2.0 are supported."));
return;
}
let c = new xC(i, {
path: t || this.resourcePath || "",
crossOrigin: this.crossOrigin,
requestHeader: this.requestHeader,
manager: this.manager,
ktx2Loader: this.ktx2Loader,
meshoptDecoder: this.meshoptDecoder
});
c.fileLoader.setRequestHeader(this.requestHeader);
for (let e = 0; e < this.pluginCallbacks.length; e++) {
let t = this.pluginCallbacks[e](c);
t.name || console.error("THREE.GLTFLoader: Invalid plugin found: missing name"), o[t.name] = t, a[t.name] = !0;
}
if (i.extensionsUsed) for (let e = 0; e < i.extensionsUsed.length; ++e) {
let t = i.extensionsUsed[e], n = i.extensionsRequired || [];
switch (t) {
case DS.KHR_MATERIALS_UNLIT:
a[t] = new kS();
break;
case DS.KHR_DRACO_MESH_COMPRESSION:
a[t] = new XS(i, this.dracoLoader);
break;
case DS.KHR_TEXTURE_TRANSFORM:
a[t] = new ZS();
break;
case DS.KHR_MESH_QUANTIZATION:
a[t] = new QS();
break;
default: n.indexOf(t) >= 0 && o[t] === void 0 && console.warn("THREE.GLTFLoader: Unknown extension \"" + t + "\".");
}
}
c.setExtensions(a), c.setPlugins(o), c.parse(n, r);
}
parseAsync(e, t) {
let n = this;
return new Promise(function(r, i) {
n.parse(e, t, r, i);
});
}
};
function TS() {
let e = {};
return {
get: function(t) {
return e[t];
},
add: function(t, n) {
e[t] = n;
},
remove: function(t) {
delete e[t];
},
removeAll: function() {
e = {};
}
};
}
function ES(e, t, n) {
let r = e.json.materials[t];
return r.extensions && r.extensions[n] ? r.extensions[n] : null;
}
var DS = {
KHR_BINARY_GLTF: "KHR_binary_glTF",
KHR_DRACO_MESH_COMPRESSION: "KHR_draco_mesh_compression",
KHR_LIGHTS_PUNCTUAL: "KHR_lights_punctual",
KHR_MATERIALS_CLEARCOAT: "KHR_materials_clearcoat",
KHR_MATERIALS_DISPERSION: "KHR_materials_dispersion",
KHR_MATERIALS_IOR: "KHR_materials_ior",
KHR_MATERIALS_SHEEN: "KHR_materials_sheen",
KHR_MATERIALS_SPECULAR: "KHR_materials_specular",
KHR_MATERIALS_TRANSMISSION: "KHR_materials_transmission",
KHR_MATERIALS_IRIDESCENCE: "KHR_materials_iridescence",
KHR_MATERIALS_ANISOTROPY: "KHR_materials_anisotropy",
KHR_MATERIALS_UNLIT: "KHR_materials_unlit",
KHR_MATERIALS_VOLUME: "KHR_materials_volume",
KHR_TEXTURE_BASISU: "KHR_texture_basisu",
KHR_TEXTURE_TRANSFORM: "KHR_texture_transform",
KHR_MESH_QUANTIZATION: "KHR_mesh_quantization",
KHR_MATERIALS_EMISSIVE_STRENGTH: "KHR_materials_emissive_strength",
EXT_MATERIALS_BUMP: "EXT_materials_bump",
EXT_TEXTURE_WEBP: "EXT_texture_webp",
EXT_TEXTURE_AVIF: "EXT_texture_avif",
EXT_MESHOPT_COMPRESSION: "EXT_meshopt_compression",
KHR_MESHOPT_COMPRESSION: "KHR_meshopt_compression",
EXT_MESH_GPU_INSTANCING: "EXT_mesh_gpu_instancing"
}, OS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_LIGHTS_PUNCTUAL, this.cache = {
refs: {},
uses: {}
};
}
_markDefs() {
let e = this.parser, t = this.parser.json.nodes || [];
for (let n = 0, r = t.length; n < r; n++) {
let r = t[n];
r.extensions && r.extensions[this.name] && r.extensions[this.name].light !== void 0 && e._addNodeRef(this.cache, r.extensions[this.name].light);
}
}
_loadLight(e) {
let t = this.parser, n = "light:" + e, r = t.cache.get(n);
if (r) return r;
let i = t.json, a = ((i.extensions && i.extensions[this.name] || {}).lights || [])[e], o, s = new gt(16777215);
a.color !== void 0 && s.setRGB(a.color[0], a.color[1], a.color[2], vt);
let c = a.range === void 0 ? 0 : a.range;
switch (a.type) {
case "directional":
o = new ht(s), o.target.position.set(0, 0, -1), o.add(o.target);
break;
case "point":
o = new it(s), o.distance = c;
break;
case "spot":
o = new Kt(s), o.distance = c, a.spot = a.spot || {}, a.spot.innerConeAngle = a.spot.innerConeAngle === void 0 ? 0 : a.spot.innerConeAngle, a.spot.outerConeAngle = a.spot.outerConeAngle === void 0 ? Math.PI / 4 : a.spot.outerConeAngle, o.angle = a.spot.outerConeAngle, o.penumbra = 1 - a.spot.innerConeAngle / a.spot.outerConeAngle, o.target.position.set(0, 0, -1), o.add(o.target);
break;
default: throw Error("THREE.GLTFLoader: Unexpected light type: " + a.type);
}
return o.position.set(0, 0, 0), pC(o, a), a.intensity !== void 0 && (o.intensity = a.intensity), o.name = t.createUniqueName(a.name || "light_" + e), r = Promise.resolve(o), t.cache.add(n, r), r;
}
getDependency(e, t) {
if (e === "light") return this._loadLight(t);
}
createNodeAttachment(e) {
let t = this, n = this.parser, r = n.json.nodes[e], i = (r.extensions && r.extensions[this.name] || {}).light;
return i === void 0 ? null : this._loadLight(i).then(function(e) {
return n._getNodeRef(t.cache, i, e);
});
}
}, kS = class {
constructor() {
this.name = DS.KHR_MATERIALS_UNLIT;
}
getMaterialType() {
return Mt;
}
extendParams(e, t, n) {
let r = [];
e.color = new gt(1, 1, 1), e.opacity = 1;
let i = t.pbrMetallicRoughness;
if (i) {
if (Array.isArray(i.baseColorFactor)) {
let t = i.baseColorFactor;
e.color.setRGB(t[0], t[1], t[2], vt), e.opacity = t[3];
}
i.baseColorTexture !== void 0 && r.push(n.assignTexture(e, "map", i.baseColorTexture, wt));
}
return Promise.all(r);
}
}, AS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_EMISSIVE_STRENGTH;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
return n === null || n.emissiveStrength !== void 0 && (t.emissiveIntensity = n.emissiveStrength), Promise.resolve();
}
}, jS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_CLEARCOAT;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
if (n.clearcoatFactor !== void 0 && (t.clearcoat = n.clearcoatFactor), n.clearcoatTexture !== void 0 && r.push(this.parser.assignTexture(t, "clearcoatMap", n.clearcoatTexture)), n.clearcoatRoughnessFactor !== void 0 && (t.clearcoatRoughness = n.clearcoatRoughnessFactor), n.clearcoatRoughnessTexture !== void 0 && r.push(this.parser.assignTexture(t, "clearcoatRoughnessMap", n.clearcoatRoughnessTexture)), n.clearcoatNormalTexture !== void 0 && (r.push(this.parser.assignTexture(t, "clearcoatNormalMap", n.clearcoatNormalTexture)), n.clearcoatNormalTexture.scale !== void 0)) {
let e = n.clearcoatNormalTexture.scale;
t.clearcoatNormalScale = new V(e, e);
}
return Promise.all(r);
}
}, MS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_DISPERSION;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
return n === null || (t.dispersion = n.dispersion === void 0 ? 0 : n.dispersion), Promise.resolve();
}
}, NS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_IRIDESCENCE;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
return n.iridescenceFactor !== void 0 && (t.iridescence = n.iridescenceFactor), n.iridescenceTexture !== void 0 && r.push(this.parser.assignTexture(t, "iridescenceMap", n.iridescenceTexture)), n.iridescenceIor !== void 0 && (t.iridescenceIOR = n.iridescenceIor), t.iridescenceThicknessRange === void 0 && (t.iridescenceThicknessRange = [100, 400]), n.iridescenceThicknessMinimum !== void 0 && (t.iridescenceThicknessRange[0] = n.iridescenceThicknessMinimum), n.iridescenceThicknessMaximum !== void 0 && (t.iridescenceThicknessRange[1] = n.iridescenceThicknessMaximum), n.iridescenceThicknessTexture !== void 0 && r.push(this.parser.assignTexture(t, "iridescenceThicknessMap", n.iridescenceThicknessTexture)), Promise.all(r);
}
}, PS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_SHEEN;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
if (t.sheenColor = new gt(0, 0, 0), t.sheenRoughness = 0, t.sheen = 1, n.sheenColorFactor !== void 0) {
let e = n.sheenColorFactor;
t.sheenColor.setRGB(e[0], e[1], e[2], vt);
}
return n.sheenRoughnessFactor !== void 0 && (t.sheenRoughness = n.sheenRoughnessFactor), n.sheenColorTexture !== void 0 && r.push(this.parser.assignTexture(t, "sheenColorMap", n.sheenColorTexture, wt)), n.sheenRoughnessTexture !== void 0 && r.push(this.parser.assignTexture(t, "sheenRoughnessMap", n.sheenRoughnessTexture)), Promise.all(r);
}
}, FS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_TRANSMISSION;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
return n.transmissionFactor !== void 0 && (t.transmission = n.transmissionFactor), n.transmissionTexture !== void 0 && r.push(this.parser.assignTexture(t, "transmissionMap", n.transmissionTexture)), Promise.all(r);
}
}, IS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_VOLUME;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
t.thickness = n.thicknessFactor === void 0 ? 0 : n.thicknessFactor, n.thicknessTexture !== void 0 && r.push(this.parser.assignTexture(t, "thicknessMap", n.thicknessTexture)), t.attenuationDistance = n.attenuationDistance || Infinity;
let i = n.attenuationColor || [
1,
1,
1
];
return t.attenuationColor = new gt().setRGB(i[0], i[1], i[2], vt), Promise.all(r);
}
}, LS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_IOR;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
return n === null ? Promise.resolve() : (t.ior = n.ior === void 0 ? 1.5 : n.ior, t.ior === 0 && (t.ior = 1e3), Promise.resolve());
}
}, RS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_SPECULAR;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
t.specularIntensity = n.specularFactor === void 0 ? 1 : n.specularFactor, n.specularTexture !== void 0 && r.push(this.parser.assignTexture(t, "specularIntensityMap", n.specularTexture));
let i = n.specularColorFactor || [
1,
1,
1
];
return t.specularColor = new gt().setRGB(i[0], i[1], i[2], vt), n.specularColorTexture !== void 0 && r.push(this.parser.assignTexture(t, "specularColorMap", n.specularColorTexture, wt)), Promise.all(r);
}
}, zS = class {
constructor(e) {
this.parser = e, this.name = DS.EXT_MATERIALS_BUMP;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
return t.bumpScale = n.bumpFactor === void 0 ? 1 : n.bumpFactor, n.bumpTexture !== void 0 && r.push(this.parser.assignTexture(t, "bumpMap", n.bumpTexture)), Promise.all(r);
}
}, BS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_MATERIALS_ANISOTROPY;
}
getMaterialType(e) {
return ES(this.parser, e, this.name) === null ? null : Ht;
}
extendMaterialParams(e, t) {
let n = ES(this.parser, e, this.name);
if (n === null) return Promise.resolve();
let r = [];
return n.anisotropyStrength !== void 0 && (t.anisotropy = n.anisotropyStrength), n.anisotropyRotation !== void 0 && (t.anisotropyRotation = n.anisotropyRotation), n.anisotropyTexture !== void 0 && r.push(this.parser.assignTexture(t, "anisotropyMap", n.anisotropyTexture)), Promise.all(r);
}
}, VS = class {
constructor(e) {
this.parser = e, this.name = DS.KHR_TEXTURE_BASISU;
}
loadTexture(e) {
let t = this.parser, n = t.json, r = n.textures[e];
if (!r.extensions || !r.extensions[this.name]) return null;
let i = r.extensions[this.name], a = t.options.ktx2Loader;
if (!a) {
if (n.extensionsRequired && n.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setKTX2Loader must be called before loading KTX2 textures");
return null;
}
return t.loadTextureImage(e, i.source, a);
}
}, HS = class {
constructor(e) {
this.parser = e, this.name = DS.EXT_TEXTURE_WEBP;
}
loadTexture(e) {
let t = this.name, n = this.parser, r = n.json, i = r.textures[e];
if (!i.extensions || !i.extensions[t]) return null;
let a = i.extensions[t], o = r.images[a.source], s = n.textureLoader;
if (o.uri) {
let e = n.options.manager.getHandler(o.uri);
e !== null && (s = e);
}
return n.loadTextureImage(e, a.source, s);
}
}, US = class {
constructor(e) {
this.parser = e, this.name = DS.EXT_TEXTURE_AVIF;
}
loadTexture(e) {
let t = this.name, n = this.parser, r = n.json, i = r.textures[e];
if (!i.extensions || !i.extensions[t]) return null;
let a = i.extensions[t], o = r.images[a.source], s = n.textureLoader;
if (o.uri) {
let e = n.options.manager.getHandler(o.uri);
e !== null && (s = e);
}
return n.loadTextureImage(e, a.source, s);
}
}, WS = class {
constructor(e, t) {
this.name = t, this.parser = e;
}
loadBufferView(e) {
let t = this.parser.json, n = t.bufferViews[e];
if (n.extensions && n.extensions[this.name]) {
let e = n.extensions[this.name], r = this.parser.getDependency("buffer", e.buffer), i = this.parser.options.meshoptDecoder;
if (!i || !i.supported) {
if (t.extensionsRequired && t.extensionsRequired.indexOf(this.name) >= 0) throw Error("THREE.GLTFLoader: setMeshoptDecoder must be called before loading compressed files");
return null;
}
return r.then(function(t) {
let n = e.byteOffset || 0, r = e.byteLength || 0, a = e.count, o = e.byteStride, s = new Uint8Array(t, n, r);
return i.decodeGltfBufferAsync ? i.decodeGltfBufferAsync(a, o, s, e.mode, e.filter).then(function(e) {
return e.buffer;
}) : i.ready.then(function() {
let t = new ArrayBuffer(a * o);
return i.decodeGltfBuffer(new Uint8Array(t), a, o, s, e.mode, e.filter), t;
});
});
} else return null;
}
}, GS = class {
constructor(e) {
this.name = DS.EXT_MESH_GPU_INSTANCING, this.parser = e;
}
createNodeMesh(e) {
let t = this.parser.json, n = t.nodes[e];
if (!n.extensions || !n.extensions[this.name] || n.mesh === void 0) return null;
let r = t.meshes[n.mesh];
for (let e of r.primitives) if (e.mode !== nC.TRIANGLES && e.mode !== nC.TRIANGLE_STRIP && e.mode !== nC.TRIANGLE_FAN && e.mode !== void 0) return null;
let i = n.extensions[this.name].attributes, a = [], o = {};
for (let e in i) a.push(this.parser.getDependency("accessor", i[e]).then((t) => (o[e] = t, o[e])));
return a.length < 1 ? null : (a.push(this.parser.createNodeMesh(e)), Promise.all(a).then((e) => {
let t = e.pop(), n = t.isGroup ? t.children : [t], r = e[0].count, i = [];
for (let e of n) {
let t = new W(), n = new U(), a = new yt(), s = new U(1, 1, 1), c = new hn(e.geometry, e.material, r);
for (let e = 0; e < r; e++) o.TRANSLATION && n.fromBufferAttribute(o.TRANSLATION, e), o.ROTATION && a.fromBufferAttribute(o.ROTATION, e), o.SCALE && s.fromBufferAttribute(o.SCALE, e), c.setMatrixAt(e, t.compose(n, a, s));
for (let t in o) if (t === "_COLOR_0") {
let e = o[t];
c.instanceColor = new Jt(e.array, e.itemSize, e.normalized);
} else t !== "TRANSLATION" && t !== "ROTATION" && t !== "SCALE" && e.geometry.setAttribute(t, o[t]);
Le.prototype.copy.call(c, e), this.parser.assignFinalMaterial(c), i.push(c);
}
return t.isGroup ? (t.clear(), t.add(...i), t) : i[0];
}));
}
}, KS = "glTF", qS = 12, JS = {
JSON: 1313821514,
BIN: 5130562
}, YS = class {
constructor(e) {
this.name = DS.KHR_BINARY_GLTF, this.content = null, this.body = null;
let t = new DataView(e, 0, qS), n = new TextDecoder();
if (this.header = {
magic: n.decode(new Uint8Array(e.slice(0, 4))),
version: t.getUint32(4, !0),
length: t.getUint32(8, !0)
}, this.header.magic !== KS) throw Error("THREE.GLTFLoader: Unsupported glTF-Binary header.");
if (this.header.version < 2) throw Error("THREE.GLTFLoader: Legacy binary file detected.");
let r = this.header.length - qS, i = new DataView(e, qS), a = 0;
for (; a < r;) {
let t = i.getUint32(a, !0);
a += 4;
let r = i.getUint32(a, !0);
if (a += 4, r === JS.JSON) {
let r = new Uint8Array(e, qS + a, t);
this.content = n.decode(r);
} else if (r === JS.BIN) {
let n = qS + a;
this.body = e.slice(n, n + t);
}
a += t;
}
if (this.content === null) throw Error("THREE.GLTFLoader: JSON content not found.");
}
}, XS = class {
constructor(e, t) {
if (!t) throw Error("THREE.GLTFLoader: No DRACOLoader instance provided.");
this.name = DS.KHR_DRACO_MESH_COMPRESSION, this.json = e, this.dracoLoader = t, this.dracoLoader.preload();
}
decodePrimitive(e, t) {
let n = this.json, r = this.dracoLoader, i = e.extensions[this.name].bufferView, a = e.extensions[this.name].attributes, o = {}, s = {}, c = {};
for (let e in a) {
let t = sC[e] || e.toLowerCase();
o[t] = a[e];
}
for (let t in e.attributes) {
let r = sC[t] || t.toLowerCase();
if (a[t] !== void 0) {
let i = n.accessors[e.attributes[t]];
c[r] = rC[i.componentType].name, s[r] = i.normalized === !0;
}
}
return t.getDependency("bufferView", i).then(function(e) {
return new Promise(function(t, n) {
r.decodeDracoFile(e, function(e) {
for (let t in e.attributes) {
let n = e.attributes[t], r = s[t];
r !== void 0 && (n.normalized = r);
}
t(e);
}, o, c, vt, n);
});
});
}
}, ZS = class {
constructor() {
this.name = DS.KHR_TEXTURE_TRANSFORM;
}
extendTexture(e, t) {
return (t.texCoord === void 0 || t.texCoord === e.channel) && t.offset === void 0 && t.rotation === void 0 && t.scale === void 0 ? e : (e = e.clone(), t.texCoord !== void 0 && (e.channel = t.texCoord), t.offset !== void 0 && e.offset.fromArray(t.offset), t.rotation !== void 0 && (e.rotation = t.rotation), t.scale !== void 0 && e.repeat.fromArray(t.scale), e.needsUpdate = !0, e);
}
}, QS = class {
constructor() {
this.name = DS.KHR_MESH_QUANTIZATION;
}
}, $S = class extends nn {
constructor(e, t, n, r) {
super(e, t, n, r);
}
copySampleValue_(e) {
let t = this.resultBuffer, n = this.sampleValues, r = this.valueSize, i = e * r * 3 + r;
for (let e = 0; e !== r; e++) t[e] = n[i + e];
return t;
}
interpolate_(e, t, n, r) {
let i = this.resultBuffer, a = this.sampleValues, o = this.valueSize, s = o * 2, c = o * 3, l = r - t, u = (n - t) / l, d = u * u, f = d * u, p = e * c, m = p - c, h = -2 * f + 3 * d, g = f - d, _ = 1 - h, v = g - d + u;
for (let e = 0; e !== o; e++) {
let t = a[m + e + o], n = a[m + e + s] * l, r = a[p + e + o], c = a[p + e] * l;
i[e] = _ * t + v * n + h * r + g * c;
}
return i;
}
}, eC = new yt(), tC = class extends $S {
interpolate_(e, t, n, r) {
let i = super.interpolate_(e, t, n, r);
return eC.fromArray(i).normalize().toArray(i), i;
}
}, nC = {
FLOAT: 5126,
FLOAT_MAT3: 35675,
FLOAT_MAT4: 35676,
FLOAT_VEC2: 35664,
FLOAT_VEC3: 35665,
FLOAT_VEC4: 35666,
LINEAR: 9729,
REPEAT: 10497,
SAMPLER_2D: 35678,
POINTS: 0,
LINES: 1,
LINE_LOOP: 2,
LINE_STRIP: 3,
TRIANGLES: 4,
TRIANGLE_STRIP: 5,
TRIANGLE_FAN: 6,
UNSIGNED_BYTE: 5121,
UNSIGNED_SHORT: 5123
}, rC = {
5120: Int8Array,
5121: Uint8Array,
5122: Int16Array,
5123: Uint16Array,
5125: Uint32Array,
5126: Float32Array
}, iC = {
9728: Gt,
9729: tt,
9984: Nt,
9985: Ye,
9986: xn,
9987: xt
}, aC = {
33071: bt,
33648: qt,
10497: Je
}, oC = {
SCALAR: 1,
VEC2: 2,
VEC3: 3,
VEC4: 4,
MAT2: 4,
MAT3: 9,
MAT4: 16
}, sC = {
POSITION: "position",
NORMAL: "normal",
TANGENT: "tangent",
TEXCOORD_0: "uv",
TEXCOORD_1: "uv1",
TEXCOORD_2: "uv2",
TEXCOORD_3: "uv3",
COLOR_0: "color",
WEIGHTS_0: "skinWeight",
JOINTS_0: "skinIndex"
}, cC = {
scale: "scale",
translation: "position",
rotation: "quaternion",
weights: "morphTargetInfluences"
}, lC = {
CUBICSPLINE: void 0,
LINEAR: kt,
STEP: Wt
}, uC = {
OPAQUE: "OPAQUE",
MASK: "MASK",
BLEND: "BLEND"
};
function dC(e) {
return e.DefaultMaterial === void 0 && (e.DefaultMaterial = new fn({
color: 16777215,
emissive: 0,
metalness: 1,
roughness: 1,
transparent: !1,
depthTest: !0,
side: 0
})), e.DefaultMaterial;
}
function fC(e, t, n) {
for (let r in n.extensions) e[r] === void 0 && (t.userData.gltfExtensions = t.userData.gltfExtensions || {}, t.userData.gltfExtensions[r] = n.extensions[r]);
}
function pC(e, t) {
t.extras !== void 0 && (typeof t.extras == "object" ? Object.assign(e.userData, t.extras) : console.warn("THREE.GLTFLoader: Ignoring primitive type .extras, " + t.extras));
}
function mC(e, t, n) {
let r = !1, i = !1, a = !1;
for (let e = 0, n = t.length; e < n; e++) {
let n = t[e];
if (n.POSITION !== void 0 && (r = !0), n.NORMAL !== void 0 && (i = !0), n.COLOR_0 !== void 0 && (a = !0), r && i && a) break;
}
if (!r && !i && !a) return Promise.resolve(e);
let o = [], s = [], c = [];
for (let l = 0, u = t.length; l < u; l++) {
let u = t[l];
if (r) {
let t = u.POSITION === void 0 ? e.attributes.position : n.getDependency("accessor", u.POSITION);
o.push(t);
}
if (i) {
let t = u.NORMAL === void 0 ? e.attributes.normal : n.getDependency("accessor", u.NORMAL);
s.push(t);
}
if (a) {
let t = u.COLOR_0 === void 0 ? e.attributes.color : n.getDependency("accessor", u.COLOR_0);
c.push(t);
}
}
return Promise.all([
Promise.all(o),
Promise.all(s),
Promise.all(c)
]).then(function(t) {
let n = t[0], o = t[1], s = t[2];
return r && (e.morphAttributes.position = n), i && (e.morphAttributes.normal = o), a && (e.morphAttributes.color = s), e.morphTargetsRelative = !0, e;
});
}
function hC(e, t) {
if (e.updateMorphTargets(), t.weights !== void 0) for (let n = 0, r = t.weights.length; n < r; n++) e.morphTargetInfluences[n] = t.weights[n];
if (t.extras && Array.isArray(t.extras.targetNames)) {
let n = t.extras.targetNames;
if (e.morphTargetInfluences.length === n.length) {
e.morphTargetDictionary = {};
for (let t = 0, r = n.length; t < r; t++) e.morphTargetDictionary[n[t]] = t;
} else console.warn("THREE.GLTFLoader: Invalid extras.targetNames length. Ignoring names.");
}
}
function gC(e) {
let t, n = e.extensions && e.extensions[DS.KHR_DRACO_MESH_COMPRESSION];
if (t = n ? "draco:" + n.bufferView + ":" + n.indices + ":" + _C(n.attributes) : e.indices + ":" + _C(e.attributes) + ":" + e.mode, e.targets !== void 0) for (let n = 0, r = e.targets.length; n < r; n++) t += ":" + _C(e.targets[n]);
return t;
}
function _C(e) {
let t = "", n = Object.keys(e).sort();
for (let r = 0, i = n.length; r < i; r++) t += n[r] + ":" + e[n[r]] + ";";
return t;
}
function vC(e) {
switch (e) {
case Int8Array: return 1 / 127;
case Uint8Array: return 1 / 255;
case Int16Array: return 1 / 32767;
case Uint16Array: return 1 / 65535;
default: throw Error("THREE.GLTFLoader: Unsupported normalized accessor component type.");
}
}
function yC(e) {
return e.search(/\.jpe?g($|\?)/i) > 0 || e.search(/^data\:image\/jpeg/) === 0 ? "image/jpeg" : e.search(/\.webp($|\?)/i) > 0 || e.search(/^data\:image\/webp/) === 0 ? "image/webp" : e.search(/\.ktx2($|\?)/i) > 0 || e.search(/^data\:image\/ktx2/) === 0 ? "image/ktx2" : "image/png";
}
var bC = new W(), xC = class {
constructor(e = {}, t = {}) {
this.json = e, this.extensions = {}, this.plugins = {}, this.options = t, this.cache = new TS(), this.associations = /* @__PURE__ */ new Map(), this.primitiveCache = {}, this.nodeCache = {}, this.meshCache = {
refs: {},
uses: {}
}, this.cameraCache = {
refs: {},
uses: {}
}, this.lightCache = {
refs: {},
uses: {}
}, this.sourceCache = {}, this.textureCache = {}, this.nodeNamesUsed = {};
let n = !1, r = -1, i = !1, a = -1;
if (typeof navigator < "u" && navigator.userAgent !== void 0) {
let e = navigator.userAgent;
n = /^((?!chrome|android).)*safari/i.test(e) === !0;
let t = e.match(/Version\/(\d+)/);
r = n && t ? parseInt(t[1], 10) : -1, i = e.indexOf("Firefox") > -1, a = i ? e.match(/Firefox\/([0-9]+)\./)[1] : -1;
}
typeof createImageBitmap > "u" || n && r < 17 || i && a < 98 ? this.textureLoader = new Ne(this.options.manager) : this.textureLoader = new je(this.options.manager), this.textureLoader.setCrossOrigin(this.options.crossOrigin), this.textureLoader.setRequestHeader(this.options.requestHeader), this.fileLoader = new We(this.options.manager), this.fileLoader.setResponseType("arraybuffer"), this.options.crossOrigin === "use-credentials" && this.fileLoader.setWithCredentials(!0);
}
setExtensions(e) {
this.extensions = e;
}
setPlugins(e) {
this.plugins = e;
}
parse(e, t) {
let n = this, r = this.json, i = this.extensions;
this.cache.removeAll(), this.nodeCache = {}, this._invokeAll(function(e) {
return e._markDefs && e._markDefs();
}), Promise.all(this._invokeAll(function(e) {
return e.beforeRoot && e.beforeRoot();
})).then(function() {
return Promise.all([
n.getDependencies("scene"),
n.getDependencies("animation"),
n.getDependencies("camera")
]);
}).then(function(t) {
let a = {
scene: t[0][r.scene || 0],
scenes: t[0],
animations: t[1],
cameras: t[2],
asset: r.asset,
parser: n,
userData: {}
};
return fC(i, a, r), pC(a, r), Promise.all(n._invokeAll(function(e) {
return e.afterRoot && e.afterRoot(a);
})).then(function() {
for (let e of a.scenes) e.updateMatrixWorld();
e(a);
});
}).catch(t);
}
_markDefs() {
let e = this.json.nodes || [], t = this.json.skins || [], n = this.json.meshes || [];
for (let n = 0, r = t.length; n < r; n++) {
let r = t[n].joints;
for (let t = 0, n = r.length; t < n; t++) e[r[t]].isBone = !0;
}
for (let t = 0, r = e.length; t < r; t++) {
let r = e[t];
r.mesh !== void 0 && (this._addNodeRef(this.meshCache, r.mesh), r.skin !== void 0 && (n[r.mesh].isSkinnedMesh = !0)), r.camera !== void 0 && this._addNodeRef(this.cameraCache, r.camera);
}
}
_addNodeRef(e, t) {
t !== void 0 && (e.refs[t] === void 0 && (e.refs[t] = e.uses[t] = 0), e.refs[t]++);
}
_getNodeRef(e, t, n) {
if (e.refs[t] <= 1) return n;
let r = n.clone(), i = (e, t) => {
let n = this.associations.get(e);
n != null && this.associations.set(t, n);
for (let [n, r] of e.children.entries()) i(r, t.children[n]);
};
return i(n, r), r.name += "_instance_" + e.uses[t]++, r;
}
_invokeOne(e) {
let t = Object.values(this.plugins);
t.push(this);
for (let n = 0; n < t.length; n++) {
let r = e(t[n]);
if (r) return r;
}
return null;
}
_invokeAll(e) {
let t = Object.values(this.plugins);
t.unshift(this);
let n = [];
for (let r = 0; r < t.length; r++) {
let i = e(t[r]);
i && n.push(i);
}
return n;
}
getDependency(e, t) {
let n = e + ":" + t, r = this.cache.get(n);
if (!r) {
switch (e) {
case "scene":
r = this.loadScene(t);
break;
case "node":
r = this._invokeOne(function(e) {
return e.loadNode && e.loadNode(t);
});
break;
case "mesh":
r = this._invokeOne(function(e) {
return e.loadMesh && e.loadMesh(t);
});
break;
case "accessor":
r = this.loadAccessor(t);
break;
case "bufferView":
r = this._invokeOne(function(e) {
return e.loadBufferView && e.loadBufferView(t);
});
break;
case "buffer":
r = this.loadBuffer(t);
break;
case "material":
r = this._invokeOne(function(e) {
return e.loadMaterial && e.loadMaterial(t);
});
break;
case "texture":
r = this._invokeOne(function(e) {
return e.loadTexture && e.loadTexture(t);
});
break;
case "skin":
r = this.loadSkin(t);
break;
case "animation":
r = this._invokeOne(function(e) {
return e.loadAnimation && e.loadAnimation(t);
});
break;
case "camera":
r = this.loadCamera(t);
break;
default:
if (r = this._invokeOne(function(n) {
return n != this && n.getDependency && n.getDependency(e, t);
}), !r) throw Error("Unknown type: " + e);
break;
}
this.cache.add(n, r);
}
return r;
}
getDependencies(e) {
let t = this.cache.get(e);
if (!t) {
let n = this, r = this.json[e + (e === "mesh" ? "es" : "s")] || [];
t = Promise.all(r.map(function(t, r) {
return n.getDependency(e, r);
})), this.cache.add(e, t);
}
return t;
}
loadBuffer(e) {
let t = this.json.buffers[e], n = this.fileLoader;
if (t.type && t.type !== "arraybuffer") throw Error("THREE.GLTFLoader: " + t.type + " buffer type is not supported.");
if (t.uri === void 0 && e === 0) return Promise.resolve(this.extensions[DS.KHR_BINARY_GLTF].body);
let r = this.options;
return new Promise(function(e, i) {
n.load($e.resolveURL(t.uri, r.path), e, void 0, function() {
i(/* @__PURE__ */ Error("THREE.GLTFLoader: Failed to load buffer \"" + t.uri + "\"."));
});
});
}
loadBufferView(e) {
let t = this.json.bufferViews[e];
return this.getDependency("buffer", t.buffer).then(function(e) {
let n = t.byteLength || 0, r = t.byteOffset || 0;
return e.slice(r, r + n);
});
}
loadAccessor(e) {
let t = this, n = this.json, r = this.json.accessors[e];
if (r.bufferView === void 0 && r.sparse === void 0) {
let e = oC[r.type], t = rC[r.componentType], n = r.normalized === !0, i = new t(r.count * e);
return Promise.resolve(new Me(i, e, n));
}
let i = [];
return r.bufferView === void 0 ? i.push(null) : i.push(this.getDependency("bufferView", r.bufferView)), r.sparse !== void 0 && (i.push(this.getDependency("bufferView", r.sparse.indices.bufferView)), i.push(this.getDependency("bufferView", r.sparse.values.bufferView))), Promise.all(i).then(function(e) {
let i = e[0], a = oC[r.type], o = rC[r.componentType], s = o.BYTES_PER_ELEMENT, c = s * a, l = r.byteOffset || 0, u = r.bufferView === void 0 ? void 0 : n.bufferViews[r.bufferView].byteStride, d = r.normalized === !0, f, p;
if (u && u !== c) {
let e = Math.floor(l / u), n = "InterleavedBuffer:" + r.bufferView + ":" + r.componentType + ":" + e + ":" + r.count, c = t.cache.get(n);
c || (f = new o(i, e * u, r.count * u / s), c = new Vt(f, u / s), t.cache.add(n, c)), p = new dn(c, a, l % u / s, d);
} else f = i === null ? new o(r.count * a) : new o(i, l, r.count * a), p = new Me(f, a, d);
if (r.sparse !== void 0) {
let t = oC.SCALAR, n = rC[r.sparse.indices.componentType], s = r.sparse.indices.byteOffset || 0, c = r.sparse.values.byteOffset || 0, l = new n(e[1], s, r.sparse.count * t), u = new o(e[2], c, r.sparse.count * a);
i !== null && (p = new Me(p.array.slice(), p.itemSize, p.normalized)), p.normalized = !1;
for (let e = 0, t = l.length; e < t; e++) {
let t = l[e];
if (p.setX(t, u[e * a]), a >= 2 && p.setY(t, u[e * a + 1]), a >= 3 && p.setZ(t, u[e * a + 2]), a >= 4 && p.setW(t, u[e * a + 3]), a >= 5) throw Error("THREE.GLTFLoader: Unsupported itemSize in sparse BufferAttribute.");
}
p.normalized = d;
}
return p;
});
}
loadTexture(e) {
let t = this.json, n = this.options, r = t.textures[e].source, i = t.images[r], a = this.textureLoader;
if (i.uri) {
let e = n.manager.getHandler(i.uri);
e !== null && (a = e);
}
return this.loadTextureImage(e, r, a);
}
loadTextureImage(e, t, n) {
let r = this, i = this.json, a = i.textures[e], o = i.images[t], s = (o.uri || o.bufferView) + ":" + a.sampler;
if (this.textureCache[s]) return this.textureCache[s];
let c = this.loadImageSource(t, n).then(function(t) {
t.flipY = !1, t.name = a.name || o.name || "", t.name === "" && typeof o.uri == "string" && o.uri.startsWith("data:image/") === !1 && (t.name = o.uri);
let n = (i.samplers || {})[a.sampler] || {};
return t.magFilter = iC[n.magFilter] || 1006, t.minFilter = iC[n.minFilter] || 1008, t.wrapS = aC[n.wrapS] || 1e3, t.wrapT = aC[n.wrapT] || 1e3, t.generateMipmaps = !t.isCompressedTexture && t.minFilter !== 1003 && t.minFilter !== 1006, r.associations.set(t, { textures: e }), t;
}).catch(function() {
return null;
});
return this.textureCache[s] = c, c;
}
loadImageSource(e, t) {
let n = this, r = this.json, i = this.options;
if (this.sourceCache[e] !== void 0) return this.sourceCache[e].then((e) => e.clone());
let a = r.images[e], o = self.URL || self.webkitURL, s = a.uri || "", c = !1;
if (a.bufferView !== void 0) s = n.getDependency("bufferView", a.bufferView).then(function(e) {
c = !0;
let t = new Blob([e], { type: a.mimeType });
return s = o.createObjectURL(t), s;
});
else if (a.uri === void 0) throw Error("THREE.GLTFLoader: Image " + e + " is missing URI and bufferView");
let l = Promise.resolve(s).then(function(e) {
return new Promise(function(n, r) {
let a = n;
t.isImageBitmapLoader === !0 && (a = function(e) {
let t = new Qt(e);
t.needsUpdate = !0, n(t);
}), t.load($e.resolveURL(e, i.path), a, void 0, r);
});
}).then(function(e) {
return c === !0 && o.revokeObjectURL(s), pC(e, a), e.userData.mimeType = a.mimeType || yC(a.uri), e;
}).catch(function(e) {
throw console.error("THREE.GLTFLoader: Couldn't load texture", s), e;
});
return this.sourceCache[e] = l, l;
}
assignTexture(e, t, n, r) {
let i = this;
return this.getDependency("texture", n.index).then(function(a) {
if (!a) return null;
if (n.texCoord !== void 0 && n.texCoord > 0 && (a = a.clone(), a.channel = n.texCoord), i.extensions[DS.KHR_TEXTURE_TRANSFORM]) {
let e = n.extensions === void 0 ? void 0 : n.extensions[DS.KHR_TEXTURE_TRANSFORM];
if (e) {
let t = i.associations.get(a);
a = i.extensions[DS.KHR_TEXTURE_TRANSFORM].extendTexture(a, e), i.associations.set(a, t);
}
}
return r !== void 0 && (a.colorSpace = r), e[t] = a, a;
});
}
assignFinalMaterial(e) {
let t = e.geometry, n = e.material, r = t.attributes.tangent === void 0, i = t.attributes.color !== void 0, a = t.attributes.normal === void 0;
if (e.isPoints) {
let e = "PointsMaterial:" + n.uuid, t = this.cache.get(e);
t || (t = new Ue(), ut.prototype.copy.call(t, n), t.color.copy(n.color), t.map = n.map, t.sizeAttenuation = !1, this.cache.add(e, t)), n = t;
} else if (e.isLine) {
let e = "LineBasicMaterial:" + n.uuid, t = this.cache.get(e);
t || (t = new Zt(), ut.prototype.copy.call(t, n), t.color.copy(n.color), t.map = n.map, this.cache.add(e, t)), n = t;
}
if (r || i || a) {
let e = "ClonedMaterial:" + n.uuid + ":";
r && (e += "derivative-tangents:"), i && (e += "vertex-colors:"), a && (e += "flat-shading:");
let t = this.cache.get(e);
t || (t = n.clone(), i && (t.vertexColors = !0), a && (t.flatShading = !0), r && (t.normalScale && (t.normalScale.y *= -1), t.clearcoatNormalScale && (t.clearcoatNormalScale.y *= -1)), this.cache.add(e, t), this.associations.set(t, this.associations.get(n))), n = t;
}
e.material = n;
}
getMaterialType() {
return fn;
}
loadMaterial(e) {
let t = this, n = this.json, r = this.extensions, i = n.materials[e], a, o = {}, s = i.extensions || {}, c = [];
if (s[DS.KHR_MATERIALS_UNLIT]) {
let e = r[DS.KHR_MATERIALS_UNLIT];
a = e.getMaterialType(), c.push(e.extendParams(o, i, t));
} else {
let n = i.pbrMetallicRoughness || {};
if (o.color = new gt(1, 1, 1), o.opacity = 1, Array.isArray(n.baseColorFactor)) {
let e = n.baseColorFactor;
o.color.setRGB(e[0], e[1], e[2], vt), o.opacity = e[3];
}
n.baseColorTexture !== void 0 && c.push(t.assignTexture(o, "map", n.baseColorTexture, wt)), o.metalness = n.metallicFactor === void 0 ? 1 : n.metallicFactor, o.roughness = n.roughnessFactor === void 0 ? 1 : n.roughnessFactor, n.metallicRoughnessTexture !== void 0 && (c.push(t.assignTexture(o, "metalnessMap", n.metallicRoughnessTexture)), c.push(t.assignTexture(o, "roughnessMap", n.metallicRoughnessTexture))), a = this._invokeOne(function(t) {
return t.getMaterialType && t.getMaterialType(e);
}), c.push(Promise.all(this._invokeAll(function(t) {
return t.extendMaterialParams && t.extendMaterialParams(e, o);
})));
}
i.doubleSided === !0 && (o.side = 2);
let l = i.alphaMode || uC.OPAQUE;
if (l === uC.BLEND ? (o.transparent = !0, o.depthWrite = !1) : (o.transparent = !1, l === uC.MASK && (o.alphaTest = i.alphaCutoff === void 0 ? .5 : i.alphaCutoff)), i.normalTexture !== void 0 && a !== Mt && (c.push(t.assignTexture(o, "normalMap", i.normalTexture)), o.normalScale = new V(1, 1), i.normalTexture.scale !== void 0)) {
let e = i.normalTexture.scale;
o.normalScale.set(e, e);
}
if (i.occlusionTexture !== void 0 && a !== Mt && (c.push(t.assignTexture(o, "aoMap", i.occlusionTexture)), i.occlusionTexture.strength !== void 0 && (o.aoMapIntensity = i.occlusionTexture.strength)), i.emissiveFactor !== void 0 && a !== Mt) {
let e = i.emissiveFactor;
o.emissive = new gt().setRGB(e[0], e[1], e[2], vt);
}
return i.emissiveTexture !== void 0 && a !== Mt && c.push(t.assignTexture(o, "emissiveMap", i.emissiveTexture, wt)), Promise.all(c).then(function() {
let n = new a(o);
return i.name && (n.name = i.name), pC(n, i), t.associations.set(n, { materials: e }), i.extensions && fC(r, n, i), n;
});
}
createUniqueName(e) {
let t = Cn.sanitizeNodeName(e || "");
return t in this.nodeNamesUsed ? t + "_" + ++this.nodeNamesUsed[t] : (this.nodeNamesUsed[t] = 0, t);
}
loadGeometries(e) {
let t = this, n = this.extensions, r = this.primitiveCache;
function i(e) {
return n[DS.KHR_DRACO_MESH_COMPRESSION].decodePrimitive(e, t).then(function(n) {
return CC(n, e, t);
});
}
let a = [];
for (let n = 0, o = e.length; n < o; n++) {
let o = e[n], s = gC(o), c = r[s];
if (c) a.push(c.promise);
else {
let e;
e = o.extensions && o.extensions[DS.KHR_DRACO_MESH_COMPRESSION] ? i(o) : CC(new Xt(), o, t), r[s] = {
primitive: o,
promise: e
}, a.push(e);
}
}
return Promise.all(a);
}
loadMesh(e) {
let t = this, n = this.json, r = this.extensions, i = n.meshes[e], a = i.primitives, o = [];
for (let e = 0, t = a.length; e < t; e++) {
let t = a[e].material === void 0 ? dC(this.cache) : this.getDependency("material", a[e].material);
o.push(t);
}
return o.push(t.loadGeometries(a)), Promise.all(o).then(function(n) {
let o = n.slice(0, n.length - 1), s = n[n.length - 1], c = [];
for (let n = 0, l = s.length; n < l; n++) {
let l = s[n], u = a[n], d, f = o[n];
if (u.mode === nC.TRIANGLES || u.mode === nC.TRIANGLE_STRIP || u.mode === nC.TRIANGLE_FAN || u.mode === void 0) d = i.isSkinnedMesh === !0 ? new Ft(l, f) : new Yt(l, f), d.isSkinnedMesh === !0 && d.normalizeSkinWeights(), u.mode === nC.TRIANGLE_STRIP ? d.geometry = bS(d.geometry, 1) : u.mode === nC.TRIANGLE_FAN && (d.geometry = bS(d.geometry, 2));
else if (u.mode === nC.LINES) d = new Qe(l, f);
else if (u.mode === nC.LINE_STRIP) d = new $t(l, f);
else if (u.mode === nC.LINE_LOOP) d = new He(l, f);
else if (u.mode === nC.POINTS) d = new st(l, f);
else throw Error("THREE.GLTFLoader: Primitive mode unsupported: " + u.mode);
Object.keys(d.geometry.morphAttributes).length > 0 && hC(d, i), d.name = t.createUniqueName(i.name || "mesh_" + e), pC(d, i), u.extensions && fC(r, d, u), t.assignFinalMaterial(d), c.push(d);
}
for (let n = 0, r = c.length; n < r; n++) t.associations.set(c[n], {
meshes: e,
primitives: n
});
if (c.length === 1) return i.extensions && fC(r, c[0], i), c[0];
let l = new mn();
i.extensions && fC(r, l, i), t.associations.set(l, { meshes: e });
for (let e = 0, t = c.length; e < t; e++) l.add(c[e]);
return l;
});
}
loadCamera(e) {
let t, n = this.json.cameras[e], r = n[n.type];
if (!r) {
console.warn("THREE.GLTFLoader: Missing camera parameters.");
return;
}
return n.type === "perspective" ? t = new ot(zt.radToDeg(r.yfov), r.aspectRatio || 1, r.znear || 1, r.zfar || 2e6) : n.type === "orthographic" && (t = new Be(-r.xmag, r.xmag, r.ymag, -r.ymag, r.znear, r.zfar)), n.name && (t.name = this.createUniqueName(n.name)), pC(t, n), Promise.resolve(t);
}
loadSkin(e) {
let t = this.json.skins[e], n = [];
for (let e = 0, r = t.joints.length; e < r; e++) n.push(this._loadNodeShallow(t.joints[e]));
return t.inverseBindMatrices === void 0 ? n.push(null) : n.push(this.getDependency("accessor", t.inverseBindMatrices)), Promise.all(n).then(function(e) {
let n = e.pop(), r = e, i = [], a = [];
for (let e = 0, o = r.length; e < o; e++) {
let o = r[e];
if (o) {
i.push(o);
let t = new W();
n !== null && t.fromArray(n.array, e * 16), a.push(t);
} else console.warn("THREE.GLTFLoader: Joint \"%s\" could not be found.", t.joints[e]);
}
return new sn(i, a);
});
}
loadAnimation(e) {
let t = this.json, n = this, r = t.animations[e], i = r.name ? r.name : "animation_" + e, a = [], o = [], s = [], c = [], l = [];
for (let e = 0, t = r.channels.length; e < t; e++) {
let t = r.channels[e], n = r.samplers[t.sampler], i = t.target, u = i.node, d = r.parameters === void 0 ? n.input : r.parameters[n.input], f = r.parameters === void 0 ? n.output : r.parameters[n.output];
i.node !== void 0 && (a.push(this.getDependency("node", u)), o.push(this.getDependency("accessor", d)), s.push(this.getDependency("accessor", f)), c.push(n), l.push(i));
}
return Promise.all([
Promise.all(a),
Promise.all(o),
Promise.all(s),
Promise.all(c),
Promise.all(l)
]).then(function(e) {
let t = e[0], a = e[1], o = e[2], s = e[3], c = e[4], l = [];
for (let e = 0, r = t.length; e < r; e++) {
let r = t[e], i = a[e], u = o[e], d = s[e], f = c[e];
if (r === void 0) continue;
r.updateMatrix && r.updateMatrix();
let p = n._createAnimationTracks(r, i, u, d, f);
if (p) for (let e = 0; e < p.length; e++) l.push(p[e]);
}
let u = new At(i, void 0, l);
return pC(u, r), u;
});
}
createNodeMesh(e) {
let t = this.json, n = this, r = t.nodes[e];
return r.mesh === void 0 ? null : n.getDependency("mesh", r.mesh).then(function(e) {
let t = n._getNodeRef(n.meshCache, r.mesh, e);
return r.weights !== void 0 && t.traverse(function(e) {
if (e.isMesh) for (let t = 0, n = r.weights.length; t < n; t++) e.morphTargetInfluences[t] = r.weights[t];
}), t;
});
}
loadNode(e) {
let t = this.json, n = this, r = t.nodes[e], i = n._loadNodeShallow(e), a = [], o = r.children || [];
for (let e = 0, t = o.length; e < t; e++) a.push(n.getDependency("node", o[e]));
let s = r.skin === void 0 ? Promise.resolve(null) : n.getDependency("skin", r.skin);
return Promise.all([
i,
Promise.all(a),
s
]).then(function(e) {
let t = e[0], n = e[1], r = e[2];
r !== null && t.traverse(function(e) {
e.isSkinnedMesh && e.bind(r, bC);
});
for (let e = 0, r = n.length; e < r; e++) t.add(n[e]);
if (t.userData.pivot !== void 0 && n.length > 0) {
let e = t.userData.pivot, r = n[0];
t.pivot = new U().fromArray(e), t.position.x -= e[0], t.position.y -= e[1], t.position.z -= e[2], r.position.set(0, 0, 0), delete t.userData.pivot;
}
return t;
});
}
_loadNodeShallow(e) {
let t = this.json, n = this.extensions, r = this;
if (this.nodeCache[e] !== void 0) return this.nodeCache[e];
let i = t.nodes[e], a = i.name ? r.createUniqueName(i.name) : "", o = [], s = r._invokeOne(function(t) {
return t.createNodeMesh && t.createNodeMesh(e);
});
return s && o.push(s), i.camera !== void 0 && o.push(r.getDependency("camera", i.camera).then(function(e) {
return r._getNodeRef(r.cameraCache, i.camera, e);
})), r._invokeAll(function(t) {
return t.createNodeAttachment && t.createNodeAttachment(e);
}).forEach(function(e) {
o.push(e);
}), this.nodeCache[e] = Promise.all(o).then(function(t) {
let o;
if (o = i.isBone === !0 ? new Ie() : t.length > 1 ? new mn() : t.length === 1 ? t[0] : new Le(), o !== t[0]) for (let e = 0, n = t.length; e < n; e++) o.add(t[e]);
if (i.name && (o.userData.name = i.name, o.name = a), pC(o, i), i.extensions && fC(n, o, i), i.matrix !== void 0) {
let e = new W();
e.fromArray(i.matrix), o.applyMatrix4(e);
} else i.translation !== void 0 && o.position.fromArray(i.translation), i.rotation !== void 0 && o.quaternion.fromArray(i.rotation), i.scale !== void 0 && o.scale.fromArray(i.scale);
if (!r.associations.has(o)) r.associations.set(o, {});
else if (i.mesh !== void 0 && r.meshCache.refs[i.mesh] > 1) {
let e = r.associations.get(o);
r.associations.set(o, { ...e });
}
return r.associations.get(o).nodes = e, o;
}), this.nodeCache[e];
}
loadScene(e) {
let t = this.extensions, n = this.json.scenes[e], r = this, i = new mn();
n.name && (i.name = r.createUniqueName(n.name)), pC(i, n), n.extensions && fC(t, i, n);
let a = n.nodes || [], o = [];
for (let e = 0, t = a.length; e < t; e++) o.push(r.getDependency("node", a[e]));
return Promise.all(o).then(function(e) {
for (let t = 0, n = e.length; t < n; t++) {
let n = e[t];
n.parent === null ? i.add(n) : i.add(SS(n));
}
return r.associations = ((e) => {
let t = /* @__PURE__ */ new Map();
for (let [e, n] of r.associations) (e instanceof ut || e instanceof Qt) && t.set(e, n);
return e.traverse((e) => {
let n = r.associations.get(e);
n != null && t.set(e, n);
}), t;
})(i), i;
});
}
_createAnimationTracks(e, t, n, r, i) {
let a = [], o = e.name ? e.name : e.uuid, s = [];
function c(e) {
e.morphTargetInfluences && s.push(e.name ? e.name : e.uuid);
}
cC[i.path] === cC.weights ? (c(e), e.isGroup && e.children.forEach(c)) : s.push(o);
let l;
switch (cC[i.path]) {
case cC.weights:
l = mt;
break;
case cC.rotation:
l = Ct;
break;
case cC.translation:
case cC.scale:
l = an;
break;
default:
switch (n.itemSize) {
case 1:
l = mt;
break;
default:
l = an;
break;
}
break;
}
let u = r.interpolation === void 0 ? kt : lC[r.interpolation], d = this._getArrayFromAccessor(n);
for (let e = 0, n = s.length; e < n; e++) {
let n = new l(s[e] + "." + cC[i.path], t.array, d, u);
r.interpolation === "CUBICSPLINE" && this._createCubicSplineTrackInterpolant(n), a.push(n);
}
return a;
}
_getArrayFromAccessor(e) {
let t = e.array;
if (e.normalized) {
let e = vC(t.constructor), n = new Float32Array(t.length);
for (let r = 0, i = t.length; r < i; r++) n[r] = t[r] * e;
t = n;
}
return t;
}
_createCubicSplineTrackInterpolant(e) {
e.createInterpolant = function(e) {
return new (this instanceof Ct ? tC : $S)(this.times, this.values, this.getValueSize() / 3, e);
}, e.createInterpolant.isInterpolantFactoryMethodGLTFCubicSpline = !0;
}
};
function SC(e, t, n) {
let r = t.attributes, i = new ze();
if (r.POSITION !== void 0) {
let e = n.json.accessors[r.POSITION], t = e.min, a = e.max;
if (t !== void 0 && a !== void 0) {
if (i.set(new U(t[0], t[1], t[2]), new U(a[0], a[1], a[2])), e.normalized) {
let t = vC(rC[e.componentType]);
i.min.multiplyScalar(t), i.max.multiplyScalar(t);
}
} else {
console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
return;
}
} else return;
let a = t.targets;
if (a !== void 0) {
let e = new U(), t = new U();
for (let r = 0, i = a.length; r < i; r++) {
let i = a[r];
if (i.POSITION !== void 0) {
let r = n.json.accessors[i.POSITION], a = r.min, o = r.max;
if (a !== void 0 && o !== void 0) {
if (t.setX(Math.max(Math.abs(a[0]), Math.abs(o[0]))), t.setY(Math.max(Math.abs(a[1]), Math.abs(o[1]))), t.setZ(Math.max(Math.abs(a[2]), Math.abs(o[2]))), r.normalized) {
let e = vC(rC[r.componentType]);
t.multiplyScalar(e);
}
e.max(t);
} else console.warn("THREE.GLTFLoader: Missing min/max properties for accessor POSITION.");
}
}
i.expandByVector(e);
}
e.boundingBox = i;
let o = new vn();
i.getCenter(o.center), o.radius = i.min.distanceTo(i.max) / 2, e.boundingSphere = o;
}
function CC(e, t, n) {
let r = t.attributes, i = [];
function a(t, r) {
return n.getDependency("accessor", t).then(function(t) {
e.setAttribute(r, t);
});
}
for (let t in r) {
let n = sC[t] || t.toLowerCase();
n in e.attributes || i.push(a(r[t], n));
}
if (t.indices !== void 0 && !e.index) {
let r = n.getDependency("accessor", t.indices).then(function(t) {
e.setIndex(t);
});
i.push(r);
}
return Ge.workingColorSpace !== "srgb-linear" && "COLOR_0" in r && console.warn(`THREE.GLTFLoader: Converting vertex colors from "srgb-linear" to "${Ge.workingColorSpace}" not supported.`), pC(e, t), SC(e, t, n), Promise.all(i).then(function() {
return t.targets === void 0 ? e : mC(e, t.targets, n);
});
}
//#endregion
//#region ../renderer/src/objects/models/model-asset.ts
var wC = $c("model");
function TC(e, t) {
let n = /* @__PURE__ */ new Map(), r = new ze();
e.updateMatrixWorld(!0), e.traverse((e) => {
if (!(e instanceof Yt)) return;
let i = e;
if (!i.geometry || !i.material) return;
let a = Array.isArray(i.material) ? i.material[0] : i.material;
if (!a) return;
let o = DC(i.geometry), s = i instanceof hn ? Object.keys(o.attributes).filter((e) => e.startsWith("_")) : [], c = (e) => {
var t;
let i = o.clone();
for (let e of s) i.deleteAttribute(e);
i.applyMatrix4(e), i.computeBoundingBox(), i.boundingBox && r.union(i.boundingBox);
let c = EC(i), l = `${a.uuid}|${c}`, u = (t = n.get(l)) == null ? {
material: a,
signature: c,
geometries: []
} : t;
u.geometries.push(i), n.set(l, u);
};
if (!(i instanceof hn)) {
c(i.matrixWorld);
return;
}
let l = i.instanceColor ? [...s, "_COLOR_0"] : s;
l.length > 0 && wC.warn("model %s: ignored per-instance attributes %s on mesh \"%s\"", t, l.join(", "), i.name);
for (let e = 0; e < i.count; e++) c(kC.multiplyMatrices(i.matrixWorld, i.getMatrixAt(e, AC)));
});
let i = [];
for (let [e, { material: r, signature: a, geometries: o }] of n) {
let n = o.length === 1 ? o[0] : vS(o);
if (!n) {
wC.warn("model %s: dropped a part, %d geometries would not merge — material \"%s\" (%s), %s", t, o.length, r.name, r.uuid, a);
continue;
}
i.push({
id: e,
geometry: n,
material: r
});
}
return {
url: t,
parts: i,
extents: r
};
}
function EC(e) {
return `${e.getIndex() ? "indexed" : "non-indexed"} [${Object.keys(e.attributes).sort().join(", ")}]`;
}
function DC(e) {
let t = Object.entries(e.attributes).filter(([, e]) => !OC(e));
if (t.length === 0) return e;
let n = e.clone();
for (let [e, r] of t) {
let { count: t, itemSize: i } = r, a = new Float32Array(t * i);
for (let e = 0; e < t; e++) for (let t = 0; t < i; t++) a[e * i + t] = r.getComponent(e, t);
n.setAttribute(e, new Me(a, i));
}
return n;
}
function OC(e) {
return e instanceof Me && e.array instanceof Float32Array && !e.normalized;
}
var kC = new W(), AC = new W();
//#endregion
//#region ../renderer/src/objects/models/gltf-cache.ts
function jC(e, t) {
let n = FC.get(e);
if (n) return n;
let r = MC(e, t).catch((t) => {
throw FC.delete(e), t;
});
return FC.set(e, r), r;
}
async function MC(e, t) {
return TC((await NC(t).loadAsync(e)).scene, e);
}
function NC(e) {
let t = IC.get(e);
return t || (t = new wS().setMeshoptDecoder(_S).setKTX2Loader(PC(e)), IC.set(e, t)), t;
}
function PC(e) {
return { load(t, n, r, i) {
import("./ktx2-Dx_h97CR.js").then(({ ktx2Loader: a }) => a(e).load(t, n, r, i), i);
} };
}
var FC = /* @__PURE__ */ new Map(), IC = /* @__PURE__ */ new WeakMap(), LC = "instanceOpacity", RC = ["opaque", "translucent"];
function zC(e) {
var t;
return ((t = e.opacity) == null ? uS() : t) < 1 ? "translucent" : "opaque";
}
var BC = class extends yy {
constructor(e, t, n = "opaque") {
super({ schema: WC }), this.args = void 0, this.kind = void 0, this.meshMatrix = HC, this.extents = void 0, this.extents = e.clone().applyMatrix4(HC), this.kind = n, this.args = [{ capacity: Math.max(t, 1) }];
}
setPaintOrder() {}
place(e, t) {
this.mesh.setMatrixAt(e, $C.multiplyMatrices(UC, VC(this.extents, t.bounds)).multiply(HC));
}
setOpacity(e, t) {
var n;
let r = this.kind === "translucent" ? (n = t.opacity) == null ? -1 : n : 1;
this.mesh.setUniformAt(e, LC, r);
}
addInstance() {
let e = -1;
return this.mesh.addInstances(1, (t) => {
e = t;
}), e;
}
removeInstance(e) {
this.mesh.removeInstances(e);
}
};
function VC(e, t) {
e.getSize(KC), e.getCenter(qC);
let n = Math.min(KC.x > 0 ? t.size.x / KC.x : 1, KC.y > 0 ? t.size.y / KC.y : 1);
return ZC.makeTranslation(-qC.x, -qC.y, -e.min.z), JC.set(t.center.x, t.center.y, t.elevation), XC.setFromAxisAngle(GC, t.rotation), YC.setScalar(n), QC.compose(JC, XC, YC).multiply(ZC);
}
var HC = new W().makeRotationX(-Math.PI / 2).multiply(new W().makeScale(1, -1, 1)), UC = HC.clone().invert(), WC = {
fragment: { [LC]: "float" },
vertex: { ...rg.vertex }
}, GC = new U(0, 0, 1), KC = new U(), qC = new U(), JC = new U(), YC = new U(), XC = new yt(), ZC = new W(), QC = new W(), $C = new W(), ew = (0, G.memo)(function(e) {
let t = (0, Z.c)(3), { def: n, container: r } = e, i;
return t[0] !== r || t[1] !== n ? (i = (e) => {
r.place(e, n), r.setOpacity(e, n), zC(n) !== r.kind && r.reportKindMismatch();
}, t[0] = r, t[1] = n, t[2] = i) : i = t[2], Sv(r, n, null, i), null;
}), tw = $c("models");
function nw(e) {
var t;
let n = (0, Z.c)(25), { defs: r } = e, i = lS(), a = (t = e.mounted) == null ? r.length : t, o;
n[0] !== i || n[1] !== r ? (o = () => ow(r, i, void 0), n[0] = i, n[1] = r, n[2] = o) : o = n[2];
let [s, c] = (0, G.useState)(o);
(s.defs !== r || s.defaultOpacity !== i) && c((e) => ow(r, i, e.batches));
let l;
n[3] !== i || n[4] !== r ? (l = function() {
c((e) => ow(r, i, e.batches));
}, n[3] = i, n[4] = r, n[5] = l) : l = n[5];
let u = l, d;
n[6] === r ? d = n[7] : (d = uw(r), n[6] = r, n[7] = d);
let f = d, [p, m] = (0, G.useState)(f);
aS(p, f) || m(f);
let h;
n[8] === Symbol.for("react.memo_cache_sentinel") ? (h = [], n[8] = h) : h = n[8];
let [g, _] = (0, G.useState)(h), v = I(aw), y = I(iw), b, x;
n[9] !== y || n[10] !== v || n[11] !== p ? (b = () => {
let e = !0;
return Promise.all(p.map((e) => lw(e, y))).then((t) => {
e && (_(t.filter(rw)), v());
}), () => {
e = !1;
};
}, x = [
p,
v,
y
], n[9] = y, n[10] = v, n[11] = p, n[12] = b, n[13] = x) : (b = n[12], x = n[13]), (0, G.useEffect)(b, x);
let S;
if (n[14] !== g || n[15] !== a || n[16] !== s.batches || n[17] !== u) {
let e;
n[19] !== a || n[20] !== s.batches || n[21] !== u ? (e = (e) => /* @__PURE__ */ (0, K.jsx)(G.Fragment, { children: RC.map((t, n) => {
let r = s.batches[t].get(e.url);
return r ? /* @__PURE__ */ (0, K.jsx)(G.Fragment, { children: e.parts.map((i) => /* @__PURE__ */ (0, K.jsx)(cw, {
asset: e,
part: i,
defs: r,
mounted: a,
kind: t,
renderOrder: n,
onKindMismatch: u
}, i.id)) }, t) : null;
}) }, e.url), n[19] = a, n[20] = s.batches, n[21] = u, n[22] = e) : e = n[22], S = g.map(e), n[14] = g, n[15] = a, n[16] = s.batches, n[17] = u, n[18] = S;
} else S = n[18];
let C;
return n[23] === S ? C = n[24] : (C = /* @__PURE__ */ (0, K.jsx)(K.Fragment, { children: S }), n[23] = S, n[24] = C), C;
}
function rw(e) {
return e !== void 0;
}
function iw(e) {
return e.gl;
}
function aw(e) {
return e.invalidate;
}
function ow(e, t, n) {
let r = {
opaque: sw(n == null ? void 0 : n.opaque),
translucent: sw(n == null ? void 0 : n.translucent)
};
for (let t of e) {
let e = r[zC(t)], n = e.get(t.url);
n ? n.push(t) : e.set(t.url, [t]);
}
return {
defs: e,
defaultOpacity: t,
batches: r
};
}
function sw(e) {
let t = /* @__PURE__ */ new Map();
if (e) for (let n of e.keys()) t.set(n, []);
return t;
}
function cw(e) {
var t;
let n = (0, Z.c)(29), { asset: r, part: i, defs: a, kind: o, renderOrder: s, onKindMismatch: c } = e, l = (t = e.mounted) == null ? a.length : t, u;
n[0] !== r.extents || n[1] !== a.length || n[2] !== o ? (u = () => new BC(r.extents, a.length, o), n[0] = r.extents, n[1] = a.length, n[2] = o, n[3] = u) : u = n[3];
let d = bv(u, a, c), f = oS(), p;
n[4] !== d || n[5] !== o || n[6] !== f ? (p = (e) => {
d.bind(e), f(o === "opaque" ? e : null), e && !e.customDepthMaterial && (e.customDepthMaterial = new ln());
}, n[4] = d, n[5] = o, n[6] = f, n[7] = p) : p = n[7];
let m;
n[8] === i.geometry ? m = n[9] : (m = /* @__PURE__ */ (0, K.jsx)("primitive", {
object: i.geometry,
attach: "geometry",
dispose: null
}), n[8] = i.geometry, n[9] = m);
let h = o === "translucent", g;
n[10] !== i.material || n[11] !== h ? (g = /* @__PURE__ */ (0, K.jsx)(mS, {
source: i.material,
opacityUniform: LC,
translucent: h
}), n[10] = i.material, n[11] = h, n[12] = g) : g = n[12];
let _;
n[13] !== d.args || n[14] !== d.meshMatrix || n[15] !== s || n[16] !== p || n[17] !== m || n[18] !== g ? (_ = /* @__PURE__ */ (0, K.jsxs)(K_, {
args: d.args,
ref: p,
matrixAutoUpdate: !1,
matrix: d.meshMatrix,
castShadow: !0,
receiveShadow: !0,
sortObjects: !0,
renderOrder: s,
children: [m, g]
}), n[13] = d.args, n[14] = d.meshMatrix, n[15] = s, n[16] = p, n[17] = m, n[18] = g, n[19] = _) : _ = n[19];
let v;
if (n[20] !== d || n[21] !== a || n[22] !== l) {
let e;
n[24] === d ? e = n[25] : (e = (e) => /* @__PURE__ */ (0, K.jsx)(ew, {
def: e,
container: d
}, Ov(e)), n[24] = d, n[25] = e), v = a.slice(0, l).map(e), n[20] = d, n[21] = a, n[22] = l, n[23] = v;
} else v = n[23];
let y;
return n[26] !== _ || n[27] !== v ? (y = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [_, v] }), n[26] = _, n[27] = v, n[28] = y) : y = n[28], y;
}
async function lw(e, t) {
try {
return await jC(e, t);
} catch (t) {
tw.warn("failed to load model %s: %O", e, t);
return;
}
}
function uw(e) {
return [...new Set(e.map((e) => e.url))].sort();
}
var dw = le(class extends bn {
constructor(...e) {
super(...e), this.uniforms = new u_(), this.patchedMaterial = null;
}
addUniforms(e) {
this.uniforms.add(e, this.maxInstanceCount), this.patchedMaterial && (this.patchedMaterial.needsUpdate = !0);
}
getUniformAt(e, t, n) {
return this.uniforms.get(e, t, n);
}
setUniformAt(e, t, n) {
this.uniforms.set(e, t, n);
}
raycast(e, t) {
let n = t.length;
super.raycast(e, t);
for (let e = n; e < t.length; e++) t[e].instanceId = t[e].batchId;
}
onBeforeRender(e, t, n, r, i, a) {
super.onBeforeRender(e, t, n, r, i, a), this.uniforms.texture && (this.patchMaterial(), this.uniforms.texture.update(e));
}
addInstance(e) {
let t = super.addInstance(e);
return this.invalidateBounds(), t;
}
deleteInstance(e) {
return super.deleteInstance(e), this.invalidateBounds(), this;
}
setMatrixAt(e, t) {
return super.setMatrixAt(e, t), this.invalidateBounds(), this;
}
setInstanceCount(e) {
super.setInstanceCount(e), this.uniforms.resize(e);
}
dispose() {
super.dispose(), this.uniforms.dispose();
}
invalidateBounds() {
this.boundingBox = null, this.boundingSphere = null;
}
patchMaterial() {
let e = this.material;
if (Array.isArray(e) || e === this.patchedMaterial) return;
let t = "batchIndex", n = `float ${t} = getIndirectIndex( gl_DrawID ) + 0.5;`;
this.patchedMaterial = e;
let r = e.onBeforeCompile.bind(e), i = e.customProgramCacheKey.bind(e);
e.customProgramCacheKey = () => `efpBatched_${this.uniforms.shaderKey}_${i()}`, e.onBeforeCompile = (e, i) => {
this.uniforms.patchShader(e, t) && (e.vertexShader = uh(e.vertexShader, n)), r(e, i);
}, e.needsUpdate = !0;
}
});
//#endregion
//#region ../renderer/src/objects/shapes/shape-geometry.ts
function fw(e, t) {
var n, r, i;
let a = t ? "solid" : "planar";
if (yr(e) || br(e)) return (n = gw[a]) == null ? gw[a] = pw(t) : n;
let o = hw.get(e);
return o || (o = {}, hw.set(e, o)), (i = (r = o)[a]) == null ? r[a] = mw(e, t) : i;
}
function pw(e) {
let t = new Fe().deleteAttribute("uv");
return e ? t.toNonIndexed() : t.deleteAttribute("normal");
}
function mw(e, t) {
let n = new Xt().setFromPoints(e.vertices).setIndex(e.indices.flat());
if (!t) return n;
let r = n.toNonIndexed();
return r.computeVertexNormals(), xS(r, _w);
}
var hw = /* @__PURE__ */ new WeakMap(), gw = {}, _w = Math.PI / 6, vw = [
"planar",
"solid",
"translucent"
];
function yw(e) {
return !Sr(e.shape) || e.shape.isPlanar ? "planar" : oy(e.color) ? "translucent" : "solid";
}
var bw = class extends yy {
constructor(e, t = "planar") {
super(), this.capacity = void 0, this.kind = void 0, this.geometryIds = /* @__PURE__ */ new Map(), this.allocated = void 0, this.target = void 0, this.kind = t, this.allocated = xw(e, (e) => this.geometryFor(e)), this.capacity = [
this.allocated.instances,
this.allocated.vertices,
this.allocated.indices
], this.target = {
instances: this.allocated.instances,
vertices: this.allocated.vertices,
indices: this.allocated.indices
};
}
geometryFor(e) {
return fw(e, this.kind !== "planar");
}
reserve(e) {
this.target.instances = e.length;
let t = this.allocated.usedVertices, n = this.allocated.usedIndices, r = /* @__PURE__ */ new Set();
for (let i of e) {
let e = this.geometryFor(i.shape);
this.geometryIds.has(e) || r.has(e) || (r.add(e), t += Sw(e), n += Cw(e));
}
this.target.vertices = t, this.target.indices = n;
}
addInstance(e) {
let t = this.geometryIdFor(e);
return this.mesh.instanceCount === this.mesh.maxInstanceCount && this.mesh.setInstanceCount(Math.max(this.target.instances, this.mesh.maxInstanceCount + 1)), this.mesh.addInstance(t);
}
removeInstance(e) {
this.mesh.deleteInstance(e);
}
geometryIdFor(e) {
let t = this.geometryIds.get(e);
if (t !== void 0) return t;
let n = this.allocated.usedVertices + Sw(e), r = this.allocated.usedIndices + Cw(e);
(n > this.allocated.vertices || r > this.allocated.indices) && (this.allocated.vertices = Math.max(n, this.target.vertices), this.allocated.indices = Math.max(r, this.target.indices), this.mesh.setGeometrySize(this.allocated.vertices, this.allocated.indices)), this.allocated.usedVertices = n, this.allocated.usedIndices = r;
let i = this.mesh.addGeometry(e);
return this.geometryIds.set(e, i), i;
}
};
function xw(e, t) {
let n = 0, r = 0, i = /* @__PURE__ */ new Set();
for (let a of e) {
let e = t(a.shape);
i.has(e) || (i.add(e), n += Sw(e), r += Cw(e));
}
return {
instances: Math.max(e.length, 1),
vertices: Math.max(n, 1),
indices: Math.max(r, 1),
usedVertices: 0,
usedIndices: 0
};
}
function Sw(e) {
return e.getAttribute("position").count;
}
function Cw(e) {
var t, n;
return (t = (n = e.getIndex()) == null ? void 0 : n.count) == null ? 0 : t;
}
//#endregion
//#region ../renderer/src/objects/shapes/ShapeInstance.tsx
var ww = $c("shape-instance"), Tw = (0, G.memo)(function(e) {
let t = (0, Z.c)(6), { def: n, container: r } = e, i;
t[0] !== r || t[1] !== n.shape ? (i = () => r.geometryFor(n.shape), t[0] = r, t[1] = n.shape, t[2] = i) : i = t[2];
let a;
return t[3] !== r || t[4] !== n ? (a = (e) => {
cy(r.mesh, e, sy(n.shape)), ly(r.mesh, e, n, ww), yw(n) !== r.kind && r.reportKindMismatch();
}, t[3] = r, t[4] = n, t[5] = a) : a = t[5], Sv(r, n, i, a), null;
});
//#endregion
//#region ../renderer/src/objects/shapes/Shapes.tsx
function Ew(e) {
var t;
let n = (0, Z.c)(10), { defs: r } = e, i = (t = e.mounted) == null ? r.length : t, a;
n[0] === r ? a = n[1] : (a = () => Dw(r, {}), n[0] = r, n[1] = a);
let [o, s] = (0, G.useState)(a);
o.defs !== r && s((e) => Dw(r, e.batches));
let c;
n[2] === r ? c = n[3] : (c = function() {
s((e) => Dw(r, e.batches));
}, n[2] = r, n[3] = c);
let l = c, { batches: u } = o, d;
n[4] !== u || n[5] !== i || n[6] !== l ? (d = vw.map((e, t) => {
let n = u[e];
return n ? /* @__PURE__ */ (0, K.jsx)(Ow, {
defs: n,
mounted: i,
kind: e,
renderOrder: t,
onKindMismatch: l
}, e) : null;
}), n[4] = u, n[5] = i, n[6] = l, n[7] = d) : d = n[7];
let f;
return n[8] === d ? f = n[9] : (f = /* @__PURE__ */ (0, K.jsx)(K.Fragment, { children: d }), n[8] = d, n[9] = f), f;
}
function Dw(e, t) {
var n, r;
let i = {};
for (let e of vw) t[e] && (i[e] = []);
for (let t of e) ((r = i[n = yw(t)]) == null ? i[n] = [] : r).push(t);
return {
defs: e,
batches: i
};
}
function Ow(e) {
var t;
let n = (0, Z.c)(26), { defs: r, kind: i, renderOrder: a, onKindMismatch: o } = e, s = (t = e.mounted) == null ? r.length : t, c;
n[0] !== r || n[1] !== i ? (c = () => new bw(r, i), n[0] = r, n[1] = i, n[2] = c) : c = n[2];
let l = bv(c, r, o), u = oS();
l.reserve(r);
let d;
n[3] !== l || n[4] !== i || n[5] !== u ? (d = (e) => {
l.bind(e), u(i === "solid" ? e : null);
}, n[3] = l, n[4] = i, n[5] = u, n[6] = d) : d = n[6];
let f = i !== "planar", p = i !== "planar", m = i === "translucent", h;
n[7] !== p || n[8] !== m ? (h = /* @__PURE__ */ (0, K.jsx)(Ug, {
solid: p,
translucent: m
}), n[7] = p, n[8] = m, n[9] = h) : h = n[9];
let g;
n[10] !== l.capacity || n[11] !== l.customSort || n[12] !== a || n[13] !== d || n[14] !== f || n[15] !== h ? (g = /* @__PURE__ */ (0, K.jsx)(dw, {
args: l.capacity,
ref: d,
customSort: l.customSort,
receiveShadow: f,
renderOrder: a,
children: h
}), n[10] = l.capacity, n[11] = l.customSort, n[12] = a, n[13] = d, n[14] = f, n[15] = h, n[16] = g) : g = n[16];
let _;
if (n[17] !== l || n[18] !== r || n[19] !== s) {
let e;
n[21] === l ? e = n[22] : (e = (e) => /* @__PURE__ */ (0, K.jsx)(Tw, {
def: e,
container: l
}, Ov(e)), n[21] = l, n[22] = e), _ = r.slice(0, s).map(e), n[17] = l, n[18] = r, n[19] = s, n[20] = _;
} else _ = n[20];
let v;
return n[23] !== g || n[24] !== _ ? (v = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [g, _] }), n[23] = g, n[24] = _, n[25] = v) : v = n[25], v;
}
//#endregion
//#region ../../node_modules/.pnpm/troika-worker-utils@0.52.0/node_modules/troika-worker-utils/dist/troika-worker-utils.esm.js
function kw() {
var e = Object.create(null);
function t(n, i) {
var a = n.id, o = n.name, s = n.dependencies;
s === void 0 && (s = []);
var c = n.init;
c === void 0 && (c = function() {});
var l = n.getTransferables;
if (l === void 0 && (l = null), !e[a]) try {
s = s.map(function(n) {
return n && n.isWorkerModule && (t(n, function(e) {
if (e instanceof Error) throw e;
}), n = e[n.id].value), n;
}), c = r("<" + o + ">.init", c), l && (l = r("<" + o + ">.getTransferables", l));
var u = null;
typeof c == "function" ? u = c.apply(void 0, s) : console.error("worker module init function failed to rehydrate"), e[a] = {
id: a,
value: u,
getTransferables: l
}, i(u);
} catch (e) {
e && e.noLog || console.error(e), i(e);
}
}
function n(t, n) {
var r, i = t.id, a = t.args;
(!e[i] || typeof e[i].value != "function") && n(/* @__PURE__ */ Error("Worker module " + i + ": not found or its 'init' did not return a function"));
try {
var o = (r = e[i]).value.apply(r, a);
o && typeof o.then == "function" ? o.then(s, function(e) {
return n(e instanceof Error ? e : /* @__PURE__ */ Error("" + e));
}) : s(o);
} catch (e) {
n(e);
}
function s(t) {
try {
var r = e[i].getTransferables && e[i].getTransferables(t);
(!r || !Array.isArray(r) || !r.length) && (r = void 0), n(t, r);
} catch (e) {
console.error(e), n(e);
}
}
}
function r(e, t) {
var n = void 0;
self.troikaDefine = function(e) {
return n = e;
};
var r = URL.createObjectURL(new Blob(["/** " + e.replace(/\*/g, "") + " **/\n\ntroikaDefine(\n" + t + "\n)"], { type: "application/javascript" }));
try {
importScripts(r);
} catch (e) {
console.error(e);
}
return URL.revokeObjectURL(r), delete self.troikaDefine, n;
}
self.addEventListener("message", function(e) {
var r = e.data, i = r.messageId, a = r.action, o = r.data;
try {
a === "registerModule" && t(o, function(e) {
e instanceof Error ? postMessage({
messageId: i,
success: !1,
error: e.message
}) : postMessage({
messageId: i,
success: !0,
result: { isCallable: typeof e == "function" }
});
}), a === "callModule" && n(o, function(e, t) {
e instanceof Error ? postMessage({
messageId: i,
success: !1,
error: e.message
}) : postMessage({
messageId: i,
success: !0,
result: e
}, t || void 0);
});
} catch (e) {
postMessage({
messageId: i,
success: !1,
error: e.stack
});
}
});
}
function Aw(e) {
var t = function() {
for (var e = [], n = arguments.length; n--;) e[n] = arguments[n];
return t._getInitResult().then(function(t) {
if (typeof t == "function") return t.apply(void 0, e);
throw Error("Worker module function was called but `init` did not return a callable function");
});
};
return t._getInitResult = function() {
var n = e.dependencies, r = e.init;
n = Array.isArray(n) ? n.map(function(e) {
return e && (e = e.onMainThread || e, e._getInitResult && (e = e._getInitResult())), e;
}) : [];
var i = Promise.all(n).then(function(e) {
return r.apply(null, e);
});
return t._getInitResult = function() {
return i;
}, i;
}, t;
}
var jw = function() {
var e = !1;
if (typeof window < "u" && window.document !== void 0) try {
new Worker(URL.createObjectURL(new Blob([""], { type: "application/javascript" }))).terminate(), e = !0;
} catch (e) {
console.log("Troika createWorkerModule: web workers not allowed; falling back to main thread execution. Cause: [" + e.message + "]");
}
return jw = function() {
return e;
}, e;
}, Mw = 0, Nw = 0, Pw = !1, Fw = Object.create(null), Iw = Object.create(null), Lw = Object.create(null);
function Rw(e) {
if ((!e || typeof e.init != "function") && !Pw) throw Error("requires `options.init` function");
var t = e.dependencies, n = e.init, r = e.getTransferables, i = e.workerId, a = Aw(e);
i == null && (i = "#default");
var o = "workerModule" + ++Mw, s = e.name || o, c = null;
t = t && t.map(function(e) {
return typeof e == "function" && !e.workerModuleData && (Pw = !0, e = Rw({
workerId: i,
name: "<" + s + "> function dependency: " + e.name,
init: "function(){return (\n" + Bw(e) + "\n)}"
}), Pw = !1), e && e.workerModuleData && (e = e.workerModuleData), e;
});
function l() {
for (var e = [], t = arguments.length; t--;) e[t] = arguments[t];
if (!jw()) return a.apply(void 0, e);
if (!c) {
c = Hw(i, "registerModule", l.workerModuleData);
var n = function() {
c = null, Iw[i].delete(n);
};
(Iw[i] || (Iw[i] = /* @__PURE__ */ new Set())).add(n);
}
return c.then(function(t) {
if (t.isCallable) return Hw(i, "callModule", {
id: o,
args: e
});
throw Error("Worker module function was called but `init` did not return a callable function");
});
}
return l.workerModuleData = {
isWorkerModule: !0,
id: o,
name: s,
dependencies: t,
init: Bw(n),
getTransferables: r && Bw(r)
}, l.onMainThread = a, l;
}
function zw(e) {
Iw[e] && Iw[e].forEach(function(e) {
e();
}), Fw[e] && (Fw[e].terminate(), delete Fw[e]);
}
function Bw(e) {
var t = e.toString();
return !/^function/.test(t) && /^\w+\s*\(/.test(t) && (t = "function " + t), t;
}
function Vw(e) {
var t = Fw[e];
if (!t) {
var n = Bw(kw);
t = Fw[e] = new Worker(URL.createObjectURL(new Blob(["/** Worker Module Bootstrap: " + e.replace(/\*/g, "") + " **/\n\n;(" + n + ")()"], { type: "application/javascript" }))), t.onmessage = function(e) {
var t = e.data, n = t.messageId, r = Lw[n];
if (!r) throw Error("WorkerModule response with empty or unknown messageId");
delete Lw[n], r(t);
};
}
return t;
}
function Hw(e, t, n) {
return new Promise(function(r, i) {
var a = ++Nw;
Lw[a] = function(e) {
e.success ? r(e.result) : i(/* @__PURE__ */ Error("Error in worker " + t + " call: " + e.error));
}, Vw(e).postMessage({
messageId: a,
action: t,
data: n
});
});
}
//#endregion
//#region ../../node_modules/.pnpm/webgl-sdf-generator@1.1.1/node_modules/webgl-sdf-generator/dist/webgl-sdf-generator.mjs
function Uw() {
return function(e) {
function t(e, t, n, r, i, a, o, s) {
var c = 1 - o;
s.x = c * c * e + 2 * c * o * n + o * o * i, s.y = c * c * t + 2 * c * o * r + o * o * a;
}
function n(e, t, n, r, i, a, o, s, c, l) {
var u = 1 - c;
l.x = u * u * u * e + 3 * u * u * c * n + 3 * u * c * c * i + c * c * c * o, l.y = u * u * u * t + 3 * u * u * c * r + 3 * u * c * c * a + c * c * c * s;
}
function r(e, t) {
for (var n = /([MLQCZ])([^MLQCZ]*)/g, r, i, a, o, s; r = n.exec(e);) {
var c = r[2].replace(/^\s*|\s*$/g, "").split(/[,\s]+/).map(function(e) {
return parseFloat(e);
});
switch (r[1]) {
case "M":
o = i = c[0], s = a = c[1];
break;
case "L":
(c[0] !== o || c[1] !== s) && t("L", o, s, o = c[0], s = c[1]);
break;
case "Q":
t("Q", o, s, o = c[2], s = c[3], c[0], c[1]);
break;
case "C":
t("C", o, s, o = c[4], s = c[5], c[0], c[1], c[2], c[3]);
break;
case "Z":
(o !== i || s !== a) && t("L", o, s, i, a);
break;
}
}
}
function i(e, i, a) {
a === void 0 && (a = 16);
var o = {
x: 0,
y: 0
};
r(e, function(e, r, s, c, l, u, d, f, p) {
switch (e) {
case "L":
i(r, s, c, l);
break;
case "Q":
for (var m = r, h = s, g = 1; g < a; g++) t(r, s, u, d, c, l, g / (a - 1), o), i(m, h, o.x, o.y), m = o.x, h = o.y;
break;
case "C":
for (var _ = r, v = s, y = 1; y < a; y++) n(r, s, u, d, f, p, c, l, y / (a - 1), o), i(_, v, o.x, o.y), _ = o.x, v = o.y;
break;
}
});
}
var a = "precision highp float;attribute vec2 aUV;varying vec2 vUV;void main(){vUV=aUV;gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}", o = /* @__PURE__ */ new WeakMap(), s = {
premultipliedAlpha: !1,
preserveDrawingBuffer: !0,
antialias: !1,
depth: !1
};
function c(e, t) {
var n = e.getContext ? e.getContext("webgl", s) : e, r = o.get(n);
if (!r) {
var i = typeof WebGL2RenderingContext < "u" && n instanceof WebGL2RenderingContext, a = {}, c = {}, l = {}, u = -1, d = [];
n.canvas.addEventListener("webglcontextlost", function(e) {
m(), e.preventDefault();
}, !1);
function e(e) {
var t = a[e];
if (!t && (t = a[e] = n.getExtension(e), !t)) throw Error(e + " not supported");
return t;
}
function t(e, t) {
var r = n.createShader(t);
return n.shaderSource(r, e), n.compileShader(r), r;
}
function s(r, a, o, s) {
if (!c[r]) {
var l = {}, u = {}, d = n.createProgram();
n.attachShader(d, t(a, n.VERTEX_SHADER)), n.attachShader(d, t(o, n.FRAGMENT_SHADER)), n.linkProgram(d), c[r] = {
program: d,
transaction: function(t) {
n.useProgram(d), t({
setUniform: function(e, t) {
for (var r = [], i = arguments.length - 2; i-- > 0;) r[i] = arguments[i + 2];
var a = u[t] || (u[t] = n.getUniformLocation(d, t));
n["uniform" + e].apply(n, [a].concat(r));
},
setAttribute: function(t, r, a, o, s) {
var c = l[t];
c || (c = l[t] = {
buf: n.createBuffer(),
loc: n.getAttribLocation(d, t),
data: null
}), n.bindBuffer(n.ARRAY_BUFFER, c.buf), n.vertexAttribPointer(c.loc, r, n.FLOAT, !1, 0, 0), n.enableVertexAttribArray(c.loc), i ? n.vertexAttribDivisor(c.loc, o) : e("ANGLE_instanced_arrays").vertexAttribDivisorANGLE(c.loc, o), s !== c.data && (n.bufferData(n.ARRAY_BUFFER, s, a), c.data = s);
}
});
}
};
}
c[r].transaction(s);
}
function f(e, t) {
u++;
try {
n.activeTexture(n.TEXTURE0 + u);
var r = l[e];
r || (r = l[e] = n.createTexture(), n.bindTexture(n.TEXTURE_2D, r), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MIN_FILTER, n.NEAREST), n.texParameteri(n.TEXTURE_2D, n.TEXTURE_MAG_FILTER, n.NEAREST)), n.bindTexture(n.TEXTURE_2D, r), t(r, u);
} finally {
u--;
}
}
function p(e, t, r) {
var i = n.createFramebuffer();
d.push(i), n.bindFramebuffer(n.FRAMEBUFFER, i), n.activeTexture(n.TEXTURE0 + t), n.bindTexture(n.TEXTURE_2D, e), n.framebufferTexture2D(n.FRAMEBUFFER, n.COLOR_ATTACHMENT0, n.TEXTURE_2D, e, 0);
try {
r(i);
} finally {
n.deleteFramebuffer(i), n.bindFramebuffer(n.FRAMEBUFFER, d[--d.length - 1] || null);
}
}
function m() {
a = {}, c = {}, l = {}, u = -1, d.length = 0;
}
o.set(n, r = {
gl: n,
isWebGL2: i,
getExtension: e,
withProgram: s,
withTexture: f,
withTextureFramebuffer: p,
handleContextLoss: m
});
}
t(r);
}
function l(e, t, n, r, i, o, s, l) {
s === void 0 && (s = 15), l === void 0 && (l = null), c(e, function(e) {
var c = e.gl, u = e.withProgram, d = e.withTexture;
d("copy", function(e, d) {
c.texImage2D(c.TEXTURE_2D, 0, c.RGBA, i, o, 0, c.RGBA, c.UNSIGNED_BYTE, t), u("copy", a, "precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){gl_FragColor=texture2D(tex,vUV);}", function(e) {
var t = e.setUniform, a = e.setAttribute;
a("aUV", 2, c.STATIC_DRAW, 0, new Float32Array([
0,
0,
2,
0,
0,
2
])), t("1i", "image", d), c.bindFramebuffer(c.FRAMEBUFFER, l || null), c.disable(c.BLEND), c.colorMask(s & 8, s & 4, s & 2, s & 1), c.viewport(n, r, i, o), c.scissor(n, r, i, o), c.drawArrays(c.TRIANGLES, 0, 3);
});
});
});
}
function u(e, t, n) {
var r = e.width, i = e.height;
c(e, function(a) {
var o = a.gl, s = new Uint8Array(r * i * 4);
o.readPixels(0, 0, r, i, o.RGBA, o.UNSIGNED_BYTE, s), e.width = t, e.height = n, l(o, s, 0, 0, r, i);
});
}
var d = /*#__PURE__*/ Object.freeze({
__proto__: null,
withWebGLContext: c,
renderImageData: l,
resizeWebGLCanvasWithoutClearing: u
});
function f(e, t, n, r, a, o) {
o === void 0 && (o = 1);
var s = new Uint8Array(e * t), c = r[2] - r[0], l = r[3] - r[1], u = [];
i(n, function(e, t, n, r) {
u.push({
x1: e,
y1: t,
x2: n,
y2: r,
minX: Math.min(e, n),
minY: Math.min(t, r),
maxX: Math.max(e, n),
maxY: Math.max(t, r)
});
}), u.sort(function(e, t) {
return e.maxX - t.maxX;
});
for (var d = 0; d < e; d++) for (var f = 0; f < t; f++) {
var p = g(r[0] + c * (d + .5) / e, r[1] + l * (f + .5) / t), m = (1 - Math.abs(p) / a) ** o / 2;
p < 0 && (m = 1 - m), m = Math.max(0, Math.min(255, Math.round(m * 255))), s[f * e + d] = m;
}
return s;
function g(e, t) {
for (var n = Infinity, r = Infinity, i = u.length; i--;) {
var a = u[i];
if (a.maxX + r <= e) break;
if (e + r > a.minX && t - r < a.maxY && t + r > a.minY) {
var o = h(e, t, a.x1, a.y1, a.x2, a.y2);
o < n && (n = o, r = Math.sqrt(n));
}
}
return _(e, t) && (r = -r), r;
}
function _(e, t) {
for (var n = 0, r = u.length; r--;) {
var i = u[r];
if (i.maxX <= e) break;
i.y1 > t != i.y2 > t && e < (i.x2 - i.x1) * (t - i.y1) / (i.y2 - i.y1) + i.x1 && (n += i.y1 < i.y2 ? 1 : -1);
}
return n !== 0;
}
}
function p(e, t, n, r, i, a, o, s, c, l) {
a === void 0 && (a = 1), s === void 0 && (s = 0), c === void 0 && (c = 0), l === void 0 && (l = 0), m(e, t, n, r, i, a, o, null, s, c, l);
}
function m(e, t, n, r, i, a, o, s, c, u, d) {
a === void 0 && (a = 1), c === void 0 && (c = 0), u === void 0 && (u = 0), d === void 0 && (d = 0);
for (var p = f(e, t, n, r, i, a), m = new Uint8Array(p.length * 4), h = 0; h < p.length; h++) m[h * 4 + d] = p[h];
l(o, m, c, u, e, t, 1 << 3 - d, s);
}
function h(e, t, n, r, i, a) {
var o = i - n, s = a - r, c = o * o + s * s, l = c ? Math.max(0, Math.min(1, ((e - n) * o + (t - r) * s) / c)) : 0, u = e - (n + l * o), d = t - (r + l * s);
return u * u + d * d;
}
var g = /*#__PURE__*/ Object.freeze({
__proto__: null,
generate: f,
generateIntoCanvas: p,
generateIntoFramebuffer: m
}), _ = "precision highp float;uniform vec4 uGlyphBounds;attribute vec2 aUV;attribute vec4 aLineSegment;varying vec4 vLineSegment;varying vec2 vGlyphXY;void main(){vLineSegment=aLineSegment;vGlyphXY=mix(uGlyphBounds.xy,uGlyphBounds.zw,aUV);gl_Position=vec4(mix(vec2(-1.0),vec2(1.0),aUV),0.0,1.0);}", v = "precision highp float;uniform vec4 uGlyphBounds;uniform float uMaxDistance;uniform float uExponent;varying vec4 vLineSegment;varying vec2 vGlyphXY;float absDistToSegment(vec2 point,vec2 lineA,vec2 lineB){vec2 lineDir=lineB-lineA;float lenSq=dot(lineDir,lineDir);float t=lenSq==0.0 ? 0.0 : clamp(dot(point-lineA,lineDir)/lenSq,0.0,1.0);vec2 linePt=lineA+t*lineDir;return distance(point,linePt);}void main(){vec4 seg=vLineSegment;vec2 p=vGlyphXY;float dist=absDistToSegment(p,seg.xy,seg.zw);float val=pow(1.0-clamp(dist/uMaxDistance,0.0,1.0),uExponent)*0.5;bool crossing=(seg.y>p.y!=seg.w>p.y)&&(p.x<(seg.z-seg.x)*(p.y-seg.y)/(seg.w-seg.y)+seg.x);bool crossingUp=crossing&&vLineSegment.y<vLineSegment.w;gl_FragColor=vec4(crossingUp ? 1.0/255.0 : 0.0,crossing&&!crossingUp ? 1.0/255.0 : 0.0,0.0,val);}", y = "precision highp float;uniform sampler2D tex;varying vec2 vUV;void main(){vec4 color=texture2D(tex,vUV);bool inside=color.r!=color.g;float val=inside ? 1.0-color.a : color.a;gl_FragColor=vec4(val);}", b = new Float32Array([
0,
0,
2,
0,
0,
2
]), x = null, S = !1, C = {}, w = /* @__PURE__ */ new WeakMap();
function T(e) {
if (!S && !k(e)) throw Error("WebGL generation not supported");
}
function E(e, t, n, r, i, a, o) {
if (a === void 0 && (a = 1), o === void 0 && (o = null), !o && (o = x, !o)) {
var s = typeof OffscreenCanvas == "function" ? new OffscreenCanvas(1, 1) : typeof document < "u" ? document.createElement("canvas") : null;
if (!s) throw Error("OffscreenCanvas or DOM canvas not supported");
o = x = s.getContext("webgl", { depth: !1 });
}
T(o);
var l = new Uint8Array(e * t * 4);
c(o, function(o) {
var s = o.gl, c = o.withTexture, u = o.withTextureFramebuffer;
c("readable", function(o, c) {
s.texImage2D(s.TEXTURE_2D, 0, s.RGBA, e, t, 0, s.RGBA, s.UNSIGNED_BYTE, null), u(o, c, function(o) {
O(e, t, n, r, i, a, s, o, 0, 0, 0), s.readPixels(0, 0, e, t, s.RGBA, s.UNSIGNED_BYTE, l);
});
});
});
for (var u = new Uint8Array(e * t), d = 0, f = 0; d < l.length; d += 4) u[f++] = l[d];
return u;
}
function D(e, t, n, r, i, a, o, s, c, l) {
a === void 0 && (a = 1), s === void 0 && (s = 0), c === void 0 && (c = 0), l === void 0 && (l = 0), O(e, t, n, r, i, a, o, null, s, c, l);
}
function O(e, t, n, r, o, s, l, u, d, f, p) {
s === void 0 && (s = 1), d === void 0 && (d = 0), f === void 0 && (f = 0), p === void 0 && (p = 0), T(l);
var m = [];
i(n, function(e, t, n, r) {
m.push(e, t, n, r);
}), m = new Float32Array(m), c(l, function(n) {
var i = n.gl, c = n.isWebGL2, l = n.getExtension, h = n.withProgram, g = n.withTexture, x = n.withTextureFramebuffer, S = n.handleContextLoss;
if (g("rawDistances", function(n, g) {
(e !== n._lastWidth || t !== n._lastHeight) && i.texImage2D(i.TEXTURE_2D, 0, i.RGBA, n._lastWidth = e, n._lastHeight = t, 0, i.RGBA, i.UNSIGNED_BYTE, null), h("main", _, v, function(a) {
var u = a.setAttribute, d = a.setUniform, f = !c && l("ANGLE_instanced_arrays"), p = !c && l("EXT_blend_minmax");
u("aUV", 2, i.STATIC_DRAW, 0, b), u("aLineSegment", 4, i.DYNAMIC_DRAW, 1, m), d.apply(void 0, ["4f", "uGlyphBounds"].concat(r)), d("1f", "uMaxDistance", o), d("1f", "uExponent", s), x(n, g, function(n) {
i.enable(i.BLEND), i.colorMask(!0, !0, !0, !0), i.viewport(0, 0, e, t), i.scissor(0, 0, e, t), i.blendFunc(i.ONE, i.ONE), i.blendEquationSeparate(i.FUNC_ADD, c ? i.MAX : p.MAX_EXT), i.clear(i.COLOR_BUFFER_BIT), c ? i.drawArraysInstanced(i.TRIANGLES, 0, 3, m.length / 4) : f.drawArraysInstancedANGLE(i.TRIANGLES, 0, 3, m.length / 4);
});
}), h("post", a, y, function(n) {
n.setAttribute("aUV", 2, i.STATIC_DRAW, 0, b), n.setUniform("1i", "tex", g), i.bindFramebuffer(i.FRAMEBUFFER, u), i.disable(i.BLEND), i.colorMask(p === 0, p === 1, p === 2, p === 3), i.viewport(d, f, e, t), i.scissor(d, f, e, t), i.drawArrays(i.TRIANGLES, 0, 3);
});
}), i.isContextLost()) throw S(), Error("webgl context lost");
});
}
function k(e) {
var t = !e || e === x ? C : e.canvas || e, n = w.get(t);
if (n === void 0) {
S = !0;
var r = null;
try {
var i = [
97,
106,
97,
61,
99,
137,
118,
80,
80,
118,
137,
99,
61,
97,
106,
97
], a = E(4, 4, "M8,8L16,8L24,24L16,24Z", [
0,
0,
32,
32
], 24, 1, e);
n = a && i.length === a.length && a.every(function(e, t) {
return e === i[t];
}), n || (r = "bad trial run results", console.info(i, a));
} catch (e) {
n = !1, r = e.message;
}
r && console.warn("WebGL SDF generation not supported:", r), S = !1, w.set(t, n);
}
return n;
}
var A = /*#__PURE__*/ Object.freeze({
__proto__: null,
generate: E,
generateIntoCanvas: D,
generateIntoFramebuffer: O,
isSupported: k
});
function j(e, t, n, r, i, a) {
i === void 0 && (i = Math.max(r[2] - r[0], r[3] - r[1]) / 2), a === void 0 && (a = 1);
try {
return E.apply(A, arguments);
} catch (e) {
return console.info("WebGL SDF generation failed, falling back to JS", e), f.apply(g, arguments);
}
}
function M(e, t, n, r, i, a, o, s, c, l) {
i === void 0 && (i = Math.max(r[2] - r[0], r[3] - r[1]) / 2), a === void 0 && (a = 1), s === void 0 && (s = 0), c === void 0 && (c = 0), l === void 0 && (l = 0);
try {
return D.apply(A, arguments);
} catch (e) {
return console.info("WebGL SDF generation failed, falling back to JS", e), p.apply(g, arguments);
}
}
return e.forEachPathCommand = r, e.generate = j, e.generateIntoCanvas = M, e.javascript = g, e.pathToLineSegments = i, e.webgl = A, e.webglUtils = d, Object.defineProperty(e, "__esModule", { value: !0 }), e;
}({});
}
//#endregion
//#region ../../node_modules/.pnpm/bidi-js@1.0.3/node_modules/bidi-js/dist/bidi.mjs
function Ww() {
return function(e) {
var t = {
R: "13k,1a,2,3,3,2+1j,ch+16,a+1,5+2,2+n,5,a,4,6+16,4+3,h+1b,4mo,179q,2+9,2+11,2i9+7y,2+68,4,3+4,5+13,4+3,2+4k,3+29,8+cf,1t+7z,w+17,3+3m,1t+3z,16o1+5r,8+30,8+mc,29+1r,29+4v,75+73",
EN: "1c+9,3d+1,6,187+9,513,4+5,7+9,sf+j,175h+9,qw+q,161f+1d,4xt+a,25i+9",
ES: "17,2,6dp+1,f+1,av,16vr,mx+1,4o,2",
ET: "z+2,3h+3,b+1,ym,3e+1,2o,p4+1,8,6u,7c,g6,1wc,1n9+4,30+1b,2n,6d,qhx+1,h0m,a+1,49+2,63+1,4+1,6bb+3,12jj",
AN: "16o+5,2j+9,2+1,35,ed,1ff2+9,87+u",
CS: "18,2+1,b,2u,12k,55v,l,17v0,2,3,53,2+1,b",
B: "a,3,f+2,2v,690",
S: "9,2,k",
WS: "c,k,4f4,1vk+a,u,1j,335",
ON: "x+1,4+4,h+5,r+5,r+3,z,5+3,2+1,2+1,5,2+2,3+4,o,w,ci+1,8+d,3+d,6+8,2+g,39+1,9,6+1,2,33,b8,3+1,3c+1,7+1,5r,b,7h+3,sa+5,2,3i+6,jg+3,ur+9,2v,ij+1,9g+9,7+a,8m,4+1,49+x,14u,2+2,c+2,e+2,e+2,e+1,i+n,e+e,2+p,u+2,e+2,36+1,2+3,2+1,b,2+2,6+5,2,2,2,h+1,5+4,6+3,3+f,16+2,5+3l,3+81,1y+p,2+40,q+a,m+13,2r+ch,2+9e,75+hf,3+v,2+2w,6e+5,f+6,75+2a,1a+p,2+2g,d+5x,r+b,6+3,4+o,g,6+1,6+2,2k+1,4,2j,5h+z,1m+1,1e+f,t+2,1f+e,d+3,4o+3,2s+1,w,535+1r,h3l+1i,93+2,2s,b+1,3l+x,2v,4g+3,21+3,kz+1,g5v+1,5a,j+9,n+v,2,3,2+8,2+1,3+2,2,3,46+1,4+4,h+5,r+5,r+a,3h+2,4+6,b+4,78,1r+24,4+c,4,1hb,ey+6,103+j,16j+c,1ux+7,5+g,fsh,jdq+1t,4,57+2e,p1,1m,1m,1m,1m,4kt+1,7j+17,5+2r,d+e,3+e,2+e,2+10,m+4,w,1n+5,1q,4z+5,4b+rb,9+c,4+c,4+37,d+2g,8+b,l+b,5+1j,9+9,7+13,9+t,3+1,27+3c,2+29,2+3q,d+d,3+4,4+2,6+6,a+o,8+6,a+2,e+6,16+42,2+1i",
BN: "0+8,6+d,2s+5,2+p,e,4m9,1kt+2,2b+5,5+5,17q9+v,7k,6p+8,6+1,119d+3,440+7,96s+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+1,1ekf+75,6p+2rz,1ben+1,1ekf+1,1ekf+1",
NSM: "lc+33,7o+6,7c+18,2,2+1,2+1,2,21+a,1d+k,h,2u+6,3+5,3+1,2+3,10,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,g+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+g,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,k1+w,2db+2,3y,2p+v,ff+3,30+1,n9x+3,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,r2,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+5,3+1,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2d+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,f0c+4,1o+6,t5,1s+3,2a,f5l+1,43t+2,i+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,gzhy+6n",
AL: "16w,3,2,e+1b,z+2,2+2s,g+1,8+1,b+m,2+t,s+2i,c+e,4h+f,1d+1e,1bwe+dp,3+3z,x+c,2+1,35+3y,2rm+z,5+7,b+5,dt+l,c+u,17nl+27,1t+27,4x+6n,3+d",
LRO: "6ct",
RLO: "6cu",
LRE: "6cq",
RLE: "6cr",
PDF: "6cs",
LRI: "6ee",
RLI: "6ef",
FSI: "6eg",
PDI: "6eh"
}, n = {}, r = {};
n.L = 1, r[1] = "L", Object.keys(t).forEach(function(e, t) {
n[e] = 1 << t + 1, r[n[e]] = e;
}), Object.freeze(n);
var i = n.LRI | n.RLI | n.FSI, a = n.L | n.R | n.AL, o = n.B | n.S | n.WS | n.ON | n.FSI | n.LRI | n.RLI | n.PDI, s = n.BN | n.RLE | n.LRE | n.RLO | n.LRO | n.PDF, c = n.S | n.WS | n.B | i | n.PDI | s, l = null;
function u() {
if (!l) {
l = /* @__PURE__ */ new Map();
var e = function(e) {
if (t.hasOwnProperty(e)) {
var r = 0;
t[e].split(",").forEach(function(t) {
var i = t.split("+"), a = i[0], o = i[1];
a = parseInt(a, 36), o = o ? parseInt(o, 36) : 0, l.set(r += a, n[e]);
for (var s = 0; s < o; s++) l.set(++r, n[e]);
});
}
};
for (var r in t) e(r);
}
}
function d(e) {
return u(), l.get(e.codePointAt(0)) || n.L;
}
function f(e) {
return r[d(e)];
}
var p = {
pairs: "14>1,1e>2,u>2,2wt>1,1>1,1ge>1,1wp>1,1j>1,f>1,hm>1,1>1,u>1,u6>1,1>1,+5,28>1,w>1,1>1,+3,b8>1,1>1,+3,1>3,-1>-1,3>1,1>1,+2,1s>1,1>1,x>1,th>1,1>1,+2,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,4q>1,1e>2,u>2,2>1,+1",
canonical: "6f1>-6dx,6dy>-6dx,6ec>-6ed,6ee>-6ed,6ww>2jj,-2ji>2jj,14r4>-1e7l,1e7m>-1e7l,1e7m>-1e5c,1e5d>-1e5b,1e5c>-14qx,14qy>-14qx,14vn>-1ecg,1ech>-1ecg,1edu>-1ecg,1eci>-1ecg,1eda>-1ecg,1eci>-1ecg,1eci>-168q,168r>-168q,168s>-14ye,14yf>-14ye"
};
function m(e, t) {
var n = 0, r = /* @__PURE__ */ new Map(), i = t && /* @__PURE__ */ new Map(), a;
return e.split(",").forEach(function e(o) {
if (o.indexOf("+") !== -1) for (var s = +o; s--;) e(a);
else {
a = o;
var c = o.split(">"), l = c[0], u = c[1];
l = String.fromCodePoint(n += parseInt(l, 36)), u = String.fromCodePoint(n += parseInt(u, 36)), r.set(l, u), t && i.set(u, l);
}
}), {
map: r,
reverseMap: i
};
}
var h, g, _;
function v() {
if (!h) {
var e = m(p.pairs, !0), t = e.map, n = e.reverseMap;
h = t, g = n, _ = m(p.canonical, !1).map;
}
}
function y(e) {
return v(), h.get(e) || null;
}
function b(e) {
return v(), g.get(e) || null;
}
function x(e) {
return v(), _.get(e) || null;
}
var S = n.L, C = n.R, w = n.EN, T = n.ES, E = n.ET, D = n.AN, O = n.CS, k = n.B, A = n.S, j = n.ON, M = n.BN, N = n.NSM, P = n.AL, ee = n.LRO, te = n.RLO, ne = n.LRE, re = n.RLE, F = n.PDF, ie = n.LRI, ae = n.RLI, oe = n.FSI, se = n.PDI;
function I(e, t) {
for (var n = 125, r = new Uint32Array(e.length), l = 0; l < e.length; l++) r[l] = d(e[l]);
var u = /* @__PURE__ */ new Map();
function f(e, t) {
var n = r[e];
r[e] = t, u.set(n, u.get(n) - 1), n & o && u.set(o, u.get(o) - 1), u.set(t, (u.get(t) || 0) + 1), t & o && u.set(o, (u.get(o) || 0) + 1);
}
for (var p = new Uint8Array(e.length), m = /* @__PURE__ */ new Map(), h = [], g = null, _ = 0; _ < e.length; _++) g || h.push(g = {
start: _,
end: e.length - 1,
level: t === "rtl" ? 1 : t === "ltr" ? 0 : Zt(_, !1)
}), r[_] & k && (g.end = _, g = null);
for (var v = re | ne | te | ee | i | se | F | k, I = function(e) {
return e + (e & 1 ? 1 : 2);
}, ce = function(e) {
return e + (e & 1 ? 2 : 1);
}, le = 0; le < h.length; le++) {
g = h[le];
var ue = [{
_level: g.level,
_override: 0,
_isolate: 0
}], L = void 0, de = 0, fe = 0, pe = 0;
u.clear();
for (var me = g.start; me <= g.end; me++) {
var he = r[me];
if (L = ue[ue.length - 1], u.set(he, (u.get(he) || 0) + 1), he & o && u.set(o, (u.get(o) || 0) + 1), he & v) if (he & (re | ne)) {
p[me] = L._level;
var ge = (he === re ? ce : I)(L._level);
ge <= n && !de && !fe ? ue.push({
_level: ge,
_override: 0,
_isolate: 0
}) : de || fe++;
} else if (he & (te | ee)) {
p[me] = L._level;
var _e = (he === te ? ce : I)(L._level);
_e <= n && !de && !fe ? ue.push({
_level: _e,
_override: he & te ? C : S,
_isolate: 0
}) : de || fe++;
} else if (he & i) {
he & oe && (he = Zt(me + 1, !0) === 1 ? ae : ie), p[me] = L._level, L._override && f(me, L._override);
var ve = (he === ae ? ce : I)(L._level);
ve <= n && de === 0 && fe === 0 ? (pe++, ue.push({
_level: ve,
_override: 0,
_isolate: 1,
_isolInitIndex: me
})) : de++;
} else if (he & se) {
if (de > 0) de--;
else if (pe > 0) {
for (fe = 0; !ue[ue.length - 1]._isolate;) ue.pop();
var ye = ue[ue.length - 1]._isolInitIndex;
ye != null && (m.set(ye, me), m.set(me, ye)), ue.pop(), pe--;
}
L = ue[ue.length - 1], p[me] = L._level, L._override && f(me, L._override);
} else he & F ? (de === 0 && (fe > 0 ? fe-- : !L._isolate && ue.length > 1 && (ue.pop(), L = ue[ue.length - 1])), p[me] = L._level) : he & k && (p[me] = g.level);
else p[me] = L._level, L._override && he !== M && f(me, L._override);
}
for (var be = [], xe = null, Se = g.start; Se <= g.end; Se++) {
var R = r[Se];
if (!(R & s)) {
var Ce = p[Se], we = R & i, z = R === se;
xe && Ce === xe._level ? (xe._end = Se, xe._endsWithIsolInit = we) : be.push(xe = {
_start: Se,
_end: Se,
_level: Ce,
_startsWithPDI: z,
_endsWithIsolInit: we
});
}
}
for (var Te = [], Ee = 0; Ee < be.length; Ee++) {
var B = be[Ee];
if (!B._startsWithPDI || B._startsWithPDI && !m.has(B._start)) {
for (var De = [xe = B], Oe = void 0; xe && xe._endsWithIsolInit && (Oe = m.get(xe._end)) != null;) for (var V = Ee + 1; V < be.length; V++) if (be[V]._start === Oe) {
De.push(xe = be[V]);
break;
}
for (var ke = [], Ae = 0; Ae < De.length; Ae++) for (var je = De[Ae], Me = je._start; Me <= je._end; Me++) ke.push(Me);
for (var Ne = p[ke[0]], Pe = g.level, Fe = ke[0] - 1; Fe >= 0; Fe--) if (!(r[Fe] & s)) {
Pe = p[Fe];
break;
}
var Ie = ke[ke.length - 1], Le = p[Ie], Re = g.level;
if (!(r[Ie] & i)) {
for (var ze = Ie + 1; ze <= g.end; ze++) if (!(r[ze] & s)) {
Re = p[ze];
break;
}
}
Te.push({
_seqIndices: ke,
_sosType: Math.max(Pe, Ne) % 2 ? C : S,
_eosType: Math.max(Re, Le) % 2 ? C : S
});
}
}
for (var Be = 0; Be < Te.length; Be++) {
var Ve = Te[Be], H = Ve._seqIndices, He = Ve._sosType, Ue = Ve._eosType, We = p[H[0]] & 1 ? C : S;
if (u.get(N)) for (var Ge = 0; Ge < H.length; Ge++) {
var Ke = H[Ge];
if (r[Ke] & N) {
for (var qe = He, Je = Ge - 1; Je >= 0; Je--) if (!(r[H[Je]] & s)) {
qe = r[H[Je]];
break;
}
f(Ke, qe & (i | se) ? j : qe);
}
}
if (u.get(w)) for (var Ye = 0; Ye < H.length; Ye++) {
var Xe = H[Ye];
if (r[Xe] & w) for (var Ze = Ye - 1; Ze >= -1; Ze--) {
var Qe = Ze === -1 ? He : r[H[Ze]];
if (Qe & a) {
Qe === P && f(Xe, D);
break;
}
}
}
if (u.get(P)) for (var $e = 0; $e < H.length; $e++) {
var et = H[$e];
r[et] & P && f(et, C);
}
if (u.get(T) || u.get(O)) for (var tt = 1; tt < H.length - 1; tt++) {
var nt = H[tt];
if (r[nt] & (T | O)) {
for (var rt = 0, it = 0, at = tt - 1; at >= 0 && (rt = r[H[at]], rt & s); at--);
for (var ot = tt + 1; ot < H.length && (it = r[H[ot]], it & s); ot++);
rt === it && (r[nt] === T ? rt === w : rt & (w | D)) && f(nt, rt);
}
}
if (u.get(w)) {
for (var st = 0; st < H.length; st++) if (r[H[st]] & w) {
for (var ct = st - 1; ct >= 0 && r[H[ct]] & (E | s); ct--) f(H[ct], w);
for (st++; st < H.length && r[H[st]] & (E | s | w); st++) r[H[st]] !== w && f(H[st], w);
}
}
if (u.get(E) || u.get(T) || u.get(O)) for (var lt = 0; lt < H.length; lt++) {
var ut = H[lt];
if (r[ut] & (E | T | O)) {
f(ut, j);
for (var dt = lt - 1; dt >= 0 && r[H[dt]] & s; dt--) f(H[dt], j);
for (var ft = lt + 1; ft < H.length && r[H[ft]] & s; ft++) f(H[ft], j);
}
}
if (u.get(w)) for (var pt = 0, mt = He; pt < H.length; pt++) {
var ht = H[pt], gt = r[ht];
gt & w ? mt === S && f(ht, S) : gt & a && (mt = gt);
}
if (u.get(o)) {
for (var _t = C | w | D, vt = _t | S, yt = [], bt = [], xt = 0; xt < H.length; xt++) if (r[H[xt]] & o) {
var St = e[H[xt]], Ct = void 0;
if (y(St) !== null) if (bt.length < 63) bt.push({
char: St,
seqIndex: xt
});
else break;
else if ((Ct = b(St)) !== null) for (var wt = bt.length - 1; wt >= 0; wt--) {
var Tt = bt[wt].char;
if (Tt === Ct || Tt === b(x(St)) || y(x(Tt)) === St) {
yt.push([bt[wt].seqIndex, xt]), bt.length = wt;
break;
}
}
}
yt.sort(function(e, t) {
return e[0] - t[0];
});
for (var Et = 0; Et < yt.length; Et++) {
for (var Dt = yt[Et], Ot = Dt[0], kt = Dt[1], At = !1, jt = 0, Mt = Ot + 1; Mt < kt; Mt++) {
var Nt = H[Mt];
if (r[Nt] & vt) {
At = !0;
var Pt = r[Nt] & _t ? C : S;
if (Pt === We) {
jt = Pt;
break;
}
}
}
if (At && !jt) {
jt = He;
for (var Ft = Ot - 1; Ft >= 0; Ft--) {
var It = H[Ft];
if (r[It] & vt) {
var Lt = r[It] & _t ? C : S;
jt = Lt === We ? We : Lt;
break;
}
}
}
if (jt) {
if (r[H[Ot]] = r[H[kt]] = jt, jt !== We) {
for (var Rt = Ot + 1; Rt < H.length; Rt++) if (!(r[H[Rt]] & s)) {
d(e[H[Rt]]) & N && (r[H[Rt]] = jt);
break;
}
}
if (jt !== We) {
for (var U = kt + 1; U < H.length; U++) if (!(r[H[U]] & s)) {
d(e[H[U]]) & N && (r[H[U]] = jt);
break;
}
}
}
}
for (var zt = 0; zt < H.length; zt++) if (r[H[zt]] & o) {
for (var Bt = zt, Vt = zt, Ht = He, Ut = zt - 1; Ut >= 0; Ut--) if (r[H[Ut]] & s) Bt = Ut;
else {
Ht = r[H[Ut]] & _t ? C : S;
break;
}
for (var Wt = Ue, Gt = zt + 1; Gt < H.length; Gt++) if (r[H[Gt]] & (o | s)) Vt = Gt;
else {
Wt = r[H[Gt]] & _t ? C : S;
break;
}
for (var Kt = Bt; Kt <= Vt; Kt++) r[H[Kt]] = Ht === Wt ? Ht : We;
zt = Vt;
}
}
}
for (var qt = g.start; qt <= g.end; qt++) {
var Jt = p[qt], Yt = r[qt];
if (Jt & 1 ? Yt & (S | w | D) && p[qt]++ : Yt & C ? p[qt]++ : Yt & (D | w) && (p[qt] += 2), Yt & s && (p[qt] = qt === 0 ? g.level : p[qt - 1]), qt === g.end || d(e[qt]) & (A | k)) for (var Xt = qt; Xt >= 0 && d(e[Xt]) & c; Xt--) p[Xt] = g.level;
}
}
return {
levels: p,
paragraphs: h
};
function Zt(t, n) {
for (var a = t; a < e.length; a++) {
var o = r[a];
if (o & (C | P)) return 1;
if (o & (k | S) || n && o === se) return 0;
if (o & i) {
var s = Qt(a);
a = s === -1 ? e.length : s;
}
}
return 0;
}
function Qt(t) {
for (var n = 1, a = t + 1; a < e.length; a++) {
var o = r[a];
if (o & k) break;
if (o & se) {
if (--n === 0) return a;
} else o & i && n++;
}
return -1;
}
}
var ce = "14>1,j>2,t>2,u>2,1a>g,2v3>1,1>1,1ge>1,1wd>1,b>1,1j>1,f>1,ai>3,-2>3,+1,8>1k0,-1jq>1y7,-1y6>1hf,-1he>1h6,-1h5>1ha,-1h8>1qi,-1pu>1,6>3u,-3s>7,6>1,1>1,f>1,1>1,+2,3>1,1>1,+13,4>1,1>1,6>1eo,-1ee>1,3>1mg,-1me>1mk,-1mj>1mi,-1mg>1mi,-1md>1,1>1,+2,1>10k,-103>1,1>1,4>1,5>1,1>1,+10,3>1,1>8,-7>8,+1,-6>7,+1,a>1,1>1,u>1,u6>1,1>1,+5,26>1,1>1,2>1,2>2,8>1,7>1,4>1,1>1,+5,b8>1,1>1,+3,1>3,-2>1,2>1,1>1,+2,c>1,3>1,1>1,+2,h>1,3>1,a>1,1>1,2>1,3>1,1>1,d>1,f>1,3>1,1a>1,1>1,6>1,7>1,13>1,k>1,1>1,+19,4>1,1>1,+2,2>1,1>1,+18,m>1,a>1,1>1,lk>1,1>1,4>1,2>1,f>1,3>1,1>1,+3,db>1,1>1,+3,3>1,1>1,+2,14qm>1,1>1,+1,6>1,4j>1,j>2,t>2,u>2,2>1,+1", le;
function ue() {
if (!le) {
var e = m(ce, !0), t = e.map;
e.reverseMap.forEach(function(e, n) {
t.set(n, e);
}), le = t;
}
}
function L(e) {
return ue(), le.get(e) || null;
}
function de(e, t, n, r) {
var i = e.length;
n = Math.max(0, n == null ? 0 : +n), r = Math.min(i - 1, r == null ? i - 1 : +r);
for (var a = /* @__PURE__ */ new Map(), o = n; o <= r; o++) if (t[o] & 1) {
var s = L(e[o]);
s !== null && a.set(o, s);
}
return a;
}
function fe(e, t, n, r) {
var i = e.length;
n = Math.max(0, n == null ? 0 : +n), r = Math.min(i - 1, r == null ? i - 1 : +r);
var a = [];
return t.paragraphs.forEach(function(i) {
var o = Math.max(n, i.start), s = Math.min(r, i.end);
if (o < s) {
for (var l = t.levels.slice(o, s + 1), u = s; u >= o && d(e[u]) & c; u--) l[u] = i.level;
for (var f = i.level, p = Infinity, m = 0; m < l.length; m++) {
var h = l[m];
h > f && (f = h), h < p && (p = h | 1);
}
for (var g = f; g >= p; g--) for (var _ = 0; _ < l.length; _++) if (l[_] >= g) {
for (var v = _; _ + 1 < l.length && l[_ + 1] >= g;) _++;
_ > v && a.push([v + o, _ + o]);
}
}
}), a;
}
function pe(e, t, n, r) {
var i = me(e, t, n, r), a = [].concat(e);
return i.forEach(function(n, r) {
a[r] = (t.levels[n] & 1 ? L(e[n]) : null) || e[n];
}), a.join("");
}
function me(e, t, n, r) {
for (var i = fe(e, t, n, r), a = [], o = 0; o < e.length; o++) a[o] = o;
return i.forEach(function(e) {
for (var t = e[0], n = e[1], r = a.slice(t, n + 1), i = r.length; i--;) a[n - i] = r[i];
}), a;
}
return e.closingToOpeningBracket = b, e.getBidiCharType = d, e.getBidiCharTypeName = f, e.getCanonicalBracket = x, e.getEmbeddingLevels = I, e.getMirroredCharacter = L, e.getMirroredCharactersMap = de, e.getReorderSegments = fe, e.getReorderedIndices = me, e.getReorderedString = pe, e.openingToClosingBracket = y, Object.defineProperty(e, "__esModule", { value: !0 }), e;
}({});
}
//#endregion
//#region ../../node_modules/.pnpm/troika-three-utils@0.52.5_three@0.185.1/node_modules/troika-three-utils/dist/troika-three-utils.esm.js
var Gw = /\bvoid\s+main\s*\(\s*\)\s*{/g;
function Kw(e) {
let t = /^[ \t]*#include +<([\w\d./]+)>/gm;
function n(e, t) {
let n = xe[t];
return n ? Kw(n) : e;
}
return e.replace(t, n);
}
var qw = [];
for (let e = 0; e < 256; e++) qw[e] = (e < 16 ? "0" : "") + e.toString(16);
function Jw() {
let e = Math.random() * 4294967295 | 0, t = Math.random() * 4294967295 | 0, n = Math.random() * 4294967295 | 0, r = Math.random() * 4294967295 | 0;
return (qw[e & 255] + qw[e >> 8 & 255] + qw[e >> 16 & 255] + qw[e >> 24 & 255] + "-" + qw[t & 255] + qw[t >> 8 & 255] + "-" + qw[t >> 16 & 15 | 64] + qw[t >> 24 & 255] + "-" + qw[n & 63 | 128] + qw[n >> 8 & 255] + "-" + qw[n >> 16 & 255] + qw[n >> 24 & 255] + qw[r & 255] + qw[r >> 8 & 255] + qw[r >> 16 & 255] + qw[r >> 24 & 255]).toUpperCase();
}
var Yw = Object.assign || function() {
let e = arguments[0];
for (let t = 1, n = arguments.length; t < n; t++) {
let n = arguments[t];
if (n) for (let t in n) Object.prototype.hasOwnProperty.call(n, t) && (e[t] = n[t]);
}
return e;
}, Xw = Date.now(), Zw = /* @__PURE__ */ new WeakMap(), Qw = /* @__PURE__ */ new Map(), $w = 1e10;
function eT(e, t) {
let n = oT(t), r = Zw.get(e);
if (r || Zw.set(e, r = Object.create(null)), r[n]) return new r[n]();
let i = `_onBeforeCompile${n}`, a = function(r, a) {
e.onBeforeCompile.call(this, r, a);
let o = this.customProgramCacheKey() + "|" + r.vertexShader + "|" + r.fragmentShader, s = Qw[o];
s || (s = Qw[o] = tT(this, r, t, n)), r.vertexShader = s.vertexShader, r.fragmentShader = s.fragmentShader, Yw(r.uniforms, this.uniforms), t.timeUniform && (r.uniforms[t.timeUniform] = { get value() {
return Date.now() - Xw;
} }), this[i] && this[i](r);
}, o = function() {
return s(t.chained ? e : e.clone());
}, s = function(r) {
let i = Object.create(r, c);
return Object.defineProperty(i, "baseMaterial", { value: e }), Object.defineProperty(i, "id", { value: $w++ }), i.uuid = Jw(), i.uniforms = Yw({}, r.uniforms, t.uniforms), i.defines = Yw({}, r.defines, t.defines), i.defines[`TROIKA_DERIVED_MATERIAL_${n}`] = "", i.extensions = Yw({}, r.extensions, t.extensions), i._listeners = void 0, i;
}, c = {
constructor: { value: o },
isDerivedMaterial: { value: !0 },
type: {
get: () => e.type,
set: (t) => {
e.type = t;
}
},
isDerivedFrom: {
writable: !0,
configurable: !0,
value: function(e) {
let t = this.baseMaterial;
return e === t || t.isDerivedMaterial && t.isDerivedFrom(e) || !1;
}
},
customProgramCacheKey: {
writable: !0,
configurable: !0,
value: function() {
return e.customProgramCacheKey() + "|" + n;
}
},
onBeforeCompile: {
get() {
return a;
},
set(e) {
this[i] = e;
}
},
copy: {
writable: !0,
configurable: !0,
value: function(t) {
return e.copy.call(this, t), !e.isShaderMaterial && !e.isDerivedMaterial && (Yw(this.extensions, t.extensions), Yw(this.defines, t.defines), Yw(this.uniforms, St.clone(t.uniforms))), this;
}
},
clone: {
writable: !0,
configurable: !0,
value: function() {
let t = new e.constructor();
return s(t).copy(this);
}
},
getDepthMaterial: {
writable: !0,
configurable: !0,
value: function() {
let n = this._depthMaterial;
return n || (n = this._depthMaterial = eT(e.isDerivedMaterial ? e.getDepthMaterial() : new ln({ depthPacking: Dt }), t), n.defines.IS_DEPTH_MATERIAL = "", n.uniforms = this.uniforms), n;
}
},
getDistanceMaterial: {
writable: !0,
configurable: !0,
value: function() {
let n = this._distanceMaterial;
return n || (n = this._distanceMaterial = eT(e.isDerivedMaterial ? e.getDistanceMaterial() : new gn(), t), n.defines.IS_DISTANCE_MATERIAL = "", n.uniforms = this.uniforms), n;
}
},
dispose: {
writable: !0,
configurable: !0,
value() {
let { _depthMaterial: t, _distanceMaterial: n } = this;
t && t.dispose(), n && n.dispose(), e.dispose.call(this);
}
}
};
return r[n] = o, new o();
}
function tT(e, { vertexShader: t, fragmentShader: n }, r, i) {
let { vertexDefs: a, vertexMainIntro: o, vertexMainOutro: s, vertexTransform: c, fragmentDefs: l, fragmentMainIntro: u, fragmentMainOutro: d, fragmentColorTransform: f, customRewriter: p, timeUniform: m } = r;
if (a = a || "", o = o || "", s = s || "", l = l || "", u = u || "", d = d || "", (c || p) && (t = Kw(t)), (f || p) && (n = n.replace(/^[ \t]*#include <((?:tonemapping|encodings|colorspace|fog|premultiplied_alpha|dithering)_fragment)>/gm, "\n//!BEGIN_POST_CHUNK $1\n$&\n//!END_POST_CHUNK\n"), n = Kw(n)), p) {
let e = p({
vertexShader: t,
fragmentShader: n
});
t = e.vertexShader, n = e.fragmentShader;
}
if (f) {
let e = [];
n = n.replace(/^\/\/!BEGIN_POST_CHUNK[^]+?^\/\/!END_POST_CHUNK/gm, (t) => (e.push(t), "")), d = `${f}\n${e.join("\n")}\n${d}`;
}
if (m) {
let e = `\nuniform float ${m};\n`;
a = e + a, l = e + l;
}
return c && (t = `vec3 troika_position_${i};
vec3 troika_normal_${i};
vec2 troika_uv_${i};
${t}
`, a = `${a}
void troikaVertexTransform${i}() {
vec3 position = troika_position_${i};
vec3 normal = troika_normal_${i};
vec2 uv = troika_uv_${i};
${c}
troika_position_${i} = position;
troika_normal_${i} = normal;
troika_uv_${i} = uv;
}
`, o = `
troika_position_${i} = vec3(position);
troika_normal_${i} = vec3(normal);
troika_uv_${i} = vec2(uv);
troikaVertexTransform${i}();
${o}
`, t = t.replace(/\b(position|normal|uv)\b/g, (e, t, n, r) => /\battribute\s+vec[23]\s+$/.test(r.substr(0, n)) ? t : `troika_${t}_${i}`), e.map && e.map.channel > 0 || (t = t.replace(/\bMAP_UV\b/g, `troika_uv_${i}`))), t = nT(t, i, a, o, s), n = nT(n, i, l, u, d), {
vertexShader: t,
fragmentShader: n
};
}
function nT(e, t, n, r, i) {
return (r || i || n) && (e = e.replace(Gw, `
${n}
void troikaOrigMain${t}() {`), e += `
void main() {
${r}
troikaOrigMain${t}();
${i}
}`), e;
}
function rT(e, t) {
return e === "uniforms" ? void 0 : typeof t == "function" ? t.toString() : t;
}
var iT = 0, aT = /* @__PURE__ */ new Map();
function oT(e) {
let t = JSON.stringify(e, rT), n = aT.get(t);
return n == null && aT.set(t, n = ++iT), n;
}
//#endregion
//#region ../../node_modules/.pnpm/troika-three-text@0.52.5_three@0.185.1/node_modules/troika-three-text/dist/troika-three-text.esm.js
function sT() {
return typeof window > "u" && (self.window = self), function(e) {
var t = {
parse: function(e) {
var n = t._bin, r = new Uint8Array(e);
if (n.readASCII(r, 0, 4) == "ttcf") {
var i = 4;
n.readUshort(r, i), i += 2, n.readUshort(r, i), i += 2;
var a = n.readUint(r, i);
i += 4;
for (var o = [], s = 0; s < a; s++) {
var c = n.readUint(r, i);
i += 4, o.push(t._readFont(r, c));
}
return o;
}
return [t._readFont(r, 0)];
},
_readFont: function(e, n) {
var r = t._bin, i = n;
r.readFixed(e, n), n += 4;
var a = r.readUshort(e, n);
n += 2, r.readUshort(e, n), n += 2, r.readUshort(e, n), n += 2, r.readUshort(e, n), n += 2;
for (var o = [
"cmap",
"head",
"hhea",
"maxp",
"hmtx",
"name",
"OS/2",
"post",
"loca",
"glyf",
"kern",
"CFF ",
"GDEF",
"GPOS",
"GSUB",
"SVG "
], s = {
_data: e,
_offset: i
}, c = {}, l = 0; l < a; l++) {
var u = r.readASCII(e, n, 4);
n += 4, r.readUint(e, n), n += 4;
var d = r.readUint(e, n);
n += 4;
var f = r.readUint(e, n);
n += 4, c[u] = {
offset: d,
length: f
};
}
for (l = 0; l < o.length; l++) {
var p = o[l];
c[p] && (s[p.trim()] = t[p.trim()].parse(e, c[p].offset, c[p].length, s));
}
return s;
},
_tabOffset: function(e, n, r) {
for (var i = t._bin, a = i.readUshort(e, r + 4), o = r + 12, s = 0; s < a; s++) {
var c = i.readASCII(e, o, 4);
o += 4, i.readUint(e, o), o += 4;
var l = i.readUint(e, o);
if (o += 4, i.readUint(e, o), o += 4, c == n) return l;
}
return 0;
}
};
t._bin = {
readFixed: function(e, t) {
return (e[t] << 8 | e[t + 1]) + (e[t + 2] << 8 | e[t + 3]) / 65540;
},
readF2dot14: function(e, n) {
return t._bin.readShort(e, n) / 16384;
},
readInt: function(e, n) {
return t._bin._view(e).getInt32(n);
},
readInt8: function(e, n) {
return t._bin._view(e).getInt8(n);
},
readShort: function(e, n) {
return t._bin._view(e).getInt16(n);
},
readUshort: function(e, n) {
return t._bin._view(e).getUint16(n);
},
readUshorts: function(e, n, r) {
for (var i = [], a = 0; a < r; a++) i.push(t._bin.readUshort(e, n + 2 * a));
return i;
},
readUint: function(e, n) {
return t._bin._view(e).getUint32(n);
},
readUint64: function(e, n) {
return 4294967296 * t._bin.readUint(e, n) + t._bin.readUint(e, n + 4);
},
readASCII: function(e, t, n) {
for (var r = "", i = 0; i < n; i++) r += String.fromCharCode(e[t + i]);
return r;
},
readUnicode: function(e, t, n) {
for (var r = "", i = 0; i < n; i++) {
var a = e[t++] << 8 | e[t++];
r += String.fromCharCode(a);
}
return r;
},
_tdec: typeof window < "u" && window.TextDecoder ? new window.TextDecoder() : null,
readUTF8: function(e, n, r) {
var i = t._bin._tdec;
return i && n == 0 && r == e.length ? i.decode(e) : t._bin.readASCII(e, n, r);
},
readBytes: function(e, t, n) {
for (var r = [], i = 0; i < n; i++) r.push(e[t + i]);
return r;
},
readASCIIArray: function(e, t, n) {
for (var r = [], i = 0; i < n; i++) r.push(String.fromCharCode(e[t + i]));
return r;
},
_view: function(e) {
return e._dataView || (e._dataView = e.buffer ? new DataView(e.buffer, e.byteOffset, e.byteLength) : new DataView(new Uint8Array(e).buffer));
}
}, t._lctf = {}, t._lctf.parse = function(e, n, r, i, a) {
var o = t._bin, s = {}, c = n;
o.readFixed(e, n), n += 4;
var l = o.readUshort(e, n);
n += 2;
var u = o.readUshort(e, n);
n += 2;
var d = o.readUshort(e, n);
return n += 2, s.scriptList = t._lctf.readScriptList(e, c + l), s.featureList = t._lctf.readFeatureList(e, c + u), s.lookupList = t._lctf.readLookupList(e, c + d, a), s;
}, t._lctf.readLookupList = function(e, n, r) {
var i = t._bin, a = n, o = [], s = i.readUshort(e, n);
n += 2;
for (var c = 0; c < s; c++) {
var l = i.readUshort(e, n);
n += 2;
var u = t._lctf.readLookupTable(e, a + l, r);
o.push(u);
}
return o;
}, t._lctf.readLookupTable = function(e, n, r) {
var i = t._bin, a = n, o = { tabs: [] };
o.ltype = i.readUshort(e, n), n += 2, o.flag = i.readUshort(e, n), n += 2;
var s = i.readUshort(e, n);
n += 2;
for (var c = o.ltype, l = 0; l < s; l++) {
var u = i.readUshort(e, n);
n += 2;
var d = r(e, c, a + u, o);
o.tabs.push(d);
}
return o;
}, t._lctf.numOfOnes = function(e) {
for (var t = 0, n = 0; n < 32; n++) e >>> n & 1 && t++;
return t;
}, t._lctf.readClassDef = function(e, n) {
var r = t._bin, i = [], a = r.readUshort(e, n);
if (n += 2, a == 1) {
var o = r.readUshort(e, n);
n += 2;
var s = r.readUshort(e, n);
n += 2;
for (var c = 0; c < s; c++) i.push(o + c), i.push(o + c), i.push(r.readUshort(e, n)), n += 2;
}
if (a == 2) {
var l = r.readUshort(e, n);
for (n += 2, c = 0; c < l; c++) i.push(r.readUshort(e, n)), n += 2, i.push(r.readUshort(e, n)), n += 2, i.push(r.readUshort(e, n)), n += 2;
}
return i;
}, t._lctf.getInterval = function(e, t) {
for (var n = 0; n < e.length; n += 3) {
var r = e[n], i = e[n + 1];
if (e[n + 2], r <= t && t <= i) return n;
}
return -1;
}, t._lctf.readCoverage = function(e, n) {
var r = t._bin, i = {};
i.fmt = r.readUshort(e, n), n += 2;
var a = r.readUshort(e, n);
return n += 2, i.fmt == 1 && (i.tab = r.readUshorts(e, n, a)), i.fmt == 2 && (i.tab = r.readUshorts(e, n, 3 * a)), i;
}, t._lctf.coverageIndex = function(e, n) {
var r = e.tab;
if (e.fmt == 1) return r.indexOf(n);
if (e.fmt == 2) {
var i = t._lctf.getInterval(r, n);
if (i != -1) return r[i + 2] + (n - r[i]);
}
return -1;
}, t._lctf.readFeatureList = function(e, n) {
var r = t._bin, i = n, a = [], o = r.readUshort(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = r.readASCII(e, n, 4);
n += 4;
var l = r.readUshort(e, n);
n += 2;
var u = t._lctf.readFeatureTable(e, i + l);
u.tag = c.trim(), a.push(u);
}
return a;
}, t._lctf.readFeatureTable = function(e, n) {
var r = t._bin, i = n, a = {}, o = r.readUshort(e, n);
n += 2, o > 0 && (a.featureParams = i + o);
var s = r.readUshort(e, n);
n += 2, a.tab = [];
for (var c = 0; c < s; c++) a.tab.push(r.readUshort(e, n + 2 * c));
return a;
}, t._lctf.readScriptList = function(e, n) {
var r = t._bin, i = n, a = {}, o = r.readUshort(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = r.readASCII(e, n, 4);
n += 4;
var l = r.readUshort(e, n);
n += 2, a[c.trim()] = t._lctf.readScriptTable(e, i + l);
}
return a;
}, t._lctf.readScriptTable = function(e, n) {
var r = t._bin, i = n, a = {}, o = r.readUshort(e, n);
n += 2, o > 0 && (a.default = t._lctf.readLangSysTable(e, i + o));
var s = r.readUshort(e, n);
n += 2;
for (var c = 0; c < s; c++) {
var l = r.readASCII(e, n, 4);
n += 4;
var u = r.readUshort(e, n);
n += 2, a[l.trim()] = t._lctf.readLangSysTable(e, i + u);
}
return a;
}, t._lctf.readLangSysTable = function(e, n) {
var r = t._bin, i = {};
r.readUshort(e, n), n += 2, i.reqFeature = r.readUshort(e, n), n += 2;
var a = r.readUshort(e, n);
return n += 2, i.features = r.readUshorts(e, n, a), i;
}, t.CFF = {}, t.CFF.parse = function(e, n, r) {
var i = t._bin;
(e = new Uint8Array(e.buffer, n, r))[n = 0], e[++n], e[++n], e[++n], n++;
var a = [];
n = t.CFF.readIndex(e, n, a);
for (var o = [], s = 0; s < a.length - 1; s++) o.push(i.readASCII(e, n + a[s], a[s + 1] - a[s]));
n += a[a.length - 1];
var c = [];
n = t.CFF.readIndex(e, n, c);
var l = [];
for (s = 0; s < c.length - 1; s++) l.push(t.CFF.readDict(e, n + c[s], n + c[s + 1]));
n += c[c.length - 1];
var u = l[0], d = [];
n = t.CFF.readIndex(e, n, d);
var f = [];
for (s = 0; s < d.length - 1; s++) f.push(i.readASCII(e, n + d[s], d[s + 1] - d[s]));
if (n += d[d.length - 1], t.CFF.readSubrs(e, n, u), u.CharStrings) {
n = u.CharStrings, d = [], n = t.CFF.readIndex(e, n, d);
var p = [];
for (s = 0; s < d.length - 1; s++) p.push(i.readBytes(e, n + d[s], d[s + 1] - d[s]));
u.CharStrings = p;
}
if (u.ROS) {
n = u.FDArray;
var m = [];
for (n = t.CFF.readIndex(e, n, m), u.FDArray = [], s = 0; s < m.length - 1; s++) {
var h = t.CFF.readDict(e, n + m[s], n + m[s + 1]);
t.CFF._readFDict(e, h, f), u.FDArray.push(h);
}
n += m[m.length - 1], n = u.FDSelect, u.FDSelect = [];
var g = e[n];
if (n++, g != 3) throw g;
var _ = i.readUshort(e, n);
for (n += 2, s = 0; s < _ + 1; s++) u.FDSelect.push(i.readUshort(e, n), e[n + 2]), n += 3;
}
return u.Encoding && (u.Encoding = t.CFF.readEncoding(e, u.Encoding, u.CharStrings.length)), u.charset && (u.charset = t.CFF.readCharset(e, u.charset, u.CharStrings.length)), t.CFF._readFDict(e, u, f), u;
}, t.CFF._readFDict = function(e, n, r) {
var i;
for (var a in n.Private && (i = n.Private[1], n.Private = t.CFF.readDict(e, i, i + n.Private[0]), n.Private.Subrs && t.CFF.readSubrs(e, i + n.Private.Subrs, n.Private)), n) [
"FamilyName",
"FontName",
"FullName",
"Notice",
"version",
"Copyright"
].indexOf(a) != -1 && (n[a] = r[n[a] - 426 + 35]);
}, t.CFF.readSubrs = function(e, n, r) {
var i = t._bin, a = [];
n = t.CFF.readIndex(e, n, a);
var o, s = a.length;
o = s < 1240 ? 107 : s < 33900 ? 1131 : 32768, r.Bias = o, r.Subrs = [];
for (var c = 0; c < a.length - 1; c++) r.Subrs.push(i.readBytes(e, n + a[c], a[c + 1] - a[c]));
}, t.CFF.tableSE = [
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
10,
11,
12,
13,
14,
15,
16,
17,
18,
19,
20,
21,
22,
23,
24,
25,
26,
27,
28,
29,
30,
31,
32,
33,
34,
35,
36,
37,
38,
39,
40,
41,
42,
43,
44,
45,
46,
47,
48,
49,
50,
51,
52,
53,
54,
55,
56,
57,
58,
59,
60,
61,
62,
63,
64,
65,
66,
67,
68,
69,
70,
71,
72,
73,
74,
75,
76,
77,
78,
79,
80,
81,
82,
83,
84,
85,
86,
87,
88,
89,
90,
91,
92,
93,
94,
95,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
96,
97,
98,
99,
100,
101,
102,
103,
104,
105,
106,
107,
108,
109,
110,
0,
111,
112,
113,
114,
0,
115,
116,
117,
118,
119,
120,
121,
122,
0,
123,
0,
124,
125,
126,
127,
128,
129,
130,
131,
0,
132,
133,
0,
134,
135,
136,
137,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
0,
138,
0,
139,
0,
0,
0,
0,
140,
141,
142,
143,
0,
0,
0,
0,
0,
144,
0,
0,
0,
145,
0,
0,
146,
147,
148,
149,
0,
0,
0,
0
], t.CFF.glyphByUnicode = function(e, t) {
for (var n = 0; n < e.charset.length; n++) if (e.charset[n] == t) return n;
return -1;
}, t.CFF.glyphBySE = function(e, n) {
return n < 0 || n > 255 ? -1 : t.CFF.glyphByUnicode(e, t.CFF.tableSE[n]);
}, t.CFF.readEncoding = function(e, n, r) {
t._bin;
var i = [".notdef"], a = e[n];
if (n++, a != 0) throw "error: unknown encoding format: " + a;
var o = e[n];
n++;
for (var s = 0; s < o; s++) i.push(e[n + s]);
return i;
}, t.CFF.readCharset = function(e, n, r) {
var i = t._bin, a = [".notdef"], o = e[n];
if (n++, o == 0) for (var s = 0; s < r; s++) {
var c = i.readUshort(e, n);
n += 2, a.push(c);
}
else {
if (o != 1 && o != 2) throw "error: format: " + o;
for (; a.length < r;) {
c = i.readUshort(e, n), n += 2;
var l = 0;
for (o == 1 ? (l = e[n], n++) : (l = i.readUshort(e, n), n += 2), s = 0; s <= l; s++) a.push(c), c++;
}
}
return a;
}, t.CFF.readIndex = function(e, n, r) {
var i = t._bin, a = i.readUshort(e, n) + 1, o = e[n += 2];
if (n++, o == 1) for (var s = 0; s < a; s++) r.push(e[n + s]);
else if (o == 2) for (s = 0; s < a; s++) r.push(i.readUshort(e, n + 2 * s));
else if (o == 3) for (s = 0; s < a; s++) r.push(16777215 & i.readUint(e, n + 3 * s - 1));
else if (a != 1) throw "unsupported offset size: " + o + ", count: " + a;
return (n += a * o) - 1;
}, t.CFF.getCharString = function(e, n, r) {
var i = t._bin, a = e[n], o = e[n + 1];
e[n + 2], e[n + 3], e[n + 4];
var s = 1, c = null, l = null;
a <= 20 && (c = a, s = 1), a == 12 && (c = 100 * a + o, s = 2), 21 <= a && a <= 27 && (c = a, s = 1), a == 28 && (l = i.readShort(e, n + 1), s = 3), 29 <= a && a <= 31 && (c = a, s = 1), 32 <= a && a <= 246 && (l = a - 139, s = 1), 247 <= a && a <= 250 && (l = 256 * (a - 247) + o + 108, s = 2), 251 <= a && a <= 254 && (l = 256 * -(a - 251) - o - 108, s = 2), a == 255 && (l = i.readInt(e, n + 1) / 65535, s = 5), r.val = l == null ? "o" + c : l, r.size = s;
}, t.CFF.readCharString = function(e, n, r) {
for (var i = n + r, a = t._bin, o = []; n < i;) {
var s = e[n], c = e[n + 1];
e[n + 2], e[n + 3], e[n + 4];
var l = 1, u = null, d = null;
s <= 20 && (u = s, l = 1), s == 12 && (u = 100 * s + c, l = 2), s != 19 && s != 20 || (u = s, l = 2), 21 <= s && s <= 27 && (u = s, l = 1), s == 28 && (d = a.readShort(e, n + 1), l = 3), 29 <= s && s <= 31 && (u = s, l = 1), 32 <= s && s <= 246 && (d = s - 139, l = 1), 247 <= s && s <= 250 && (d = 256 * (s - 247) + c + 108, l = 2), 251 <= s && s <= 254 && (d = 256 * -(s - 251) - c - 108, l = 2), s == 255 && (d = a.readInt(e, n + 1) / 65535, l = 5), o.push(d == null ? "o" + u : d), n += l;
}
return o;
}, t.CFF.readDict = function(e, n, r) {
for (var i = t._bin, a = {}, o = []; n < r;) {
var s = e[n], c = e[n + 1];
e[n + 2], e[n + 3], e[n + 4];
var l = 1, u = null, d = null;
if (s == 28 && (d = i.readShort(e, n + 1), l = 3), s == 29 && (d = i.readInt(e, n + 1), l = 5), 32 <= s && s <= 246 && (d = s - 139, l = 1), 247 <= s && s <= 250 && (d = 256 * (s - 247) + c + 108, l = 2), 251 <= s && s <= 254 && (d = 256 * -(s - 251) - c - 108, l = 2), s == 255) throw d = i.readInt(e, n + 1) / 65535, l = 5, "unknown number";
if (s == 30) {
var f = [];
for (l = 1;;) {
var p = e[n + l];
l++;
var m = p >> 4, h = 15 & p;
if (m != 15 && f.push(m), h != 15 && f.push(h), h == 15) break;
}
for (var g = "", _ = [
0,
1,
2,
3,
4,
5,
6,
7,
8,
9,
".",
"e",
"e-",
"reserved",
"-",
"endOfNumber"
], v = 0; v < f.length; v++) g += _[f[v]];
d = parseFloat(g);
}
s <= 21 && (u = [
"version",
"Notice",
"FullName",
"FamilyName",
"Weight",
"FontBBox",
"BlueValues",
"OtherBlues",
"FamilyBlues",
"FamilyOtherBlues",
"StdHW",
"StdVW",
"escape",
"UniqueID",
"XUID",
"charset",
"Encoding",
"CharStrings",
"Private",
"Subrs",
"defaultWidthX",
"nominalWidthX"
][s], l = 1, s == 12 && (u = [
"Copyright",
"isFixedPitch",
"ItalicAngle",
"UnderlinePosition",
"UnderlineThickness",
"PaintType",
"CharstringType",
"FontMatrix",
"StrokeWidth",
"BlueScale",
"BlueShift",
"BlueFuzz",
"StemSnapH",
"StemSnapV",
"ForceBold",
0,
0,
"LanguageGroup",
"ExpansionFactor",
"initialRandomSeed",
"SyntheticBase",
"PostScript",
"BaseFontName",
"BaseFontBlend",
0,
0,
0,
0,
0,
0,
"ROS",
"CIDFontVersion",
"CIDFontRevision",
"CIDFontType",
"CIDCount",
"UIDBase",
"FDArray",
"FDSelect",
"FontName"
][c], l = 2)), u == null ? o.push(d) : (a[u] = o.length == 1 ? o[0] : o, o = []), n += l;
}
return a;
}, t.cmap = {}, t.cmap.parse = function(e, n, r) {
e = new Uint8Array(e.buffer, n, r), n = 0;
var i = t._bin, a = {};
i.readUshort(e, n), n += 2;
var o = i.readUshort(e, n);
n += 2;
var s = [];
a.tables = [];
for (var c = 0; c < o; c++) {
var l = i.readUshort(e, n);
n += 2;
var u = i.readUshort(e, n);
n += 2;
var d = i.readUint(e, n);
n += 4;
var f = "p" + l + "e" + u, p = s.indexOf(d);
if (p == -1) {
var m;
p = a.tables.length, s.push(d);
var h = i.readUshort(e, d);
h == 0 ? m = t.cmap.parse0(e, d) : h == 4 ? m = t.cmap.parse4(e, d) : h == 6 ? m = t.cmap.parse6(e, d) : h == 12 ? m = t.cmap.parse12(e, d) : console.debug("unknown format: " + h, l, u, d), a.tables.push(m);
}
if (a[f] != null) throw "multiple tables for one platform+encoding";
a[f] = p;
}
return a;
}, t.cmap.parse0 = function(e, n) {
var r = t._bin, i = {};
i.format = r.readUshort(e, n), n += 2;
var a = r.readUshort(e, n);
n += 2, r.readUshort(e, n), n += 2, i.map = [];
for (var o = 0; o < a - 6; o++) i.map.push(e[n + o]);
return i;
}, t.cmap.parse4 = function(e, n) {
var r = t._bin, i = n, a = {};
a.format = r.readUshort(e, n), n += 2;
var o = r.readUshort(e, n);
n += 2, r.readUshort(e, n), n += 2;
var s = r.readUshort(e, n);
n += 2;
var c = s / 2;
a.searchRange = r.readUshort(e, n), n += 2, a.entrySelector = r.readUshort(e, n), n += 2, a.rangeShift = r.readUshort(e, n), n += 2, a.endCount = r.readUshorts(e, n, c), n += 2 * c, n += 2, a.startCount = r.readUshorts(e, n, c), n += 2 * c, a.idDelta = [];
for (var l = 0; l < c; l++) a.idDelta.push(r.readShort(e, n)), n += 2;
for (a.idRangeOffset = r.readUshorts(e, n, c), n += 2 * c, a.glyphIdArray = []; n < i + o;) a.glyphIdArray.push(r.readUshort(e, n)), n += 2;
return a;
}, t.cmap.parse6 = function(e, n) {
var r = t._bin, i = {};
i.format = r.readUshort(e, n), n += 2, r.readUshort(e, n), n += 2, r.readUshort(e, n), n += 2, i.firstCode = r.readUshort(e, n), n += 2;
var a = r.readUshort(e, n);
n += 2, i.glyphIdArray = [];
for (var o = 0; o < a; o++) i.glyphIdArray.push(r.readUshort(e, n)), n += 2;
return i;
}, t.cmap.parse12 = function(e, n) {
var r = t._bin, i = {};
i.format = r.readUshort(e, n), n += 2, n += 2, r.readUint(e, n), n += 4, r.readUint(e, n), n += 4;
var a = r.readUint(e, n);
n += 4, i.groups = [];
for (var o = 0; o < a; o++) {
var s = n + 12 * o, c = r.readUint(e, s + 0), l = r.readUint(e, s + 4), u = r.readUint(e, s + 8);
i.groups.push([
c,
l,
u
]);
}
return i;
}, t.glyf = {}, t.glyf.parse = function(e, t, n, r) {
for (var i = [], a = 0; a < r.maxp.numGlyphs; a++) i.push(null);
return i;
}, t.glyf._parseGlyf = function(e, n) {
var r = t._bin, i = e._data, a = t._tabOffset(i, "glyf", e._offset) + e.loca[n];
if (e.loca[n] == e.loca[n + 1]) return null;
var o = {};
if (o.noc = r.readShort(i, a), a += 2, o.xMin = r.readShort(i, a), a += 2, o.yMin = r.readShort(i, a), a += 2, o.xMax = r.readShort(i, a), a += 2, o.yMax = r.readShort(i, a), a += 2, o.xMin >= o.xMax || o.yMin >= o.yMax) return null;
if (o.noc > 0) {
o.endPts = [];
for (var s = 0; s < o.noc; s++) o.endPts.push(r.readUshort(i, a)), a += 2;
var c = r.readUshort(i, a);
if (a += 2, i.length - a < c) return null;
o.instructions = r.readBytes(i, a, c), a += c;
var l = o.endPts[o.noc - 1] + 1;
for (o.flags = [], s = 0; s < l; s++) {
var u = i[a];
if (a++, o.flags.push(u), 8 & u) {
var d = i[a];
a++;
for (var f = 0; f < d; f++) o.flags.push(u), s++;
}
}
for (o.xs = [], s = 0; s < l; s++) {
var p = (2 & o.flags[s]) != 0, m = (16 & o.flags[s]) != 0;
p ? (o.xs.push(m ? i[a] : -i[a]), a++) : m ? o.xs.push(0) : (o.xs.push(r.readShort(i, a)), a += 2);
}
for (o.ys = [], s = 0; s < l; s++) p = (4 & o.flags[s]) != 0, m = (32 & o.flags[s]) != 0, p ? (o.ys.push(m ? i[a] : -i[a]), a++) : m ? o.ys.push(0) : (o.ys.push(r.readShort(i, a)), a += 2);
var h = 0, g = 0;
for (s = 0; s < l; s++) h += o.xs[s], g += o.ys[s], o.xs[s] = h, o.ys[s] = g;
} else {
var _;
o.parts = [];
do {
_ = r.readUshort(i, a), a += 2;
var v = {
m: {
a: 1,
b: 0,
c: 0,
d: 1,
tx: 0,
ty: 0
},
p1: -1,
p2: -1
};
if (o.parts.push(v), v.glyphIndex = r.readUshort(i, a), a += 2, 1 & _) {
var y = r.readShort(i, a);
a += 2;
var b = r.readShort(i, a);
a += 2;
} else y = r.readInt8(i, a), a++, b = r.readInt8(i, a), a++;
2 & _ ? (v.m.tx = y, v.m.ty = b) : (v.p1 = y, v.p2 = b), 8 & _ ? (v.m.a = v.m.d = r.readF2dot14(i, a), a += 2) : 64 & _ ? (v.m.a = r.readF2dot14(i, a), a += 2, v.m.d = r.readF2dot14(i, a), a += 2) : 128 & _ && (v.m.a = r.readF2dot14(i, a), a += 2, v.m.b = r.readF2dot14(i, a), a += 2, v.m.c = r.readF2dot14(i, a), a += 2, v.m.d = r.readF2dot14(i, a), a += 2);
} while (32 & _);
if (256 & _) {
var x = r.readUshort(i, a);
for (a += 2, o.instr = [], s = 0; s < x; s++) o.instr.push(i[a]), a++;
}
}
return o;
}, t.GDEF = {}, t.GDEF.parse = function(e, n, r, i) {
var a = n;
n += 4;
var o = t._bin.readUshort(e, n);
return { glyphClassDef: o === 0 ? null : t._lctf.readClassDef(e, a + o) };
}, t.GPOS = {}, t.GPOS.parse = function(e, n, r, i) {
return t._lctf.parse(e, n, r, i, t.GPOS.subt);
}, t.GPOS.subt = function(e, n, r, i) {
var a = t._bin, o = r, s = {};
if (s.fmt = a.readUshort(e, r), r += 2, n == 1 || n == 2 || n == 3 || n == 7 || n == 8 && s.fmt <= 2) {
var c = a.readUshort(e, r);
r += 2, s.coverage = t._lctf.readCoverage(e, c + o);
}
if (n == 1 && s.fmt == 1) {
var l = a.readUshort(e, r);
r += 2, l != 0 && (s.pos = t.GPOS.readValueRecord(e, r, l));
} else if (n == 2 && s.fmt >= 1 && s.fmt <= 2) {
l = a.readUshort(e, r), r += 2;
var u = a.readUshort(e, r);
r += 2;
var d = t._lctf.numOfOnes(l), f = t._lctf.numOfOnes(u);
if (s.fmt == 1) {
s.pairsets = [];
var p = a.readUshort(e, r);
r += 2;
for (var m = 0; m < p; m++) {
var h = o + a.readUshort(e, r);
r += 2;
var g = a.readUshort(e, h);
h += 2;
for (var _ = [], v = 0; v < g; v++) {
var y = a.readUshort(e, h);
h += 2, l != 0 && (T = t.GPOS.readValueRecord(e, h, l), h += 2 * d), u != 0 && (E = t.GPOS.readValueRecord(e, h, u), h += 2 * f), _.push({
gid2: y,
val1: T,
val2: E
});
}
s.pairsets.push(_);
}
}
if (s.fmt == 2) {
var b = a.readUshort(e, r);
r += 2;
var x = a.readUshort(e, r);
r += 2;
var S = a.readUshort(e, r);
r += 2;
var C = a.readUshort(e, r);
for (r += 2, s.classDef1 = t._lctf.readClassDef(e, o + b), s.classDef2 = t._lctf.readClassDef(e, o + x), s.matrix = [], m = 0; m < S; m++) {
var w = [];
for (v = 0; v < C; v++) {
var T = null, E = null;
l != 0 && (T = t.GPOS.readValueRecord(e, r, l), r += 2 * d), u != 0 && (E = t.GPOS.readValueRecord(e, r, u), r += 2 * f), w.push({
val1: T,
val2: E
});
}
s.matrix.push(w);
}
}
} else if (n == 4 && s.fmt == 1) s.markCoverage = t._lctf.readCoverage(e, a.readUshort(e, r) + o), s.baseCoverage = t._lctf.readCoverage(e, a.readUshort(e, r + 2) + o), s.markClassCount = a.readUshort(e, r + 4), s.markArray = t.GPOS.readMarkArray(e, a.readUshort(e, r + 6) + o), s.baseArray = t.GPOS.readBaseArray(e, a.readUshort(e, r + 8) + o, s.markClassCount);
else if (n == 6 && s.fmt == 1) s.mark1Coverage = t._lctf.readCoverage(e, a.readUshort(e, r) + o), s.mark2Coverage = t._lctf.readCoverage(e, a.readUshort(e, r + 2) + o), s.markClassCount = a.readUshort(e, r + 4), s.mark1Array = t.GPOS.readMarkArray(e, a.readUshort(e, r + 6) + o), s.mark2Array = t.GPOS.readBaseArray(e, a.readUshort(e, r + 8) + o, s.markClassCount);
else {
if (n == 9 && s.fmt == 1) {
var D = a.readUshort(e, r);
r += 2;
var O = a.readUint(e, r);
if (r += 4, i.ltype == 9) i.ltype = D;
else if (i.ltype != D) throw "invalid extension substitution";
return t.GPOS.subt(e, i.ltype, o + O);
}
console.debug("unsupported GPOS table LookupType", n, "format", s.fmt);
}
return s;
}, t.GPOS.readValueRecord = function(e, n, r) {
var i = t._bin, a = [];
return a.push(1 & r ? i.readShort(e, n) : 0), n += 1 & r ? 2 : 0, a.push(2 & r ? i.readShort(e, n) : 0), n += 2 & r ? 2 : 0, a.push(4 & r ? i.readShort(e, n) : 0), n += 4 & r ? 2 : 0, a.push(8 & r ? i.readShort(e, n) : 0), n += 8 & r ? 2 : 0, a;
}, t.GPOS.readBaseArray = function(e, n, r) {
var i = t._bin, a = [], o = n, s = i.readUshort(e, n);
n += 2;
for (var c = 0; c < s; c++) {
for (var l = [], u = 0; u < r; u++) l.push(t.GPOS.readAnchorRecord(e, o + i.readUshort(e, n))), n += 2;
a.push(l);
}
return a;
}, t.GPOS.readMarkArray = function(e, n) {
var r = t._bin, i = [], a = n, o = r.readUshort(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = t.GPOS.readAnchorRecord(e, r.readUshort(e, n + 2) + a);
c.markClass = r.readUshort(e, n), i.push(c), n += 4;
}
return i;
}, t.GPOS.readAnchorRecord = function(e, n) {
var r = t._bin, i = {};
return i.fmt = r.readUshort(e, n), i.x = r.readShort(e, n + 2), i.y = r.readShort(e, n + 4), i;
}, t.GSUB = {}, t.GSUB.parse = function(e, n, r, i) {
return t._lctf.parse(e, n, r, i, t.GSUB.subt);
}, t.GSUB.subt = function(e, n, r, i) {
var a = t._bin, o = r, s = {};
if (s.fmt = a.readUshort(e, r), r += 2, n != 1 && n != 2 && n != 4 && n != 5 && n != 6) return null;
if (n == 1 || n == 2 || n == 4 || n == 5 && s.fmt <= 2 || n == 6 && s.fmt <= 2) {
var c = a.readUshort(e, r);
r += 2, s.coverage = t._lctf.readCoverage(e, o + c);
}
if (n == 1 && s.fmt >= 1 && s.fmt <= 2) {
if (s.fmt == 1) s.delta = a.readShort(e, r), r += 2;
else if (s.fmt == 2) {
var l = a.readUshort(e, r);
r += 2, s.newg = a.readUshorts(e, r, l), r += 2 * s.newg.length;
}
} else if (n == 2 && s.fmt == 1) {
l = a.readUshort(e, r), r += 2, s.seqs = [];
for (var u = 0; u < l; u++) {
var d = a.readUshort(e, r) + o;
r += 2;
var f = a.readUshort(e, d);
s.seqs.push(a.readUshorts(e, d + 2, f));
}
} else if (n == 4) for (s.vals = [], l = a.readUshort(e, r), r += 2, u = 0; u < l; u++) {
var p = a.readUshort(e, r);
r += 2, s.vals.push(t.GSUB.readLigatureSet(e, o + p));
}
else if (n == 5 && s.fmt == 2) {
if (s.fmt == 2) {
var m = a.readUshort(e, r);
r += 2, s.cDef = t._lctf.readClassDef(e, o + m), s.scset = [];
var h = a.readUshort(e, r);
for (r += 2, u = 0; u < h; u++) {
var g = a.readUshort(e, r);
r += 2, s.scset.push(g == 0 ? null : t.GSUB.readSubClassSet(e, o + g));
}
}
} else if (n == 6 && s.fmt == 3) {
if (s.fmt == 3) {
for (u = 0; u < 3; u++) {
l = a.readUshort(e, r), r += 2;
for (var _ = [], v = 0; v < l; v++) _.push(t._lctf.readCoverage(e, o + a.readUshort(e, r + 2 * v)));
r += 2 * l, u == 0 && (s.backCvg = _), u == 1 && (s.inptCvg = _), u == 2 && (s.ahedCvg = _);
}
l = a.readUshort(e, r), r += 2, s.lookupRec = t.GSUB.readSubstLookupRecords(e, r, l);
}
} else {
if (n == 7 && s.fmt == 1) {
var y = a.readUshort(e, r);
r += 2;
var b = a.readUint(e, r);
if (r += 4, i.ltype == 9) i.ltype = y;
else if (i.ltype != y) throw "invalid extension substitution";
return t.GSUB.subt(e, i.ltype, o + b);
}
console.debug("unsupported GSUB table LookupType", n, "format", s.fmt);
}
return s;
}, t.GSUB.readSubClassSet = function(e, n) {
var r = t._bin.readUshort, i = n, a = [], o = r(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = r(e, n);
n += 2, a.push(t.GSUB.readSubClassRule(e, i + c));
}
return a;
}, t.GSUB.readSubClassRule = function(e, n) {
var r = t._bin.readUshort, i = {}, a = r(e, n), o = r(e, n += 2);
n += 2, i.input = [];
for (var s = 0; s < a - 1; s++) i.input.push(r(e, n)), n += 2;
return i.substLookupRecords = t.GSUB.readSubstLookupRecords(e, n, o), i;
}, t.GSUB.readSubstLookupRecords = function(e, n, r) {
for (var i = t._bin.readUshort, a = [], o = 0; o < r; o++) a.push(i(e, n), i(e, n + 2)), n += 4;
return a;
}, t.GSUB.readChainSubClassSet = function(e, n) {
var r = t._bin, i = n, a = [], o = r.readUshort(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = r.readUshort(e, n);
n += 2, a.push(t.GSUB.readChainSubClassRule(e, i + c));
}
return a;
}, t.GSUB.readChainSubClassRule = function(e, n) {
for (var r = t._bin, i = {}, a = [
"backtrack",
"input",
"lookahead"
], o = 0; o < a.length; o++) {
var s = r.readUshort(e, n);
n += 2, o == 1 && s--, i[a[o]] = r.readUshorts(e, n, s), n += 2 * i[a[o]].length;
}
return s = r.readUshort(e, n), n += 2, i.subst = r.readUshorts(e, n, 2 * s), n += 2 * i.subst.length, i;
}, t.GSUB.readLigatureSet = function(e, n) {
var r = t._bin, i = n, a = [], o = r.readUshort(e, n);
n += 2;
for (var s = 0; s < o; s++) {
var c = r.readUshort(e, n);
n += 2, a.push(t.GSUB.readLigature(e, i + c));
}
return a;
}, t.GSUB.readLigature = function(e, n) {
var r = t._bin, i = { chain: [] };
i.nglyph = r.readUshort(e, n), n += 2;
var a = r.readUshort(e, n);
n += 2;
for (var o = 0; o < a - 1; o++) i.chain.push(r.readUshort(e, n)), n += 2;
return i;
}, t.head = {}, t.head.parse = function(e, n, r) {
var i = t._bin, a = {};
return i.readFixed(e, n), n += 4, a.fontRevision = i.readFixed(e, n), n += 4, i.readUint(e, n), n += 4, i.readUint(e, n), n += 4, a.flags = i.readUshort(e, n), n += 2, a.unitsPerEm = i.readUshort(e, n), n += 2, a.created = i.readUint64(e, n), n += 8, a.modified = i.readUint64(e, n), n += 8, a.xMin = i.readShort(e, n), n += 2, a.yMin = i.readShort(e, n), n += 2, a.xMax = i.readShort(e, n), n += 2, a.yMax = i.readShort(e, n), n += 2, a.macStyle = i.readUshort(e, n), n += 2, a.lowestRecPPEM = i.readUshort(e, n), n += 2, a.fontDirectionHint = i.readShort(e, n), n += 2, a.indexToLocFormat = i.readShort(e, n), n += 2, a.glyphDataFormat = i.readShort(e, n), n += 2, a;
}, t.hhea = {}, t.hhea.parse = function(e, n, r) {
var i = t._bin, a = {};
return i.readFixed(e, n), n += 4, a.ascender = i.readShort(e, n), n += 2, a.descender = i.readShort(e, n), n += 2, a.lineGap = i.readShort(e, n), n += 2, a.advanceWidthMax = i.readUshort(e, n), n += 2, a.minLeftSideBearing = i.readShort(e, n), n += 2, a.minRightSideBearing = i.readShort(e, n), n += 2, a.xMaxExtent = i.readShort(e, n), n += 2, a.caretSlopeRise = i.readShort(e, n), n += 2, a.caretSlopeRun = i.readShort(e, n), n += 2, a.caretOffset = i.readShort(e, n), n += 2, n += 8, a.metricDataFormat = i.readShort(e, n), n += 2, a.numberOfHMetrics = i.readUshort(e, n), n += 2, a;
}, t.hmtx = {}, t.hmtx.parse = function(e, n, r, i) {
for (var a = t._bin, o = {
aWidth: [],
lsBearing: []
}, s = 0, c = 0, l = 0; l < i.maxp.numGlyphs; l++) l < i.hhea.numberOfHMetrics && (s = a.readUshort(e, n), n += 2, c = a.readShort(e, n), n += 2), o.aWidth.push(s), o.lsBearing.push(c);
return o;
}, t.kern = {}, t.kern.parse = function(e, n, r, i) {
var a = t._bin, o = a.readUshort(e, n);
if (n += 2, o == 1) return t.kern.parseV1(e, n - 2, r, i);
var s = a.readUshort(e, n);
n += 2;
for (var c = {
glyph1: [],
rval: []
}, l = 0; l < s; l++) {
n += 2, r = a.readUshort(e, n), n += 2;
var u = a.readUshort(e, n);
n += 2;
var d = u >>> 8;
if ((d &= 15) != 0) throw "unknown kern table format: " + d;
n = t.kern.readFormat0(e, n, c);
}
return c;
}, t.kern.parseV1 = function(e, n, r, i) {
var a = t._bin;
a.readFixed(e, n), n += 4;
var o = a.readUint(e, n);
n += 4;
for (var s = {
glyph1: [],
rval: []
}, c = 0; c < o; c++) {
a.readUint(e, n), n += 4;
var l = a.readUshort(e, n);
n += 2, a.readUshort(e, n), n += 2;
var u = l >>> 8;
if ((u &= 15) != 0) throw "unknown kern table format: " + u;
n = t.kern.readFormat0(e, n, s);
}
return s;
}, t.kern.readFormat0 = function(e, n, r) {
var i = t._bin, a = -1, o = i.readUshort(e, n);
n += 2, i.readUshort(e, n), n += 2, i.readUshort(e, n), n += 2, i.readUshort(e, n), n += 2;
for (var s = 0; s < o; s++) {
var c = i.readUshort(e, n);
n += 2;
var l = i.readUshort(e, n);
n += 2;
var u = i.readShort(e, n);
n += 2, c != a && (r.glyph1.push(c), r.rval.push({
glyph2: [],
vals: []
}));
var d = r.rval[r.rval.length - 1];
d.glyph2.push(l), d.vals.push(u), a = c;
}
return n;
}, t.loca = {}, t.loca.parse = function(e, n, r, i) {
var a = t._bin, o = [], s = i.head.indexToLocFormat, c = i.maxp.numGlyphs + 1;
if (s == 0) for (var l = 0; l < c; l++) o.push(a.readUshort(e, n + (l << 1)) << 1);
if (s == 1) for (l = 0; l < c; l++) o.push(a.readUint(e, n + (l << 2)));
return o;
}, t.maxp = {}, t.maxp.parse = function(e, n, r) {
var i = t._bin, a = {}, o = i.readUint(e, n);
return n += 4, a.numGlyphs = i.readUshort(e, n), n += 2, o == 65536 && (a.maxPoints = i.readUshort(e, n), n += 2, a.maxContours = i.readUshort(e, n), n += 2, a.maxCompositePoints = i.readUshort(e, n), n += 2, a.maxCompositeContours = i.readUshort(e, n), n += 2, a.maxZones = i.readUshort(e, n), n += 2, a.maxTwilightPoints = i.readUshort(e, n), n += 2, a.maxStorage = i.readUshort(e, n), n += 2, a.maxFunctionDefs = i.readUshort(e, n), n += 2, a.maxInstructionDefs = i.readUshort(e, n), n += 2, a.maxStackElements = i.readUshort(e, n), n += 2, a.maxSizeOfInstructions = i.readUshort(e, n), n += 2, a.maxComponentElements = i.readUshort(e, n), n += 2, a.maxComponentDepth = i.readUshort(e, n), n += 2), a;
}, t.name = {}, t.name.parse = function(e, n, r) {
var i = t._bin, a = {};
i.readUshort(e, n), n += 2;
var o = i.readUshort(e, n);
n += 2, i.readUshort(e, n);
for (var s, c = [
"copyright",
"fontFamily",
"fontSubfamily",
"ID",
"fullName",
"version",
"postScriptName",
"trademark",
"manufacturer",
"designer",
"description",
"urlVendor",
"urlDesigner",
"licence",
"licenceURL",
"---",
"typoFamilyName",
"typoSubfamilyName",
"compatibleFull",
"sampleText",
"postScriptCID",
"wwsFamilyName",
"wwsSubfamilyName",
"lightPalette",
"darkPalette"
], l = n += 2, u = 0; u < o; u++) {
var d = i.readUshort(e, n);
n += 2;
var f = i.readUshort(e, n);
n += 2;
var p = i.readUshort(e, n);
n += 2;
var m = i.readUshort(e, n);
n += 2;
var h = i.readUshort(e, n);
n += 2;
var g = i.readUshort(e, n);
n += 2;
var _, v = c[m], y = l + 12 * o + g;
if (d == 0) _ = i.readUnicode(e, y, h / 2);
else if (d == 3 && f == 0) _ = i.readUnicode(e, y, h / 2);
else if (f == 0) _ = i.readASCII(e, y, h);
else if (f == 1) _ = i.readUnicode(e, y, h / 2);
else if (f == 3) _ = i.readUnicode(e, y, h / 2);
else {
if (d != 1) throw "unknown encoding " + f + ", platformID: " + d;
_ = i.readASCII(e, y, h), console.debug("reading unknown MAC encoding " + f + " as ASCII");
}
var b = "p" + d + "," + p.toString(16);
a[b] == null && (a[b] = {}), a[b][v === void 0 ? m : v] = _, a[b]._lang = p;
}
for (var x in a) if (a[x].postScriptName != null && a[x]._lang == 1033) return a[x];
for (var x in a) if (a[x].postScriptName != null && a[x]._lang == 0) return a[x];
for (var x in a) if (a[x].postScriptName != null && a[x]._lang == 3084) return a[x];
for (var x in a) if (a[x].postScriptName != null) return a[x];
for (var x in a) {
s = x;
break;
}
return console.debug("returning name table with languageID " + a[s]._lang), a[s];
}, t["OS/2"] = {}, t["OS/2"].parse = function(e, n, r) {
var i = t._bin.readUshort(e, n);
n += 2;
var a = {};
if (i == 0) t["OS/2"].version0(e, n, a);
else if (i == 1) t["OS/2"].version1(e, n, a);
else if (i == 2 || i == 3 || i == 4) t["OS/2"].version2(e, n, a);
else {
if (i != 5) throw "unknown OS/2 table version: " + i;
t["OS/2"].version5(e, n, a);
}
return a;
}, t["OS/2"].version0 = function(e, n, r) {
var i = t._bin;
return r.xAvgCharWidth = i.readShort(e, n), n += 2, r.usWeightClass = i.readUshort(e, n), n += 2, r.usWidthClass = i.readUshort(e, n), n += 2, r.fsType = i.readUshort(e, n), n += 2, r.ySubscriptXSize = i.readShort(e, n), n += 2, r.ySubscriptYSize = i.readShort(e, n), n += 2, r.ySubscriptXOffset = i.readShort(e, n), n += 2, r.ySubscriptYOffset = i.readShort(e, n), n += 2, r.ySuperscriptXSize = i.readShort(e, n), n += 2, r.ySuperscriptYSize = i.readShort(e, n), n += 2, r.ySuperscriptXOffset = i.readShort(e, n), n += 2, r.ySuperscriptYOffset = i.readShort(e, n), n += 2, r.yStrikeoutSize = i.readShort(e, n), n += 2, r.yStrikeoutPosition = i.readShort(e, n), n += 2, r.sFamilyClass = i.readShort(e, n), n += 2, r.panose = i.readBytes(e, n, 10), n += 10, r.ulUnicodeRange1 = i.readUint(e, n), n += 4, r.ulUnicodeRange2 = i.readUint(e, n), n += 4, r.ulUnicodeRange3 = i.readUint(e, n), n += 4, r.ulUnicodeRange4 = i.readUint(e, n), n += 4, r.achVendID = [
i.readInt8(e, n),
i.readInt8(e, n + 1),
i.readInt8(e, n + 2),
i.readInt8(e, n + 3)
], n += 4, r.fsSelection = i.readUshort(e, n), n += 2, r.usFirstCharIndex = i.readUshort(e, n), n += 2, r.usLastCharIndex = i.readUshort(e, n), n += 2, r.sTypoAscender = i.readShort(e, n), n += 2, r.sTypoDescender = i.readShort(e, n), n += 2, r.sTypoLineGap = i.readShort(e, n), n += 2, r.usWinAscent = i.readUshort(e, n), n += 2, r.usWinDescent = i.readUshort(e, n), n += 2;
}, t["OS/2"].version1 = function(e, n, r) {
var i = t._bin;
return n = t["OS/2"].version0(e, n, r), r.ulCodePageRange1 = i.readUint(e, n), n += 4, r.ulCodePageRange2 = i.readUint(e, n), n += 4;
}, t["OS/2"].version2 = function(e, n, r) {
var i = t._bin;
return n = t["OS/2"].version1(e, n, r), r.sxHeight = i.readShort(e, n), n += 2, r.sCapHeight = i.readShort(e, n), n += 2, r.usDefault = i.readUshort(e, n), n += 2, r.usBreak = i.readUshort(e, n), n += 2, r.usMaxContext = i.readUshort(e, n), n += 2;
}, t["OS/2"].version5 = function(e, n, r) {
var i = t._bin;
return n = t["OS/2"].version2(e, n, r), r.usLowerOpticalPointSize = i.readUshort(e, n), n += 2, r.usUpperOpticalPointSize = i.readUshort(e, n), n += 2;
}, t.post = {}, t.post.parse = function(e, n, r) {
var i = t._bin, a = {};
return a.version = i.readFixed(e, n), n += 4, a.italicAngle = i.readFixed(e, n), n += 4, a.underlinePosition = i.readShort(e, n), n += 2, a.underlineThickness = i.readShort(e, n), n += 2, a;
}, t == null && (t = {}), t.U == null && (t.U = {}), t.U.codeToGlyph = function(e, t) {
var n = e.cmap, r = -1;
if (n.p0e4 == null ? n.p3e1 == null ? n.p1e0 == null ? n.p0e3 != null && (r = n.p0e3) : r = n.p1e0 : r = n.p3e1 : r = n.p0e4, r == -1) throw "no familiar platform and encoding!";
var i = n.tables[r];
if (i.format == 0) return t >= i.map.length ? 0 : i.map[t];
if (i.format == 4) {
for (var a = -1, o = 0; o < i.endCount.length; o++) if (t <= i.endCount[o]) {
a = o;
break;
}
return a == -1 || i.startCount[a] > t ? 0 : 65535 & (i.idRangeOffset[a] == 0 ? t + i.idDelta[a] : i.glyphIdArray[t - i.startCount[a] + (i.idRangeOffset[a] >> 1) - (i.idRangeOffset.length - a)]);
}
if (i.format == 12) {
if (t > i.groups[i.groups.length - 1][1]) return 0;
for (o = 0; o < i.groups.length; o++) {
var s = i.groups[o];
if (s[0] <= t && t <= s[1]) return s[2] + (t - s[0]);
}
return 0;
}
throw "unknown cmap table format " + i.format;
}, t.U.glyphToPath = function(e, n) {
var r = {
cmds: [],
crds: []
};
if (e.SVG && e.SVG.entries[n]) {
var i = e.SVG.entries[n];
return i == null ? r : (typeof i == "string" && (i = t.SVG.toPath(i), e.SVG.entries[n] = i), i);
}
if (e.CFF) {
var a = {
x: 0,
y: 0,
stack: [],
nStems: 0,
haveWidth: !1,
width: e.CFF.Private ? e.CFF.Private.defaultWidthX : 0,
open: !1
}, o = e.CFF, s = e.CFF.Private;
if (o.ROS) {
for (var c = 0; o.FDSelect[c + 2] <= n;) c += 2;
s = o.FDArray[o.FDSelect[c + 1]].Private;
}
t.U._drawCFF(e.CFF.CharStrings[n], a, o, s, r);
} else e.glyf && t.U._drawGlyf(n, e, r);
return r;
}, t.U._drawGlyf = function(e, n, r) {
var i = n.glyf[e];
i == null && (i = n.glyf[e] = t.glyf._parseGlyf(n, e)), i != null && (i.noc > -1 ? t.U._simpleGlyph(i, r) : t.U._compoGlyph(i, n, r));
}, t.U._simpleGlyph = function(e, n) {
for (var r = 0; r < e.noc; r++) {
for (var i = r == 0 ? 0 : e.endPts[r - 1] + 1, a = e.endPts[r], o = i; o <= a; o++) {
var s = o == i ? a : o - 1, c = o == a ? i : o + 1, l = 1 & e.flags[o], u = 1 & e.flags[s], d = 1 & e.flags[c], f = e.xs[o], p = e.ys[o];
if (o == i) if (l) {
if (!u) {
t.U.P.moveTo(n, f, p);
continue;
}
t.U.P.moveTo(n, e.xs[s], e.ys[s]);
} else u ? t.U.P.moveTo(n, e.xs[s], e.ys[s]) : t.U.P.moveTo(n, (e.xs[s] + f) / 2, (e.ys[s] + p) / 2);
l ? u && t.U.P.lineTo(n, f, p) : d ? t.U.P.qcurveTo(n, f, p, e.xs[c], e.ys[c]) : t.U.P.qcurveTo(n, f, p, (f + e.xs[c]) / 2, (p + e.ys[c]) / 2);
}
t.U.P.closePath(n);
}
}, t.U._compoGlyph = function(e, n, r) {
for (var i = 0; i < e.parts.length; i++) {
var a = {
cmds: [],
crds: []
}, o = e.parts[i];
t.U._drawGlyf(o.glyphIndex, n, a);
for (var s = o.m, c = 0; c < a.crds.length; c += 2) {
var l = a.crds[c], u = a.crds[c + 1];
r.crds.push(l * s.a + u * s.b + s.tx), r.crds.push(l * s.c + u * s.d + s.ty);
}
for (c = 0; c < a.cmds.length; c++) r.cmds.push(a.cmds[c]);
}
}, t.U._getGlyphClass = function(e, n) {
var r = t._lctf.getInterval(n, e);
return r == -1 ? 0 : n[r + 2];
}, t.U._applySubs = function(e, n, r, i) {
for (var a = e.length - n - 1, o = 0; o < r.tabs.length; o++) if (r.tabs[o] != null) {
var s, c = r.tabs[o];
if (!c.coverage || (s = t._lctf.coverageIndex(c.coverage, e[n])) != -1) {
if (r.ltype == 1) e[n], c.fmt == 1 ? e[n] = e[n] + c.delta : e[n] = c.newg[s];
else if (r.ltype == 4) for (var l = c.vals[s], u = 0; u < l.length; u++) {
var d = l[u], f = d.chain.length;
if (!(f > a)) {
for (var p = !0, m = 0, h = 0; h < f; h++) {
for (; e[n + m + (1 + h)] == -1;) m++;
d.chain[h] != e[n + m + (1 + h)] && (p = !1);
}
if (p) {
for (e[n] = d.nglyph, h = 0; h < f + m; h++) e[n + h + 1] = -1;
break;
}
}
}
else if (r.ltype == 5 && c.fmt == 2) for (var g = t._lctf.getInterval(c.cDef, e[n]), _ = c.cDef[g + 2], v = c.scset[_], y = 0; y < v.length; y++) {
var b = v[y], x = b.input;
if (!(x.length > a)) {
for (p = !0, h = 0; h < x.length; h++) {
var S = t._lctf.getInterval(c.cDef, e[n + 1 + h]);
if (g == -1 && c.cDef[S + 2] != x[h]) {
p = !1;
break;
}
}
if (p) {
var C = b.substLookupRecords;
for (u = 0; u < C.length; u += 2) C[u], C[u + 1];
}
}
}
else if (r.ltype == 6 && c.fmt == 3) {
if (!t.U._glsCovered(e, c.backCvg, n - c.backCvg.length) || !t.U._glsCovered(e, c.inptCvg, n) || !t.U._glsCovered(e, c.ahedCvg, n + c.inptCvg.length)) continue;
var w = c.lookupRec;
for (y = 0; y < w.length; y += 2) {
g = w[y];
var T = i[w[y + 1]];
t.U._applySubs(e, n + g, T, i);
}
}
}
}
}, t.U._glsCovered = function(e, n, r) {
for (var i = 0; i < n.length; i++) if (t._lctf.coverageIndex(n[i], e[r + i]) == -1) return !1;
return !0;
}, t.U.glyphsToPath = function(e, n, r) {
for (var i = {
cmds: [],
crds: []
}, a = 0, o = 0; o < n.length; o++) {
var s = n[o];
if (s != -1) {
for (var c = o < n.length - 1 && n[o + 1] != -1 ? n[o + 1] : 0, l = t.U.glyphToPath(e, s), u = 0; u < l.crds.length; u += 2) i.crds.push(l.crds[u] + a), i.crds.push(l.crds[u + 1]);
for (r && i.cmds.push(r), u = 0; u < l.cmds.length; u++) i.cmds.push(l.cmds[u]);
r && i.cmds.push("X"), a += e.hmtx.aWidth[s], o < n.length - 1 && (a += t.U.getPairAdjustment(e, s, c));
}
}
return i;
}, t.U.P = {}, t.U.P.moveTo = function(e, t, n) {
e.cmds.push("M"), e.crds.push(t, n);
}, t.U.P.lineTo = function(e, t, n) {
e.cmds.push("L"), e.crds.push(t, n);
}, t.U.P.curveTo = function(e, t, n, r, i, a, o) {
e.cmds.push("C"), e.crds.push(t, n, r, i, a, o);
}, t.U.P.qcurveTo = function(e, t, n, r, i) {
e.cmds.push("Q"), e.crds.push(t, n, r, i);
}, t.U.P.closePath = function(e) {
e.cmds.push("Z");
}, t.U._drawCFF = function(e, n, r, i, a) {
for (var o = n.stack, s = n.nStems, c = n.haveWidth, l = n.width, u = n.open, d = 0, f = n.x, p = n.y, m = 0, h = 0, g = 0, _ = 0, v = 0, y = 0, b = 0, x = 0, S = 0, C = 0, w = {
val: 0,
size: 0
}; d < e.length;) {
t.CFF.getCharString(e, d, w);
var T = w.val;
if (d += w.size, T == "o1" || T == "o18") o.length % 2 != 0 && !c && (l = o.shift() + i.nominalWidthX), s += o.length >> 1, o.length = 0, c = !0;
else if (T == "o3" || T == "o23") o.length % 2 != 0 && !c && (l = o.shift() + i.nominalWidthX), s += o.length >> 1, o.length = 0, c = !0;
else if (T == "o4") o.length > 1 && !c && (l = o.shift() + i.nominalWidthX, c = !0), u && t.U.P.closePath(a), p += o.pop(), t.U.P.moveTo(a, f, p), u = !0;
else if (T == "o5") for (; o.length > 0;) f += o.shift(), p += o.shift(), t.U.P.lineTo(a, f, p);
else if (T == "o6" || T == "o7") for (var E = o.length, D = T == "o6", O = 0; O < E; O++) {
var k = o.shift();
D ? f += k : p += k, D = !D, t.U.P.lineTo(a, f, p);
}
else if (T == "o8" || T == "o24") {
E = o.length;
for (var A = 0; A + 6 <= E;) m = f + o.shift(), h = p + o.shift(), g = m + o.shift(), _ = h + o.shift(), f = g + o.shift(), p = _ + o.shift(), t.U.P.curveTo(a, m, h, g, _, f, p), A += 6;
T == "o24" && (f += o.shift(), p += o.shift(), t.U.P.lineTo(a, f, p));
} else {
if (T == "o11") break;
if (T == "o1234" || T == "o1235" || T == "o1236" || T == "o1237") T == "o1234" && (h = p, g = (m = f + o.shift()) + o.shift(), C = _ = h + o.shift(), y = _, x = p, f = (b = (v = (S = g + o.shift()) + o.shift()) + o.shift()) + o.shift(), t.U.P.curveTo(a, m, h, g, _, S, C), t.U.P.curveTo(a, v, y, b, x, f, p)), T == "o1235" && (m = f + o.shift(), h = p + o.shift(), g = m + o.shift(), _ = h + o.shift(), S = g + o.shift(), C = _ + o.shift(), v = S + o.shift(), y = C + o.shift(), b = v + o.shift(), x = y + o.shift(), f = b + o.shift(), p = x + o.shift(), o.shift(), t.U.P.curveTo(a, m, h, g, _, S, C), t.U.P.curveTo(a, v, y, b, x, f, p)), T == "o1236" && (m = f + o.shift(), h = p + o.shift(), g = m + o.shift(), C = _ = h + o.shift(), y = _, b = (v = (S = g + o.shift()) + o.shift()) + o.shift(), x = y + o.shift(), f = b + o.shift(), t.U.P.curveTo(a, m, h, g, _, S, C), t.U.P.curveTo(a, v, y, b, x, f, p)), T == "o1237" && (m = f + o.shift(), h = p + o.shift(), g = m + o.shift(), _ = h + o.shift(), S = g + o.shift(), C = _ + o.shift(), v = S + o.shift(), y = C + o.shift(), b = v + o.shift(), x = y + o.shift(), Math.abs(b - f) > Math.abs(x - p) ? f = b + o.shift() : p = x + o.shift(), t.U.P.curveTo(a, m, h, g, _, S, C), t.U.P.curveTo(a, v, y, b, x, f, p));
else if (T == "o14") {
if (o.length > 0 && !c && (l = o.shift() + r.nominalWidthX, c = !0), o.length == 4) {
var j = o.shift(), M = o.shift(), N = o.shift(), P = o.shift(), ee = t.CFF.glyphBySE(r, N), te = t.CFF.glyphBySE(r, P);
t.U._drawCFF(r.CharStrings[ee], n, r, i, a), n.x = j, n.y = M, t.U._drawCFF(r.CharStrings[te], n, r, i, a);
}
u && (t.U.P.closePath(a), u = !1);
} else if (T == "o19" || T == "o20") o.length % 2 != 0 && !c && (l = o.shift() + i.nominalWidthX), s += o.length >> 1, o.length = 0, c = !0, d += s + 7 >> 3;
else if (T == "o21") o.length > 2 && !c && (l = o.shift() + i.nominalWidthX, c = !0), p += o.pop(), f += o.pop(), u && t.U.P.closePath(a), t.U.P.moveTo(a, f, p), u = !0;
else if (T == "o22") o.length > 1 && !c && (l = o.shift() + i.nominalWidthX, c = !0), f += o.pop(), u && t.U.P.closePath(a), t.U.P.moveTo(a, f, p), u = !0;
else if (T == "o25") {
for (; o.length > 6;) f += o.shift(), p += o.shift(), t.U.P.lineTo(a, f, p);
m = f + o.shift(), h = p + o.shift(), g = m + o.shift(), _ = h + o.shift(), f = g + o.shift(), p = _ + o.shift(), t.U.P.curveTo(a, m, h, g, _, f, p);
} else if (T == "o26") for (o.length % 2 && (f += o.shift()); o.length > 0;) m = f, h = p + o.shift(), f = g = m + o.shift(), p = (_ = h + o.shift()) + o.shift(), t.U.P.curveTo(a, m, h, g, _, f, p);
else if (T == "o27") for (o.length % 2 && (p += o.shift()); o.length > 0;) h = p, g = (m = f + o.shift()) + o.shift(), _ = h + o.shift(), f = g + o.shift(), p = _, t.U.P.curveTo(a, m, h, g, _, f, p);
else if (T == "o10" || T == "o29") {
var ne = T == "o10" ? i : r;
if (o.length == 0) console.debug("error: empty stack");
else {
var re = o.pop(), F = ne.Subrs[re + ne.Bias];
n.x = f, n.y = p, n.nStems = s, n.haveWidth = c, n.width = l, n.open = u, t.U._drawCFF(F, n, r, i, a), f = n.x, p = n.y, s = n.nStems, c = n.haveWidth, l = n.width, u = n.open;
}
} else if (T == "o30" || T == "o31") {
var ie = o.length, ae = (A = 0, T == "o31");
for (A += ie - (E = -3 & ie); A < E;) ae ? (h = p, g = (m = f + o.shift()) + o.shift(), p = (_ = h + o.shift()) + o.shift(), E - A == 5 ? (f = g + o.shift(), A++) : f = g, ae = !1) : (m = f, h = p + o.shift(), g = m + o.shift(), _ = h + o.shift(), f = g + o.shift(), E - A == 5 ? (p = _ + o.shift(), A++) : p = _, ae = !0), t.U.P.curveTo(a, m, h, g, _, f, p), A += 4;
} else {
if ((T + "").charAt(0) == "o") throw console.debug("Unknown operation: " + T, e), T;
o.push(T);
}
}
}
n.x = f, n.y = p, n.nStems = s, n.haveWidth = c, n.width = l, n.open = u;
};
var n = t, r = { Typr: n };
return e.Typr = n, e.default = r, Object.defineProperty(e, "__esModule", { value: !0 }), e;
}({}).Typr;
}
function cT() {
return function(e) {
var t = Uint8Array, n = Uint16Array, r = Uint32Array, i = new t([
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
4,
4,
4,
4,
5,
5,
5,
5,
0,
0,
0,
0
]), a = new t([
0,
0,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
5,
5,
6,
6,
7,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
13,
13,
0,
0
]), o = new t([
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
]), s = function(e, t) {
for (var i = new n(31), a = 0; a < 31; ++a) i[a] = t += 1 << e[a - 1];
var o = new r(i[30]);
for (a = 1; a < 30; ++a) for (var s = i[a]; s < i[a + 1]; ++s) o[s] = s - i[a] << 5 | a;
return [i, o];
}, c = s(i, 2), l = c[0], u = c[1];
l[28] = 258, u[258] = 28;
for (var d = s(a, 0)[0], f = new n(32768), p = 0; p < 32768; ++p) {
var m = (43690 & p) >>> 1 | (21845 & p) << 1;
m = (61680 & (m = (52428 & m) >>> 2 | (13107 & m) << 2)) >>> 4 | (3855 & m) << 4, f[p] = ((65280 & m) >>> 8 | (255 & m) << 8) >>> 1;
}
var h = function(e, t, r) {
for (var i = e.length, a = 0, o = new n(t); a < i; ++a) ++o[e[a] - 1];
var s, c = new n(t);
for (a = 0; a < t; ++a) c[a] = c[a - 1] + o[a - 1] << 1;
if (r) {
s = new n(1 << t);
var l = 15 - t;
for (a = 0; a < i; ++a) if (e[a]) for (var u = a << 4 | e[a], d = t - e[a], p = c[e[a] - 1]++ << d, m = p | (1 << d) - 1; p <= m; ++p) s[f[p] >>> l] = u;
} else for (s = new n(i), a = 0; a < i; ++a) e[a] && (s[a] = f[c[e[a] - 1]++] >>> 15 - e[a]);
return s;
}, g = new t(288);
for (p = 0; p < 144; ++p) g[p] = 8;
for (p = 144; p < 256; ++p) g[p] = 9;
for (p = 256; p < 280; ++p) g[p] = 7;
for (p = 280; p < 288; ++p) g[p] = 8;
var _ = new t(32);
for (p = 0; p < 32; ++p) _[p] = 5;
var v = h(g, 9, 1), y = h(_, 5, 1), b = function(e) {
for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
return t;
}, x = function(e, t, n) {
var r = t / 8 | 0;
return (e[r] | e[r + 1] << 8) >> (7 & t) & n;
}, S = function(e, t) {
var n = t / 8 | 0;
return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (7 & t);
}, C = [
"unexpected EOF",
"invalid block type",
"invalid length/literal",
"invalid distance",
"stream finished",
"no stream handler",
,
"no callback",
"invalid UTF-8 data",
"extra field too long",
"date not in range 1980-2099",
"filename too long",
"stream finishing",
"invalid zip data"
], w = function(e, t, n) {
var r = Error(t || C[e]);
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, w), !n) throw r;
return r;
}, T = function(e, s, c) {
var u = e.length;
if (!u || c && !c.l && u < 5) return s || new t(0);
var f = !s || c, p = !c || c.i;
c || (c = {}), s || (s = new t(3 * u));
var m, g = function(e) {
var n = s.length;
if (e > n) {
var r = new t(Math.max(2 * n, e));
r.set(s), s = r;
}
}, _ = c.f || 0, C = c.p || 0, T = c.b || 0, E = c.l, D = c.d, O = c.m, k = c.n, A = 8 * u;
do {
if (!E) {
c.f = _ = x(e, C, 1);
var j = x(e, C + 1, 3);
if (C += 3, !j) {
var M = e[(se = ((m = C) / 8 | 0) + (7 & m && 1) + 4) - 4] | e[se - 3] << 8, N = se + M;
if (N > u) {
p && w(0);
break;
}
f && g(T + M), s.set(e.subarray(se, N), T), c.b = T += M, c.p = C = 8 * N;
continue;
}
if (j == 1) E = v, D = y, O = 9, k = 5;
else if (j == 2) {
var P = x(e, C, 31) + 257, ee = x(e, C + 10, 15) + 4, te = P + x(e, C + 5, 31) + 1;
C += 14;
for (var ne = new t(te), re = new t(19), F = 0; F < ee; ++F) re[o[F]] = x(e, C + 3 * F, 7);
C += 3 * ee;
var ie = b(re), ae = (1 << ie) - 1, oe = h(re, ie, 1);
for (F = 0; F < te;) {
var se, I = oe[x(e, C, ae)];
if (C += 15 & I, (se = I >>> 4) < 16) ne[F++] = se;
else {
var ce = 0, le = 0;
for (se == 16 ? (le = 3 + x(e, C, 3), C += 2, ce = ne[F - 1]) : se == 17 ? (le = 3 + x(e, C, 7), C += 3) : se == 18 && (le = 11 + x(e, C, 127), C += 7); le--;) ne[F++] = ce;
}
}
var ue = ne.subarray(0, P), L = ne.subarray(P);
O = b(ue), k = b(L), E = h(ue, O, 1), D = h(L, k, 1);
} else w(1);
if (C > A) {
p && w(0);
break;
}
}
f && g(T + 131072);
for (var de = (1 << O) - 1, fe = (1 << k) - 1, pe = C;; pe = C) {
var me = (ce = E[S(e, C) & de]) >>> 4;
if ((C += 15 & ce) > A) {
p && w(0);
break;
}
if (ce || w(2), me < 256) s[T++] = me;
else {
if (me == 256) {
pe = C, E = null;
break;
}
var he = me - 254;
if (me > 264) {
var ge = i[F = me - 257];
he = x(e, C, (1 << ge) - 1) + l[F], C += ge;
}
var _e = D[S(e, C) & fe], ve = _e >>> 4;
if (_e || w(3), C += 15 & _e, L = d[ve], ve > 3 && (ge = a[ve], L += S(e, C) & (1 << ge) - 1, C += ge), C > A) {
p && w(0);
break;
}
f && g(T + 131072);
for (var ye = T + he; T < ye; T += 4) s[T] = s[T - L], s[T + 1] = s[T + 1 - L], s[T + 2] = s[T + 2 - L], s[T + 3] = s[T + 3 - L];
T = ye;
}
}
c.l = E, c.p = pe, c.b = T, E && (_ = 1, c.m = O, c.d = D, c.n = k);
} while (!_);
return T == s.length ? s : function(e, i, a) {
(i == null || i < 0) && (i = 0), (a == null || a > e.length) && (a = e.length);
var o = new (e instanceof n ? n : e instanceof r ? r : t)(a - i);
return o.set(e.subarray(i, a)), o;
}(s, 0, T);
}, E = new t(0), D = typeof TextDecoder < "u" && new TextDecoder();
try {
D.decode(E, { stream: !0 });
} catch {}
return e.convert_streams = function(e) {
var t = new DataView(e), n = 0;
function r() {
var e = t.getUint16(n);
return n += 2, e;
}
function i() {
var e = t.getUint32(n);
return n += 4, e;
}
function a(e) {
_.setUint16(v, e), v += 2;
}
function o(e) {
_.setUint32(v, e), v += 4;
}
for (var s = {
signature: i(),
flavor: i(),
length: i(),
numTables: r(),
reserved: r(),
totalSfntSize: i(),
majorVersion: r(),
minorVersion: r(),
metaOffset: i(),
metaLength: i(),
metaOrigLength: i(),
privOffset: i(),
privLength: i()
}, c = 0; 2 ** c <= s.numTables;) c++;
c--;
for (var l = 16 * 2 ** c, u = 16 * s.numTables - l, d = 12, f = [], p = 0; p < s.numTables; p++) f.push({
tag: i(),
offset: i(),
compLength: i(),
origLength: i(),
origChecksum: i()
}), d += 16;
var m, h = new Uint8Array(12 + 16 * f.length + f.reduce((function(e, t) {
return e + t.origLength + 4;
}), 0)), g = h.buffer, _ = new DataView(g), v = 0;
return o(s.flavor), a(s.numTables), a(l), a(c), a(u), f.forEach((function(e) {
o(e.tag), o(e.origChecksum), o(d), o(e.origLength), e.outOffset = d, (d += e.origLength) % 4 != 0 && (d += 4 - d % 4);
})), f.forEach((function(t) {
var n, r = e.slice(t.offset, t.offset + t.compLength);
if (t.compLength != t.origLength) {
var i = new Uint8Array(t.origLength);
n = new Uint8Array(r, 2), T(n, i);
} else i = new Uint8Array(r);
h.set(i, t.outOffset);
var a = 0;
(d = t.outOffset + t.origLength) % 4 != 0 && (a = 4 - d % 4), h.set(new Uint8Array(a).buffer, t.outOffset + t.origLength), m = d + a;
})), g.slice(0, m);
}, Object.defineProperty(e, "__esModule", { value: !0 }), e;
}({}).convert_streams;
}
function lT(e, t) {
let n = {
M: 2,
L: 2,
Q: 4,
C: 6,
Z: 0
}, r = {
C: "18g,ca,368,1kz",
D: "17k,6,2,2+4,5+c,2+6,2+1,10+1,9+f,j+11,2+1,a,2,2+1,15+2,3,j+2,6+3,2+8,2,2,2+1,w+a,4+e,3+3,2,3+2,3+5,23+w,2f+4,3,2+9,2,b,2+3,3,1k+9,6+1,3+1,2+2,2+d,30g,p+y,1,1+1g,f+x,2,sd2+1d,jf3+4,f+3,2+4,2+2,b+3,42,2,4+2,2+1,2,3,t+1,9f+w,2,el+2,2+g,d+2,2l,2+1,5,3+1,2+1,2,3,6,16wm+1v",
R: "17m+3,2,2,6+3,m,15+2,2+2,h+h,13,3+8,2,2,3+1,2,p+1,x,5+4,5,a,2,2,3,u,c+2,g+1,5,2+1,4+1,5j,6+1,2,b,2+2,f,2+1,1s+2,2,3+1,7,1ez0,2,2+1,4+4,b,4,3,b,42,2+2,4,3,2+1,2,o+3,ae,ep,x,2o+2,3+1,3,5+1,6",
L: "x9u,jff,a,fd,jv",
T: "4t,gj+33,7o+4,1+1,7c+18,2,2+1,2+1,2,21+a,2,1b+k,h,2u+6,3+5,3+1,2+3,y,2,v+q,2k+a,1n+8,a,p+3,2+8,2+2,2+4,18+2,3c+e,2+v,1k,2,5+7,5,4+6,b+1,u,1n,5+3,9,l+1,r,3+1,1m,5+1,5+1,3+2,4,v+1,4,c+1,1m,5+4,2+1,5,l+1,n+5,2,1n,3,2+3,9,8+1,c+1,v,1q,d,1f,4,1m+2,6+2,2+3,8+1,c+1,u,1n,3,7,6+1,l+1,t+1,1m+1,5+3,9,l+1,u,21,8+2,2,2j,3+6,d+7,2r,3+8,c+5,23+1,s,2,2,1k+d,2+4,2+1,6+a,2+z,a,2v+3,2+5,2+1,3+1,q+1,5+2,h+3,e,3+1,7,g,jk+2,qb+2,u+2,u+1,v+1,1t+1,2+6,9,3+a,a,1a+2,3c+1,z,3b+2,5+1,a,7+2,64+1,3,1n,2+6,2,2,3+7,7+9,3,1d+d,1,1+1,1s+3,1d,2+4,2,6,15+8,d+1,x+3,3+1,2+2,1l,2+1,4,2+2,1n+7,3+1,49+2,2+c,2+6,5,7,4+1,5j+1l,2+4,ek,3+1,r+4,1e+4,6+5,2p+c,1+3,1,1+2,1+b,2db+2,3y,2p+v,ff+3,30+1,n9x,1+2,2+9,x+1,29+1,7l,4,5,q+1,6,48+1,r+h,e,13+7,q+a,1b+2,1d,3+3,3+1,14,1w+5,3+1,3+1,d,9,1c,1g,2+2,3+1,6+1,2,17+1,9,6n,3,5,fn5,ki+f,h+f,5s,6y+2,ea,6b,46+4,1af+2,2+1,6+3,15+2,5,4m+1,fy+3,as+1,4a+a,4x,1j+e,1l+2,1e+3,3+1,1y+2,11+4,2+7,1r,d+1,1h+8,b+3,3,2o+2,3,2+1,7,4h,4+7,m+1,1m+1,4,12+6,4+4,5g+7,3+2,2,o,2d+5,2,5+1,2+1,6n+3,7+1,2+1,s+1,2e+7,3,2+1,2z,2,3+5,2,2u+2,3+3,2+4,78+8,2+1,75+1,2,5,41+3,3+1,5,x+9,15+5,3+3,9,a+5,3+2,1b+c,2+1,bb+6,2+5,2,2b+l,3+6,2+1,2+1,3f+5,4,2+1,2+6,2,21+1,4,2,9o+1,470+8,at4+4,1o+6,t5,1s+3,2a,f5l+1,2+3,43o+2,a+7,1+7,3+6,v+3,45+2,1j0+1i,5+1d,9,f,n+4,2+e,11t+6,2+g,3+6,2+1,2+4,7a+6,c6+3,15t+6,32+6,1,gzau,v+2n,3l+6n"
}, i;
function a(e) {
if (!i) {
let e = {
R: 2,
L: 1,
D: 4,
C: 16,
U: 32,
T: 8
};
i = /* @__PURE__ */ new Map();
for (let t in r) {
let n = 0;
r[t].split(",").forEach((r) => {
let [a, o] = r.split("+");
a = parseInt(a, 36), o = o ? parseInt(o, 36) : 0, i.set(n += a, e[t]);
for (let r = o; r--;) i.set(++n, e[t]);
});
}
}
return i.get(e) || 32;
}
let o = [
null,
"isol",
"init",
"fina",
"medi"
];
function s(e) {
let t = new Uint8Array(e.length), n = 32, r = 1, i = -1;
for (let o = 0; o < e.length; o++) {
let s = e.codePointAt(o), c = a(s) | 0, l = 1;
c & 8 || (n & 21 ? c & 22 ? (l = 3, (r === 1 || r === 3) && t[i]++) : c & 33 && (r === 2 || r === 4) && t[i]-- : n & 34 && (r === 2 || r === 4) && t[i]--, r = t[o] = l, n = c, i = o, s > 65535 && o++);
}
return t;
}
function c(t, n) {
let r = [];
for (let i = 0; i < n.length; i++) {
let a = n.codePointAt(i);
a > 65535 && i++, r.push(e.U.codeToGlyph(t, a));
}
let i = t.GSUB;
if (i) {
let { lookupList: t, featureList: a } = i, c, l = /^(rlig|liga|mset|isol|init|fina|medi|half|pres|blws|ccmp)$/, u = [];
a.forEach((i) => {
if (l.test(i.tag)) for (let a = 0; a < i.tab.length; a++) {
if (u[i.tab[a]]) continue;
u[i.tab[a]] = !0;
let l = t[i.tab[a]], d = /^(isol|init|fina|medi)$/.test(i.tag);
d && !c && (c = s(n));
for (let n = 0; n < r.length; n++) (!c || !d || o[c[n]] === i.tag) && e.U._applySubs(r, n, l, t);
}
});
}
return r;
}
function l(t, n) {
let r = new Int16Array(n.length * 3), i = 0;
for (; i < n.length; i++) {
let c = n[i];
if (c === -1) continue;
r[i * 3 + 2] = t.hmtx.aWidth[c];
let l = t.GPOS;
if (l) {
let d = l.lookupList;
for (let l = 0; l < d.length; l++) {
let f = d[l];
for (let l = 0; l < f.tabs.length; l++) {
let d = f.tabs[l];
if (f.ltype === 1) {
if (e._lctf.coverageIndex(d.coverage, c) !== -1 && d.pos) {
s(d.pos, i);
break;
}
} else if (f.ltype === 2) {
let t = null, r = a();
if (r !== -1) {
let a = e._lctf.coverageIndex(d.coverage, n[r]);
if (a !== -1) {
if (d.fmt === 1) {
let e = d.pairsets[a];
for (let n = 0; n < e.length; n++) e[n].gid2 === c && (t = e[n]);
} else if (d.fmt === 2) {
let i = e.U._getGlyphClass(n[r], d.classDef1), a = e.U._getGlyphClass(c, d.classDef2);
t = d.matrix[i][a];
}
if (t) {
t.val1 && s(t.val1, r), t.val2 && s(t.val2, i);
break;
}
}
}
} else if (f.ltype === 4) {
let t = e._lctf.coverageIndex(d.markCoverage, c);
if (t !== -1) {
let s = a(o), c = s === -1 ? -1 : e._lctf.coverageIndex(d.baseCoverage, n[s]);
if (c !== -1) {
let e = d.markArray[t], n = d.baseArray[c][e.markClass];
r[i * 3] = n.x - e.x + r[s * 3] - r[s * 3 + 2], r[i * 3 + 1] = n.y - e.y + r[s * 3 + 1];
break;
}
}
} else if (f.ltype === 6) {
let o = e._lctf.coverageIndex(d.mark1Coverage, c);
if (o !== -1) {
let s = a();
if (s !== -1) {
let a = n[s];
if (u(t, a) === 3) {
let t = e._lctf.coverageIndex(d.mark2Coverage, a);
if (t !== -1) {
let e = d.mark1Array[o], n = d.mark2Array[t][e.markClass];
r[i * 3] = n.x - e.x + r[s * 3] - r[s * 3 + 2], r[i * 3 + 1] = n.y - e.y + r[s * 3 + 1];
break;
}
}
}
}
}
}
}
} else if (t.kern && !t.cff) {
let e = a();
if (e !== -1) {
let i = t.kern.glyph1.indexOf(n[e]);
if (i !== -1) {
let n = t.kern.rval[i].glyph2.indexOf(c);
n !== -1 && (r[e * 3 + 2] += t.kern.rval[i].vals[n]);
}
}
}
}
return r;
function a(e) {
for (let t = i - 1; t >= 0; t--) if (n[t] !== -1 && (!e || e(n[t]))) return t;
return -1;
}
function o(e) {
return u(t, e) === 1;
}
function s(e, t) {
for (let n = 0; n < 3; n++) r[t * 3 + n] += e[n] || 0;
}
}
function u(t, n) {
let r = t.GDEF && t.GDEF.glyphClassDef;
return r ? e.U._getGlyphClass(n, r) : 0;
}
function d(...e) {
for (let t = 0; t < e.length; t++) if (typeof e[t] == "number") return e[t];
}
function f(t) {
let r = Object.create(null), i = t["OS/2"], a = t.hhea, o = t.head.unitsPerEm, s = d(i && i.sTypoAscender, a && a.ascender, o), u = {
unitsPerEm: o,
ascender: s,
descender: d(i && i.sTypoDescender, a && a.descender, 0),
capHeight: d(i && i.sCapHeight, s),
xHeight: d(i && i.sxHeight, s),
lineGap: d(i && i.sTypoLineGap, a && a.lineGap),
supportsCodePoint(n) {
return e.U.codeToGlyph(t, n) > 0;
},
forEachGlyph(i, a, o, s) {
let d = 0, f = 1 / u.unitsPerEm * a, p = c(t, i), m = 0, h = l(t, p);
return p.forEach((c, l) => {
if (c !== -1) {
let i = r[c];
if (!i) {
let { cmds: a, crds: o } = e.U.glyphToPath(t, c), s = "", l = 0;
for (let e = 0, t = a.length; e < t; e++) {
let t = n[a[e]];
s += a[e];
for (let e = 1; e <= t; e++) s += (e > 1 ? "," : "") + o[l++];
}
let u, d, f, p;
if (o.length) {
u = d = Infinity, f = p = -Infinity;
for (let e = 0, t = o.length; e < t; e += 2) {
let t = o[e], n = o[e + 1];
t < u && (u = t), n < d && (d = n), t > f && (f = t), n > p && (p = n);
}
} else u = f = d = p = 0;
i = r[c] = {
index: c,
advanceWidth: t.hmtx.aWidth[c],
xMin: u,
yMin: d,
xMax: f,
yMax: p,
path: s
};
}
s.call(null, i, d + h[l * 3] * f, h[l * 3 + 1] * f, m), d += h[l * 3 + 2] * f, o && (d += o * a);
}
m += i.codePointAt(m) > 65535 ? 2 : 1;
}), d;
}
};
return u;
}
return function(n) {
let r = new Uint8Array(n, 0, 4), i = e._bin.readASCII(r, 0, 4);
if (i === "wOFF") n = t(n);
else if (i === "wOF2") throw Error("woff2 fonts not supported");
return f(e.parse(n)[0]);
};
}
var uT = /*#__PURE__*/ Rw({
name: "Typr Font Parser",
dependencies: [
sT,
cT,
lT
],
init(e, t, n) {
return n(e(), t());
}
});
function dT() {
return function(e) {
var t = function() {
this.buckets = /* @__PURE__ */ new Map();
};
t.prototype.add = function(e) {
var t = e >> 5;
this.buckets.set(t, (this.buckets.get(t) || 0) | 1 << (31 & e));
}, t.prototype.has = function(e) {
var t = this.buckets.get(e >> 5);
return t !== void 0 && (t & 1 << (31 & e)) != 0;
}, t.prototype.serialize = function() {
var e = [];
return this.buckets.forEach((function(t, n) {
e.push((+n).toString(36) + ":" + t.toString(36));
})), e.join(",");
}, t.prototype.deserialize = function(e) {
var t = this;
this.buckets.clear(), e.split(",").forEach((function(e) {
var n = e.split(":");
t.buckets.set(parseInt(n[0], 36), parseInt(n[1], 36));
}));
};
var n = 2 ** 8, r = n - 1, i = ~r;
function a(e) {
var t = function(e) {
return e & i;
}(e).toString(16), r = function(e) {
return (e & i) + n - 1;
}(e).toString(16);
return "codepoint-index/plane" + (e >> 16) + "/" + t + "-" + r + ".json";
}
function o(e, t) {
var n = e & r, i = t.codePointAt(n / 6 | 0);
return ((i = (i || 48) - 48) & 1 << n % 6) != 0;
}
function s(e, t) {
var n;
(n = e, n.replace(/U\+/gi, "").replace(/^,+|,+$/g, "").split(/,+/).map((function(e) {
return e.split("-").map((function(e) {
return parseInt(e.trim(), 16);
}));
}))).forEach((function(e) {
var n = e[0], r = e[1];
r === void 0 && (r = n), t(n, r);
}));
}
function c(e, t) {
s(e, (function(e, n) {
for (var r = e; r <= n; r++) t(r);
}));
}
var l = {}, u = {}, d = /* @__PURE__ */ new WeakMap(), f = "https://cdn.jsdelivr.net/gh/lojjic/unicode-font-resolver@v1.0.1/packages/data";
function p(e) {
var n = d.get(e);
return n || (n = new t(), c(e.ranges, (function(e) {
return n.add(e);
})), d.set(e, n)), n;
}
var m, h = /* @__PURE__ */ new Map();
function g(e, t, n) {
return e[t] ? t : e[n] ? n : function(e) {
for (var t in e) return t;
}(e);
}
function _(e, t) {
var n = t;
if (!e.includes(n)) {
n = Infinity;
for (var r = 0; r < e.length; r++) Math.abs(e[r] - t) < Math.abs(n - t) && (n = e[r]);
}
return n;
}
function v(e) {
return m || (m = /* @__PURE__ */ new Set(), c("9-D,20,85,A0,1680,2000-200A,2028-202F,205F,3000", (function(e) {
m.add(e);
}))), m.has(e);
}
return e.CodePointSet = t, e.clearCache = function() {
l = {}, u = {};
}, e.getFontsForString = function(e, t) {
t === void 0 && (t = {});
var n, r = t.lang;
r === void 0 && (r = /\p{Script=Hangul}/u.test(n = e) ? "ko" : /\p{Script=Hiragana}|\p{Script=Katakana}/u.test(n) ? "ja" : "en");
var i = t.category;
i === void 0 && (i = "sans-serif");
var s = t.style;
s === void 0 && (s = "normal");
var c = t.weight;
c === void 0 && (c = 400);
var d = (t.dataUrl || f).replace(/\/$/g, ""), m = /* @__PURE__ */ new Map(), y = new Uint8Array(e.length), b = {}, x = {}, S = Array(e.length), C = /* @__PURE__ */ new Map(), w = !1;
function T(e) {
var t = h.get(e);
return t || (t = fetch(d + "/" + e).then((function(e) {
if (!e.ok) throw Error(e.statusText);
return e.json().then((function(e) {
if (!Array.isArray(e) || e[0] !== 1) throw Error("Incorrect schema version; need 1, got " + e[0]);
return e[1];
}));
})).catch((function(t) {
if (d !== f) return w || (console.error("unicode-font-resolver: Failed loading from dataUrl \"" + d + "\", trying default CDN. " + t.message), w = !0), d = f, h.delete(e), T(e);
throw t;
})), h.set(e, t)), t;
}
for (var E = function(t) {
var n = e.codePointAt(t), r = a(n);
S[t] = r, l[r] || C.has(r) || C.set(r, T(r).then((function(e) {
l[r] = e;
}))), n > 65535 && (t++, D = t);
}, D = 0; D < e.length; D++) E(D);
return Promise.all(C.values()).then((function() {
C.clear();
for (var t = function(t) {
var i = e.codePointAt(t), a = null, s = l[S[t]], c = void 0;
for (var d in s) {
var f = x[d];
if (f === void 0 && (f = x[d] = new RegExp(d).test(r || "en")), f) {
for (var p in c = d, s[d]) if (o(i, s[d][p])) {
a = p;
break;
}
break;
}
}
if (!a) {
t: for (var m in s) if (m !== c) {
for (var h in s[m]) if (o(i, s[m][h])) {
a = h;
break t;
}
}
}
a || (console.debug("No font coverage for U+" + i.toString(16)), a = "latin"), S[t] = a, u[a] || C.has(a) || C.set(a, T("font-meta/" + a + ".json").then((function(e) {
u[a] = e;
}))), i > 65535 && (t++, n = t);
}, n = 0; n < e.length; n++) t(n);
return Promise.all(C.values());
})).then((function() {
for (var t, n = null, r = 0; r < e.length; r++) {
var a = e.codePointAt(r);
if (n && (v(a) || p(n).has(a))) y[r] = y[r - 1];
else {
n = u[S[r]];
var o = b[n.id];
if (!o) {
var l = n.typeforms, f = g(l, i, "sans-serif"), h = g(l[f], s, "normal"), x = _((t = l[f]) == null ? void 0 : t[h], c);
o = b[n.id] = d + "/font-files/" + n.id + "/" + f + "." + h + "." + x + ".woff";
}
var C = m.get(o);
C == null && (C = m.size, m.set(o, C)), y[r] = C;
}
a > 65535 && (r++, y[r] = y[r - 1]);
}
return {
fontUrls: Array.from(m.keys()),
chars: y
};
}));
}, Object.defineProperty(e, "__esModule", { value: !0 }), e;
}({});
}
function fT(e, t) {
let n = Object.create(null), r = Object.create(null);
function i(t, n) {
let r = (e) => {
console.error(`Failure loading font ${t}`, e);
};
try {
let i = new XMLHttpRequest();
i.open("get", t, !0), i.responseType = "arraybuffer", i.onload = function() {
if (i.status >= 400) r(Error(i.statusText));
else if (i.status > 0) try {
let r = e(i.response);
r.src = t, n(r);
} catch (e) {
r(e);
}
}, i.onerror = r, i.send();
} catch (e) {
r(e);
}
}
function a(e, t) {
let a = n[e];
a ? t(a) : r[e] ? r[e].push(t) : (r[e] = [t], i(e, (t) => {
t.src = e, n[e] = t, r[e].forEach((e) => e(t)), delete r[e];
}));
}
return function(e, r, { lang: i, fonts: o = [], style: s = "normal", weight: c = "normal", unicodeFontsURL: l } = {}) {
let u = new Uint8Array(e.length), d = [];
e.length || h();
let f = /* @__PURE__ */ new Map(), p = [];
if (s !== "italic" && (s = "normal"), typeof c != "number" && (c = c === "bold" ? 700 : 400), o && !Array.isArray(o) && (o = [o]), o = o.slice().filter((e) => !e.lang || e.lang.test(i)).reverse(), o.length) {
let t = 0;
(function r(i = 0) {
for (let s = i, c = e.length; s < c; s++) {
let i = e.codePointAt(s);
if (t === 1 && d[u[s - 1]].supportsCodePoint(i) || s > 0 && /\s/.test(e[s])) u[s] = u[s - 1], t === 2 && (p[p.length - 1][1] = s);
else for (let e = u[s], c = o.length; e <= c; e++) if (e === c) {
let e = t === 2 ? p[p.length - 1] : p[p.length] = [s, s];
e[1] = s, t = 2;
} else {
u[s] = e;
let { src: c, unicodeRange: l } = o[e];
if (!l || g(i, l)) {
let e = n[c];
if (!e) {
a(c, () => {
r(s);
});
return;
}
if (e.supportsCodePoint(i)) {
let n = f.get(e);
typeof n != "number" && (n = d.length, d.push(e), f.set(e, n)), u[s] = n, t = 1;
break;
}
}
}
i > 65535 && s + 1 < c && (u[s + 1] = u[s], s++, t === 2 && (p[p.length - 1][1] = s));
}
m();
})();
} else p.push([0, e.length - 1]), m();
function m() {
if (p.length) {
let n = p.map((t) => e.substring(t[0], t[1] + 1)).join("\n");
t.getFontsForString(n, {
lang: i || void 0,
style: s,
weight: c,
dataUrl: l
}).then(({ fontUrls: e, chars: t }) => {
let n = d.length, r = 0;
p.forEach((e) => {
for (let i = 0, a = e[1] - e[0]; i <= a; i++) u[e[0] + i] = t[r++] + n;
r++;
});
let i = 0;
e.forEach((t, r) => {
a(t, (t) => {
d[r + n] = t, ++i === e.length && h();
});
});
});
} else h();
}
function h() {
r({
chars: u,
fonts: d
});
}
function g(e, t) {
for (let n = 0; n < t.length; n++) {
let [r, i = r] = t[n];
if (r <= e && e <= i) return !0;
}
return !1;
}
};
}
var pT = /*#__PURE__*/ Rw({
name: "FontResolver",
dependencies: [
fT,
uT,
dT
],
init(e, t, n) {
return e(t, n());
}
});
function mT(e, t) {
let n = Infinity, r = /[\u00AD\u034F\u061C\u115F-\u1160\u17B4-\u17B5\u180B-\u180E\u200B-\u200F\u202A-\u202E\u2060-\u206F\u3164\uFE00-\uFE0F\uFEFF\uFFA0\uFFF0-\uFFF8]/, i = "[^\\S\\u00A0]", a = RegExp(`${i}|[\\-\\u007C\\u00AD\\u2010\\u2012-\\u2014\\u2027\\u2056\\u2E17\\u2E40]`);
function o({ text: t, lang: n, fonts: r, style: i, weight: a, preResolvedFonts: o, unicodeFontsURL: s }, c) {
let l = ({ chars: e, fonts: t }) => {
let n, r, i = [];
for (let a = 0; a < e.length; a++) e[a] === r ? n.end = a : (r = e[a], i.push(n = {
start: a,
end: a,
fontObj: t[e[a]]
}));
c(i);
};
o ? l(o) : e(t, l, {
lang: n,
fonts: r,
style: i,
weight: a,
unicodeFontsURL: s
});
}
function s({ text: e = "", font: s, lang: c, sdfGlyphSize: p = 64, fontSize: m = 400, fontWeight: h = 1, fontStyle: g = "normal", letterSpacing: _ = 0, lineHeight: v = "normal", maxWidth: y = n, direction: b, textAlign: x = "left", textIndent: S = 0, whiteSpace: C = "normal", overflowWrap: w = "normal", anchorX: T = 0, anchorY: E = 0, metricsOnly: D = !1, unicodeFontsURL: O, preResolvedFonts: k = null, includeCaretPositions: A = !1, chunkedBoundsSize: j = 8192, colorRanges: M = null }, N) {
let P = d(), ee = {
fontLoad: 0,
typesetting: 0
};
e.indexOf("\r") > -1 && (console.info("Typesetter: got text with \\r chars; normalizing to \\n"), e = e.replace(/\r\n/g, "\n").replace(/\r/g, "\n")), m = +m, _ = +_, y = +y, v = v || "normal", S = +S, o({
text: e,
lang: c,
style: g,
weight: h,
fonts: typeof s == "string" ? [{ src: s }] : s,
unicodeFontsURL: O,
preResolvedFonts: k
}, (o) => {
ee.fontLoad = d() - P;
let s = isFinite(y), c = null, p = null, h = null, g = null, O = null, k = null, te = null, ne = null, re = 0, F = 0, ie = C !== "nowrap", ae = /* @__PURE__ */ new Map(), oe = d(), se = S, I = 0, ce = new f(), le = [ce];
o.forEach((t) => {
let { fontObj: n } = t, { ascender: o, descender: c, unitsPerEm: l, lineGap: u, capHeight: d, xHeight: p } = n, h = ae.get(n);
if (!h) {
let e = m / l, t = v === "normal" ? (o - c + u) * e : v * m, r = (t - (o - c) * e) / 2, i = Math.min(t, (o - c) * e), a = (o + c) / 2 * e + i / 2;
h = {
index: ae.size,
src: n.src,
fontObj: n,
fontSizeMult: e,
unitsPerEm: l,
ascender: o * e,
descender: c * e,
capHeight: d * e,
xHeight: p * e,
lineHeight: t,
baseline: -r - o * e,
caretTop: a,
caretBottom: a - i
}, ae.set(n, h);
}
let { fontSizeMult: g } = h, b = e.slice(t.start, t.end + 1), x, C;
n.forEachGlyph(b, m, _, (n, o, c, l) => {
o += I, l += t.start, x = o, C = n;
let u = e.charAt(l), d = n.advanceWidth * g, p = ce.count, v;
if ("isEmpty" in n || (n.isWhitespace = !!u && RegExp(i).test(u), n.canBreakAfter = !!u && a.test(u), n.isEmpty = n.xMin === n.xMax || n.yMin === n.yMax || r.test(u)), !n.isWhitespace && !n.isEmpty && F++, ie && s && !n.isWhitespace && o + d + se > y && p) {
if (ce.glyphAt(p - 1).glyphObj.canBreakAfter) v = new f(), se = -o;
else for (let e = p; e--;) if (e === 0 && w === "break-word") {
v = new f(), se = -o;
break;
} else if (ce.glyphAt(e).glyphObj.canBreakAfter) {
v = ce.splitAt(e + 1);
let t = v.glyphAt(0).x;
se -= t;
for (let e = v.count; e--;) v.glyphAt(e).x -= t;
break;
}
v && (ce.isSoftWrapped = !0, ce = v, le.push(ce), re = y);
}
let b = ce.glyphAt(ce.count);
b.glyphObj = n, b.x = o + se, b.y = c, b.width = d, b.charIndex = l, b.fontData = h, u === "\n" && (ce = new f(), le.push(ce), se = -(o + d + _ * m) + S);
}), I = x + C.advanceWidth * g + _ * m;
});
let ue = 0;
le.forEach((e) => {
let t = !0;
for (let n = e.count; n--;) {
let r = e.glyphAt(n);
t && !r.glyphObj.isWhitespace && (e.width = r.x + r.width, e.width > re && (re = e.width), t = !1);
let { lineHeight: i, capHeight: a, xHeight: o, baseline: s } = r.fontData;
i > e.lineHeight && (e.lineHeight = i);
let c = s - e.baseline;
c < 0 && (e.baseline += c, e.cap += c, e.ex += c), e.cap = Math.max(e.cap, e.baseline + a), e.ex = Math.max(e.ex, e.baseline + o);
}
e.baseline -= ue, e.cap -= ue, e.ex -= ue, ue += e.lineHeight;
});
let L = 0, de = 0;
if (T && (typeof T == "number" ? L = -T : typeof T == "string" && (L = -re * (T === "left" ? 0 : T === "center" ? .5 : T === "right" ? 1 : l(T)))), E && (typeof E == "number" ? de = -E : typeof E == "string" && (de = E === "top" ? 0 : E === "top-baseline" ? -le[0].baseline : E === "top-cap" ? -le[0].cap : E === "top-ex" ? -le[0].ex : E === "middle" ? ue / 2 : E === "bottom" ? ue : E === "bottom-baseline" ? -le[le.length - 1].baseline : l(E) * ue)), !D) {
let r = t.getEmbeddingLevels(e, b);
c = new Uint16Array(F), p = new Uint8Array(F), h = new Float32Array(F * 2), g = {}, te = [
n,
n,
-Infinity,
-Infinity
], ne = [], A && (k = new Float32Array(e.length * 4)), M && (O = new Uint8Array(F * 3));
let i = 0, a = -1, o = -1, s, l;
if (le.forEach((d, f) => {
let { count: m, width: _ } = d;
if (m > 0) {
let f = 0;
for (let e = m; e-- && d.glyphAt(e).glyphObj.isWhitespace;) f++;
let v = 0, y = 0;
if (x === "center") v = (re - _) / 2;
else if (x === "right") v = re - _;
else if (x === "justify" && d.isSoftWrapped) {
let e = 0;
for (let t = m - f; t--;) d.glyphAt(t).glyphObj.isWhitespace && e++;
y = (re - _) / e;
}
if (y || v) {
let e = 0;
for (let t = 0; t < m; t++) {
let n = d.glyphAt(t), r = n.glyphObj;
n.x += v + e, y !== 0 && r.isWhitespace && t < m - f && (e += y, n.width += y);
}
}
let b = t.getReorderSegments(e, r, d.glyphAt(0).charIndex, d.glyphAt(d.count - 1).charIndex);
for (let e = 0; e < b.length; e++) {
let [t, n] = b[e], r = Infinity, i = -Infinity;
for (let e = 0; e < m; e++) if (d.glyphAt(e).charIndex >= t) {
let t = e, a = e;
for (; a < m; a++) {
let e = d.glyphAt(a);
if (e.charIndex > n) break;
a < m - f && (r = Math.min(r, e.x), i = Math.max(i, e.x + e.width));
}
for (let e = t; e < a; e++) {
let t = d.glyphAt(e);
t.x = i - (t.x + t.width - r);
}
break;
}
}
let S, C = (e) => S = e;
for (let f = 0; f < m; f++) {
let m = d.glyphAt(f);
S = m.glyphObj;
let _ = S.index, v = r.levels[m.charIndex] & 1;
if (v) {
let n = t.getMirroredCharacter(e[m.charIndex]);
n && m.fontData.fontObj.forEachGlyph(n, 0, 0, C);
}
if (A) {
let { charIndex: e, fontData: t } = m, n = m.x + L, r = m.x + m.width + L;
k[e * 4] = v ? r : n, k[e * 4 + 1] = v ? n : r, k[e * 4 + 2] = d.baseline + t.caretBottom + de, k[e * 4 + 3] = d.baseline + t.caretTop + de;
let i = e - a;
i > 1 && u(k, a, i), a = e;
}
if (M) {
let { charIndex: e } = m;
for (; e > o;) o++, M.hasOwnProperty(o) && (l = M[o]);
}
if (!S.isWhitespace && !S.isEmpty) {
let e = i++, { fontSizeMult: t, src: r, index: a } = m.fontData, o = g[r] || (g[r] = {});
o[_] || (o[_] = {
path: S.path,
pathBounds: [
S.xMin,
S.yMin,
S.xMax,
S.yMax
]
});
let u = m.x + L, f = m.y + d.baseline + de;
h[e * 2] = u, h[e * 2 + 1] = f;
let v = u + S.xMin * t, y = f + S.yMin * t, b = u + S.xMax * t, x = f + S.yMax * t;
v < te[0] && (te[0] = v), y < te[1] && (te[1] = y), b > te[2] && (te[2] = b), x > te[3] && (te[3] = x), e % j === 0 && (s = {
start: e,
end: e,
rect: [
n,
n,
-Infinity,
-Infinity
]
}, ne.push(s)), s.end++;
let C = s.rect;
if (v < C[0] && (C[0] = v), y < C[1] && (C[1] = y), b > C[2] && (C[2] = b), x > C[3] && (C[3] = x), c[e] = _, p[e] = a, M) {
let t = e * 3;
O[t] = l >> 16 & 255, O[t + 1] = l >> 8 & 255, O[t + 2] = l & 255;
}
}
}
}
}), k) {
let t = e.length - a;
t > 1 && u(k, a, t);
}
}
let fe = [];
ae.forEach(({ index: e, src: t, unitsPerEm: n, ascender: r, descender: i, lineHeight: a, capHeight: o, xHeight: s }) => {
fe[e] = {
src: t,
unitsPerEm: n,
ascender: r,
descender: i,
lineHeight: a,
capHeight: o,
xHeight: s
};
}), ee.typesetting = d() - oe, N({
glyphIds: c,
glyphFontIndices: p,
glyphPositions: h,
glyphData: g,
fontData: fe,
caretPositions: k,
glyphColors: O,
chunkedBounds: ne,
fontSize: m,
topBaseline: de + le[0].baseline,
blockBounds: [
L,
de - ue,
L + re,
de
],
visibleBounds: te,
timings: ee
});
});
}
function c(e, t) {
s({
...e,
metricsOnly: !0
}, (e) => {
let [n, r, i, a] = e.blockBounds;
t({
width: i - n,
height: a - r
});
});
}
function l(e) {
let t = e.match(/^([\d.]+)%$/), n = t ? parseFloat(t[1]) : NaN;
return isNaN(n) ? 0 : n / 100;
}
function u(e, t, n) {
let r = e[t * 4], i = e[t * 4 + 1], a = e[t * 4 + 2], o = e[t * 4 + 3], s = (i - r) / n;
for (let i = 0; i < n; i++) {
let n = (t + i) * 4;
e[n] = r + s * i, e[n + 1] = r + s * (i + 1), e[n + 2] = a, e[n + 3] = o;
}
}
function d() {
return (self.performance || Date).now();
}
function f() {
this.data = [];
}
let p = [
"glyphObj",
"x",
"y",
"width",
"charIndex",
"fontData"
];
return f.prototype = {
width: 0,
lineHeight: 0,
baseline: 0,
cap: 0,
ex: 0,
isSoftWrapped: !1,
get count() {
return Math.ceil(this.data.length / p.length);
},
glyphAt(e) {
let t = f.flyweight;
return t.data = this.data, t.index = e, t;
},
splitAt(e) {
let t = new f();
return t.data = this.data.splice(e * p.length), t;
}
}, f.flyweight = p.reduce((e, t, n, r) => (Object.defineProperty(e, t, {
get() {
return this.data[this.index * p.length + n];
},
set(e) {
this.data[this.index * p.length + n] = e;
}
}), e), {
data: null,
index: 0
}), {
typeset: s,
measure: c
};
}
var hT = () => (self.performance || Date).now(), gT = /*#__PURE__*/ Uw(), _T;
function vT(e, t, n, r, i, a, o, s, c, l, u = !0) {
return u ? CT(e, t, n, r, i, a, o, s, c, l).then(null, (u) => (_T || (console.warn("WebGL SDF generation failed, falling back to JS", u), _T = !0), OT(e, t, n, r, i, a, o, s, c, l))) : OT(e, t, n, r, i, a, o, s, c, l);
}
var yT = [], bT = 5, xT = 0;
function ST() {
let e = hT();
for (; yT.length && hT() - e < bT;) yT.shift()();
xT = yT.length ? setTimeout(ST, 0) : 0;
}
var CT = (...e) => new Promise((t, n) => {
yT.push(() => {
let r = hT();
try {
gT.webgl.generateIntoCanvas(...e), t({ timing: hT() - r });
} catch (e) {
n(e);
}
}), xT || (xT = setTimeout(ST, 0));
}), wT = 4, TT = 2e3, ET = {}, DT = 0;
function OT(e, t, n, r, i, a, o, s, c, l) {
let u = "TroikaTextSDFGenerator_JS_" + DT++ % wT, d = ET[u];
return d || (d = ET[u] = {
workerModule: Rw({
name: u,
workerId: u,
dependencies: [Uw, hT],
init(e, t) {
let n = e().javascript.generate;
return function(...e) {
let r = t();
return {
textureData: n(...e),
timing: t() - r
};
};
},
getTransferables(e) {
return [e.textureData.buffer];
}
}),
requests: 0,
idleTimer: null
}), d.requests++, clearTimeout(d.idleTimer), d.workerModule(e, t, n, r, i, a).then(({ textureData: n, timing: r }) => {
let i = hT(), a = new Uint8Array(n.length * 4);
for (let e = 0; e < n.length; e++) a[e * 4 + l] = n[e];
return gT.webglUtils.renderImageData(o, a, s, c, e, t, 1 << 3 - l), r += hT() - i, --d.requests === 0 && (d.idleTimer = setTimeout(() => {
zw(u);
}, TT)), { timing: r };
});
}
function kT(e) {
e._warm || (gT.webgl.isSupported(e), e._warm = !0);
}
var AT = gT.webglUtils.resizeWebGLCanvasWithoutClearing, jT = {
defaultFontURL: null,
unicodeFontsURL: null,
sdfGlyphSize: 64,
sdfMargin: 1 / 16,
sdfExponent: 9,
textureWidth: 2048,
useWorker: !0
}, MT = /*#__PURE__*/ new gt();
function NT() {
return (self.performance || Date).now();
}
var PT = Object.create(null);
function FT(e, t) {
e = RT({}, e);
let n = NT(), { defaultFontURL: r } = jT, i = [];
if (r && i.push({
label: "default",
src: BT(r)
}), e.font && i.push({
label: "user",
src: BT(e.font)
}), e.font = i, e.text = "" + e.text, e.sdfGlyphSize = e.sdfGlyphSize || jT.sdfGlyphSize, e.unicodeFontsURL = e.unicodeFontsURL || jT.unicodeFontsURL, e.colorRanges != null) {
let t = {};
for (let n in e.colorRanges) if (e.colorRanges.hasOwnProperty(n)) {
let r = e.colorRanges[n];
typeof r != "number" && (r = MT.set(r).getHex()), t[n] = r;
}
e.colorRanges = t;
}
Object.freeze(e);
let { textureWidth: a, sdfExponent: o } = jT, { sdfGlyphSize: s } = e, c = a / s * 4, l = PT[s];
if (!l) {
let e = document.createElement("canvas");
e.width = a, e.height = s * 256 / c, l = PT[s] = {
glyphCount: 0,
sdfGlyphSize: s,
sdfCanvas: e,
sdfTexture: new Qt(e, void 0, void 0, void 0, tt, tt),
contextLost: !1,
glyphsByFont: /* @__PURE__ */ new Map()
}, l.sdfTexture.generateMipmaps = !1, LT(l);
}
let { sdfTexture: u, sdfCanvas: d } = l;
(jT.useWorker ? HT : UT)(e).then((r) => {
let { glyphIds: i, glyphFontIndices: f, fontData: p, glyphPositions: m, fontSize: h, timings: g } = r, _ = [], v = new Float32Array(i.length * 4), y = 0, b = 0, x = NT(), S = p.map((e) => {
let t = l.glyphsByFont.get(e.src);
return t || l.glyphsByFont.set(e.src, t = /* @__PURE__ */ new Map()), t;
});
i.forEach((e, t) => {
let n = f[t], { src: a, unitsPerEm: o } = p[n], c = S[n].get(e);
if (!c) {
let { path: t, pathBounds: i } = r.glyphData[a][e], o = Math.max(i[2] - i[0], i[3] - i[1]) / s * (jT.sdfMargin * s + .5), u = l.glyphCount++, d = [
i[0] - o,
i[1] - o,
i[2] + o,
i[3] + o
];
S[n].set(e, c = {
path: t,
atlasIndex: u,
sdfViewBox: d
}), _.push(c);
}
let { sdfViewBox: u } = c, d = m[b++], g = m[b++], x = h / o;
v[y++] = d + u[0] * x, v[y++] = g + u[1] * x, v[y++] = d + u[2] * x, v[y++] = g + u[3] * x, i[t] = c.atlasIndex;
}), g.quads = (g.quads || 0) + (NT() - x);
let C = NT();
g.sdf = {};
let w = d.height, T = Math.ceil(l.glyphCount / c), E = 2 ** Math.ceil(Math.log2(T * s));
E > w && (console.info(`Increasing SDF texture size ${w}->${E}`), AT(d, a, E), u.dispose()), Promise.all(_.map((t) => IT(t, l, e.gpuAccelerateSDF).then(({ timing: e }) => {
g.sdf[t.atlasIndex] = e;
}))).then(() => {
_.length && !l.contextLost && (VT(l), u.needsUpdate = !0), g.sdfTotal = NT() - C, g.total = NT() - n, t(Object.freeze({
parameters: e,
sdfTexture: u,
sdfGlyphSize: s,
sdfExponent: o,
glyphBounds: v,
glyphAtlasIndices: i,
glyphColors: r.glyphColors,
caretPositions: r.caretPositions,
chunkedBounds: r.chunkedBounds,
ascender: r.ascender,
descender: r.descender,
lineHeight: r.lineHeight,
capHeight: r.capHeight,
xHeight: r.xHeight,
topBaseline: r.topBaseline,
blockBounds: r.blockBounds,
visibleBounds: r.visibleBounds,
timings: r.timings
}));
});
}), Promise.resolve().then(() => {
l.contextLost || kT(d);
});
}
function IT({ path: e, atlasIndex: t, sdfViewBox: n }, { sdfGlyphSize: r, sdfCanvas: i, contextLost: a }, o) {
if (a) return Promise.resolve({ timing: -1 });
let { textureWidth: s, sdfExponent: c } = jT, l = Math.max(n[2] - n[0], n[3] - n[1]), u = Math.floor(t / 4);
return vT(r, r, e, n, l, c, i, u % (s / r) * r, Math.floor(u / (s / r)) * r, t % 4, o);
}
function LT(e) {
let t = e.sdfCanvas;
t.addEventListener("webglcontextlost", (t) => {
console.log("Context Lost", t), t.preventDefault(), e.contextLost = !0;
}), t.addEventListener("webglcontextrestored", (t) => {
console.log("Context Restored", t), e.contextLost = !1;
let n = [];
e.glyphsByFont.forEach((t) => {
t.forEach((t) => {
n.push(IT(t, e, !0));
});
}), Promise.all(n).then(() => {
VT(e), e.sdfTexture.needsUpdate = !0;
});
});
}
function RT(e, t) {
for (let n in t) t.hasOwnProperty(n) && (e[n] = t[n]);
return e;
}
var zT;
function BT(e) {
return zT || (zT = typeof document > "u" ? {} : document.createElement("a")), zT.href = e, zT.href;
}
function VT(e) {
if (typeof createImageBitmap != "function") {
console.info("Safari<15: applying SDF canvas workaround");
let { sdfCanvas: t, sdfTexture: n } = e, { width: r, height: i } = t, a = e.sdfCanvas.getContext("webgl"), o = n.image.data;
(!o || o.length !== r * i * 4) && (o = new Uint8Array(r * i * 4), n.image = {
width: r,
height: i,
data: o
}, n.flipY = !1, n.isDataTexture = !0), a.readPixels(0, 0, r, i, a.RGBA, a.UNSIGNED_BYTE, o);
}
}
var HT = /*#__PURE__*/ Rw({
name: "Typesetter",
dependencies: [/* @__PURE__ */ Rw({
name: "Typesetter",
dependencies: [
mT,
pT,
Ww
],
init(e, t, n) {
return e(t, n());
}
})],
init(e) {
return function(t) {
return new Promise((n) => {
e.typeset(t, n);
});
};
},
getTransferables(e) {
let t = [];
for (let n in e) e[n] && e[n].buffer && t.push(e[n].buffer);
return t;
}
}), UT = HT.onMainThread, WT = {};
function GT(e) {
let t = WT[e];
return t || (t = WT[e] = new Fe(1, 1, e, e).translate(.5, .5, 0)), t;
}
var KT = "aTroikaGlyphBounds", qT = "aTroikaGlyphIndex", JT = "aTroikaGlyphColor", YT = class extends jt {
constructor() {
super(), this.detail = 1, this.curveRadius = 0, this.groups = [{
start: 0,
count: Infinity,
materialIndex: 0
}, {
start: 0,
count: Infinity,
materialIndex: 1
}], this.boundingSphere = new vn(), this.boundingBox = new ze();
}
computeBoundingSphere() {}
computeBoundingBox() {}
set detail(e) {
if (e !== this._detail) {
this._detail = e, (typeof e != "number" || e < 1) && (e = 1);
let t = GT(e);
[
"position",
"normal",
"uv"
].forEach((e) => {
this.attributes[e] = t.attributes[e].clone();
}), this.setIndex(t.getIndex().clone());
}
}
get detail() {
return this._detail;
}
set curveRadius(e) {
e !== this._curveRadius && (this._curveRadius = e, this._updateBounds());
}
get curveRadius() {
return this._curveRadius;
}
updateGlyphs(e, t, n, r, i) {
this.updateAttributeData(KT, e, 4), this.updateAttributeData(qT, t, 1), this.updateAttributeData(JT, i, 3), this._blockBounds = n, this._chunkedBounds = r, this.instanceCount = t.length, this._updateBounds();
}
_updateBounds() {
let e = this._blockBounds;
if (e) {
let { curveRadius: t, boundingBox: n } = this;
if (t) {
let { PI: r, floor: i, min: a, max: o, sin: s, cos: c } = Math, l = r / 2, u = r * 2, d = Math.abs(t), f = e[0] / d, p = e[2] / d, m = i((f + l) / u) === i((p + l) / u) ? a(s(f) * d, s(p) * d) : -d, h = i((f - l) / u) === i((p - l) / u) ? o(s(f) * d, s(p) * d) : d, g = i((f + r) / u) === i((p + r) / u) ? o(d - c(f) * d, d - c(p) * d) : d * 2;
n.min.set(m, e[1], t < 0 ? -g : 0), n.max.set(h, e[3], t < 0 ? 0 : g);
} else n.min.set(e[0], e[1], 0), n.max.set(e[2], e[3], 0);
n.getBoundingSphere(this.boundingSphere);
}
}
applyClipRect(e) {
let t = this.getAttribute(qT).count, n = this._chunkedBounds;
if (n) for (let r = n.length; r--;) {
t = n[r].end;
let i = n[r].rect;
if (i[1] < e.w && i[3] > e.y && i[0] < e.z && i[2] > e.x) break;
}
this.instanceCount = t;
}
updateAttributeData(e, t, n) {
let r = this.getAttribute(e);
t ? r && r.array.length === t.length ? (r.array.set(t), r.needsUpdate = !0) : (this.setAttribute(e, new Jt(t, n)), delete this._maxInstanceCount, this.dispose()) : r && this.deleteAttribute(e);
}
}, XT = "\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform vec4 uTroikaTotalBounds;\nuniform vec4 uTroikaClipRect;\nuniform mat3 uTroikaOrient;\nuniform bool uTroikaUseGlyphColors;\nuniform float uTroikaEdgeOffset;\nuniform float uTroikaBlurRadius;\nuniform vec2 uTroikaPositionOffset;\nuniform float uTroikaCurveRadius;\nattribute vec4 aTroikaGlyphBounds;\nattribute float aTroikaGlyphIndex;\nattribute vec3 aTroikaGlyphColor;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec3 vTroikaGlyphColor;\nvarying vec2 vTroikaGlyphDimensions;\n", ZT = "\nvec4 bounds = aTroikaGlyphBounds;\nbounds.xz += uTroikaPositionOffset.x;\nbounds.yw -= uTroikaPositionOffset.y;\n\nvec4 outlineBounds = vec4(\n bounds.xy - uTroikaEdgeOffset - uTroikaBlurRadius,\n bounds.zw + uTroikaEdgeOffset + uTroikaBlurRadius\n);\nvec4 clippedBounds = vec4(\n clamp(outlineBounds.xy, uTroikaClipRect.xy, uTroikaClipRect.zw),\n clamp(outlineBounds.zw, uTroikaClipRect.xy, uTroikaClipRect.zw)\n);\n\nvec2 clippedXY = (mix(clippedBounds.xy, clippedBounds.zw, position.xy) - bounds.xy) / (bounds.zw - bounds.xy);\n\nposition.xy = mix(bounds.xy, bounds.zw, clippedXY);\n\nuv = (position.xy - uTroikaTotalBounds.xy) / (uTroikaTotalBounds.zw - uTroikaTotalBounds.xy);\n\nfloat rad = uTroikaCurveRadius;\nif (rad != 0.0) {\n float angle = position.x / rad;\n position.xz = vec2(sin(angle) * rad, rad - cos(angle) * rad);\n normal.xz = vec2(sin(angle), cos(angle));\n}\n \nposition = uTroikaOrient * position;\nnormal = uTroikaOrient * normal;\n\nvTroikaGlyphUV = clippedXY.xy;\nvTroikaGlyphDimensions = vec2(bounds[2] - bounds[0], bounds[3] - bounds[1]);\n\n\nfloat txCols = uTroikaSDFTextureSize.x / uTroikaSDFGlyphSize;\nvec2 txUvPerSquare = uTroikaSDFGlyphSize / uTroikaSDFTextureSize;\nvec2 txStartUV = txUvPerSquare * vec2(\n mod(floor(aTroikaGlyphIndex / 4.0), txCols),\n floor(floor(aTroikaGlyphIndex / 4.0) / txCols)\n);\nvTroikaTextureUVBounds = vec4(txStartUV, vec2(txStartUV) + txUvPerSquare);\nvTroikaTextureChannel = mod(aTroikaGlyphIndex, 4.0);\n", QT = "\nuniform sampler2D uTroikaSDFTexture;\nuniform vec2 uTroikaSDFTextureSize;\nuniform float uTroikaSDFGlyphSize;\nuniform float uTroikaSDFExponent;\nuniform float uTroikaEdgeOffset;\nuniform float uTroikaFillOpacity;\nuniform float uTroikaBlurRadius;\nuniform vec3 uTroikaStrokeColor;\nuniform float uTroikaStrokeWidth;\nuniform float uTroikaStrokeOpacity;\nuniform bool uTroikaSDFDebug;\nvarying vec2 vTroikaGlyphUV;\nvarying vec4 vTroikaTextureUVBounds;\nvarying float vTroikaTextureChannel;\nvarying vec2 vTroikaGlyphDimensions;\n\nfloat troikaSdfValueToSignedDistance(float alpha) {\n // Inverse of exponential encoding in webgl-sdf-generator\n \n float maxDimension = max(vTroikaGlyphDimensions.x, vTroikaGlyphDimensions.y);\n float absDist = (1.0 - pow(2.0 * (alpha > 0.5 ? 1.0 - alpha : alpha), 1.0 / uTroikaSDFExponent)) * maxDimension;\n float signedDist = absDist * (alpha > 0.5 ? -1.0 : 1.0);\n return signedDist;\n}\n\nfloat troikaGlyphUvToSdfValue(vec2 glyphUV) {\n vec2 textureUV = mix(vTroikaTextureUVBounds.xy, vTroikaTextureUVBounds.zw, glyphUV);\n vec4 rgba = texture2D(uTroikaSDFTexture, textureUV);\n float ch = floor(vTroikaTextureChannel + 0.5); //NOTE: can't use round() in WebGL1\n return ch == 0.0 ? rgba.r : ch == 1.0 ? rgba.g : ch == 2.0 ? rgba.b : rgba.a;\n}\n\nfloat troikaGlyphUvToDistance(vec2 uv) {\n return troikaSdfValueToSignedDistance(troikaGlyphUvToSdfValue(uv));\n}\n\nfloat troikaGetAADist() {\n \n #if defined(GL_OES_standard_derivatives) || __VERSION__ >= 300\n return length(fwidth(vTroikaGlyphUV * vTroikaGlyphDimensions)) * 0.5;\n #else\n return vTroikaGlyphDimensions.x / 64.0;\n #endif\n}\n\nfloat troikaGetFragDistValue() {\n vec2 clampedGlyphUV = clamp(vTroikaGlyphUV, 0.5 / uTroikaSDFGlyphSize, 1.0 - 0.5 / uTroikaSDFGlyphSize);\n float distance = troikaGlyphUvToDistance(clampedGlyphUV);\n \n // Extrapolate distance when outside bounds:\n distance += clampedGlyphUV == vTroikaGlyphUV ? 0.0 : \n length((vTroikaGlyphUV - clampedGlyphUV) * vTroikaGlyphDimensions);\n\n \n\n return distance;\n}\n\nfloat troikaGetEdgeAlpha(float distance, float distanceOffset, float aaDist) {\n #if defined(IS_DEPTH_MATERIAL) || defined(IS_DISTANCE_MATERIAL)\n float alpha = step(-distanceOffset, -distance);\n #else\n\n float alpha = smoothstep(\n distanceOffset + aaDist,\n distanceOffset - aaDist,\n distance\n );\n #endif\n\n return alpha;\n}\n", $T = "\nfloat aaDist = troikaGetAADist();\nfloat fragDistance = troikaGetFragDistValue();\nfloat edgeAlpha = uTroikaSDFDebug ?\n troikaGlyphUvToSdfValue(vTroikaGlyphUV) :\n troikaGetEdgeAlpha(fragDistance, uTroikaEdgeOffset, max(aaDist, uTroikaBlurRadius));\n\n#if !defined(IS_DEPTH_MATERIAL) && !defined(IS_DISTANCE_MATERIAL)\nvec4 fillRGBA = gl_FragColor;\nfillRGBA.a *= uTroikaFillOpacity;\nvec4 strokeRGBA = uTroikaStrokeWidth == 0.0 ? fillRGBA : vec4(uTroikaStrokeColor, uTroikaStrokeOpacity);\nif (fillRGBA.a == 0.0) fillRGBA.rgb = strokeRGBA.rgb;\ngl_FragColor = mix(fillRGBA, strokeRGBA, smoothstep(\n -uTroikaStrokeWidth - aaDist,\n -uTroikaStrokeWidth + aaDist,\n fragDistance\n));\ngl_FragColor.a *= edgeAlpha;\n#endif\n\nif (edgeAlpha == 0.0) {\n discard;\n}\n";
function eE(e) {
let t = eT(e, {
chained: !0,
extensions: { derivatives: !0 },
uniforms: {
uTroikaSDFTexture: { value: null },
uTroikaSDFTextureSize: { value: new V() },
uTroikaSDFGlyphSize: { value: 0 },
uTroikaSDFExponent: { value: 0 },
uTroikaTotalBounds: { value: new _n(0, 0, 0, 0) },
uTroikaClipRect: { value: new _n(0, 0, 0, 0) },
uTroikaEdgeOffset: { value: 0 },
uTroikaFillOpacity: { value: 1 },
uTroikaPositionOffset: { value: new V() },
uTroikaCurveRadius: { value: 0 },
uTroikaBlurRadius: { value: 0 },
uTroikaStrokeWidth: { value: 0 },
uTroikaStrokeColor: { value: new gt() },
uTroikaStrokeOpacity: { value: 1 },
uTroikaOrient: { value: new on() },
uTroikaUseGlyphColors: { value: !0 },
uTroikaSDFDebug: { value: !1 }
},
vertexDefs: XT,
vertexTransform: ZT,
fragmentDefs: QT,
fragmentColorTransform: $T,
customRewriter({ vertexShader: e, fragmentShader: t }) {
let n = /\buniform\s+vec3\s+diffuse\b/;
return n.test(t) && (t = t.replace(n, "varying vec3 vTroikaGlyphColor").replace(/\bdiffuse\b/g, "vTroikaGlyphColor"), n.test(e) || (e = e.replace(Gw, "uniform vec3 diffuse;\n$&\nvTroikaGlyphColor = uTroikaUseGlyphColors ? aTroikaGlyphColor / 255.0 : diffuse;\n"))), {
vertexShader: e,
fragmentShader: t
};
}
});
return t.transparent = !0, t.forceSinglePass = !0, Object.defineProperties(t, {
isTroikaTextMaterial: { value: !0 },
shadowSide: {
get() {
return this.side;
},
set() {}
}
}), t;
}
var tE = /*#__PURE__*/ new Mt({
color: 16777215,
side: 2,
transparent: !0
}), nE = 8421504, rE = /*#__PURE__*/ new W(), iE = /*#__PURE__*/ new U(), aE = /*#__PURE__*/ new U(), oE = [], sE = /*#__PURE__*/ new U(), cE = "+x+y";
function lE(e) {
return Array.isArray(e) ? e[0] : e;
}
var uE = () => {
let e = new Yt(new Fe(1, 1), tE);
return uE = () => e, e;
}, dE = () => {
let e = new Yt(new Fe(1, 1, 32, 1), tE);
return dE = () => e, e;
}, fE = { type: "syncstart" }, pE = { type: "synccomplete" }, mE = [
"font",
"fontSize",
"fontStyle",
"fontWeight",
"lang",
"letterSpacing",
"lineHeight",
"maxWidth",
"overflowWrap",
"text",
"direction",
"textAlign",
"textIndent",
"whiteSpace",
"anchorX",
"anchorY",
"colorRanges",
"sdfGlyphSize"
], hE = mE.concat("material", "color", "depthOffset", "clipRect", "curveRadius", "orientation", "glyphGeometryDetail"), gE = class extends Yt {
constructor() {
let e = new YT();
super(e, null), this.text = "", this.anchorX = 0, this.anchorY = 0, this.curveRadius = 0, this.direction = "auto", this.font = null, this.unicodeFontsURL = null, this.fontSize = .1, this.fontWeight = "normal", this.fontStyle = "normal", this.lang = null, this.letterSpacing = 0, this.lineHeight = "normal", this.maxWidth = Infinity, this.overflowWrap = "normal", this.textAlign = "left", this.textIndent = 0, this.whiteSpace = "normal", this.material = null, this.color = null, this.colorRanges = null, this.outlineWidth = 0, this.outlineColor = 0, this.outlineOpacity = 1, this.outlineBlur = 0, this.outlineOffsetX = 0, this.outlineOffsetY = 0, this.strokeWidth = 0, this.strokeColor = nE, this.strokeOpacity = 1, this.fillOpacity = 1, this.depthOffset = 0, this.clipRect = null, this.orientation = cE, this.glyphGeometryDetail = 1, this.sdfGlyphSize = null, this.gpuAccelerateSDF = !0, this.debugSDF = !1;
}
sync(e) {
this._needsSync && (this._needsSync = !1, this._isSyncing ? (this._queuedSyncs || (this._queuedSyncs = [])).push(e) : (this._isSyncing = !0, this.dispatchEvent(fE), FT({
text: this.text,
font: this.font,
lang: this.lang,
fontSize: this.fontSize || .1,
fontWeight: this.fontWeight || "normal",
fontStyle: this.fontStyle || "normal",
letterSpacing: this.letterSpacing || 0,
lineHeight: this.lineHeight || "normal",
maxWidth: this.maxWidth,
direction: this.direction || "auto",
textAlign: this.textAlign,
textIndent: this.textIndent,
whiteSpace: this.whiteSpace,
overflowWrap: this.overflowWrap,
anchorX: this.anchorX,
anchorY: this.anchorY,
colorRanges: this.colorRanges,
includeCaretPositions: !0,
sdfGlyphSize: this.sdfGlyphSize,
gpuAccelerateSDF: this.gpuAccelerateSDF,
unicodeFontsURL: this.unicodeFontsURL
}, (t) => {
this._isSyncing = !1, this._textRenderInfo = t, this.geometry.updateGlyphs(t.glyphBounds, t.glyphAtlasIndices, t.blockBounds, t.chunkedBounds, t.glyphColors);
let n = this._queuedSyncs;
n && (this._queuedSyncs = null, this._needsSync = !0, this.sync(() => {
n.forEach((e) => e && e());
})), this.dispatchEvent(pE), e && e();
})));
}
onBeforeRender(e, t, n, r, i, a) {
this.sync(), i.isTroikaTextMaterial && this._prepareForRender(i);
}
dispose() {
this.geometry.dispose();
}
get textRenderInfo() {
return this._textRenderInfo || null;
}
createDerivedMaterial(e) {
return eE(e);
}
get material() {
let e = this._derivedMaterial, t = this._baseMaterial || this._defaultMaterial || (this._defaultMaterial = tE.clone());
if ((!e || !e.isDerivedFrom(t)) && (e = this._derivedMaterial = this.createDerivedMaterial(t), t.addEventListener("dispose", function n() {
t.removeEventListener("dispose", n), e.dispose();
})), this.hasOutline()) {
let t = e._outlineMtl;
return t || (t = e._outlineMtl = Object.create(e, { id: { value: e.id + .1 } }), t.isTextOutlineMaterial = !0, t.depthWrite = !1, t.map = null, e.addEventListener("dispose", function n() {
e.removeEventListener("dispose", n), t.dispose();
})), [t, e];
} else return e;
}
set material(e) {
e && e.isTroikaTextMaterial ? (this._derivedMaterial = e, this._baseMaterial = e.baseMaterial) : this._baseMaterial = e;
}
hasOutline() {
return !!(this.outlineWidth || this.outlineBlur || this.outlineOffsetX || this.outlineOffsetY);
}
get glyphGeometryDetail() {
return this.geometry.detail;
}
set glyphGeometryDetail(e) {
this.geometry.detail = e;
}
get curveRadius() {
return this.geometry.curveRadius;
}
set curveRadius(e) {
this.geometry.curveRadius = e;
}
get customDepthMaterial() {
return lE(this.material).getDepthMaterial();
}
set customDepthMaterial(e) {}
get customDistanceMaterial() {
return lE(this.material).getDistanceMaterial();
}
set customDistanceMaterial(e) {}
_prepareForRender(e) {
let t = e.isTextOutlineMaterial, n = e.uniforms, r = this.textRenderInfo;
if (r) {
let { sdfTexture: e, blockBounds: i } = r;
n.uTroikaSDFTexture.value = e, n.uTroikaSDFTextureSize.value.set(e.image.width, e.image.height), n.uTroikaSDFGlyphSize.value = r.sdfGlyphSize, n.uTroikaSDFExponent.value = r.sdfExponent, n.uTroikaTotalBounds.value.fromArray(i), n.uTroikaUseGlyphColors.value = !t && !!r.glyphColors;
let a = 0, o = 0, s = 0, c, l, u, d = 0, f = 0;
if (t) {
let { outlineWidth: e, outlineOffsetX: t, outlineOffsetY: n, outlineBlur: r, outlineOpacity: i } = this;
a = this._parsePercent(e) || 0, o = Math.max(0, this._parsePercent(r) || 0), c = i, d = this._parsePercent(t) || 0, f = this._parsePercent(n) || 0;
} else s = Math.max(0, this._parsePercent(this.strokeWidth) || 0), s && (u = this.strokeColor, n.uTroikaStrokeColor.value.set(u == null ? nE : u), l = this.strokeOpacity, l == null && (l = 1)), c = this.fillOpacity;
n.uTroikaEdgeOffset.value = a, n.uTroikaPositionOffset.value.set(d, f), n.uTroikaBlurRadius.value = o, n.uTroikaStrokeWidth.value = s, n.uTroikaStrokeOpacity.value = l, n.uTroikaFillOpacity.value = c == null ? 1 : c, n.uTroikaCurveRadius.value = this.curveRadius || 0;
let p = this.clipRect;
if (p && Array.isArray(p) && p.length === 4) n.uTroikaClipRect.value.fromArray(p);
else {
let e = (this.fontSize || .1) * 100;
n.uTroikaClipRect.value.set(i[0] - e, i[1] - e, i[2] + e, i[3] + e);
}
this.geometry.applyClipRect(n.uTroikaClipRect.value);
}
n.uTroikaSDFDebug.value = !!this.debugSDF, e.polygonOffset = !!this.depthOffset, e.polygonOffsetFactor = e.polygonOffsetUnits = this.depthOffset || 0;
let i = t ? this.outlineColor || 0 : this.color;
if (i == null) delete e.color;
else {
let t = e.hasOwnProperty("color") ? e.color : e.color = new gt();
(i !== t._input || typeof i == "object") && t.set(t._input = i);
}
let a = this.orientation || cE;
if (a !== e._orientation) {
let t = n.uTroikaOrient.value;
a = a.replace(/[^-+xyz]/g, "");
let r = a !== cE && a.match(/^([-+])([xyz])([-+])([xyz])$/);
if (r) {
let [, e, n, i, a] = r;
iE.set(0, 0, 0)[n] = e === "-" ? 1 : -1, aE.set(0, 0, 0)[a] = i === "-" ? -1 : 1, rE.lookAt(sE, iE.cross(aE), aE), t.setFromMatrix4(rE);
} else t.identity();
e._orientation = a;
}
}
_parsePercent(e) {
if (typeof e == "string") {
let t = e.match(/^(-?[\d.]+)%$/), n = t ? parseFloat(t[1]) : NaN;
e = (isNaN(n) ? 0 : n / 100) * this.fontSize;
}
return e;
}
localPositionToTextCoords(e, t = new V()) {
t.copy(e);
let n = this.curveRadius;
return n && (t.x = Math.atan2(e.x, Math.abs(n) - Math.abs(e.z)) * Math.abs(n)), t;
}
worldPositionToTextCoords(e, t = new V()) {
return iE.copy(e), this.localPositionToTextCoords(this.worldToLocal(iE), t);
}
raycast(e, t) {
let { textRenderInfo: n, curveRadius: r } = this;
if (n) {
let i = n.blockBounds, a = r ? dE() : uE(), o = a.geometry, { position: s, uv: c } = o.attributes;
for (let e = 0; e < c.count; e++) {
let t = i[0] + c.getX(e) * (i[2] - i[0]), n = i[1] + c.getY(e) * (i[3] - i[1]), a = 0;
r && (a = r - Math.cos(t / r) * r, t = Math.sin(t / r) * r), s.setXYZ(e, t, n, a);
}
o.boundingSphere = this.geometry.boundingSphere, o.boundingBox = this.geometry.boundingBox, a.matrixWorld = this.matrixWorld, a.material.side = this.material.side, oE.length = 0, a.raycast(e, oE);
for (let e = 0; e < oE.length; e++) oE[e].object = this, t.push(oE[e]);
}
}
copy(e) {
let t = this.geometry;
return super.copy(e), this.geometry = t, hE.forEach((t) => {
this[t] = e[t];
}), this;
}
clone() {
return new this.constructor().copy(this);
}
};
mE.forEach((e) => {
let t = "_private_" + e;
Object.defineProperty(gE.prototype, e, {
get() {
return this[t];
},
set(e) {
e !== this[t] && (this[t] = e, this._needsSync = !0);
}
});
});
var _E = { type: "syncstart" }, vE = { type: "synccomplete" }, yE = "aTroikaTextBatchMemberIndex", bE = 32, xE = new ze(), SE = new gt(), CE = class e extends gE {
constructor() {
super(), this._members = /* @__PURE__ */ new Map(), this._dataTextures = {}, this._onMemberSynced = (e) => {
this._members.get(e.target).dirty = !0;
};
}
add(...e) {
for (let t = 0; t < e.length; t++) e[t] instanceof gE ? this.addText(e[t]) : super.add(e[t]);
return this;
}
remove(...e) {
for (let t = 0; t < e.length; t++) e[t] instanceof gE ? this.removeText(e[t]) : super.remove(e[t]);
return this;
}
addText(e) {
this._members.has(e) || (this._members.set(e, {
index: -1,
glyphCount: -1,
dirty: !0
}), e.addEventListener("synccomplete", this._onMemberSynced));
}
removeText(e) {
this._needsRepack = !0, e.removeEventListener("synccomplete", this._onMemberSynced), this._members.delete(e);
}
createDerivedMaterial(e) {
return TE(e);
}
updateMatrixWorld(e) {
super.updateMatrixWorld(e), this.updateBounds();
}
updateBounds() {
let e = this.geometry.boundingBox.makeEmpty();
this._members.forEach((t, n) => {
n.matrixAutoUpdate && n.updateMatrix(), xE.copy(n.geometry.boundingBox).applyMatrix4(n.matrix), e.union(xE);
}), e.getBoundingSphere(this.geometry.boundingSphere);
}
hasOutline() {
for (let e of this._members.keys()) if (e.hasOutline()) return !0;
return !1;
}
_prepareForRender(e) {
let t = e.isTextOutlineMaterial;
e.uniforms.uTroikaIsOutline.value = t;
let n = this._dataTextures[t ? "outline" : "main"], r = 2 ** Math.ceil(Math.log2(this._members.size * bE));
if (!n || r !== n.image.data.length) {
n && n.dispose();
let e = Math.min(r / 4, 1024);
n = this._dataTextures[t ? "outline" : "main"] = new Ut(new Float32Array(r), e, r / 4 / e, dt, pt);
}
let i = n.image.data, a = (e, t) => {
t !== i[e] && (i[e] = t, n.needsUpdate = !0);
};
this._members.forEach(({ index: n, dirty: r }, i) => {
if (n > -1) {
let r = n * bE, o = i.matrix.elements;
for (let e = 0; e < 16; e++) a(r + e, o[e]);
i._prepareForRender(e);
let { uTroikaTotalBounds: s, uTroikaClipRect: c, uTroikaPositionOffset: l, uTroikaEdgeOffset: u, uTroikaBlurRadius: d, uTroikaStrokeWidth: f, uTroikaStrokeColor: p, uTroikaStrokeOpacity: m, uTroikaFillOpacity: h, uTroikaCurveRadius: g } = e.uniforms;
for (let e = 0; e < 4; e++) a(r + 16 + e, s.value.getComponent(e));
for (let e = 0; e < 4; e++) a(r + 20 + e, c.value.getComponent(e));
let _ = t ? i.outlineColor || 0 : i.color;
_ == null && (_ = this.color), _ == null && (_ = this.material.color), _ == null && (_ = 16777215), a(r + 24, SE.set(_).getHex()), a(r + 25, h.value), a(r + 26, g.value), t ? (a(r + 28, l.value.x), a(r + 29, l.value.y), a(r + 30, u.value), a(r + 31, d.value)) : (a(r + 28, f.value), a(r + 29, SE.set(p.value).getHex()), a(r + 30, m.value));
}
}), e.setMatrixTexture(n), super._prepareForRender(e);
}
sync(e) {
let t = this._needsRepack ? [] : null;
this._needsRepack = !1, this._members.forEach((e, n) => {
(e.dirty || n._needsSync) && (e.dirty = !1, (t || (t = [])).push(new Promise((e) => {
n._needsSync ? n.sync(e) : e();
})));
}), t && (this.dispatchEvent(_E), Promise.all(t).then(() => {
let { geometry: t } = this, n = t.attributes, r = n[yE] && n[yE].array || /* @__PURE__ */ new Uint16Array(), i = n[qT] && n[qT].array || /* @__PURE__ */ new Float32Array(), a = n[KT] && n[KT].array || /* @__PURE__ */ new Float32Array(), o = 0;
this._members.forEach((e, { textRenderInfo: t }) => {
t && (o += t.glyphAtlasIndices.length, this._textRenderInfo = t);
}), o !== r.length && (r = wE(r, o), i = wE(i, o), a = wE(a, o * 4));
let s = 0, c = 0;
this._members.forEach((e, { textRenderInfo: t }) => {
if (t) {
let n = t.glyphAtlasIndices.length;
r.fill(s, c, c + n), i.set(t.glyphAtlasIndices, c, c + n), a.set(t.glyphBounds, c * 4, (c + n) * 4), c += n, e.index = s++;
}
}), t.updateAttributeData(yE, r, 1), t.getAttribute(yE).setUsage(Re), t.updateAttributeData(qT, i, 1), t.updateAttributeData(KT, a, 4), this.updateBounds(), this.dispatchEvent(vE), e && e();
}));
}
copy(t) {
return t instanceof e && (super.copy(t), this._members.forEach((e, t) => this.removeText(t)), t._members.forEach((e, t) => this.addText(t))), this;
}
dispose() {
super.dispose(), Object.values(this._dataTextures).forEach((e) => e.dispose());
}
};
function wE(e, t) {
let n = new e.constructor(t);
return n.set(e.subarray(0, t)), n;
}
function TE(e) {
let t = "uTroikaMatricesTexture", n = "uTroikaMatricesTextureSize", r = eT(e, {
chained: !0,
uniforms: {
[n]: { value: new V() },
[t]: { value: null }
},
vertexDefs: `
uniform highp sampler2D ${t};
uniform vec2 ${n};
attribute float ${yE};
vec4 troikaBatchTexel(float offset) {
offset += ${yE} * ${bE.toFixed(1)} / 4.0;
float w = ${n}.x;
vec2 uv = (vec2(mod(offset, w), floor(offset / w)) + 0.5) / ${n};
return texture2D(${t}, uv);
}
`,
vertexTransform: "\n mat4 matrix = mat4(\n troikaBatchTexel(0.0),\n troikaBatchTexel(1.0),\n troikaBatchTexel(2.0),\n troikaBatchTexel(3.0)\n );\n position.xyz = (matrix * vec4(position, 1.0)).xyz;\n "
});
return r = eE(r), r = eT(r, {
chained: !0,
uniforms: { uTroikaIsOutline: { value: !1 } },
customRewriter(e) {
return [
"uTroikaTotalBounds",
"uTroikaClipRect",
"uTroikaPositionOffset",
"uTroikaEdgeOffset",
"uTroikaBlurRadius",
"uTroikaStrokeWidth",
"uTroikaStrokeColor",
"uTroikaStrokeOpacity",
"uTroikaFillOpacity",
"uTroikaCurveRadius",
"diffuse"
].forEach((t) => {
e = EE(e, t);
}), e;
},
vertexDefs: "\n uniform bool uTroikaIsOutline;\n vec3 troikaFloatToColor(float v) {\n return mod(floor(vec3(v / 65536.0, v / 256.0, v)), 256.0) / 256.0;\n }\n ",
vertexTransform: "\n uTroikaTotalBounds = troikaBatchTexel(4.0);\n uTroikaClipRect = troikaBatchTexel(5.0);\n \n vec4 data = troikaBatchTexel(6.0);\n diffuse = troikaFloatToColor(data.x);\n uTroikaFillOpacity = data.y;\n uTroikaCurveRadius = data.z;\n \n data = troikaBatchTexel(7.0);\n if (uTroikaIsOutline) {\n if (data == vec4(0.0)) { // degenerate if zero outline\n position = vec3(0.0);\n } else {\n uTroikaPositionOffset = data.xy;\n uTroikaEdgeOffset = data.z;\n uTroikaBlurRadius = data.w;\n }\n } else {\n uTroikaStrokeWidth = data.x;\n uTroikaStrokeColor = troikaFloatToColor(data.y);\n uTroikaStrokeOpacity = data.z;\n }\n "
}), r.setMatrixTexture = (e) => {
r.uniforms[t].value = e, r.uniforms[n].value.set(e.image.width, e.image.height);
}, r;
}
function EE({ vertexShader: e, fragmentShader: t }, n, r = n) {
let i = RegExp(`uniform\\s+(bool|float|vec[234]|mat[34])\\s+${n}\\b`), a, o = !1;
t = t.replace(i, (e, t) => (o = !0, `varying ${a = t} ${r}`));
let s = !1;
return e = e.replace(i, (e, t) => (s = !0, `${o ? "varying" : ""} ${a = t} ${r}`)), s || (e = `${o ? "varying" : ""} ${a} ${r};\n${e}`), {
vertexShader: e,
fragmentShader: t
};
}
//#endregion
//#region ../renderer/src/core/text/batched-text-material.ts
var DE = "aTroikaTextBatchMemberIndex";
function OE(e, t) {
let n = e.onBeforeCompile.bind(e);
e.onBeforeCompile = (e, r) => {
t.patchShader(e, DE), n(e, r);
};
}
function kE(e, t, n) {
e.transparent = t.transparent, e._outlineMtl = jE(e);
let r = e.customProgramCacheKey.bind(e);
return e.customProgramCacheKey = () => `efpText_${n.shaderKey}|${r()}`, e.onBeforeCompile = (e) => {
e.vertexShader = uh(e.vertexShader, ME);
}, e;
}
function AE(e) {
var t;
return !!((t = e.uniforms) != null && t.uTroikaMatricesTexture);
}
function jE(e) {
let t = Object.create(e, { id: { value: e.id - .5 } });
return t.isTextOutlineMaterial = !0, t.depthWrite = !1, t.map = null, e.addEventListener("dispose", function n() {
e.removeEventListener("dispose", n), t.dispose();
}), t;
}
var ME = "uTroikaPositionOffset = vec2(0.0);";
//#endregion
//#region ../renderer/src/core/text/glyph-packing.ts
function NE(e, t, n) {
var r, i, a, o, s, c;
let l = e.attributes, u = (r = (i = l.aTroikaTextBatchMemberIndex) == null ? void 0 : i.array) == null ? /* @__PURE__ */ new Uint16Array() : r, d = (a = (o = l[PE]) == null ? void 0 : o.array) == null ? /* @__PURE__ */ new Float32Array() : a, f = (s = (c = l[FE]) == null ? void 0 : c.array) == null ? /* @__PURE__ */ new Float32Array() : s, p = 0, m;
for (let e of t) {
var h;
let t = (h = n(e)) == null ? void 0 : h.textRenderInfo;
t && (p += t.glyphAtlasIndices.length, m = t);
}
p !== u.length && (u = n_(u, p), d = n_(d, p), f = n_(f, p * 4));
let g = 0;
for (let e of t) {
var _;
let t = (_ = n(e)) == null ? void 0 : _.textRenderInfo;
if (!t) continue;
let r = t.glyphAtlasIndices.length;
u.fill(e, g, g + r), d.set(t.glyphAtlasIndices, g), f.set(t.glyphBounds, g * 4), g += r;
}
return e.updateAttributeData(DE, u, 1), e.getAttribute(DE).setUsage(Re), e.updateAttributeData(PE, d, 1), e.updateAttributeData(FE, f, 4), m;
}
var PE = "aTroikaGlyphIndex", FE = "aTroikaGlyphBounds", IE = class {
constructor() {
this.textures = {}, this.needsUpdate = !1;
}
prepareForRender(e, t, n) {
var r, i;
let a = t.isTextOutlineMaterial;
t.uniforms.uTroikaIsOutline.value = a;
let o = e.addedMembersCount, s = this.textureFor(a ? "outline" : "main", Math.max(1, o)), c = s.image.data;
this.needsUpdate = !1, UE.multiplyMatrices(n.projectionMatrix, n.matrixWorldInverse).multiply(e.matrixWorld), WE.setFromProjectionMatrix(UE, n.coordinateSystem), KE.extractRotation(e.matrixWorld).transpose().multiply(qE.extractRotation(n.matrixWorld)).multiply(dl);
let l = (r = (i = e.color) == null ? t.color : i) == null ? 16777215 : r, u = n.isPerspectiveCamera ? Ko(n, e.matrixWorld) : 0;
ZE.setFromMatrixPosition(n.matrixWorld), QE.setFromMatrixColumn(n.matrixWorld, 2).normalize().negate();
for (let n = 0; n < o; n++) {
let r = e.getText(n);
if (!(r != null && r.textRenderInfo)) continue;
RE(r, KE, u > 0 ? LE(r, e.matrixWorld, u) : 1);
let i = n * VE;
zE(r) ? this.writeMember(c, i, r, t, l) : this.collapse(c, i);
}
s.needsUpdate = this.needsUpdate, BE(t, s);
}
dispose() {
for (let t of Object.keys(this.textures)) {
var e;
(e = this.textures[t]) == null || e.dispose(), delete this.textures[t];
}
}
textureFor(e, t) {
let n = this.textures[e], r = 2 ** Math.ceil(Math.log2(t * VE));
if (n && r === n.image.data.length) return n;
n == null || n.dispose();
let i = Math.min(r / 4, 1024);
return n = new Ut(new Float32Array(r), i, r / 4 / i, dt, pt), this.textures[e] = n, n;
}
writeMember(e, t, n, r, i) {
var a;
let o = r.isTextOutlineMaterial, s = n.matrix.elements;
for (let n = 0; n < 16; n++) this.setTexData(e, t + n, s[n]);
n._prepareForRender(r);
let { uTroikaTotalBounds: c, uTroikaClipRect: l, uTroikaPositionOffset: u, uTroikaEdgeOffset: d, uTroikaBlurRadius: f, uTroikaStrokeWidth: p, uTroikaStrokeColor: m, uTroikaStrokeOpacity: h, uTroikaFillOpacity: g, uTroikaCurveRadius: _ } = r.uniforms;
for (let n = 0; n < 4; n++) this.setTexData(e, t + 16 + n, c.value.getComponent(n));
for (let n = 0; n < 4; n++) this.setTexData(e, t + 20 + n, l.value.getComponent(n));
let v = (a = o ? n.outlineColor || 0 : n.color) == null ? i : a;
this.setTexData(e, t + 24, HE.set(v).getHex()), this.setTexData(e, t + 25, g.value), this.setTexData(e, t + 26, _.value), o ? (this.setTexData(e, t + 28, u.value.x), this.setTexData(e, t + 29, u.value.y), this.setTexData(e, t + 30, d.value), this.setTexData(e, t + 31, f.value)) : (this.setTexData(e, t + 28, p.value), this.setTexData(e, t + 29, HE.set(m.value).getHex()), this.setTexData(e, t + 30, h.value));
}
collapse(e, t) {
for (let n = 0; n < 16; n++) this.setTexData(e, t + n, 0);
}
setTexData(e, t, n) {
n !== e[t] && (e[t] = n, this.needsUpdate = !0);
}
};
function LE(e, t, n) {
let r = e.spriteAnchor;
if (!r) return 1;
let i = XE.set(r.x, r.y, e.position.z).applyMatrix4(t).sub(ZE).dot(QE);
return i > 0 ? i / n : 1;
}
function RE(e, t, n) {
let r = e.spriteAnchor;
r && (XE.set(e.position.x - r.x, e.position.y - r.y, 0), JE.copy(t).multiply(YE.makeScale(n, n, n)).multiply(YE.makeTranslation(XE.x, XE.y, XE.z)).multiply(YE.makeRotationZ(e.rotation.z)).scale(e.scale).premultiply(YE.makeTranslation(r.x, r.y, e.position.z)), e.matrix.equals(JE) || e.setMatrix(JE));
}
function zE(e) {
return e.visible ? WE.intersectsSphere(GE.copy(e.geometry.boundingSphere).applyMatrix4(e.matrix)) : !1;
}
function BE(e, t) {
let { uTroikaMatricesTexture: n, uTroikaMatricesTextureSize: r } = e.uniforms;
n.value = t, r.value.set(t.image.width, t.image.height);
}
var VE = 32, HE = new gt(), UE = new W(), WE = new Xe(), GE = new vn(), KE = new W(), qE = new W(), JE = new W(), YE = new W(), XE = new U(), ZE = new U(), QE = new U(), $E = le(class extends CE {
constructor() {
super(), this.isBatchedText = !0, this.uniforms = new u_(), this.memberTexture = new IE(), this.ordered = [], this.textById = [], this.freeIds = [], this._addedMembersCount = 0, this.boundsNeedsUpdate = !1, this.batchNeedsSync = !0, this.disposed = !1, this.patchedMaterial = null, this.addEventListener("synccomplete", () => {
this.boundsNeedsUpdate = !0;
});
}
get size() {
return this._members.size;
}
get addedMembersCount() {
return this._addedMembersCount;
}
requestSync() {
this.batchNeedsSync = !0;
}
invalidateBounds() {
this.boundsNeedsUpdate = !0;
}
getText(e) {
return this.textById[e];
}
setVisibleAt(e, t) {
let n = this.textById[e];
!n || n.visible === t || (n.visible = t, this.invalidateBounds());
}
setOrder(e) {
this.ordered = [];
for (let n of e) {
var t;
let e = (t = this._members.get(n)) == null ? void 0 : t.index;
e !== void 0 && this.ordered.push(e);
}
this._needsRepack = !0, this.batchNeedsSync = !0, this.boundsNeedsUpdate = !0;
}
addUniforms(e) {
this.uniforms.add(e, Math.max(1, this._addedMembersCount)), this.materialsNeedUpdate();
}
getUniformAt(e, t, n) {
return this.uniforms.get(e, t, n);
}
setUniformAt(e, t, n) {
this.uniforms.set(e, t, n);
}
addText(e) {
var t;
let n = this._members.get(e);
if (n) return n.index;
let r = (t = this.freeIds.pop()) == null ? this._addedMembersCount++ : t;
return super.addText(e), this._members.get(e).index = r, e._batchParent = this, this.textById[r] = e, this.ordered.push(r), this.uniforms.resize(this._addedMembersCount), this.batchNeedsSync = !0, this.boundsNeedsUpdate = !0, r;
}
removeText(e) {
let t = this._members.get(e);
if (super.removeText(e), !t) return;
this.textById[t.index] = void 0, this.freeIds.push(t.index), e._batchParent === this && (e._batchParent = void 0);
let n = this.ordered.indexOf(t.index);
n >= 0 && this.ordered.splice(n, 1), this.batchNeedsSync = !0, this.boundsNeedsUpdate = !0;
}
copy(e) {
return gE.prototype.copy.call(this, e), this;
}
dispose() {
this.disposed = !0, super.dispose();
for (let e of this.textById) e && (super.removeText(e), e._batchParent === this && (e._batchParent = void 0));
this.memberTexture.dispose(), this.uniforms.dispose(), this.ordered.length = 0, this.textById.length = 0, this.freeIds.length = 0, this._addedMembersCount = 0, this.dispatchEvent(nD);
}
updateBounds() {
if (!this.boundsNeedsUpdate) return;
let e = this.geometry.boundingBox.makeEmpty();
for (let t of this.ordered) {
let n = this.textById[t];
n && (n.matrixAutoUpdate && n.updateMatrix(), n.visible && (iD.copy(n.geometry.boundingBox).applyMatrix4(n.matrix), e.union(iD)));
}
e.getBoundingSphere(this.geometry.boundingSphere), this.boundsNeedsUpdate = !1;
}
raycast(e, t) {
this.updateBounds();
let n = this.geometry.boundingSphere;
if (!(n && Number.isFinite(n.radius) && n.radius > 0 && (rD.copy(n).applyMatrix4(this.matrixWorld), !e.ray.intersectsSphere(rD)))) for (let n = 0; n < this._addedMembersCount; n++) {
let r = this.textById[n];
if (!(r != null && r.visible) || !r.textRenderInfo) continue;
r.matrixAutoUpdate && r.updateMatrix(), r.matrixWorld.multiplyMatrices(this.matrixWorld, r.matrix);
let i = t.length;
r.raycast(e, t);
for (let e = i; e < t.length; e++) t[e].object = this, t[e].instanceId = n;
}
}
onBeforeRender(e, t, n, r, i) {
var a;
this.batchNeedsSync && this.sync(), AE(i) && this.memberTexture.prepareForRender(this, i, n), (a = this.uniforms.texture) == null || a.update(e);
}
sync(e) {
if (this.disposed || !this.batchNeedsSync) {
e == null || e();
return;
}
this.batchNeedsSync = !1;
let t = this._needsRepack;
this._needsRepack = !1;
let n = [];
if (this._members.forEach((e, r) => {
let i = r._needsSync;
(e.dirty || i) && (e.dirty = !1, t = !0, i && n.push(new Promise((e) => r.sync(e))));
}), !t) {
e == null || e();
return;
}
this.dispatchEvent(eD);
let r = () => {
this.disposed || (this.repackBatchedGeometry(), this.dispatchEvent(tD)), e == null || e();
};
n.length ? Promise.all(n).then(r) : r();
}
get material() {
return super.material;
}
set material(e) {
super.material = Array.isArray(e) ? e[e.length - 1] : e;
}
createDerivedMaterial(e) {
return e !== this.patchedMaterial && (this.patchedMaterial = e, OE(e, this.uniforms)), kE(super.createDerivedMaterial(e), e, this.uniforms);
}
repackBatchedGeometry() {
let e = NE(this.geometry, this.ordered, (e) => this.textById[e]);
e && (this._textRenderInfo = e), this.boundsNeedsUpdate = !0, this.updateBounds();
}
materialsNeedUpdate() {
let e = this.material;
for (let t of Array.isArray(e) ? e : [e]) t.needsUpdate = !0;
}
}), eD = { type: "syncstart" }, tD = { type: "synccomplete" }, nD = { type: "dispose" }, rD = new vn(), iD = new ze(), aD = class extends gE {
constructor(...e) {
super(...e), this._batchParent = void 0, this._syncFlag = !0, this.spriteAnchor = null;
}
setMatrix(e) {
var t;
this.matrixAutoUpdate = !1, this.matrix.copy(e), (t = this._batchParent) == null || t.invalidateBounds();
}
updateMatrix() {
var e;
super.updateMatrix(), (e = this._batchParent) == null || e.invalidateBounds();
}
_prepareForRender(e) {
let t = "+x+y", n = e.isTextOutlineMaterial, r = e.uniforms, i = this.textRenderInfo, a = this._batchParent !== void 0;
if (i) {
var o;
let { sdfTexture: e, blockBounds: t } = i, { width: l, height: u } = e.image;
r.uTroikaSDFTexture.value = e, r.uTroikaSDFTextureSize.value.set(l, u), r.uTroikaSDFGlyphSize.value = i.sdfGlyphSize, r.uTroikaSDFExponent.value = i.sdfExponent, r.uTroikaTotalBounds.value.fromArray(t), r.uTroikaUseGlyphColors.value = !n && !!i.glyphColors;
let d = 0, f = 0, p = 0, m, h = 1, g, _ = 0, v = 0;
if (n) {
let { outlineWidth: e, outlineOffsetX: t, outlineOffsetY: n, outlineBlur: r, outlineOpacity: i } = this;
d = this._parsePercent(e) || 0, f = Math.max(0, this._parsePercent(r) || 0), m = i, _ = this._parsePercent(t) || 0, v = this._parsePercent(n) || 0;
} else {
if (p = Math.max(0, this._parsePercent(this.strokeWidth) || 0), p) {
var s, c;
g = this.strokeColor, r.uTroikaStrokeColor.value.set((s = g) == null ? 8421504 : s), h = (c = this.strokeOpacity) == null ? 1 : c;
}
m = this.fillOpacity;
}
r.uTroikaEdgeOffset.value = d, r.uTroikaPositionOffset.value.set(_, v), r.uTroikaBlurRadius.value = f, r.uTroikaStrokeWidth.value = p, r.uTroikaStrokeOpacity.value = h, r.uTroikaFillOpacity.value = (o = m) == null ? 1 : o, r.uTroikaCurveRadius.value = this.curveRadius || 0;
let y = this.clipRect;
if (y && Array.isArray(y) && y.length === 4) r.uTroikaClipRect.value.fromArray(y);
else {
let e = (this.fontSize || .1) * 100;
r.uTroikaClipRect.value.set(t[0] - e, t[1] - e, t[2] + e, t[3] + e);
}
a || this.geometry.applyClipRect(r.uTroikaClipRect.value);
}
if (r.uTroikaSDFDebug.value = !!this.debugSDF, !a) {
let t = n ? this.outlineColor || 0 : this.color;
if (t == null) delete e.color;
else {
let n = e.hasOwnProperty("color") ? e.color : e.color = new gt();
(t !== n._input || typeof t == "object") && n.set(n._input = t);
}
}
let l = this.orientation || t;
if (l !== e._orientation) {
let n = r.uTroikaOrient.value;
l = l.replace(/[^-+xyz]/g, "");
let i = l !== t && /^([-+])([xyz])([-+])([xyz])$/.exec(l);
if (i) {
let [, e, t, r, a] = i;
sD.set(0, 0, 0)[t] = e === "-" ? 1 : -1, cD.set(0, 0, 0)[a] = r === "-" ? -1 : 1, oD.lookAt(lD, sD.cross(cD), cD), n.setFromMatrix4(oD);
} else n.identity();
e._orientation = l;
}
}
};
Object.defineProperty(aD.prototype, "_needsSync", {
configurable: !0,
get() {
return this._syncFlag;
},
set(e) {
var t;
this._syncFlag = e, e && ((t = this._batchParent) == null || t.requestSync());
}
}), le(aD);
var oD = new W(), sD = new U(), cD = new U(), lD = new U(), uD = 1.1;
function dD(e) {
let { bounds: t, lines: n, alignment: r, padding: i } = e, a = _D.set(t.size.x, t.size.y).multiplyScalar(.5), o = vD.copy(a);
if (r.vertical === "center") {
let e = 0;
for (let t of n) e += pD(t);
o.y -= (t.size.y - e) / 2;
} else o.sub(yD.fromArray(i));
o.multiply(mD(r));
let s = [];
for (let e of n) {
var c;
let t = e.fontSize, n = -t;
s.push({
anchorX: r.horizontal,
anchorY: r.vertical === "bottom" ? "bottom" : "top",
textAlign: (c = r.text) == null ? r.horizontal : c,
offsetX: o.x,
offsetY: o.y,
scaleX: t,
scaleY: n,
clipRect: [
(-a.x - o.x) / t,
(a.y - o.y) / n,
(a.x - o.x) / t,
(-a.y - o.y) / n
]
}), o.y += pD(e);
}
return s;
}
function fD(e, t, n, r) {
var i;
let { rotation: a } = n, o = xD.set(t.offsetX, t.offsetY).rotateAround(SD, a).add(n.center);
if (e.position.set(o.x, o.y, n.elevation), e.rotation.set(0, 0, a), e.scale.set(t.scaleX, t.scaleY, 1), r) {
var s;
let t = (s = e.spriteAnchor) == null ? new V() : s;
t.set(n.center.x, n.center.y), e.spriteAnchor = t, e.matrixAutoUpdate = !1;
} else e.spriteAnchor = null, e.matrixAutoUpdate = !0;
e.updateMatrix();
let c = (i = e.clipRect) == null ? e.clipRect = [
0,
0,
0,
0
] : i;
c[0] = t.clipRect[0], c[1] = t.clipRect[1], c[2] = t.clipRect[2], c[3] = t.clipRect[3];
}
function pD(e) {
return e.fontSize * uD * e.text.split("\n").length;
}
function mD(e) {
return bD.set(hD[e.horizontal], gD[e.vertical]);
}
var hD = {
left: -1,
center: 0,
right: 1
}, gD = {
top: -1,
center: -1,
bottom: 1
}, _D = new V(), vD = new V(), yD = new V(), bD = new V(), xD = new V(), SD = new V(0, 0), CD = class extends yy {
constructor(e) {
super(), this.groups = [], this.freeGroups = [], this.groupByMember = /* @__PURE__ */ new Map(), this.groupCount = 0, this.appliedOrder = [], this.syncScheduled = !1, this.invalidate = void 0, this.invalidate = e;
}
bind(e) {
let t = e !== null && this.mesh === void 0;
super.bind(e), t && e.addEventListener("synccomplete", () => this.invalidate());
}
linesAt(e) {
var t;
return (t = this.groups[e]) == null ? TD : t;
}
scheduleSync() {
this.syncScheduled || (this.syncScheduled = !0, Promise.resolve().then(() => {
this.syncScheduled = !1, this.mesh && this.mesh.sync(this.invalidate);
}));
}
claim(e, t) {
let n = super.claim(e, t);
return this.layerDefs.length && this.applyOrder(), n;
}
setVisibleAt(e, t) {
let n = this.groups[e];
if (n) for (let e of n.slots) this.mesh.setVisibleAt(e, t);
}
setPaintOrder(e, t) {
super.setPaintOrder(e, t), this.scheduleSync();
}
defAt(e) {
return super.defAt(e === void 0 ? void 0 : this.groupByMember.get(e));
}
applyOrder() {
let e = [];
for (let t of this.orderedDefs()) {
let n = this.slotOf(t);
if (n === void 0) continue;
let r = this.groups[n];
r && (e.push(...r.texts), this.dimmedBySlot[n] = $h(t.dim, this.layerDimmed));
}
aS(e, this.appliedOrder) || (this.appliedOrder = e, this.mesh.setOrder(e));
}
writeDim(e, t) {
let n = this.groups[e];
if (n) for (let e of n.slots) super.writeDim(e, t);
}
addInstance(e) {
var t;
let n = (t = this.freeGroups.pop()) == null ? this.groupCount++ : t, r = [], i = [];
for (let t = 0; t < e; t++) {
let e = wD();
r.push(e), i.push(this.mesh.addText(e));
}
this.groups[n] = {
texts: r,
slots: i
};
for (let e of i) this.groupByMember.set(e, n);
return n;
}
removeInstance(e) {
let t = this.groups[e];
if (t) {
for (let e of t.slots) this.groupByMember.delete(e);
for (let e of t.texts) this.mesh.removeText(e), e.dispose();
this.groups[e] = void 0, this.freeGroups.push(e), this.appliedOrder = [];
}
}
};
function wD() {
let e = new aD();
return e.fontSize = 1, e.lineHeight = uD, e.whiteSpace = "nowrap", e;
}
var TD = {
texts: [],
slots: []
}, ED = $c("text-instance"), DD = (0, G.memo)(function(e) {
let t = (0, Z.c)(5), { def: n, container: r } = e, i;
t[0] === n.lines.length ? i = t[1] : (i = () => n.lines.length, t[0] = n.lines.length, t[1] = i);
let a;
return t[2] !== r || t[3] !== n ? (a = (e) => {
OD(r, e, n);
}, t[2] = r, t[3] = n, t[4] = a) : a = t[4], Sv(r, n, i, a), null;
});
function OD(e, t, n) {
let { texts: r, slots: i } = e.linesAt(t), a = dD(n);
for (let t = 0; t < r.length; t++) kD(e.mesh, i[t], r[t], n.lines[t], a[t], n);
e.scheduleSync();
}
function kD(e, t, n, r, i, a) {
e.setVisibleAt(t, r.fontSize > 0), !(r.fontSize <= 0) && (n.text = r.text, n.font = r.fontUrl, n.anchorX = i.anchorX, n.anchorY = i.anchorY, n.textAlign = i.textAlign, AD(n, r.color, "fill"), r.stroke && (AD(n, r.stroke.color, "outline"), n.outlineWidth = r.fontSize == 0 ? 0 : r.stroke.width / r.fontSize), fD(n, i, a.bounds, a.screenSpace === !0));
}
function AD(e, t, n) {
let r = n == "fill" ? "color" : "outlineColor", i = `${n}Opacity`, a = ay(t);
if (!a) {
ED.warn(`Invalid color: ${t} %O`, e), e[r] = t;
return;
}
jD.setRGB(a.r / 255, a.g / 255, a.b / 255, wt), e[r] = jD.getHex(vt), e[i] = a.a;
}
var jD = new gt();
//#endregion
//#region ../renderer/src/objects/text/Texts.tsx
function MD(e) {
var t;
let n = (0, Z.c)(16), { defs: r } = e, i = (t = e.mounted) == null ? r.length : t, a = I(ND), o;
n[0] === a ? o = n[1] : (o = () => new CD(a), n[0] = a, n[1] = o);
let s = bv(o, r), c;
n[2] === s ? c = n[3] : (c = (e) => s.bind(e), n[2] = s, n[3] = c);
let l;
n[4] === Symbol.for("react.memo_cache_sentinel") ? (l = /* @__PURE__ */ (0, K.jsx)(Ug, {}), n[4] = l) : l = n[4];
let u;
n[5] === c ? u = n[6] : (u = /* @__PURE__ */ (0, K.jsx)($E, {
ref: c,
children: l
}), n[5] = c, n[6] = u);
let d;
if (n[7] !== s || n[8] !== r || n[9] !== i) {
let e;
n[11] === s ? e = n[12] : (e = (e) => /* @__PURE__ */ (0, K.jsx)(DD, {
def: e,
container: s
}, Ov(e)), n[11] = s, n[12] = e), d = r.slice(0, i).map(e), n[7] = s, n[8] = r, n[9] = i, n[10] = d;
} else d = n[10];
let f;
return n[13] !== u || n[14] !== d ? (f = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [u, d] }), n[13] = u, n[14] = d, n[15] = f) : f = n[15], f;
}
function ND(e) {
return e.invalidate;
}
//#endregion
//#region ../renderer/src/objects/layer/mount-scheduler.ts
var PD = $c("mount");
function FD(e = zD) {
let t = [], n = /* @__PURE__ */ new WeakMap(), r = /* @__PURE__ */ new WeakSet(), i = /* @__PURE__ */ new WeakMap(), a = /* @__PURE__ */ new Set(), o = null, s = 0, c = 0, l = !1, u = 0, d = 0, f = [], p = HD, m = typeof requestAnimationFrame == "function" ? (e) => void requestAnimationFrame(e) : (e) => void setTimeout(e, 0), h = () => {
for (let e of [...a]) e();
}, g = (e, t, n) => {
let r = i.get(e), a = Math.max(1, Math.round(n / Math.max(r == null ? p : r, UD))), o = r === void 0 ? Math.min(a, WD) : a, s = Math.ceil(e.children.length / GD);
return Math.min(e.children.length - t, Math.max(o, s));
}, _ = (e) => {
var t;
return r.has(e) ? e.children.length : Math.min((t = n.get(e)) == null ? 0 : t, e.children.length);
}, v = () => {
if (f.length !== 0) {
for (let t of f) {
var e;
PD.debug(`${(e = t.name) == null ? "?" : e}, admitted ${_(t)}/${t.children.length}`);
}
f.length = 0;
}
}, y = () => {
l || (l = !0, v(), m(() => {
l = !1, u = 0, d = 0, b();
}));
}, b = () => {
var i;
if (o || l) return;
let a = t.find((e) => {
var t;
return !r.has(e) && ((t = n.get(e)) == null ? 0 : t) < e.children.length;
});
if (!a) {
v();
return;
}
let p = e - u;
if ((p < BD || d >= VD) && d > 0) {
y();
return;
}
let m = (i = n.get(a)) == null ? 0 : i, _ = g(a, m, p);
n.set(a, m + _), m + _ >= a.children.length && r.add(a), o = a, s = _, c = performance.now(), f.includes(a) || f.push(a), h();
};
return {
register: (e) => (e.children.length === 0 && !r.has(e) && (r.add(e), h()), t.includes(e) || (t.push(e), h()), b(), () => {
let n = t.indexOf(e);
n >= 0 && (t.splice(n, 1), h()), o === e && (o = null, b());
}),
leaves: () => [...t],
admittedCount: (e) => {
var t;
return r.has(e) ? e.children.length : Math.min((t = n.get(e)) == null ? 0 : t, e.children.length);
},
subscribe: (e) => (a.add(e), () => {
a.delete(e);
}),
reportMounted: (e) => {
if (o !== e) return;
let t = performance.now() - c;
s > 0 && (p = Math.max(t / s, UD), i.set(e, p)), o = null, u += t, d++, b();
}
};
}
function ID(e) {
let t = (0, Z.c)(8), n, r;
t[0] === e ? (n = t[1], r = t[2]) : (n = (t) => dd(e, t), r = () => fd(e), t[0] = e, t[1] = n, t[2] = r);
let i = (0, G.useDeferredValue)((0, G.useSyncExternalStore)(n, r)), a;
t[3] === i ? a = t[4] : (a = Gc(i), t[3] = i, t[4] = a);
let o = LD(e, !a, i.length), s;
return t[5] !== i || t[6] !== o ? (s = {
children: i,
mounted: o
}, t[5] = i, t[6] = o, t[7] = s) : s = t[7], s;
}
function LD(e, t, n) {
let r = (0, Z.c)(18), i = (0, G.use)(RD), a;
r[0] === i ? a = r[1] : (a = (e) => i ? i.subscribe(e) : KD, r[0] = i, r[1] = a);
let o;
r[2] !== e || r[3] !== t || r[4] !== i || r[5] !== n ? (o = () => !t || !i ? n : i.admittedCount(e), r[2] = e, r[3] = t, r[4] = i, r[5] = n, r[6] = o) : o = r[6];
let s = (0, G.useSyncExternalStore)(a, o), c, l;
r[7] !== e || r[8] !== t || r[9] !== i ? (c = () => {
if (!(!i || !t)) return i.register(e);
}, l = [
i,
e,
t
], r[7] = e, r[8] = t, r[9] = i, r[10] = c, r[11] = l) : (c = r[10], l = r[11]), (0, G.useEffect)(c, l);
let u, d;
return r[12] !== e || r[13] !== t || r[14] !== s || r[15] !== i ? (u = () => {
i && t && s > 0 && i.reportMounted(e);
}, d = [
i,
e,
t,
s
], r[12] = e, r[13] = t, r[14] = s, r[15] = i, r[16] = u, r[17] = d) : (u = r[16], d = r[17]), (0, G.useEffect)(u, d), s;
}
var RD = (0, G.createContext)(null), zD = 11, BD = 2, VD = 12, HD = .25, UD = .02, WD = 64, GD = 8, KD = () => void 0;
//#endregion
//#region ../renderer/src/objects/layer/visibility-gui.ts
function qD(e, t) {
e.add({
get visible() {
return !t.hidden;
},
set visible(e) {
t.hidden = !e, ud(t);
}
}, "visible").name(t.name).listen();
}
function JD(e, t) {
let n = [];
return () => {
let r = t();
if (!(r.length === n.length && r.every((e, t) => e === n[t]))) {
n = r;
for (let t of [...e.controllers]) t.destroy();
for (let t of r) qD(e, t);
}
};
}
function YD(e) {
let t = (0, Z.c)(5), n = de(), r = (0, G.use)(RD), i, a;
t[0] !== n || t[1] !== e || t[2] !== r ? (i = () => {
if (!n) return;
let t = n.addFolder("Main layers"), i = JD(t, () => {
let t = fd(e);
return Gc(t) ? t : [];
});
i();
let a = dd(e, i), o = n.addFolder("Content layers"), s;
if (r) {
let e = JD(o, () => r.leaves());
e(), s = r.subscribe(e);
}
return () => {
a(), s == null || s(), t.destroy(), o.destroy();
};
}, a = [
n,
r,
e
], t[0] = n, t[1] = e, t[2] = r, t[3] = i, t[4] = a) : (i = t[3], a = t[4]), (0, G.useEffect)(i, a);
}
//#endregion
//#region ../renderer/src/objects/layer/Layer.tsx
function XD(e) {
let t = (0, Z.c)(3), { layer: n, children: r } = e;
YD(n);
let i;
return t[0] !== r || t[1] !== n ? (i = /* @__PURE__ */ (0, K.jsx)($D, {
layer: n,
hidden: !1,
orderBase: 0,
orderStep: 1,
children: r
}), t[0] = r, t[1] = n, t[2] = i) : i = t[2], i;
}
function ZD(e) {
let t = (0, Z.c)(17), { defs: n, mounted: r } = e, i = null;
if (Kc(n)) {
let e;
t[0] !== n || t[1] !== r ? (e = /* @__PURE__ */ (0, K.jsx)(Ew, {
defs: n,
mounted: r
}), t[0] = n, t[1] = r, t[2] = e) : e = t[2], i = e;
} else if (qc(n)) {
let e;
t[3] !== n || t[4] !== r ? (e = /* @__PURE__ */ (0, K.jsx)(kb, {
defs: n,
mounted: r
}), t[3] = n, t[4] = r, t[5] = e) : e = t[5], i = e;
} else if (Jc(n)) {
let e;
t[6] !== n || t[7] !== r ? (e = /* @__PURE__ */ (0, K.jsx)(MD, {
defs: n,
mounted: r
}), t[6] = n, t[7] = r, t[8] = e) : e = t[8], i = e;
} else if (Yc(n)) {
let e;
t[9] !== n || t[10] !== r ? (e = /* @__PURE__ */ (0, K.jsx)(iS, {
defs: n,
mounted: r
}), t[9] = n, t[10] = r, t[11] = e) : e = t[11], i = e;
} else if (Xc(n)) {
let e;
t[12] !== n || t[13] !== r ? (e = /* @__PURE__ */ (0, K.jsx)(nw, {
defs: n,
mounted: r
}), t[12] = n, t[13] = r, t[14] = e) : e = t[14], i = e;
}
let a;
return t[15] === i ? a = t[16] : (a = /* @__PURE__ */ (0, K.jsx)(G.Suspense, {
fallback: null,
children: i
}), t[15] = i, t[16] = a), a;
}
function QD(e) {
let t = (0, Z.c)(28), { layer: n, children: r, hidden: i, orderBase: a, orderStep: o } = e, s = hh(), c = gh(), l = i || n.hidden === !0, u = c || n.overlay === !0, d;
t[0] !== n || t[1] !== s ? (d = [n, ...s], t[0] = n, t[1] = s, t[2] = d) : d = t[2];
let f = d, p = !l, { children: m, mounted: h } = ID(n);
lf(n, m);
let g = Qp(n, p), _ = null;
if (Gc(m)) {
let e = o / m.length, n;
if (t[3] !== e || t[4] !== m || t[5] !== l || t[6] !== a) {
let r;
t[8] !== e || t[9] !== l || t[10] !== a ? (r = (t, n) => /* @__PURE__ */ (0, K.jsx)($D, {
layer: t,
hidden: l,
orderBase: a + n * e,
orderStep: e
}, t.name), t[8] = e, t[9] = l, t[10] = a, t[11] = r) : r = t[11], n = m.map(r), t[3] = e, t[4] = m, t[5] = l, t[6] = a, t[7] = n;
} else n = t[7];
_ = n;
} else if (h > 0) {
let e;
t[12] !== m || t[13] !== h ? (e = /* @__PURE__ */ (0, K.jsx)(ZD, {
defs: m,
mounted: h
}), t[12] = m, t[13] = h, t[14] = e) : e = t[14], _ = e;
}
let v = !n.hidden, y = (u ? tO : eO) + a, b;
t[15] !== _ || t[16] !== n.name || t[17] !== g || t[18] !== r || t[19] !== v || t[20] !== y ? (b = /* @__PURE__ */ (0, K.jsxs)("group", {
name: n.name,
visible: v,
renderOrder: y,
...g,
children: [r, _]
}), t[15] = _, t[16] = n.name, t[17] = g, t[18] = r, t[19] = v, t[20] = y, t[21] = b) : b = t[21];
let x = b, S;
t[22] !== x || t[23] !== u ? (S = /* @__PURE__ */ (0, K.jsx)(bh, {
value: u,
children: x
}), t[22] = x, t[23] = u, t[24] = S) : S = t[24];
let C;
return t[25] !== f || t[26] !== S ? (C = /* @__PURE__ */ (0, K.jsx)(yh, {
value: f,
children: S
}), t[25] = f, t[26] = S, t[27] = C) : C = t[27], C;
}
var $D = (0, G.memo)(QD), eO = 0, tO = 1;
//#endregion
//#region ../renderer/src/objects/lighting/lighting-gui.ts
function nO(e) {
let t = (0, Z.c)(5), n = de(), r = Tg(), i, a;
t[0] !== r || t[1] !== n || t[2] !== e ? (i = () => {
if (!n) return;
let t = rO(n, e, r);
return () => {
t.destroy();
};
}, a = [
r,
n,
e
], t[0] = r, t[1] = n, t[2] = e, t[3] = i, t[4] = a) : (i = t[3], a = t[4]), (0, G.useEffect)(i, a);
}
function rO(e, t, n) {
let r = e.addFolder("Lighting"), i = r.add(t, "trackPitch").name("track camera pitch"), a = r.add(t, "pitchDegrees", 0, 89, 1).name("pitch°");
i.onChange((e) => sO(a, !e)), sO(a, !t.trackPitch), r.addColor(t, "skyColor").name("sky color"), r.addColor(t, "groundColor").name("ground color"), r.addColor(t, "directionalColor").name("directional color"), r.add(t, "contrast", 0, 1, .01).name("contrast"), r.add(t.environment, "share", 0, 1, .01).name("environment share"), r.add(t.environment, "rotationDegrees", -180, 180, 1).name("environment rotation°"), r.addColor(n, "shadowHex").name("shadow color").onChange((e) => n.shadowColor.value.set(e));
let o = { opacity: uS() };
return r.add(o, "opacity", 0, 1, .01).name("model opacity").onChange((e) => dS(e)), iO(r, t.sunShadow), aO(r, n), oO(r, n), r;
}
function iO(e, t) {
let n = e.addFolder("Sun shadows");
n.add(t, "enabled").name("enabled"), n.add(t, "headingDegrees", -180, 180, 1).name("heading°"), n.add(t, "elevationDegrees", 5, 90, 1).name("elevation°"), n.add(t, "strength", 0, 1, .01).name("strength");
}
function aO(e, t) {
let n = e.addFolder("Contact shadow");
n.add(t, "contactEnabled").name("enabled").onChange(() => lg(t)), n.add(t.shadowDistance, "value", 1, 5, .1).name("distance"), n.add(t, "contactStrength", 0, 1, .01).name("strength").onChange(() => lg(t));
}
function oO(e, t) {
let n = e.addFolder("Ambient occlusion");
n.add(t, "enabled").name("enabled"), n.add(t, "radius", 1, 30, .5).name("radius"), n.add(t.aoStrength, "value", 0, 1, .01).name("strength");
}
function sO(e, t) {
t ? e.show() : e.hide();
}
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/examples/jsm/libs/fflate.module.js
var cO = Uint8Array, lO = Uint16Array, uO = Int32Array, dO = new cO([
0,
0,
0,
0,
0,
0,
0,
0,
1,
1,
1,
1,
2,
2,
2,
2,
3,
3,
3,
3,
4,
4,
4,
4,
5,
5,
5,
5,
0,
0,
0,
0
]), fO = new cO([
0,
0,
0,
0,
1,
1,
2,
2,
3,
3,
4,
4,
5,
5,
6,
6,
7,
7,
8,
8,
9,
9,
10,
10,
11,
11,
12,
12,
13,
13,
0,
0
]), pO = new cO([
16,
17,
18,
0,
8,
7,
9,
6,
10,
5,
11,
4,
12,
3,
13,
2,
14,
1,
15
]), mO = function(e, t) {
for (var n = new lO(31), r = 0; r < 31; ++r) n[r] = t += 1 << e[r - 1];
for (var i = new uO(n[30]), r = 1; r < 30; ++r) for (var a = n[r]; a < n[r + 1]; ++a) i[a] = a - n[r] << 5 | r;
return {
b: n,
r: i
};
}, hO = mO(dO, 2), gO = hO.b, _O = hO.r;
gO[28] = 258, _O[258] = 28;
var vO = mO(fO, 0), yO = vO.b;
vO.r;
for (var bO = new lO(32768), xO = 0; xO < 32768; ++xO) {
var SO = (xO & 43690) >> 1 | (xO & 21845) << 1;
SO = (SO & 52428) >> 2 | (SO & 13107) << 2, SO = (SO & 61680) >> 4 | (SO & 3855) << 4, bO[xO] = ((SO & 65280) >> 8 | (SO & 255) << 8) >> 1;
}
for (var CO = (function(e, t, n) {
for (var r = e.length, i = 0, a = new lO(t); i < r; ++i) e[i] && ++a[e[i] - 1];
var o = new lO(t);
for (i = 1; i < t; ++i) o[i] = o[i - 1] + a[i - 1] << 1;
var s;
if (n) {
s = new lO(1 << t);
var c = 15 - t;
for (i = 0; i < r; ++i) if (e[i]) for (var l = i << 4 | e[i], u = t - e[i], d = o[e[i] - 1]++ << u, f = d | (1 << u) - 1; d <= f; ++d) s[bO[d] >> c] = l;
} else for (s = new lO(r), i = 0; i < r; ++i) e[i] && (s[i] = bO[o[e[i] - 1]++] >> 15 - e[i]);
return s;
}), wO = new cO(288), xO = 0; xO < 144; ++xO) wO[xO] = 8;
for (var xO = 144; xO < 256; ++xO) wO[xO] = 9;
for (var xO = 256; xO < 280; ++xO) wO[xO] = 7;
for (var xO = 280; xO < 288; ++xO) wO[xO] = 8;
for (var TO = new cO(32), xO = 0; xO < 32; ++xO) TO[xO] = 5;
var EO = /*#__PURE__*/ CO(wO, 9, 1), DO = /*#__PURE__*/ CO(TO, 5, 1), OO = function(e) {
for (var t = e[0], n = 1; n < e.length; ++n) e[n] > t && (t = e[n]);
return t;
}, kO = function(e, t, n) {
var r = t / 8 | 0;
return (e[r] | e[r + 1] << 8) >> (t & 7) & n;
}, AO = function(e, t) {
var n = t / 8 | 0;
return (e[n] | e[n + 1] << 8 | e[n + 2] << 16) >> (t & 7);
}, jO = function(e) {
return (e + 7) / 8 | 0;
}, MO = function(e, t, n) {
return (t == null || t < 0) && (t = 0), (n == null || n > e.length) && (n = e.length), new cO(e.subarray(t, n));
}, NO = [
"unexpected EOF",
"invalid block type",
"invalid length/literal",
"invalid distance",
"stream finished",
"no stream handler",
,
"no callback",
"invalid UTF-8 data",
"extra field too long",
"date not in range 1980-2099",
"filename too long",
"stream finishing",
"invalid zip data"
], PO = function(e, t, n) {
var r = Error(t || NO[e]);
if (r.code = e, Error.captureStackTrace && Error.captureStackTrace(r, PO), !n) throw r;
return r;
}, FO = function(e, t, n, r) {
var i = e.length, a = r ? r.length : 0;
if (!i || t.f && !t.l) return n || new cO(0);
var o = !n, s = o || t.i != 2, c = t.i;
o && (n = new cO(i * 3));
var l = function(e) {
var t = n.length;
if (e > t) {
var r = new cO(Math.max(t * 2, e));
r.set(n), n = r;
}
}, u = t.f || 0, d = t.p || 0, f = t.b || 0, p = t.l, m = t.d, h = t.m, g = t.n, _ = i * 8;
do {
if (!p) {
u = kO(e, d, 1);
var v = kO(e, d + 1, 3);
if (d += 3, !v) {
var y = jO(d) + 4, b = e[y - 4] | e[y - 3] << 8, x = y + b;
if (x > i) {
c && PO(0);
break;
}
s && l(f + b), n.set(e.subarray(y, x), f), t.b = f += b, t.p = d = x * 8, t.f = u;
continue;
} else if (v == 1) p = EO, m = DO, h = 9, g = 5;
else if (v == 2) {
var S = kO(e, d, 31) + 257, C = kO(e, d + 10, 15) + 4, w = S + kO(e, d + 5, 31) + 1;
d += 14;
for (var T = new cO(w), E = new cO(19), D = 0; D < C; ++D) E[pO[D]] = kO(e, d + D * 3, 7);
d += C * 3;
for (var O = OO(E), k = (1 << O) - 1, A = CO(E, O, 1), D = 0; D < w;) {
var j = A[kO(e, d, k)];
d += j & 15;
var y = j >> 4;
if (y < 16) T[D++] = y;
else {
var M = 0, N = 0;
for (y == 16 ? (N = 3 + kO(e, d, 3), d += 2, M = T[D - 1]) : y == 17 ? (N = 3 + kO(e, d, 7), d += 3) : y == 18 && (N = 11 + kO(e, d, 127), d += 7); N--;) T[D++] = M;
}
}
var P = T.subarray(0, S), ee = T.subarray(S);
h = OO(P), g = OO(ee), p = CO(P, h, 1), m = CO(ee, g, 1);
} else PO(1);
if (d > _) {
c && PO(0);
break;
}
}
s && l(f + 131072);
for (var te = (1 << h) - 1, ne = (1 << g) - 1, re = d;; re = d) {
var M = p[AO(e, d) & te], F = M >> 4;
if (d += M & 15, d > _) {
c && PO(0);
break;
}
if (M || PO(2), F < 256) n[f++] = F;
else if (F == 256) {
re = d, p = null;
break;
} else {
var ie = F - 254;
if (F > 264) {
var D = F - 257, ae = dO[D];
ie = kO(e, d, (1 << ae) - 1) + gO[D], d += ae;
}
var oe = m[AO(e, d) & ne], se = oe >> 4;
oe || PO(3), d += oe & 15;
var ee = yO[se];
if (se > 3) {
var ae = fO[se];
ee += AO(e, d) & (1 << ae) - 1, d += ae;
}
if (d > _) {
c && PO(0);
break;
}
s && l(f + 131072);
var I = f + ie;
if (f < ee) {
var ce = a - ee, le = Math.min(ee, I);
for (ce + f < 0 && PO(3); f < le; ++f) n[f] = r[ce + f];
}
for (; f < I; ++f) n[f] = n[f - ee];
}
}
t.l = p, t.p = re, t.b = f, t.f = u, p && (u = 1, t.m = h, t.d = m, t.n = g);
} while (!u);
return f != n.length && o ? MO(n, 0, f) : n.subarray(0, f);
}, IO = /*#__PURE__*/ new cO(0), LO = function(e, t) {
return ((e[0] & 15) != 8 || e[0] >> 4 > 7 || (e[0] << 8 | e[1]) % 31) && PO(6, "invalid zlib data"), (e[1] >> 5 & 1) == +!t && PO(6, "invalid zlib data: " + (e[1] & 32 ? "need" : "unexpected") + " dictionary"), (e[1] >> 3 & 4) + 2;
};
function RO(e, t) {
return FO(e.subarray(LO(e, t && t.dictionary), -4), { i: 2 }, t && t.out, t && t.dictionary);
}
var zO = typeof TextDecoder < "u" && /*#__PURE__*/ new TextDecoder();
try {
zO.decode(IO, { stream: !0 });
} catch {}
//#endregion
//#region ../../node_modules/.pnpm/three@0.185.1/node_modules/three/examples/jsm/loaders/EXRLoader.js
var BO = class extends pn {
constructor(e) {
super(e), this.type = Et, this.outputFormat = dt, this.part = 0;
}
parse(e) {
let t = 65536, n = 8192, r = 65537, i = 16384, a = i - 1, o = 65535, s = 2.7182818 ** 2.2, c = null;
function l(e, n) {
let r = 0;
for (let i = 0; i < t; ++i) (i == 0 || e[i >> 3] & 1 << (i & 7)) && (n[r++] = i);
let i = r - 1;
for (; r < t;) n[r++] = 0;
return i;
}
function u(e) {
for (let t = 0; t < i; t++) e[t] = {}, e[t].len = 0, e[t].lit = 0, e[t].p = null;
}
let d = {
l: 0,
c: 0,
lc: 0
};
function f(e, t, n, r, i) {
for (; n < e;) t = t << 8 | ve(r, i), n += 8;
n -= e, d.l = t >> n & (1 << e) - 1, d.c = t, d.lc = n;
}
let p = Array(59);
function m(e) {
for (let e = 0; e <= 58; ++e) p[e] = 0;
for (let t = 0; t < r; ++t) p[e[t]] += 1;
let t = 0;
for (let e = 58; e > 0; --e) {
let n = t + p[e] >> 1;
p[e] = t, t = n;
}
for (let t = 0; t < r; ++t) {
let n = e[t];
n > 0 && (e[t] = n | p[n]++ << 6);
}
}
function h(e, t, n, r, i, a) {
let o = t, s = 0, c = 0;
for (; r <= i; r++) {
if (o.value - t.value > n) return !1;
f(6, s, c, e, o);
let l = d.l;
if (s = d.c, c = d.lc, a[r] = l, l == 63) {
if (o.value - t.value > n) throw Error("THREE.EXRLoader: Something wrong with hufUnpackEncTable");
f(8, s, c, e, o);
let l = d.l + 6;
if (s = d.c, c = d.lc, r + l > i + 1) throw Error("THREE.EXRLoader: Something wrong with hufUnpackEncTable");
for (; l--;) a[r++] = 0;
r--;
} else if (l >= 59) {
let e = l - 59 + 2;
if (r + e > i + 1) throw Error("THREE.EXRLoader: Something wrong with hufUnpackEncTable");
for (; e--;) a[r++] = 0;
r--;
}
}
m(a);
}
function g(e) {
return e & 63;
}
function _(e) {
return e >> 6;
}
function v(e, t, n, r) {
for (; t <= n; t++) {
let n = _(e[t]), i = g(e[t]);
if (n >> i) throw Error("THREE.EXRLoader: Invalid table entry");
if (i > 14) {
let e = r[n >> i - 14];
if (e.len) throw Error("THREE.EXRLoader: Invalid table entry");
if (e.lit++, e.p) {
let t = e.p;
e.p = Array(e.lit);
for (let n = 0; n < e.lit - 1; ++n) e.p[n] = t[n];
} else e.p = [,];
e.p[e.lit - 1] = t;
} else if (i) {
let e = 0;
for (let a = 1 << 14 - i; a > 0; a--) {
let a = r[(n << 14 - i) + e];
if (a.len || a.p) throw Error("THREE.EXRLoader: Invalid table entry");
a.len = i, a.lit = t, e++;
}
}
}
return !0;
}
let y = {
c: 0,
lc: 0
};
function b(e, t, n, r) {
e = e << 8 | ve(n, r), t += 8, y.c = e, y.lc = t;
}
let x = {
c: 0,
lc: 0
};
function S(e, t, n, r, i, a, o, s, c) {
if (e == t) {
r < 8 && (b(n, r, i, a), n = y.c, r = y.lc), r -= 8;
let e = n >> r;
if (e = new Uint8Array([e])[0], s.value + e > c) return !1;
let t = o[s.value - 1];
for (; e-- > 0;) o[s.value++] = t;
} else if (s.value < c) o[s.value++] = e;
else return !1;
x.c = n, x.lc = r;
}
function C(e) {
return e & 65535;
}
function w(e) {
let t = C(e);
return t > 32767 ? t - 65536 : t;
}
let T = {
a: 0,
b: 0
};
function E(e, t) {
let n = w(e), r = w(t), i = n + (r & 1) + (r >> 1), a = i, o = i - r;
T.a = a, T.b = o;
}
function D(e, t) {
let n = C(e), r = C(t), i = n - (r >> 1) & o, a = r + i - 32768 & o;
T.a = a, T.b = i;
}
function O(e, t, n, r, i, a, o) {
let s = o < 16384, c = n > i ? i : n, l = 1, u, d;
for (; l <= c;) l <<= 1;
for (l >>= 1, u = l, l >>= 1; l >= 1;) {
d = 0;
let o = d + a * (i - u), c = a * l, f = a * u, p = r * l, m = r * u, h, g, _, v;
for (; d <= o; d += f) {
let i = d, a = d + r * (n - u);
for (; i <= a; i += m) {
let n = i + p, r = i + c, a = r + p;
s ? (E(e[i + t], e[r + t]), h = T.a, _ = T.b, E(e[n + t], e[a + t]), g = T.a, v = T.b, E(h, g), e[i + t] = T.a, e[n + t] = T.b, E(_, v), e[r + t] = T.a, e[a + t] = T.b) : (D(e[i + t], e[r + t]), h = T.a, _ = T.b, D(e[n + t], e[a + t]), g = T.a, v = T.b, D(h, g), e[i + t] = T.a, e[n + t] = T.b, D(_, v), e[r + t] = T.a, e[a + t] = T.b);
}
if (n & l) {
let n = i + c;
s ? E(e[i + t], e[n + t]) : D(e[i + t], e[n + t]), h = T.a, e[n + t] = T.b, e[i + t] = h;
}
}
if (i & l) {
let i = d, a = d + r * (n - u);
for (; i <= a; i += m) {
let n = i + p;
s ? E(e[i + t], e[n + t]) : D(e[i + t], e[n + t]), h = T.a, e[n + t] = T.b, e[i + t] = h;
}
}
u = l, l >>= 1;
}
return d;
}
function k(e, t, n, r, i, o, s, c, l) {
let u = 0, d = 0, f = s, p = Math.trunc(r.value + (i + 7) / 8);
for (; r.value < p;) for (b(u, d, n, r), u = y.c, d = y.lc; d >= 14;) {
let i = t[u >> d - 14 & a];
if (i.len) d -= i.len, S(i.lit, o, u, d, n, r, c, l, f), u = x.c, d = x.lc;
else {
if (!i.p) throw Error("THREE.EXRLoader: hufDecode issues");
let t;
for (t = 0; t < i.lit; t++) {
let a = g(e[i.p[t]]);
for (; d < a && r.value < p;) b(u, d, n, r), u = y.c, d = y.lc;
if (d >= a && _(e[i.p[t]]) == (u >> d - a & (1 << a) - 1)) {
d -= a, S(i.p[t], o, u, d, n, r, c, l, f), u = x.c, d = x.lc;
break;
}
}
if (t == i.lit) throw Error("THREE.EXRLoader: hufDecode issues");
}
}
let m = 8 - i & 7;
for (u >>= m, d -= m; d > 0;) {
let e = t[u << 14 - d & a];
if (e.len) d -= e.len, S(e.lit, o, u, d, n, r, c, l, f), u = x.c, d = x.lc;
else throw Error("THREE.EXRLoader: hufDecode issues");
}
return !0;
}
function A(e, t, n, a, o, s) {
let c = { value: 0 }, l = n.value, d = _e(t, n), f = _e(t, n);
n.value += 4;
let p = _e(t, n);
if (n.value += 4, d < 0 || d >= r || f < 0 || f >= r) throw Error("THREE.EXRLoader: Something wrong with HUF_ENCSIZE");
let m = Array(r), g = Array(i);
if (u(g), h(e, n, a - (n.value - l), d, f, m), p > 8 * (a - (n.value - l))) throw Error("THREE.EXRLoader: Something wrong with hufUncompress");
v(m, d, f, g), k(m, g, e, n, p, f, s, o, c);
}
function j(e, t, n) {
for (let r = 0; r < n; ++r) t[r] = e[t[r]];
}
function M(e) {
for (let t = 1; t < e.length; t++) e[t] = e[t - 1] + e[t] - 128;
}
function N(e, t) {
let n = 0, r = Math.floor((e.length + 1) / 2), i = 0, a = e.length - 1;
for (; !(i > a || (t[i++] = e[n++], i > a));) t[i++] = e[r++];
}
function P(e) {
let t = e.byteLength, n = [], r = 0, i = new DataView(e);
for (; t > 0;) {
let e = i.getInt8(r++);
if (e < 0) {
let a = -e;
t -= a + 1;
for (let e = 0; e < a; e++) n.push(i.getUint8(r++));
} else {
let a = e;
t -= 2;
let o = i.getUint8(r++);
for (let e = 0; e < a + 1; e++) n.push(o);
}
}
return n;
}
function ee(e, t, n, r, i, a) {
let o = new DataView(a.buffer), s = n[e.idx[0]].width, c = n[e.idx[0]].height, l = Math.floor(s / 8), u = Math.ceil(s / 8), d = Math.ceil(c / 8), f = s - (u - 1) * 8, p = c - (d - 1) * 8, m = { value: 0 }, h = [
,
,
,
], g = [
,
,
,
], _ = [
,
,
,
], v = [
,
,
,
], y = [
,
,
,
];
for (let n = 0; n < 3; ++n) y[n] = t[e.idx[n]], h[n] = n < 1 ? 0 : h[n - 1] + u * d, g[n] = /* @__PURE__ */ new Float32Array(64), _[n] = /* @__PURE__ */ new Uint16Array(64), v[n] = new Uint16Array(u * 64);
for (let t = 0; t < d; ++t) {
let a = 8;
t == d - 1 && (a = p);
let s = 8;
for (let e = 0; e < u; ++e) {
e == u - 1 && (s = f);
for (let e = 0; e < 3; ++e) _[e].fill(0), _[e][0] = i[h[e]++], ne(m, r, _[e]), re(_[e], g[e]), F(g[e]);
ie(g);
for (let t = 0; t < 3; ++t) ae(g[t], v[t], e * 64);
}
let c = 0;
for (let r = 0; r < 3; ++r) {
let i = n[e.idx[r]].type;
for (let e = 8 * t; e < 8 * t + a; ++e) {
c = y[r][e];
for (let t = 0; t < l; ++t) {
let n = t * 64 + (e & 7) * 8;
o.setUint16(c + 0 * i, v[r][n + 0], !0), o.setUint16(c + 2 * i, v[r][n + 1], !0), o.setUint16(c + 4 * i, v[r][n + 2], !0), o.setUint16(c + 6 * i, v[r][n + 3], !0), o.setUint16(c + 8 * i, v[r][n + 4], !0), o.setUint16(c + 10 * i, v[r][n + 5], !0), o.setUint16(c + 12 * i, v[r][n + 6], !0), o.setUint16(c + 14 * i, v[r][n + 7], !0), c += 16 * i;
}
}
if (l != u) for (let e = 8 * t; e < 8 * t + a; ++e) {
let t = y[r][e] + 8 * l * 2 * i, n = l * 64 + (e & 7) * 8;
for (let e = 0; e < s; ++e) o.setUint16(t + e * 2 * i, v[r][n + e], !0);
}
}
}
let b = new Uint16Array(s);
o = new DataView(a.buffer);
for (let t = 0; t < 3; ++t) {
n[e.idx[t]].decoded = !0;
let r = n[e.idx[t]].type;
if (n[t].type == 2) for (let e = 0; e < c; ++e) {
let n = y[t][e];
for (let e = 0; e < s; ++e) b[e] = o.getUint16(n + e * 2 * r, !0);
for (let e = 0; e < s; ++e) o.setFloat32(n + e * 2 * r, R(b[e]), !0);
}
}
}
function te(e, t, n, r, i, a) {
let o = new DataView(a.buffer), s = n[e], c = s.width, l = s.height, u = Math.ceil(c / 8), d = Math.ceil(l / 8), f = Math.floor(c / 8), p = c - (u - 1) * 8, m = l - (d - 1) * 8, h = { value: 0 }, g = 0, _ = /* @__PURE__ */ new Float32Array(64), v = /* @__PURE__ */ new Uint16Array(64), y = new Uint16Array(u * 64);
for (let n = 0; n < d; ++n) {
let a = 8;
n == d - 1 && (a = m);
for (let e = 0; e < u; ++e) v.fill(0), v[0] = i[g++], ne(h, r, v), re(v, _), F(_), ae(_, y, e * 64);
for (let r = 8 * n; r < 8 * n + a; ++r) {
let n = t[e][r];
for (let e = 0; e < f; ++e) {
let t = e * 64 + (r & 7) * 8;
for (let e = 0; e < 8; ++e) o.setUint16(n + e * 2 * s.type, y[t + e], !0);
n += 16 * s.type;
}
if (u != f) {
let e = f * 64 + (r & 7) * 8;
for (let t = 0; t < p; ++t) o.setUint16(n + t * 2 * s.type, y[e + t], !0);
}
}
}
s.decoded = !0;
}
function ne(e, t, n) {
let r, i = 1;
for (; i < 64;) r = t[e.value], r == 65280 ? i = 64 : r >> 8 == 255 ? i += r & 255 : (n[i] = r, i++), e.value++;
}
function re(e, t) {
t[0] = R(e[0]), t[1] = R(e[1]), t[2] = R(e[5]), t[3] = R(e[6]), t[4] = R(e[14]), t[5] = R(e[15]), t[6] = R(e[27]), t[7] = R(e[28]), t[8] = R(e[2]), t[9] = R(e[4]), t[10] = R(e[7]), t[11] = R(e[13]), t[12] = R(e[16]), t[13] = R(e[26]), t[14] = R(e[29]), t[15] = R(e[42]), t[16] = R(e[3]), t[17] = R(e[8]), t[18] = R(e[12]), t[19] = R(e[17]), t[20] = R(e[25]), t[21] = R(e[30]), t[22] = R(e[41]), t[23] = R(e[43]), t[24] = R(e[9]), t[25] = R(e[11]), t[26] = R(e[18]), t[27] = R(e[24]), t[28] = R(e[31]), t[29] = R(e[40]), t[30] = R(e[44]), t[31] = R(e[53]), t[32] = R(e[10]), t[33] = R(e[19]), t[34] = R(e[23]), t[35] = R(e[32]), t[36] = R(e[39]), t[37] = R(e[45]), t[38] = R(e[52]), t[39] = R(e[54]), t[40] = R(e[20]), t[41] = R(e[22]), t[42] = R(e[33]), t[43] = R(e[38]), t[44] = R(e[46]), t[45] = R(e[51]), t[46] = R(e[55]), t[47] = R(e[60]), t[48] = R(e[21]), t[49] = R(e[34]), t[50] = R(e[37]), t[51] = R(e[47]), t[52] = R(e[50]), t[53] = R(e[56]), t[54] = R(e[59]), t[55] = R(e[61]), t[56] = R(e[35]), t[57] = R(e[36]), t[58] = R(e[48]), t[59] = R(e[49]), t[60] = R(e[57]), t[61] = R(e[58]), t[62] = R(e[62]), t[63] = R(e[63]);
}
function F(e) {
let t = .5 * Math.cos(3.14159 / 4), n = .5 * Math.cos(3.14159 / 16), r = .5 * Math.cos(3.14159 / 8), i = .5 * Math.cos(3 * 3.14159 / 16), a = .5 * Math.cos(5 * 3.14159 / 16), o = .5 * Math.cos(3 * 3.14159 / 8), s = .5 * Math.cos(7 * 3.14159 / 16), c = [
,
,
,
,
], l = [
,
,
,
,
], u = [
,
,
,
,
], d = [
,
,
,
,
];
for (let f = 0; f < 8; ++f) {
let p = f * 8;
c[0] = r * e[p + 2], c[1] = o * e[p + 2], c[2] = r * e[p + 6], c[3] = o * e[p + 6], l[0] = n * e[p + 1] + i * e[p + 3] + a * e[p + 5] + s * e[p + 7], l[1] = i * e[p + 1] - s * e[p + 3] - n * e[p + 5] - a * e[p + 7], l[2] = a * e[p + 1] - n * e[p + 3] + s * e[p + 5] + i * e[p + 7], l[3] = s * e[p + 1] - a * e[p + 3] + i * e[p + 5] - n * e[p + 7], u[0] = t * (e[p + 0] + e[p + 4]), u[3] = t * (e[p + 0] - e[p + 4]), u[1] = c[0] + c[3], u[2] = c[1] - c[2], d[0] = u[0] + u[1], d[1] = u[3] + u[2], d[2] = u[3] - u[2], d[3] = u[0] - u[1], e[p + 0] = d[0] + l[0], e[p + 1] = d[1] + l[1], e[p + 2] = d[2] + l[2], e[p + 3] = d[3] + l[3], e[p + 4] = d[3] - l[3], e[p + 5] = d[2] - l[2], e[p + 6] = d[1] - l[1], e[p + 7] = d[0] - l[0];
}
for (let f = 0; f < 8; ++f) c[0] = r * e[16 + f], c[1] = o * e[16 + f], c[2] = r * e[48 + f], c[3] = o * e[48 + f], l[0] = n * e[8 + f] + i * e[24 + f] + a * e[40 + f] + s * e[56 + f], l[1] = i * e[8 + f] - s * e[24 + f] - n * e[40 + f] - a * e[56 + f], l[2] = a * e[8 + f] - n * e[24 + f] + s * e[40 + f] + i * e[56 + f], l[3] = s * e[8 + f] - a * e[24 + f] + i * e[40 + f] - n * e[56 + f], u[0] = t * (e[f] + e[32 + f]), u[3] = t * (e[f] - e[32 + f]), u[1] = c[0] + c[3], u[2] = c[1] - c[2], d[0] = u[0] + u[1], d[1] = u[3] + u[2], d[2] = u[3] - u[2], d[3] = u[0] - u[1], e[0 + f] = d[0] + l[0], e[8 + f] = d[1] + l[1], e[16 + f] = d[2] + l[2], e[24 + f] = d[3] + l[3], e[32 + f] = d[3] - l[3], e[40 + f] = d[2] - l[2], e[48 + f] = d[1] - l[1], e[56 + f] = d[0] - l[0];
}
function ie(e) {
for (let t = 0; t < 64; ++t) {
let n = e[0][t], r = e[1][t], i = e[2][t];
e[0][t] = n + 1.5747 * i, e[1][t] = n - .1873 * r - .4682 * i, e[2][t] = n + 1.8556 * r;
}
}
function ae(e, t, n) {
for (let r = 0; r < 64; ++r) t[n + r] = rn.toHalfFloat(oe(e[r]));
}
function oe(e) {
return e <= 1 ? Math.sign(e) * Math.abs(e) ** 2.2 : Math.sign(e) * s ** (Math.abs(e) - 1);
}
function se(e) {
return new DataView(e.array.buffer, e.offset.value, e.size);
}
function I(e) {
let t = e.viewer.buffer.slice(e.offset.value, e.offset.value + e.size), n = new Uint8Array(P(t)), r = new Uint8Array(n.length);
return M(n), N(n, r), new DataView(r.buffer);
}
function ce(e) {
let t = RO(e.array.slice(e.offset.value, e.offset.value + e.size)), n = new Uint8Array(t.length);
return M(t), N(t, n), new DataView(n.buffer);
}
function le(e) {
let r = e.viewer, i = { value: e.offset.value }, a = new Uint16Array(e.columns * e.lines * (e.inputChannels.length * e.type)), o = new Uint8Array(n), s = 0, c = Array(e.inputChannels.length);
for (let t = 0, n = e.inputChannels.length; t < n; t++) c[t] = {}, c[t].start = s, c[t].end = c[t].start, c[t].nx = e.columns, c[t].ny = e.lines, c[t].size = e.type, s += c[t].nx * c[t].ny * c[t].size;
let u = Ce(r, i), d = Ce(r, i);
if (d >= n) throw Error("THREE.EXRLoader: Something is wrong with PIZ_COMPRESSION BITMAP_SIZE");
if (u <= d) for (let e = 0; e < d - u + 1; e++) o[e + u] = ye(r, i);
let f = new Uint16Array(t), p = l(o, f), m = _e(r, i);
A(e.array, r, i, m, a, s);
for (let t = 0; t < e.inputChannels.length; ++t) {
let e = c[t];
for (let n = 0; n < c[t].size; ++n) O(a, e.start + n, e.nx, e.size, e.ny, e.nx * e.size, p);
}
j(f, a, s);
let h = 0, g = new Uint8Array(a.buffer.byteLength);
for (let t = 0; t < e.lines; t++) for (let t = 0; t < e.inputChannels.length; t++) {
let e = c[t], n = e.nx * e.size, r = new Uint8Array(a.buffer, e.end * 2, n * 2);
g.set(r, h), h += n * 2, e.end += n;
}
return new DataView(g.buffer);
}
function ue(e) {
let t = RO(e.array.slice(e.offset.value, e.offset.value + e.size)), n = e.inputChannels.length * e.lines * e.columns * e.totalBytes, r = new ArrayBuffer(n), i = new DataView(r), a = 0, o = 0, s = [
,
,
,
,
];
for (let n = 0; n < e.lines; n++) for (let n = 0; n < e.inputChannels.length; n++) {
let r = 0;
switch (e.inputChannels[n].pixelType) {
case 1:
s[0] = a, s[1] = s[0] + e.columns, a = s[1] + e.columns;
for (let n = 0; n < e.columns; ++n) {
let e = t[s[0]++] << 8 | t[s[1]++];
r += e, i.setUint16(o, r, !0), o += 2;
}
break;
case 2:
s[0] = a, s[1] = s[0] + e.columns, s[2] = s[1] + e.columns, a = s[2] + e.columns;
for (let n = 0; n < e.columns; ++n) {
let e = t[s[0]++] << 24 | t[s[1]++] << 16 | t[s[2]++] << 8;
r += e, i.setUint32(o, r, !0), o += 4;
}
break;
}
}
return i;
}
function L(e) {
let t = e.array, n = e.offset.value, r = e.columns, i = e.lines, a = e.inputChannels, o = e.totalBytes, s = qe.compression === "B44A_COMPRESSION", l = new Uint8Array(i * r * o), u = /* @__PURE__ */ new Uint16Array(16), d = 0;
for (let e = 0; e < a.length; e++) {
let f = a[e], p = f.pixelType * 2, m = Math.ceil(r / f.xSampling), h = Math.ceil(i / f.ySampling), g = f.xSampling === 1 && f.ySampling === 1;
if (f.pixelType !== 1) {
for (let e = 0; e < h; e++) if (g) {
let i = e * r * o + d * r;
for (let e = 0; e < m * p; e++) l[i + e] = t[n++];
} else n += m * p;
d += p;
continue;
}
let _ = Math.ceil(m / 4), v = Math.ceil(h / 4);
for (let e = 0; e < v; e++) for (let a = 0; a < _; a++) {
if (s && t[n + 2] >= 52) {
let e = t[n] << 8 | t[n + 1], r = e & 32768 ? e & 32767 : ~e & 65535;
u.fill(r), n += 3;
} else {
let e = t[n] << 8 | t[n + 1], r = t[n + 2] >> 2, i = 32 << r, a = e + ((t[n + 2] << 4 | t[n + 3] >> 4) & 63) * (1 << r) - i & 65535, o = a + ((t[n + 3] << 2 | t[n + 4] >> 6) & 63) * (1 << r) - i & 65535, s = o + (t[n + 4] & 63) * (1 << r) - i & 65535, c = e + (t[n + 5] >> 2 & 63) * (1 << r) - i & 65535, l = a + ((t[n + 5] << 4 | t[n + 6] >> 4) & 63) * (1 << r) - i & 65535, d = o + ((t[n + 6] << 2 | t[n + 7] >> 6) & 63) * (1 << r) - i & 65535, f = s + (t[n + 7] & 63) * (1 << r) - i & 65535, p = c + (t[n + 8] >> 2 & 63) * (1 << r) - i & 65535, m = l + ((t[n + 8] << 4 | t[n + 9] >> 4) & 63) * (1 << r) - i & 65535, h = d + ((t[n + 9] << 2 | t[n + 10] >> 6) & 63) * (1 << r) - i & 65535, g = f + (t[n + 10] & 63) * (1 << r) - i & 65535, _ = [
e,
c,
p,
p + (t[n + 11] >> 2 & 63) * (1 << r) - i & 65535,
a,
l,
m,
m + ((t[n + 11] << 4 | t[n + 12] >> 4) & 63) * (1 << r) - i & 65535,
o,
d,
h,
h + ((t[n + 12] << 2 | t[n + 13] >> 6) & 63) * (1 << r) - i & 65535,
s,
f,
g,
g + (t[n + 13] & 63) * (1 << r) - i & 65535
];
for (let e = 0; e < 16; e++) u[e] = _[e] & 32768 ? _[e] & 32767 : ~_[e] & 65535;
n += 14;
}
if (f.pLinear) {
if (c === null) {
c = /* @__PURE__ */ new Uint16Array(65536);
for (let e = 0; e < 65536; e++) if ((e & 31744) == 31744 || e > 32768) c[e] = 0;
else {
let t = R(e);
c[e] = t <= 0 ? 0 : rn.toHalfFloat(8 * Math.log(t));
}
}
for (let e = 0; e < 16; e++) u[e] = c[u[e]];
}
for (let t = 0; t < 4; t++) {
let n = e * 4 + t;
if (!(n >= h)) for (let e = 0; e < 4; e++) {
let s = a * 4 + e;
if (s >= m) continue;
let c = u[t * 4 + e];
for (let e = 0; e < f.ySampling; e++) {
let t = n * f.ySampling + e;
if (!(t >= i)) for (let e = 0; e < f.xSampling; e++) {
let n = s * f.xSampling + e;
if (n >= r) continue;
let i = t * r * o + d * r + n * 2;
l[i] = c & 255, l[i + 1] = c >> 8 & 255;
}
}
}
}
}
d += 2;
}
return new DataView(l.buffer);
}
function de(e) {
let t = e.viewer, n = { value: e.offset.value }, r = new Uint8Array(e.columns * e.lines * (e.inputChannels.length * e.type * 2)), i = {
version: be(t, n),
unknownUncompressedSize: be(t, n),
unknownCompressedSize: be(t, n),
acCompressedSize: be(t, n),
dcCompressedSize: be(t, n),
rleCompressedSize: be(t, n),
rleUncompressedSize: be(t, n),
rleRawSize: be(t, n),
totalAcUncompressedCount: be(t, n),
totalDcUncompressedCount: be(t, n),
acCompression: be(t, n)
};
if (i.version < 2) throw Error("THREE.EXRLoader: " + qe.compression + " version " + i.version + " is unsupported");
let a = [], o = Ce(t, n) - 2;
for (; o > 0;) {
let e = fe(t.buffer, n), r = ye(t, n), i = r >> 2 & 3, s = (r >> 4) - 1, c = new Int8Array([s])[0], l = ye(t, n);
a.push({
name: e,
index: c,
type: l,
compression: i
}), o -= e.length + 3;
}
let s = qe.channels, c = Array(e.inputChannels.length);
for (let t = 0; t < e.inputChannels.length; ++t) {
let n = c[t] = {}, r = s[t];
n.name = r.name, n.compression = 0, n.decoded = !1, n.type = r.pixelType, n.pLinear = r.pLinear, n.width = e.columns, n.height = e.lines;
}
let l = { idx: [
,
,
,
] };
for (let t = 0; t < e.inputChannels.length; ++t) {
let e = c[t], n = e.name.lastIndexOf("."), r = n >= 0 ? e.name.substring(n + 1) : e.name;
for (let n = 0; n < a.length; ++n) {
let i = a[n];
r === i.name && e.type === i.type && (e.compression = i.compression, i.index >= 0 && (l.idx[i.index] = t), e.offset = t);
}
}
let u, d, f;
if (i.acCompressedSize > 0) switch (i.acCompression) {
case 0:
u = new Uint16Array(i.totalAcUncompressedCount), A(e.array, t, n, i.acCompressedSize, u, i.totalAcUncompressedCount);
break;
case 1:
let r = RO(e.array.slice(n.value, n.value + i.totalAcUncompressedCount));
u = new Uint16Array(r.buffer), n.value += i.totalAcUncompressedCount;
break;
}
if (i.dcCompressedSize > 0) {
let t = {
array: e.array,
offset: n,
size: i.dcCompressedSize
};
d = new Uint16Array(ce(t).buffer), n.value += i.dcCompressedSize;
}
i.rleRawSize > 0 && (f = P(RO(e.array.slice(n.value, n.value + i.rleCompressedSize)).buffer), n.value += i.rleCompressedSize);
let p = 0, m = Array(c.length);
for (let e = 0; e < m.length; ++e) m[e] = [];
for (let t = 0; t < e.lines; ++t) for (let t = 0; t < c.length; ++t) m[t].push(p), p += c[t].width * e.type * 2;
l.idx[0] !== void 0 && c[l.idx[0]] && ee(l, m, c, u, d, r);
for (let t = 0; t < c.length; ++t) {
let n = c[t];
if (!n.decoded) switch (n.compression) {
case 2:
let i = 0, a = 0;
for (let o = 0; o < e.lines; ++o) {
let e = m[t][i];
for (let t = 0; t < n.width; ++t) {
for (let t = 0; t < 2 * n.type; ++t) r[e++] = f[a + t * n.width * n.height];
a++;
}
i++;
}
break;
case 1:
te(t, m, c, u, d, r);
break;
default: throw Error("THREE.EXRLoader: unsupported channel compression");
}
}
return new DataView(r.buffer);
}
function fe(e, t) {
let n = new Uint8Array(e), r = 0;
for (; n[t.value + r] != 0;) r += 1;
let i = new TextDecoder().decode(n.slice(t.value, t.value + r));
return t.value = t.value + r + 1, i;
}
function pe(e, t, n) {
let r = new TextDecoder().decode(new Uint8Array(e).slice(t.value, t.value + n));
return t.value += n, r;
}
function me(e, t) {
return [ge(e, t), _e(e, t)];
}
function he(e, t) {
return [_e(e, t), _e(e, t)];
}
function ge(e, t) {
let n = e.getInt32(t.value, !0);
return t.value += 4, n;
}
function _e(e, t) {
let n = e.getUint32(t.value, !0);
return t.value += 4, n;
}
function ve(e, t) {
let n = e[t.value];
return t.value += 1, n;
}
function ye(e, t) {
let n = e.getUint8(t.value);
return t.value += 1, n;
}
let be = function(e, t) {
let n = Number(e.getBigInt64(t.value, !0));
return t.value += 8, n;
};
function xe(e, t) {
let n = e.getFloat32(t.value, !0);
return t.value += 4, n;
}
function Se(e, t) {
return rn.toHalfFloat(xe(e, t));
}
function R(e) {
let t = (e & 31744) >> 10, n = e & 1023;
return (e >> 15 ? -1 : 1) * (t ? t === 31 ? n ? NaN : Infinity : 2 ** (t - 15) * (1 + n / 1024) : n / 1024 * 6103515625e-14);
}
function Ce(e, t) {
let n = e.getUint16(t.value, !0);
return t.value += 2, n;
}
function we(e, t) {
return R(Ce(e, t));
}
function z(e, t, n, r) {
let i = n.value, a = [];
for (; n.value < i + r - 1;) {
let r = fe(t, n), i = ge(e, n), o = ye(e, n);
n.value += 3;
let s = ge(e, n), c = ge(e, n);
a.push({
name: r,
pixelType: i,
pLinear: o,
xSampling: s,
ySampling: c
});
}
return n.value += 1, a;
}
function Te(e, t) {
return {
redX: xe(e, t),
redY: xe(e, t),
greenX: xe(e, t),
greenY: xe(e, t),
blueX: xe(e, t),
blueY: xe(e, t),
whiteX: xe(e, t),
whiteY: xe(e, t)
};
}
function Ee(e, t) {
return [
"NO_COMPRESSION",
"RLE_COMPRESSION",
"ZIPS_COMPRESSION",
"ZIP_COMPRESSION",
"PIZ_COMPRESSION",
"PXR24_COMPRESSION",
"B44_COMPRESSION",
"B44A_COMPRESSION",
"DWAA_COMPRESSION",
"DWAB_COMPRESSION"
][ye(e, t)];
}
function B(e, t) {
return {
xMin: ge(e, t),
yMin: ge(e, t),
xMax: ge(e, t),
yMax: ge(e, t)
};
}
function De(e, t) {
return [
"INCREASING_Y",
"DECREASING_Y",
"RANDOM_Y"
][ye(e, t)];
}
function Oe(e, t) {
return ["ENVMAP_LATLONG", "ENVMAP_CUBE"][ye(e, t)];
}
function V(e, t) {
let n = [
"ONE_LEVEL",
"MIPMAP_LEVELS",
"RIPMAP_LEVELS"
], r = ["ROUND_DOWN", "ROUND_UP"], i = _e(e, t), a = _e(e, t), o = ye(e, t);
return {
xSize: i,
ySize: a,
levelMode: n[o & 15],
roundingMode: r[o >> 4]
};
}
function ke(e, t) {
return [xe(e, t), xe(e, t)];
}
function Ae(e, t) {
return [
xe(e, t),
xe(e, t),
xe(e, t)
];
}
function je(e, t, n, r, i) {
if (r === "string" || r === "stringvector" || r === "iccProfile") return pe(t, n, i);
if (r === "chlist") return z(e, t, n, i);
if (r === "chromaticities") return Te(e, n);
if (r === "compression") return Ee(e, n);
if (r === "box2i") return B(e, n);
if (r === "envmap") return Oe(e, n);
if (r === "tiledesc") return V(e, n);
if (r === "lineOrder") return De(e, n);
if (r === "float") return xe(e, n);
if (r === "v2f") return ke(e, n);
if (r === "v3f") return Ae(e, n);
if (r === "int") return ge(e, n);
if (r === "rational") return me(e, n);
if (r === "timecode") return he(e, n);
if (r === "preview" || r === "deepImageState" || r === "idmanifest") return n.value += i, "skipped";
n.value += i;
}
function Me(e, t) {
let n = Math.log2(e);
return t == "ROUND_DOWN" ? Math.floor(n) : Math.ceil(n);
}
function Ne(e, t, n) {
let r = 0;
switch (e.levelMode) {
case "ONE_LEVEL":
r = 1;
break;
case "MIPMAP_LEVELS":
r = Me(Math.max(t, n), e.roundingMode) + 1;
break;
case "RIPMAP_LEVELS": throw Error("THREE.EXRLoader: RIPMAP_LEVELS tiles currently unsupported.");
}
return r;
}
function Pe(e, t, n, r) {
let i = Array(e);
for (let a = 0; a < e; a++) {
let e = 1 << a, o = t / e | 0;
r == "ROUND_UP" && o * e < t && (o += 1), i[a] = (Math.max(o, 1) + n - 1) / n | 0;
}
return i;
}
function Fe() {
let e = this, t = e.offset, n = { value: 0 };
for (let r = 0; r < e.tileCount; r++) {
let r = ge(e.viewer, t), i = ge(e.viewer, t);
t.value += 8, e.size = _e(e.viewer, t);
let a = r * e.blockWidth, o = i * e.blockHeight;
e.columns = a + e.blockWidth > e.width ? e.width - a : e.blockWidth, e.lines = o + e.blockHeight > e.height ? e.height - o : e.blockHeight;
let s = e.columns * e.totalBytes, c = e.size < e.lines * s ? e.uncompress(e) : se(e);
t.value += e.size;
for (let t = 0; t < e.lines; t++) {
let r = t * e.columns * e.totalBytes;
for (let i = 0; i < e.inputChannels.length; i++) {
let s = qe.channels[i].name, l = e.channelByteOffsets[s] * e.columns, u = e.decodeChannels[s];
if (u === void 0) continue;
n.value = r + l;
let d = (e.height - (1 + o + t)) * e.outLineWidth;
for (let t = 0; t < e.columns; t++) {
let r = d + (t + a) * e.outputChannels + u;
e.byteArray[r] = e.getter(c, n);
}
}
}
}
}
function Ie() {
let e = this, t = e.offset, n = { value: 0 };
for (let r = 0; r < e.height / e.blockHeight; r++) {
let r = ge(e.viewer, t) - qe.dataWindow.yMin;
e.size = _e(e.viewer, t), e.lines = r + e.blockHeight > e.height ? e.height - r : e.blockHeight;
let i = e.columns * e.totalBytes, a = e.size < e.lines * i ? e.uncompress(e) : se(e);
t.value += e.size;
for (let t = 0; t < e.lines; t++) {
let o = r + t, s = t * i, c = (e.height - 1 - o) * e.outLineWidth;
for (let t = 0; t < e.inputChannels.length; t++) {
let r = qe.channels[t].name, i = e.channelByteOffsets[r] * e.columns, o = e.decodeChannels[r];
if (o !== void 0) {
n.value = s + i;
for (let t = 0; t < e.columns; t++) {
let r = c + t * e.outputChannels + o;
e.byteArray[r] = e.getter(a, n);
}
}
}
}
}
}
function Le() {
let e = this, t = e.chunkOffsets, n = { value: 0 };
for (let r = 0; r < t.length; r++) {
let i = { value: t[r] };
i.value += 4;
let a = ge(e.viewer, i) - qe.dataWindow.yMin;
e.size = _e(e.viewer, i), e.lines = a + e.blockHeight > e.height ? e.height - a : e.blockHeight;
let o = e.columns * e.totalBytes, s = e.size < e.lines * o, c = e.offset;
e.offset = i;
let l = s ? e.uncompress(e) : se(e);
e.offset = c;
for (let t = 0; t < e.lines; t++) {
let r = a + t, i = t * o, s = (e.height - 1 - r) * e.outLineWidth;
for (let t = 0; t < e.inputChannels.length; t++) {
let r = qe.channels[t].name, a = e.channelByteOffsets[r] * e.columns, o = e.decodeChannels[r];
if (o !== void 0) {
n.value = i + a;
for (let t = 0; t < e.columns; t++) {
let r = s + t * e.outputChannels + o;
e.byteArray[r] = e.getter(l, n);
}
}
}
}
}
}
function Re(e, t, n, r) {
if (n === 0) return null;
let i = e.slice(t, t + n);
switch (r) {
case "NO_COMPRESSION": return new DataView(i.buffer, i.byteOffset, i.byteLength);
case "RLE_COMPRESSION": {
let e = new Uint8Array(P(i.buffer.slice(i.byteOffset, i.byteOffset + i.byteLength))), t = new Uint8Array(e.length);
return M(e), N(e, t), new DataView(t.buffer);
}
case "ZIPS_COMPRESSION": {
let e = RO(i), t = new Uint8Array(e.length);
return M(e), N(e, t), new DataView(t.buffer);
}
default: throw Error("THREE.EXRLoader: " + r + " is unsupported for deep data");
}
}
function ze() {
let e = this, t = e.chunkOffsets, n = e.width, r = e.height, i = e.deepChannels, a = qe.compression, o = e.multiPart, s = e.decodeChannels, c = e.outputChannels, l = e.byteArray instanceof Uint16Array, u = -1;
for (let e = 0; e < i.length; e++) if (i[e].name === "A") {
u = e;
break;
}
for (let d = 0; d < t.length; d++) {
let f = { value: t[d] };
o && (f.value += 4);
let p = ge(e.viewer, f) - qe.dataWindow.yMin, m = be(e.viewer, f), h = be(e.viewer, f);
be(e.viewer, f);
let g = Re(e.array, f.value, m, a);
if (f.value += m, g === null) continue;
let _ = new Uint32Array(n);
for (let e = 0; e < n; e++) _[e] = g.getUint32(e * 4, !0);
let v = _[n - 1];
if (v === 0) {
f.value += h;
continue;
}
let y = Re(e.array, f.value, h, a), b = [], x = 0;
for (let e = 0; e < i.length; e++) b.push(x), x += v * i[e].bytesPerSample;
let S = (r - 1 - p) * e.outLineWidth;
for (let t = 0; t < n; t++) {
let n = t === 0 ? 0 : _[t - 1], r = _[t] - n;
if (r === 0) continue;
let a = new Float32Array(c), o = 0;
for (let e = 0; e < r; e++) {
let t = n + e, r = 1 - o;
if (r <= 0) break;
let c = 1;
if (u >= 0) {
let e = i[u].bytesPerSample, n = b[u] + t * e;
c = e === 2 ? R(y.getUint16(n, !0)) : y.getFloat32(n, !0);
}
for (let e = 0; e < i.length; e++) {
let n = i[e], o = s[n.name];
if (o === void 0) continue;
let c = n.bytesPerSample, l = b[e] + t * c, u = c === 2 ? R(y.getUint16(l, !0)) : y.getFloat32(l, !0);
a[o] += u * r;
}
o += c * r;
}
s.A !== void 0 && (a[s.A] = o);
let d = S + t * c;
for (let t = 0; t < c; t++) e.byteArray[d + t] = l ? rn.toHalfFloat(a[t]) : a[t];
}
}
}
function Be(e, t, n) {
let r = {}, i = !1;
for (;;) {
let a = fe(t, n);
if (a === "") break;
i = !0;
let o = fe(t, n), s = je(e, t, n, o, _e(e, n));
s === void 0 ? console.warn(`THREE.EXRLoader: Skipped unknown header attribute type \'${o}\'.`) : r[a] = s;
}
return i ? r : null;
}
function Ve(e, t, n) {
if (e.getUint32(0, !0) != 20000630) throw Error("THREE.EXRLoader: Provided file doesn't appear to be in OpenEXR format.");
let r = e.getUint8(4), i = e.getUint8(5), a = {
singleTile: !!(i & 2),
longName: !!(i & 4),
deepFormat: !!(i & 8),
multiPart: !!(i & 16)
};
n.value = 8;
let o = [];
if (a.multiPart) {
for (;;) {
let i = Be(e, t, n);
if (i === null) break;
i.version = r, i.spec = a, o.push(i);
}
if (o.length === 0) throw Error("THREE.EXRLoader: No valid part headers found.");
} else {
let i = Be(e, t, n);
i.version = r, i.spec = a, o.push(i);
}
return o;
}
function H(e, t, n, r, i, a) {
let o = {
size: 0,
viewer: t,
array: n,
offset: r,
width: e.dataWindow.xMax - e.dataWindow.xMin + 1,
height: e.dataWindow.yMax - e.dataWindow.yMin + 1,
inputChannels: e.channels,
channelByteOffsets: {},
shouldExpand: !1,
yCbCr: !1,
totalBytes: null,
columns: null,
lines: null,
type: null,
uncompress: null,
getter: null,
format: null,
colorSpace: vt
};
switch (e.compression) {
case "NO_COMPRESSION":
o.blockHeight = 1, o.uncompress = se;
break;
case "RLE_COMPRESSION":
o.blockHeight = 1, o.uncompress = I;
break;
case "ZIPS_COMPRESSION":
o.blockHeight = 1, o.uncompress = ce;
break;
case "ZIP_COMPRESSION":
o.blockHeight = 16, o.uncompress = ce;
break;
case "PIZ_COMPRESSION":
o.blockHeight = 32, o.uncompress = le;
break;
case "PXR24_COMPRESSION":
o.blockHeight = 16, o.uncompress = ue;
break;
case "B44_COMPRESSION":
case "B44A_COMPRESSION":
o.blockHeight = 32, o.uncompress = L;
break;
case "DWAA_COMPRESSION":
o.blockHeight = 32, o.uncompress = de;
break;
case "DWAB_COMPRESSION":
o.blockHeight = 256, o.uncompress = de;
break;
default: throw Error("THREE.EXRLoader: " + e.compression + " is unsupported");
}
let s = {};
for (let t of e.channels) switch (t.name) {
case "BY":
case "RY":
case "Y":
case "R":
case "G":
case "B":
case "A": s[t.name] = !0, o.type = t.pixelType;
}
let c = !1, l = !1;
if (s.Y && s.RY && s.BY) o.outputChannels = 4, o.yCbCr = !0;
else if (s.R && s.G && s.B) o.outputChannels = 4;
else if (s.Y) o.outputChannels = 1;
else throw Error("THREE.EXRLoader: file contains unsupported data channels.");
switch (o.outputChannels) {
case 4:
a == 1023 ? (c = !s.A, o.format = dt, o.colorSpace = vt, o.outputChannels = 4, o.decodeChannels = {
R: 0,
G: 1,
B: 2,
A: 3
}) : a == 1030 ? (o.format = rt, o.colorSpace = vt, o.outputChannels = 2, o.decodeChannels = {
R: 0,
G: 1
}) : a == 1028 ? (o.format = ft, o.colorSpace = vt, o.outputChannels = 1, o.decodeChannels = { R: 0 }) : l = !0;
break;
case 1:
a == 1023 ? (c = !0, o.format = dt, o.colorSpace = vt, o.outputChannels = 4, o.shouldExpand = !0, o.decodeChannels = { Y: 0 }) : a == 1030 ? (o.format = rt, o.colorSpace = vt, o.outputChannels = 2, o.shouldExpand = !0, o.decodeChannels = { Y: 0 }) : a == 1028 ? (o.format = ft, o.colorSpace = vt, o.outputChannels = 1, o.decodeChannels = { Y: 0 }) : l = !0;
break;
default: l = !0;
}
if (l) throw Error("THREE.EXRLoader: invalid output format for specified file.");
if (o.yCbCr && (o.format = dt, o.outputChannels = 4, o.decodeChannels = {
Y: 0,
RY: 1,
BY: 2
}, c = !0), o.type == 1) switch (i) {
case pt:
o.getter = we;
break;
case Et:
o.getter = Ce;
break;
}
else if (o.type == 2) switch (i) {
case pt:
o.getter = xe;
break;
case Et: o.getter = Se;
}
else throw Error("THREE.EXRLoader: unsupported pixelType " + o.type + " for " + e.compression + ".");
o.columns = o.width;
let u = o.width * o.height * o.outputChannels;
switch (i) {
case pt:
o.byteArray = new Float32Array(u), c && o.byteArray.fill(1, 0, u);
break;
case Et:
o.byteArray = new Uint16Array(u), c && o.byteArray.fill(15360, 0, u);
break;
default:
console.error("THREE.EXRLoader: unsupported type: ", i);
break;
}
let d = 0;
for (let t of e.channels) o.decodeChannels[t.name] !== void 0 && (o.channelByteOffsets[t.name] = d), d += t.pixelType * 2;
if (o.totalBytes = d, o.outLineWidth = o.width * o.outputChannels, e.spec.deepFormat) {
o.deepChannels = [];
let t = 0;
for (let n of e.channels) {
let e = n.pixelType === 0 ? 4 : n.pixelType * 2;
o.deepChannels.push({
name: n.name,
pixelType: n.pixelType,
bytesPerSample: e
}), t += e;
}
o.deepBytesPerSample = t, o.chunkOffsets = e._chunkOffsets, o.multiPart = e.spec.multiPart, o.decode = ze.bind(o);
} else if (e.spec.singleTile) {
o.blockHeight = e.tiles.ySize, o.blockWidth = e.tiles.xSize;
let n = Ne(e.tiles, o.width, o.height), i = Pe(n, o.width, e.tiles.xSize, e.tiles.roundingMode), a = Pe(n, o.height, e.tiles.ySize, e.tiles.roundingMode);
o.tileCount = i[0] * a[0];
for (let e = 0; e < n; e++) for (let n = 0; n < a[e]; n++) for (let n = 0; n < i[e]; n++) be(t, r);
o.decode = Fe.bind(o);
} else if (e.spec.multiPart) o.blockWidth = o.width, o.chunkOffsets = e._chunkOffsets, o.decode = Le.bind(o);
else {
o.blockWidth = o.width;
let e = Math.ceil(o.height / o.blockHeight);
for (let n = 0; n < e; n++) be(t, r);
o.decode = Ie.bind(o);
}
return o;
}
let He = { value: 0 }, Ue = new DataView(e), We = new Uint8Array(e), Ge = Ve(Ue, e, He), Ke = Math.max(0, Math.min(this.part, Ge.length - 1)), qe = Ge[Ke];
if (qe.spec.multiPart || qe.spec.deepFormat) for (let e = 0; e < Ge.length; e++) {
let t = Ge[e].chunkCount;
if (e === Ke) {
qe._chunkOffsets = [];
for (let e = 0; e < t; e++) qe._chunkOffsets.push(be(Ue, He));
} else for (let e = 0; e < t; e++) be(Ue, He);
}
let Je = H(qe, Ue, We, He, this.type, this.outputFormat);
if (Je.decode(), Je.shouldExpand) {
let e = Je.byteArray;
if (this.outputFormat == 1023) for (let t = 0; t < e.length; t += 4) e[t + 2] = e[t + 1] = e[t];
else if (this.outputFormat == 1030) for (let t = 0; t < e.length; t += 2) e[t + 1] = e[t];
}
if (Je.yCbCr) {
let e = Je.byteArray, t = Je.width * Je.height;
if (this.type === 1016) for (let n = 0; n < t; n++) {
let t = n * 4, r = R(e[t]), i = R(e[t + 1]), a = R(e[t + 2]), o = (1 + i) * r, s = (1 + a) * r, c = (r - o * .2126 - s * .0722) / .7152;
e[t] = rn.toHalfFloat(Math.max(0, o)), e[t + 1] = rn.toHalfFloat(Math.max(0, c)), e[t + 2] = rn.toHalfFloat(Math.max(0, s));
}
else for (let n = 0; n < t; n++) {
let t = n * 4, r = e[t], i = e[t + 1], a = e[t + 2], o = (1 + i) * r, s = (1 + a) * r;
e[t] = Math.max(0, o), e[t + 1] = Math.max(0, (r - o * .2126 - s * .0722) / .7152), e[t + 2] = Math.max(0, s);
}
}
return {
header: qe,
width: Je.width,
height: Je.height,
data: Je.byteArray,
format: Je.format,
colorSpace: Je.colorSpace,
type: this.type,
minFilter: tt,
magFilter: tt,
generateMipmaps: !1,
flipY: !1
};
}
setDataType(e) {
return this.type = e, this;
}
setOutputFormat(e) {
return this.outputFormat = e, this;
}
setPart(e) {
return this.part = e, this;
}
}, VO = "/forest.exr";
//#endregion
//#region ../renderer/src/objects/lighting/studio-environment.ts
async function HO(e, t) {
let { data: n, width: r, height: i, up: a, wall: o } = await KO(t), s = new Ut(n, r, i, dt, pt);
s.mapping = 303, s.colorSpace = vt, s.minFilter = tt, s.magFilter = tt, s.generateMipmaps = !1, s.needsUpdate = !0;
let c = new te(e), l = c.fromEquirectangular(s).texture;
return s.dispose(), c.dispose(), {
texture: l,
up: a,
wall: o
};
}
function UO(e) {
let t = !1;
return e.traverseVisible((e) => {
t || !e.isMesh || (t = [].concat(e.material).some((e) => e.isMeshStandardMaterial || e.isMeshLambertMaterial));
}), t;
}
function WO(e, t, n) {
rk.extractRotation(e.matrixInverse).premultiply(UC), ik.makeRotationY(wn(t)), rk.premultiply(ik).transpose(), n.setFromRotationMatrix(rk);
}
function GO(e, t) {
e.userData[XO] = t;
}
function KO(e) {
let t = $O.get(e);
return t || (t = qO(e), t.catch(() => $O.delete(e)), $O.set(e, t)), t;
}
async function qO(e) {
let { data: t, width: n, height: r } = (await new BO().setDataType(pt).loadAsync(e)).image, i = YO(t, n, r), a = JO(i, ek.set(0, 1, 0), new gt()), o = new gt(0, 0, 0);
for (let e = 0; e < QO; e++) {
let t = e / QO * Math.PI * 2;
JO(i, ek.set(Math.cos(t), 0, Math.sin(t)), tk), o.add(tk.multiplyScalar(1 / QO));
}
return {
data: t,
width: n,
height: r,
up: a,
wall: o
};
}
function JO(e, t, n) {
return e.getIrradianceAt(t, nk), n.setRGB(nk.x, nk.y, nk.z).multiplyScalar(1 / Math.PI);
}
function YO(e, t, n) {
let r = new un(), i = Array(9).fill(0), a = 2 * Math.PI / t * (Math.PI / n);
for (let o = 0; o < n; o++) {
let s = ((o + .5) / n - .5) * Math.PI, c = Math.cos(s) * a;
for (let n = 0; n < t; n++) {
let a = ((n + .5) / t - .5) * Math.PI * 2;
ek.set(Math.cos(s) * Math.cos(a), Math.sin(s), Math.cos(s) * Math.sin(a)), un.getBasisAt(ek, i);
let l = (o * t + n) * 4;
tk.setRGB(e[l], e[l + 1], e[l + 2]);
for (let e = 0; e < 9; e++) r.coefficients[e].x += tk.r * i[e] * c, r.coefficients[e].y += tk.g * i[e] * c, r.coefficients[e].z += tk.b * i[e] * c;
}
}
return r;
}
var XO = "efpEnvironmentPending", ZO = VO, QO = 16, $O = /* @__PURE__ */ new Map(), ek = new U(), tk = new gt(), nk = new U(), rk = new W(), ik = new W();
//#endregion
//#region ../renderer/src/objects/lighting/sun-shadow-map.ts
function ak(e, t) {
let n = wn(e.sunShadow.headingDegrees), r = wn(e.sunShadow.elevationDegrees);
t.set(Math.cos(r) * Math.cos(n), -Math.cos(r) * Math.sin(n), Math.sin(r));
}
function ok(e) {
let t = e.gl;
t.shadowMap.enabled = !0, t.shadowMap.type = 1;
let n = t.shadowMap;
if (n.__efpDepthRange) return;
n.__efpDepthRange = !0;
let r = t.getContext(), i = n.render.bind(n);
n.render = (e, t, n) => {
if (!e.some((e) => {
var t;
return e.castShadow && ((t = e.shadow) == null ? void 0 : t.needsUpdate);
})) {
i(e, t, n);
return;
}
let a = r.getParameter(r.DEPTH_RANGE);
r.depthRange(0, 1), i(e, t, n), r.depthRange(a[0], a[1]);
};
}
function sk(e, t, n, r, i) {
e.shadow.autoUpdate = !1;
let a = lk(e, t), o = a !== Sk;
if (o) {
if (Sk = a, !uk(e, n, r)) {
e.shadow.needsUpdate = !0;
return;
}
} else if (Ek.isEmpty()) return;
let s = dk(e, n, i, o);
s !== void 0 && fk(e, s);
}
function ck(e) {
let t = !1;
return e.traverseVisible((e) => {
!t && e.isMesh && e.castShadow && (t = !0);
}), t;
}
function lk(e, t) {
let n = `${e.position.x},${e.position.y},${e.position.z}`;
return Ck.length = 0, t.traverseVisible((e) => {
let t = e;
!t.isMesh || !t.castShadow || (Ck.push(t), n += `|${t.id}:${t.matrixWorld.elements.join(",")}:${mk(t)}`);
}), n;
}
function uk(e, t, n) {
Ek.makeEmpty();
for (let e of Ck) {
var r, i;
let t = e;
(r = t.computeBoundingBox) == null || r.call(t);
let n = (i = t.boundingBox) == null ? e.geometry.boundingBox : i;
n && Ek.union(Dk.copy(n).applyMatrix4(e.matrixWorld));
}
if (Ek.isEmpty()) return !1;
Ok.copy(Ek).applyMatrix4(t.matrixInverse), Ok.getCenter(Ak), Ok.getSize(jk), n.position.set(Ak.x, Ak.y, _k), n.scale.set(jk.x * 1.2, jk.y * 1.2, 1);
let a = e.shadow.camera;
e.updateWorldMatrix(!0, !1), e.target.updateWorldMatrix(!0, !1), a.position.setFromMatrixPosition(e.matrixWorld), a.lookAt(kk.setFromMatrixPosition(e.target.matrixWorld)), a.updateMatrixWorld(), wk[0] = Infinity, wk[1] = -Infinity;
for (let e = 0; e < 8; e++) hk(Ek, e, Ak).applyMatrix4(a.matrixWorldInverse), wk[0] = Math.min(wk[0], Ak.z), wk[1] = Math.max(wk[1], Ak.z);
return !0;
}
function dk(e, t, n, r) {
let i = e.shadow.camera.matrixWorldInverse, a = pk(n, t, xk, Ok, Ak), o = a.x, s = a.y, c = 0;
for (let e = 0; e < 4; e++) {
let r = pk(n, t, e, Ok, Ak);
c = Math.max(c, Math.hypot(r.x - o, r.y - s));
}
let l = Uo(Ok.max.z, 0, c);
jk.set(o, s, 0).applyMatrix4(t.matrix).applyMatrix4(i);
let u = jk.x, d = jk.y, f = 0;
for (let e = 0; e < 4; e++) {
let r = pk(n, t, e, Ok, Ak);
for (let e of [0, l]) jk.set(r.x, r.y, e).applyMatrix4(t.matrix).applyMatrix4(i), f = Math.max(f, Math.hypot(jk.x - u, jk.y - d));
}
let p = 2 ** (Math.ceil(Math.log2(Math.max(f, 1e-30)) * 4) / 4);
if (Math.hypot(u - Tk[0], d - Tk[1]) + p <= Tk[2] && p * yk >= Tk[2] / bk && !r) return;
let m = p * bk, h = 2 * m / gk;
return Tk[0] = Math.round(u / h) * h, Tk[1] = Math.round(d / h) * h, Tk[2] = m, h;
}
function fk(e, t) {
let n = e.shadow.camera, [r, i, a] = Tk, [o, s] = wk, c = (s - o) * .01 + t;
n.left = r - a, n.right = r + a, n.bottom = i - a, n.top = i + a, n.near = -s - c, n.far = -o + c, n.updateProjectionMatrix(), e.shadow.normalBias = t * 1.5, e.shadow.bias = -t / (n.far - n.near), e.shadow.needsUpdate = !0;
}
function pk(e, t, n, r, i) {
let a = n === xk ? 0 : n & 1 ? 1 : -1, o = n === xk ? 0 : n & 2 ? 1 : -1;
Mk.set(a, o, -1).unproject(e).applyMatrix4(t.matrixInverse), Nk.set(a, o, 1).unproject(e).applyMatrix4(t.matrixInverse);
let s = Nk.z - Mk.z, c = Math.abs(s) > 1e-12 ? -Mk.z / s : -1;
return c >= 0 && c <= 1 ? i.lerpVectors(Mk, Nk, c) : i.copy(Nk), i.x = Uo(i.x, r.min.x, r.max.x), i.y = Uo(i.y, r.min.y, r.max.y), i;
}
function mk(e) {
var t, n;
let r = e;
if (r.instancesCount === void 0 || !r.getVisibleAt) return "";
let i = 0;
for (let e = 0; e < r.instancesCount; e++) r.getVisibleAt(e) && (i = i * 31 + e + 1 | 0);
return `${r.instancesCount}/${i}/${(t = (n = r.matricesTexture) == null ? void 0 : n.version) == null ? 0 : t}`;
}
function hk(e, t, n) {
return n.set(t & 1 ? e.max.x : e.min.x, t & 2 ? e.max.y : e.min.y, t & 4 ? e.max.z : e.min.z);
}
var gk = 4096, _k = -.5, vk = 1e6, yk = Math.SQRT2, bk = 1.25, xk = -1, Sk = "", Ck = [], wk = [0, 0], Tk = [
NaN,
NaN,
NaN
], Ek = new ze(), Dk = new ze(), Ok = new ze(), kk = new U(), Ak = new U(), jk = new U(), Mk = new U(), Nk = new U(), Pk = $c("lighting");
function Fk(e) {
let t = (0, Z.c)(68), { contrast: n, skyColor: r, groundColor: i, directionalColor: a, shadowColor: o, modelOpacity: s } = e, c;
if (t[0] !== e.environment) {
var l;
c = (l = e.environment) == null ? {} : l, t[0] = e.environment, t[1] = c;
} else c = t[1];
let { share: u, rotationDegrees: d } = c, f;
if (t[2] !== e.sunShadow) {
var p;
f = (p = e.sunShadow) == null ? {} : p, t[2] = e.sunShadow, t[3] = f;
} else f = t[3];
let { enabled: m, headingDegrees: h, elevationDegrees: g, strength: _ } = f, v;
if (t[4] !== e.contactShadow) {
var y;
v = (y = e.contactShadow) == null ? {} : y, t[4] = e.contactShadow, t[5] = v;
} else v = t[5];
let { enabled: b, distance: x, strength: S } = v, C;
if (t[6] !== e.ambientOcclusion) {
var w;
C = (w = e.ambientOcclusion) == null ? {} : w, t[6] = e.ambientOcclusion, t[7] = C;
} else C = t[7];
let { enabled: T, radius: E, strength: D } = C, O = (0, G.useRef)(null), k = (0, G.useRef)(null), A = (0, G.useRef)(null), j = al(), M = Tg(), N = I(Rk), [P] = (0, G.useState)(zk), ee;
t[8] === Symbol.for("react.memo_cache_sentinel") ? (ee = {
sky: "",
ground: "",
directional: ""
}, t[8] = ee) : ee = t[8];
let te = (0, G.useRef)(ee), ne = (0, G.useRef)(null), re = (0, G.useRef)(null), F = I(Lk), [ie, ae] = (0, G.useState)(null), oe, se;
t[9] === Symbol.for("react.memo_cache_sentinel") ? (oe = () => {
k.current.target = A.current, re.current.target = A.current;
}, se = [], t[9] = oe, t[10] = se) : (oe = t[9], se = t[10]), (0, G.useLayoutEffect)(oe, se);
let [ce, le] = (0, G.useState)(!1), L;
t[11] !== F || t[12] !== ce ? (L = () => {
if (!ce) return;
let e = !1, t = null;
return GO(F().scene, !0), HO(F().gl, ZO).then((n) => {
if (e) {
n.texture.dispose();
return;
}
t = n, ae(n);
}, (e) => {
GO(F().scene, !1), Pk.warn("failed to load the studio HDRI: %O", e);
}), () => {
e = !0;
let { scene: n } = F();
GO(n, !1), n.environment && n.environment === (t == null ? void 0 : t.texture) && (n.environment = null), t == null || t.texture.dispose();
};
}, t[11] = F, t[12] = ce, t[13] = L) : L = t[13];
let de;
t[14] !== F || t[15] !== N || t[16] !== ce ? (de = [
F,
N,
ce
], t[14] = F, t[15] = N, t[16] = ce, t[17] = de) : de = t[17], (0, G.useEffect)(L, de);
let fe, pe;
t[18] !== N || t[19] !== ie ? (pe = () => {
ie && N();
}, fe = [ie, N], t[18] = N, t[19] = ie, t[20] = fe, t[21] = pe) : (fe = t[20], pe = t[21]), (0, G.useEffect)(pe, fe);
let me, he;
t[22] === F ? (me = t[23], he = t[24]) : (me = () => {
ok(F());
}, he = [F], t[22] = F, t[23] = me, t[24] = he), (0, G.useEffect)(me, he);
let ge;
t[25] !== F || t[26] !== P.sunShadow.enabled || t[27] !== j ? (ge = () => {
let { scene: e } = F(), t = e.onBeforeRender;
return e.onBeforeRender = (n, r, i, ...a) => {
let o = a;
t.call(e, n, r, i, ...o);
let s = re.current;
if (!s) return;
let c = P.sunShadow.enabled && ck(e);
s.castShadow = c, ne.current.visible = c, c && (sk(s, e, j, ne.current, i), s.shadow.updateMatrices(s), iA.copy(i.matrixWorldInverse).invert(), Og.value.multiplyMatrices(s.shadow.matrix, iA));
}, () => {
e.onBeforeRender = t;
};
}, t[25] = F, t[26] = P.sunShadow.enabled, t[27] = j, t[28] = ge) : ge = t[28];
let _e;
t[29] !== F || t[30] !== P || t[31] !== j ? (_e = [
F,
j,
P
], t[29] = F, t[30] = P, t[31] = j, t[32] = _e) : _e = t[32], (0, G.useEffect)(ge, _e);
let ve, ye;
t[33] !== x || t[34] !== b || t[35] !== S || t[36] !== n || t[37] !== a || t[38] !== M || t[39] !== d || t[40] !== u || t[41] !== i || t[42] !== N || t[43] !== s || t[44] !== T || t[45] !== E || t[46] !== D || t[47] !== P || t[48] !== o || t[49] !== r || t[50] !== g || t[51] !== m || t[52] !== h || t[53] !== _ ? (ve = () => {
Bk(P, {
contrast: n,
skyColor: r,
groundColor: i,
directionalColor: a,
environment: {
share: u,
rotationDegrees: d
},
sunShadow: {
enabled: m,
headingDegrees: h,
elevationDegrees: g,
strength: _
}
}), Vk(M, {
shadowColor: o,
contactShadow: {
enabled: b,
distance: x,
strength: S
},
ambientOcclusion: {
enabled: T,
radius: E,
strength: D
}
}), s !== void 0 && dS(s), N();
}, ye = [
P,
M,
N,
n,
r,
i,
a,
u,
d,
m,
h,
g,
_,
o,
s,
b,
x,
S,
T,
E,
D
], t[33] = x, t[34] = b, t[35] = S, t[36] = n, t[37] = a, t[38] = M, t[39] = d, t[40] = u, t[41] = i, t[42] = N, t[43] = s, t[44] = T, t[45] = E, t[46] = D, t[47] = P, t[48] = o, t[49] = r, t[50] = g, t[51] = m, t[52] = h, t[53] = _, t[54] = ve, t[55] = ye) : (ve = t[54], ye = t[55]), (0, G.useEffect)(ve, ye), nO(P);
let be;
t[56] !== M || t[57] !== P || t[58] !== j || t[59] !== ie || t[60] !== ce ? (be = (e) => {
var t, n;
let r = O.current, i = k.current, a = e.scene;
!ce && UO(a) && (GO(a, !0), le(!0)), Hk(e.camera, j, P, i.position), r.position.setFromMatrixColumn(j.matrix, 2).normalize().applyMatrix4(j.matrixInverse), Uk(r.color, P.skyColor, te.current, "sky"), Uk(r.groundColor, P.groundColor, te.current, "ground"), Uk(i.color, P.directionalColor, te.current, "directional");
let o = Math.acos(Uo(i.position.z, -1, 1)), s = Uo(P.contrast, 0, 1), c = ie ? Uo(P.environment.share, 0, 1) : 0, l = ie ? c / rA(ie.up) : 0, u = {
intensity: l,
up: (t = ie == null ? void 0 : ie.up) == null ? Xk : t,
wall: (n = ie == null ? void 0 : ie.wall) == null ? Xk : n
}, { hemisphereIntensity: d, directionalIntensity: f } = Gk(s, o, r.color, r.groundColor, i.color, u);
r.intensity = d * Math.PI, i.intensity = f * Math.PI;
let p = ie && c > 0 ? ie.texture : null;
a.environment !== p && (a.environment = p), ie && GO(a, !1), a.environmentIntensity = l, WO(j, P.environment.rotationDegrees, a.environmentRotation);
let m = re.current;
if (Dg.value = 0, P.sunShadow.enabled) {
m.shadow.radius = 2, m.shadow.mapSize.set(gk, gk), ak(P, m.position), ne.current.material.color.copy(M.shadowColor.value);
let e = Uo(P.sunShadow.strength, 0, 1);
ne.current.material.opacity = e, Dg.value = e / Math.max(Math.sin(wn(P.sunShadow.elevationDegrees)), .05);
}
}, t[56] = M, t[57] = P, t[58] = j, t[59] = ie, t[60] = ce, t[61] = be) : be = t[61], ue(be);
let xe, Se, R, Ce;
t[62] === Symbol.for("react.memo_cache_sentinel") ? (xe = /* @__PURE__ */ (0, K.jsx)("hemisphereLight", {
ref: O,
color: Jk.skyColor,
groundColor: Jk.groundColor,
intensity: tA.hemisphereIntensity * Math.PI
}), Se = /* @__PURE__ */ (0, K.jsx)("directionalLight", {
ref: k,
color: Jk.directionalColor,
intensity: tA.directionalIntensity * Math.PI
}), R = /* @__PURE__ */ (0, K.jsx)("object3D", { ref: A }), Ce = /* @__PURE__ */ (0, K.jsx)("directionalLight", {
ref: re,
intensity: 0
}), t[62] = xe, t[63] = Se, t[64] = R, t[65] = Ce) : (xe = t[62], Se = t[63], R = t[64], Ce = t[65]);
let we;
t[66] === Symbol.for("react.memo_cache_sentinel") ? (we = [
0,
0,
_k
], t[66] = we) : we = t[66];
let z;
return t[67] === Symbol.for("react.memo_cache_sentinel") ? (z = /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [
xe,
Se,
R,
Ce,
/* @__PURE__ */ (0, K.jsxs)("mesh", {
ref: ne,
position: we,
receiveShadow: !0,
renderOrder: vk,
raycast: Ik,
visible: !1,
children: [/* @__PURE__ */ (0, K.jsx)("planeGeometry", { args: [1, 1] }), /* @__PURE__ */ (0, K.jsx)("shadowMaterial", {
color: "#000000",
depthWrite: !1,
onBeforeCompile: jg
})]
})
] }), t[67] = z) : z = t[67], z;
}
function Ik() {
return null;
}
function Lk(e) {
return e.get;
}
function Rk(e) {
return e.invalidate;
}
function zk() {
return {
...Jk,
environment: { ...Jk.environment },
sunShadow: { ...Jk.sunShadow }
};
}
function Bk(e, t) {
var n, r;
t.contrast !== void 0 && (e.contrast = t.contrast), t.skyColor !== void 0 && (e.skyColor = t.skyColor), t.groundColor !== void 0 && (e.groundColor = t.groundColor), t.directionalColor !== void 0 && (e.directionalColor = t.directionalColor);
let i = (n = t.environment) == null ? {} : n;
i.share !== void 0 && (e.environment.share = i.share), i.rotationDegrees !== void 0 && (e.environment.rotationDegrees = i.rotationDegrees);
let a = (r = t.sunShadow) == null ? {} : r;
a.enabled !== void 0 && (e.sunShadow.enabled = a.enabled), a.headingDegrees !== void 0 && (e.sunShadow.headingDegrees = a.headingDegrees), a.elevationDegrees !== void 0 && (e.sunShadow.elevationDegrees = a.elevationDegrees), a.strength !== void 0 && (e.sunShadow.strength = a.strength);
}
function Vk(e, t) {
var n, r;
t.shadowColor !== void 0 && (e.shadowHex = t.shadowColor, e.shadowColor.value.set(t.shadowColor));
let i = (n = t.contactShadow) == null ? {} : n;
i.enabled !== void 0 && (e.contactEnabled = i.enabled), i.distance !== void 0 && (e.shadowDistance.value = i.distance), i.strength !== void 0 && (e.contactStrength = i.strength), lg(e);
let a = (r = t.ambientOcclusion) == null ? {} : r;
a.enabled !== void 0 && (e.enabled = a.enabled), a.radius !== void 0 && (e.radius = a.radius), a.strength !== void 0 && (e.aoStrength.value = a.strength);
}
function Hk(e, t, n, r) {
if (n.trackPitch) return r.setFromMatrixColumn(e.matrixWorld, 2).transformDirection(t.matrixInverse);
let i = nA.setFromMatrixColumn(e.matrixWorld, 1).transformDirection(t.matrixInverse), a = wn(n.pitchDegrees);
return r.set(-i.x, -i.y, 0).normalize().multiplyScalar(Math.sin(a)).setZ(Math.cos(a));
}
function Uk(e, t, n, r) {
n[r] !== t && (e.set(t), n[r] = t);
}
function Wk(e, t, n, r, i = Zk) {
let a = Math.cos(e), o = Infinity;
for (let e of Yk) {
let t = Math.max(1 - i.intensity * i.up[e], 0);
o = Math.min(o, t / Math.max(r[e] * a, eA));
}
if (qk(o, e, t, n, r, i) < 1) return o;
let s = 0, c = o;
for (let a = 0; a < Qk; a++) {
let a = (s + c) / 2;
qk(a, e, t, n, r, i) < 1 ? s = a : c = a;
}
return (s + c) / 2;
}
function Gk(e, t, n, r, i, a = Zk) {
let o = e * Wk(t, n, r, i, a);
return {
hemisphereIntensity: Kk(o, t, n, i, a),
directionalIntensity: o
};
}
function Kk(e, t, n, r, i = Zk) {
let a = Math.cos(t), o = Infinity;
for (let t of Yk) {
let s = Math.max(n[t], $k);
o = Math.min(o, (1 - e * r[t] * a - i.intensity * i.up[t]) / s);
}
return Math.max(o, 0);
}
function qk(e, t, n, r, i, a = Zk) {
let o = Kk(e, t, n, i, a), s = Math.sin(t), c = -Infinity;
for (let t of Yk) {
let l = (r[t] + n[t]) / 2;
c = Math.max(c, o * l + e * i[t] * s + a.intensity * a.wall[t]);
}
return c;
}
var Jk = {
trackPitch: !1,
pitchDegrees: 38,
contrast: .3,
skyColor: "#ffffff",
groundColor: "#b9c1cc",
directionalColor: "#fff3e6",
environment: {
share: .5,
rotationDegrees: 180
},
sunShadow: {
enabled: !0,
headingDegrees: -55,
elevationDegrees: 48,
strength: .3
}
}, Yk = [
"r",
"g",
"b"
], Xk = new gt(0, 0, 0), Zk = {
intensity: 0,
up: Xk,
wall: Xk
}, Qk = 20, $k = 1e-6, eA = 1e-6, tA = Gk(Jk.contrast, wn(Jk.pitchDegrees), new gt(Jk.skyColor), new gt(Jk.groundColor), new gt(Jk.directionalColor)), nA = new U();
function rA(e) {
return Math.max(e.r, e.g, e.b, eA);
}
var iA = new W(), aA = $c("occlusion"), oA = class {
constructor() {
this.depthTarget = null, this.aoTarget = null, this.blurTarget = null, this.targetSize = new V(), this.unavailable = !1;
}
get depth() {
return this.depthTarget;
}
get ao() {
return this.aoTarget;
}
get blur() {
return this.blurTarget;
}
get size() {
return this.targetSize;
}
get held() {
return this.depthTarget !== null;
}
dispose() {
this.release();
}
sync(e) {
if (this.unavailable) return !1;
let t = e.getSize(dA), n = Math.floor(t.x * cA), r = Math.floor(t.y * cA);
return n < 1 || r < 1 ? !1 : this.depthTarget && this.targetSize.x === n && this.targetSize.y === r ? !0 : this.build(e, n, r);
}
allocate(e, t, n) {
this.depthTarget = new It(e, t, {
...uA,
depthBuffer: !0,
depthTexture: new Pt(e, t, n)
}), this.aoTarget = new It(e, t, {
...uA,
depthBuffer: !1
}), this.blurTarget = new It(e, t, { depthBuffer: !1 }), this.blurTarget.texture = this.depthTarget.texture, this.targetSize.set(e, t);
}
build(e, t, n) {
this.release();
for (let r of lA) {
if (this.allocate(t, n, r), this.verify(e)) return !0;
this.release();
}
return aA.debug("ambient occlusion off: this context gives no complete render targets"), this.unavailable = !0, !1;
}
release() {
var e, t, n, r;
(e = this.depthTarget) == null || e.dispose(), (t = this.aoTarget) == null || t.dispose(), (n = this.blurTarget) == null || n.dispose(), (r = this.depthTarget) == null || (r = r.depthTexture) == null || r.dispose(), this.depthTarget = null, this.aoTarget = null, this.blurTarget = null, this.targetSize.set(0, 0);
}
verify(e) {
let t = sA(e);
if (!t) return !1;
let n = e.getRenderTarget();
try {
let n = !0;
for (let r of [this.depthTarget, this.blurTarget]) e.setRenderTarget(r), t.checkFramebufferStatus(t.FRAMEBUFFER) !== t.FRAMEBUFFER_COMPLETE && (n = !1);
return n;
} catch {
return !1;
} finally {
e.setRenderTarget(n);
}
}
};
function sA(e) {
let t = e.getContext();
if (typeof WebGL2RenderingContext == "function") return t instanceof WebGL2RenderingContext ? t : void 0;
}
var cA = .5, lA = [Tt, ct], uA = {
format: ft,
type: Ke,
minFilter: Gt,
magFilter: Gt
}, dA = new V();
//#endregion
//#region ../renderer/src/objects/lighting/OcclusionPasses.tsx
function fA() {
let e = (0, Z.c)(14), t = Tg(), n = al(), [r] = (0, G.useState)(mA), [i] = (0, G.useState)(pA), a;
e[0] === t ? a = e[1] : (a = () => hA("occlusion-blur", Fh, Nh(t)), e[0] = t, e[1] = a);
let [o] = (0, G.useState)(a), s, c;
e[2] !== i || e[3] !== o || e[4] !== t || e[5] !== r ? (s = () => () => {
r.dispose(), i.uniforms.uNoise.value.dispose(), yA(i), yA(o), xA(t);
}, c = [
i,
o,
t,
r
], e[2] = i, e[3] = o, e[4] = t, e[5] = r, e[6] = s, e[7] = c) : (s = e[6], c = e[7]), (0, G.useEffect)(s, c);
let l;
return e[8] !== i || e[9] !== o || e[10] !== t || e[11] !== r || e[12] !== n ? (l = (e) => {
if (xA(t), !t.enabled || t.occluders.size === 0) {
r.held && r.dispose();
return;
}
r.sync(e.gl) && (gA(e.gl, e.scene, e.camera, r, i, o, t.aoGuard.value, t.radius * n.scale, t.taps), bA(t, r, e.gl));
}, e[8] = i, e[9] = o, e[10] = t, e[11] = r, e[12] = n, e[13] = l) : l = e[13], ue(l), null;
}
function pA() {
return hA("occlusion-ao", Eh, xh());
}
function mA() {
return new oA();
}
function hA(e, t, n) {
let r = new ke({
uniforms: n,
vertexShader: Th,
fragmentShader: t,
depthTest: !1,
depthWrite: !1,
blending: 0
}), i = new Yt(new Fe(2, 2), r);
i.name = e, i.frustumCulled = !1;
let a = new lt();
return a.add(i), {
scene: a,
material: r,
quad: i,
uniforms: n
};
}
function gA(e, t, n, r, i, a, o, s, c) {
let l = r.depth, u = r.ao, d = r.blur;
if (!(l != null && l.depthTexture) || !u || !d) return;
let f = 1 / (1 + o);
i.uniforms.uProjection.value.copy(n.projectionMatrix).premultiply(TA.makeScale(f, f, 1)), i.uniforms.uUnprojection.value.copy(i.uniforms.uProjection.value).invert(), i.uniforms.uDepth.value = l.depthTexture, i.uniforms.uRadius.value = s, i.uniforms.uTaps.value = c, i.uniforms.uTexel.value.set(1 / r.size.x, 1 / r.size.y), i.uniforms.uNoiseScale.value.set(r.size.x / 4, r.size.y / 4), a.uniforms.uOcclusion.value = u.texture, a.uniforms.uDepth.value = l.depthTexture, a.uniforms.uTexel.value.copy(i.uniforms.uTexel.value), _A(e, t, n, l, i.uniforms);
let p = e.getRenderTarget();
try {
vA(e, u, i.scene, n), vA(e, d, a.scene, n);
} finally {
e.setRenderTarget(p);
}
}
function _A(e, t, n, r, i) {
let a = e.getRenderTarget(), o = n.layers.mask, s = t.overrideMaterial, c = CA.copy(n.projectionMatrix), l = wA.copy(n.projectionMatrixInverse);
n.layers.set(1), t.overrideMaterial = SA, n.projectionMatrix.copy(i.uProjection.value), n.projectionMatrixInverse.copy(i.uUnprojection.value), e.setRenderTarget(r);
try {
e.clear(!1, !0, !1), e.render(t, n);
} finally {
n.projectionMatrix.copy(c), n.projectionMatrixInverse.copy(l), t.overrideMaterial = s, n.layers.mask = o, e.setRenderTarget(a);
}
}
function vA(e, t, n, r) {
e.setRenderTarget(t), e.render(n, r);
}
function yA(e) {
e.material.dispose(), e.quad.geometry.dispose();
}
function bA(e, t, n) {
let r = t.depth, i = t.blur;
!(r != null && r.depthTexture) || !i || (e.aoMap.value = i.texture, e.aoDepth.value = r.depthTexture, n.getDrawingBufferSize(e.aoViewport.value), e.aoActive.value = 1);
}
function xA(e) {
e.aoActive.value = 0, e.aoMap.value = null, e.aoDepth.value = null;
}
var SA = new Mt({
side: 2,
colorWrite: !1,
depthWrite: !0,
depthTest: !0,
blending: 0,
polygonOffset: !1,
toneMapped: !1
}), CA = new W(), wA = new W(), TA = new W();
//#endregion
//#region ../renderer/src/space/Camera.tsx
function EA(e) {
var t, n, r, i;
let a = (0, Z.c)(67), o = (t = e.minZoom) == null ? FA : t, s = (n = e.maxZoom) == null ? IA : n, c = (r = e.minPitch) == null ? LA : r, l = (i = e.maxPitch) == null ? RA : i, u = e.bounds, d = e.smoothTime, f = e.children, p = I(kA), m = I(OA), h = I(DA), g = Tf(), _ = al(), { width: v, height: y, dpr: b } = xf(), x = y * b, S = (0, G.useRef)(1), C;
a[0] !== g || a[1] !== p ? (C = () => jA(g, p().camera), a[0] = g, a[1] = p, a[2] = C) : C = a[2];
let w;
a[3] !== x || a[4] !== C ? (w = vf(x, C), a[3] = x, a[4] = C, a[5] = w) : w = a[5];
let T = w, E;
a[6] !== g || a[7] !== p ? (E = () => {
let e = p().camera;
tl(e) && (e.fov = bf, e.up.set(0, 0, -1), e.updateProjectionMatrix(), g == null || g.updateCameraUp());
}, a[6] = g, a[7] = p, a[8] = E) : E = a[8];
let D;
a[9] !== h || a[10] !== g || a[11] !== p ? (D = [
h,
g,
p
], a[9] = h, a[10] = g, a[11] = p, a[12] = D) : D = a[12], (0, G.useLayoutEffect)(E, D);
let O, k;
a[13] !== g || a[14] !== d ? (O = () => {
g && PA(g, d);
}, k = [g, d], a[13] = g, a[14] = d, a[15] = O, a[16] = k) : (O = a[15], k = a[16]), (0, G.useLayoutEffect)(O, k);
let A;
a[17] !== u || a[18] !== g || a[19] !== m || a[20] !== _ ? (A = () => {
g && (NA(g, u, _), m());
}, a[17] = u, a[18] = g, a[19] = m, a[20] = _, a[21] = A) : A = a[21];
let j;
a[22] !== u || a[23] !== g || a[24] !== b || a[25] !== y || a[26] !== m || a[27] !== _ || a[28] !== v ? (j = [
u,
g,
b,
y,
m,
_,
v
], a[22] = u, a[23] = g, a[24] = b, a[25] = y, a[26] = m, a[27] = _, a[28] = v, a[29] = j) : j = a[29], (0, G.useEffect)(A, j);
let M, N;
a[30] !== g || a[31] !== l || a[32] !== c ? (M = () => {
g && AA(g, c, l);
}, N = [
g,
l,
c
], a[30] = g, a[31] = l, a[32] = c, a[33] = M, a[34] = N) : (M = a[33], N = a[34]), (0, G.useLayoutEffect)(M, N);
let P;
a[35] !== x || a[36] !== g || a[37] !== p || a[38] !== T || a[39] !== m || a[40] !== s || a[41] !== o ? (P = () => {
let e = p().camera;
if (!tl(e)) return;
let t = yf(x, bf);
if (t <= 0) return;
let n = T.zoomFactorToDistance(S.current), r = t / o, i = t / s;
e.far = Gp(r), e.updateProjectionMatrix(), g ? (MA(g, i, r), g.dollyTo(n, !1)) : (e.position.set(0, 0, -n), e.updateMatrixWorld()), m();
}, a[35] = x, a[36] = g, a[37] = p, a[38] = T, a[39] = m, a[40] = s, a[41] = o, a[42] = P) : P = a[42];
let ee;
a[43] !== x || a[44] !== h || a[45] !== g || a[46] !== p || a[47] !== T || a[48] !== m || a[49] !== s || a[50] !== o ? (ee = [
x,
h,
g,
p,
T,
m,
s,
o
], a[43] = x, a[44] = h, a[45] = g, a[46] = p, a[47] = T, a[48] = m, a[49] = s, a[50] = o, a[51] = ee) : ee = a[51], (0, G.useLayoutEffect)(P, ee);
let te;
a[52] !== g || a[53] !== p || a[54] !== T ? (te = () => {
if (!tl(p().camera) || !g) return;
let e = function() {
S.current = T.distanceToZoomFactor(g.distance);
};
return g.addEventListener("update", e), () => g.removeEventListener("update", e);
}, a[52] = g, a[53] = p, a[54] = T, a[55] = te) : te = a[55];
let ne;
a[56] !== h || a[57] !== g || a[58] !== p || a[59] !== T ? (ne = [
h,
g,
p,
T
], a[56] = h, a[57] = g, a[58] = p, a[59] = T, a[60] = ne) : ne = a[60], (0, G.useEffect)(te, ne);
let re;
a[61] !== g || a[62] !== _ ? (re = (e) => {
let t = e.camera;
if (!tl(t)) return;
let n = Wp(jA(g, e.camera), _.scale);
n === void 0 || t.near === n || (t.near = n, t.updateProjectionMatrix());
}, a[61] = g, a[62] = _, a[63] = re) : re = a[63], ue(re);
let F;
return a[64] !== f || a[65] !== T ? (F = /* @__PURE__ */ (0, K.jsx)(gf, {
value: T,
children: f
}), a[64] = f, a[65] = T, a[66] = F) : F = a[66], F;
}
function DA(e) {
return e.camera.uuid;
}
function OA(e) {
return e.invalidate;
}
function kA(e) {
return e.get;
}
function AA(e, t, n) {
e.minPolarAngle = wn(t), e.maxPolarAngle = wn(Math.min(n, 85)), e.polarAngle < e.minPolarAngle ? e.rotatePolarTo(e.minPolarAngle, !1) : e.polarAngle > e.maxPolarAngle && e.rotatePolarTo(e.maxPolarAngle, !1);
}
function jA(e, t) {
var n;
return (n = e == null ? void 0 : e.distance) == null ? Math.abs(t.position.z) : n;
}
function MA(e, t, n) {
e.minDistance = t, e.maxDistance = n;
}
function NA(e, t, n) {
if (!t) {
e.setBoundary(void 0);
return;
}
let r = n.planToWorld({
...t.min,
z: 0
}, VA), i = n.planToWorld({
...t.max,
z: 0
}, HA);
e.setBoundary(BA.set(r, i));
}
function PA(e, t) {
var n, r, i, a;
e.smoothTime = {
dolly: (n = t == null ? void 0 : t.zoomTime) == null ? zA : n,
truck: (r = t == null ? void 0 : t.panTime) == null ? zA : r,
rotateAzimuth: (i = t == null ? void 0 : t.rollTime) == null ? zA : i,
rotatePolar: (a = t == null ? void 0 : t.pitchTime) == null ? zA : a
};
}
var FA = .1, IA = 35, LA = 0, RA = 85, zA = .25, BA = new ze(), VA = new U(), HA = new U();
//#endregion
//#region ../renderer/src/space/VisibleRect.tsx
function UA(e) {
let t = (0, Z.c)(16), { rect: n, viewbox: r } = e, i = I(GA), a = I(WA), o = Tf(), { width: s, height: c, dpr: l } = xf(), u;
t[0] !== l || t[1] !== c || t[2] !== n || t[3] !== r || t[4] !== s ? (u = KA(n, r, s, c, l), t[0] = l, t[1] = c, t[2] = n, t[3] = r, t[4] = s, t[5] = u) : u = t[5];
let d = u, f = n.center.x, p = n.center.y, m, h;
return t[6] !== a || t[7] !== f || t[8] !== p || t[9] !== o || t[10] !== c || t[11] !== i || t[12] !== d || t[13] !== s ? (m = () => {
if (tl(a) && !(s <= 0 || c <= 0) && !(d === 1 && f === s / 2 && p === c / 2)) return qA(a, o, d, f, p, s, c), i(), () => {
a.clearViewOffset(), o == null || o.setViewport(null, 0, 0, 0), i();
};
}, h = [
d,
f,
p,
s,
c,
a,
o,
i
], t[6] = a, t[7] = f, t[8] = p, t[9] = o, t[10] = c, t[11] = i, t[12] = d, t[13] = s, t[14] = m, t[15] = h) : (m = t[14], h = t[15]), (0, G.useLayoutEffect)(m, h), null;
}
function WA(e) {
return e.camera;
}
function GA(e) {
return e.invalidate;
}
function KA(e, t, n, r, i) {
let a = sl(t, n * i, r * i), o = t.size.width * a, s = t.size.height * a;
return !(o > 0) || !(s > 0) ? 1 : Math.min(e.size.width * i / o, e.size.height * i / s, 1);
}
function qA(e, t, n, r, i, a, o) {
let s = n * a, c = n * o;
e.setViewOffset(s, c, s / 2 - r, c / 2 - i, a, o), t == null || t.setViewport(r - s / 2, o - c / 2 - i, s, c);
}
//#endregion
//#region ../renderer/src/space/Scene.tsx
var JA = $c("scene");
function YA(e) {
let t = (0, Z.c)(27), n, r, i, a, o, s, c;
t[0] === e ? (n = t[1], r = t[2], i = t[3], a = t[4], o = t[5], s = t[6], c = t[7]) : ({sceneDef: s, memoryLimit: o, lighting: a, visibleRect: c, external: i, children: r, ...n} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = o, t[6] = s, t[7] = c);
let { viewbox: l, staticTransform: u } = s, d, f;
t[8] !== u || t[9] !== c ? (d = () => {
c && u && JA.warn("visibleRect is ignored for a scene with a staticTransform");
}, f = [c, u], t[8] = u, t[9] = c, t[10] = d, t[11] = f) : (d = t[10], f = t[11]), (0, G.useEffect)(d, f);
let p;
t[12] !== r || t[13] !== a || t[14] !== o || t[15] !== s ? (p = /* @__PURE__ */ (0, K.jsx)(ZA, {
sceneDef: s,
memoryLimit: o,
lighting: a,
children: r
}), t[12] = r, t[13] = a, t[14] = o, t[15] = s, t[16] = p) : p = t[16];
let m = p, h;
t[17] !== n || t[18] !== i || t[19] !== m || t[20] !== u || t[21] !== l || t[22] !== c ? (h = i ? m : /* @__PURE__ */ (0, K.jsxs)(EA, {
...n,
children: [c && !u && /* @__PURE__ */ (0, K.jsx)(UA, {
rect: c,
viewbox: l
}), m]
}), t[17] = n, t[18] = i, t[19] = m, t[20] = u, t[21] = l, t[22] = c, t[23] = h) : h = t[23];
let g;
return t[24] !== s || t[25] !== h ? (g = /* @__PURE__ */ (0, K.jsx)(XA, {
sceneDef: s,
children: h
}), t[24] = s, t[25] = h, t[26] = g) : g = t[26], g;
}
function XA(e) {
let t = (0, Z.c)(9), { sceneDef: n, children: r } = e, { viewbox: i, staticTransform: a } = n, { width: o, height: s, dpr: c } = xf(), l;
t[0] !== c || t[1] !== s || t[2] !== a || t[3] !== i || t[4] !== o ? (l = () => new ol({
viewbox: i,
width: o,
height: s,
dpr: c,
staticTransform: a
}), t[0] = c, t[1] = s, t[2] = a, t[3] = i, t[4] = o, t[5] = l) : l = t[5];
let [u] = (0, G.useState)(l), d;
return t[6] !== r || t[7] !== u ? (d = /* @__PURE__ */ (0, K.jsx)(cl, {
value: u,
children: r
}), t[6] = r, t[7] = u, t[8] = d) : d = t[8], d;
}
function ZA(e) {
let t = (0, Z.c)(44), { sceneDef: n, memoryLimit: r, lighting: i, children: a } = e, { viewbox: o, staticTransform: s, rootLayer: c } = n, { width: l, height: u, dpr: d } = xf(), f = I(QA), p = al();
$p();
let [m] = (0, G.useState)(FD), h;
t[0] === r ? h = t[1] : (h = () => new $g(r), t[0] = r, t[1] = h);
let [g] = (0, G.useState)(h), _;
t[2] === p.matrixInverse ? _ = t[3] : (_ = () => {
let e = wg();
return e.planFromWorld.value = p.matrixInverse, e;
}, t[2] = p.matrixInverse, t[3] = _);
let [v] = (0, G.useState)(_), y = (0, G.useRef)(null), b, x;
t[4] !== d || t[5] !== u || t[6] !== f || t[7] !== p || t[8] !== s || t[9] !== o || t[10] !== l ? (b = () => {
p.refit({
viewbox: o,
width: l,
height: u,
dpr: d,
staticTransform: s
});
let e = y.current;
e && (e.matrix.copy(p.matrix), e.matrixWorldNeedsUpdate = !0), f();
}, x = [
p,
o,
l,
u,
d,
s,
f
], t[4] = d, t[5] = u, t[6] = f, t[7] = p, t[8] = s, t[9] = o, t[10] = l, t[11] = b, t[12] = x) : (b = t[11], x = t[12]), (0, G.useLayoutEffect)(b, x);
let S, C;
t[13] !== g || t[14] !== r ? (S = () => {
g.setMemoryLimit(r), r || JA.debug("no memory limit set, image atlases upload at full size");
}, C = [g, r], t[13] = g, t[14] = r, t[15] = S, t[16] = C) : (S = t[15], C = t[16]), (0, G.useEffect)(S, C);
let w, T;
t[17] === n ? (w = t[18], T = t[19]) : (w = () => {
el(n, JA.debug);
}, T = [n], t[17] = n, t[18] = w, t[19] = T), (0, G.useEffect)(w, T);
let E;
t[20] === n.background ? E = t[21] : (E = n.background !== void 0 && /* @__PURE__ */ (0, K.jsx)(Wg, { color: n.background }), t[20] = n.background, t[21] = E);
let D;
t[22] !== c || t[23] !== E ? (D = /* @__PURE__ */ (0, K.jsx)(XD, {
layer: c,
children: E
}), t[22] = c, t[23] = E, t[24] = D) : D = t[24];
let O;
t[25] !== m || t[26] !== D ? (O = /* @__PURE__ */ (0, K.jsx)(RD, {
value: m,
children: D
}), t[25] = m, t[26] = D, t[27] = O) : O = t[27];
let k;
t[28] !== g || t[29] !== O ? (k = /* @__PURE__ */ (0, K.jsx)(e_, {
value: g,
children: O
}), t[28] = g, t[29] = O, t[30] = k) : k = t[30];
let A;
t[31] === i ? A = t[32] : (A = /* @__PURE__ */ (0, K.jsx)(Fk, { ...i }), t[31] = i, t[32] = A);
let j;
t[33] !== p.matrix || t[34] !== k || t[35] !== A ? (j = /* @__PURE__ */ (0, K.jsxs)("group", {
name: "world",
ref: y,
matrixAutoUpdate: !1,
matrix: p.matrix,
children: [k, A]
}), t[33] = p.matrix, t[34] = k, t[35] = A, t[36] = j) : j = t[36];
let M;
t[37] === Symbol.for("react.memo_cache_sentinel") ? (M = /* @__PURE__ */ (0, K.jsx)(fA, {}), t[37] = M) : M = t[37];
let N;
t[38] !== a || t[39] !== j ? (N = /* @__PURE__ */ (0, K.jsxs)(qm, { children: [
j,
M,
a
] }), t[38] = a, t[39] = j, t[40] = N) : N = t[40];
let P;
return t[41] !== v || t[42] !== N ? (P = /* @__PURE__ */ (0, K.jsx)(Eg, {
value: v,
children: N
}), t[41] = v, t[42] = N, t[43] = P) : P = t[43], P;
}
function QA(e) {
return e.invalidate;
}
//#endregion
//#region ../renderer/src/Renderer.tsx
var $A = $c("renderer");
function ej(e) {
let t = (0, Z.c)(61), n, r, i, a, o, s, c, l, u, d, f, p, m, h, g, _, v, y;
t[0] === e ? (n = t[1], r = t[2], i = t[3], a = t[4], o = t[5], s = t[6], c = t[7], l = t[8], u = t[9], d = t[10], f = t[11], p = t[12], m = t[13], h = t[14], g = t[15], _ = t[16], v = t[17], y = t[18]) : ({debug: o, scene: _, memoryLimit: d, minZoom: p, maxZoom: u, minPitch: f, maxPitch: l, bounds: n, smoothTime: v, controls: a, lighting: c, visibleRect: y, onPointerMissed: h, gl: s, requestFrame: g, onFrame: m, children: i, ...r} = e, t[0] = e, t[1] = n, t[2] = r, t[3] = i, t[4] = a, t[5] = o, t[6] = s, t[7] = c, t[8] = l, t[9] = u, t[10] = d, t[11] = f, t[12] = p, t[13] = m, t[14] = h, t[15] = g, t[16] = _, t[17] = v, t[18] = y);
let b;
t[19] !== n || t[20] !== l || t[21] !== u || t[22] !== f || t[23] !== p || t[24] !== v ? (b = {
minZoom: p,
maxZoom: u,
minPitch: f,
maxPitch: l,
bounds: n,
smoothTime: v
}, t[19] = n, t[20] = l, t[21] = u, t[22] = f, t[23] = p, t[24] = v, t[25] = b) : b = t[25];
let x = b, S = s !== void 0, C = (0, G.useRef)(void 0), w, T;
t[26] === Symbol.for("react.memo_cache_sentinel") ? (w = () => () => {
var e;
(e = C.current) == null || e.forceContextLoss(), C.current = void 0;
}, T = [], t[26] = w, t[27] = T) : (w = t[26], T = t[27]), (0, G.useEffect)(w, T);
let E;
t[28] !== a || t[29] !== S ? (E = !S && /* @__PURE__ */ (0, K.jsx)(Fp, { config: a }), t[28] = a, t[29] = S, t[30] = E) : E = t[30];
let D;
t[31] === h ? D = t[32] : (D = /* @__PURE__ */ (0, K.jsx)(mm, { onPointerMissed: h }), t[31] = h, t[32] = D);
let O;
t[33] !== x || t[34] !== i || t[35] !== S || t[36] !== c || t[37] !== d || t[38] !== _ || t[39] !== E || t[40] !== D || t[41] !== y ? (O = /* @__PURE__ */ (0, K.jsxs)(YA, {
sceneDef: _,
external: S,
memoryLimit: d,
lighting: c,
visibleRect: y,
...x,
children: [
E,
D,
i
]
}), t[33] = x, t[34] = i, t[35] = S, t[36] = c, t[37] = d, t[38] = _, t[39] = E, t[40] = D, t[41] = y, t[42] = O) : O = t[42];
let k;
t[43] !== o || t[44] !== O ? (k = /* @__PURE__ */ (0, K.jsx)(Up, {
enabled: o,
children: O
}), t[43] = o, t[44] = O, t[45] = k) : k = t[45];
let A = k;
if (s) {
if (!g || !m) return $A.error("external mode needs requestFrame and onFrame alongside gl; nothing will render"), null;
let e;
return t[46] !== s || t[47] !== m || t[48] !== g || t[49] !== A ? (e = /* @__PURE__ */ (0, K.jsx)(Mm, {
gl: s,
requestFrame: g,
onFrame: m,
children: A
}), t[46] = s, t[47] = m, t[48] = g, t[49] = A, t[50] = e) : e = t[50], e;
}
let j;
t[51] === Symbol.for("react.memo_cache_sentinel") ? (j = { stencil: !0 }, t[51] = j) : j = t[51];
let M;
t[52] === o ? M = t[53] : (M = (e) => {
var t;
e.gl.debug.checkShaderErrors = (t = o) != null && t, C.current = e.gl;
}, t[52] = o, t[53] = M);
let N = o ? "always" : "demand", P;
t[54] === Symbol.for("react.memo_cache_sentinel") ? (P = { debounce: 50 }, t[54] = P) : P = t[54];
let ee;
return t[55] !== r || t[56] !== o || t[57] !== M || t[58] !== N || t[59] !== A ? (ee = /* @__PURE__ */ (0, K.jsx)(G.StrictMode, { children: /* @__PURE__ */ (0, K.jsx)(G.Suspense, {
fallback: null,
children: /* @__PURE__ */ (0, K.jsx)(Hp, {
...r,
debugEnabled: o,
flat: !0,
gl: j,
onCreated: M,
frameloop: N,
resize: P,
children: A
})
}) }), t[55] = r, t[56] = o, t[57] = M, t[58] = N, t[59] = A, t[60] = ee) : ee = t[60], ee;
}
//#endregion
//#region ../renderer/src/space/viewport.ts
function tj() {
let e = (0, Z.c)(3), t = I(nj), n = al(), r;
return e[0] !== t || e[1] !== n ? (r = new rj({
get: t,
space: n
}), e[0] = t, e[1] = n, e[2] = r) : r = e[2], r;
}
function nj(e) {
return e.get;
}
var rj = class {
constructor(e) {
this.context = e;
}
canvasToPlan(e, t) {
let { space: n, get: r } = this.context;
return n.canvasToPlan(e, r().camera, t);
}
planToCanvas(e, t) {
let { space: n, get: r } = this.context;
return n.planToCanvas(e, r().camera, t);
}
isVisible(e) {
let { space: t, get: n } = this.context, r = t.planToNdc(e, n().camera, ij);
return !!r && Math.abs(r.x) <= 1 && Math.abs(r.y) <= 1;
}
}, ij = new V();
//#endregion
//#region src/engine/update-def.ts
function aj(e, t, n) {
let r = !1;
return e.forEach((e, i) => {
let a = 0;
n[i].forEach(({ value: e, scaleFactor: n }) => {
t < n && (a = e);
}), e.fontSize !== a * t && (r = !0), e.fontSize = a * t;
}), r;
}
function oj(e, t) {
let { center: n, size: r, rotation: i, elevation: a } = e.bounds, o = t % 2 != 0;
return e.bounds.set(n.x, n.y, o ? r.y : r.x, o ? r.x : r.y, i + t * Math.PI / 2, a), e;
}
function sj(e, t) {
let { size: n, center: r, rotation: i, elevation: a } = e;
return new Xn(r, t % 2 == 0 ? n : {
x: n.y,
y: n.x
}, i + t * Math.PI / 2, a);
}
function cj(e, t) {
if (!Number.isFinite(e) || !Number.isFinite(t)) return 0;
let n = On(e, t);
return Math.abs(n) <= Math.PI / 4 ? 0 : Math.round(n / (Math.PI / 2));
}
function lj(e, t) {
let n = On(e, t), r = Math.PI / 2;
return Math.abs(n) > r + .1;
}
function uj(e) {
return (e + Math.PI + Math.PI) % (2 * Math.PI) - Math.PI;
}
function dj(e, t, n, r) {
let i = t.width, a = t.height, o = e.size, s = e.center, c = e.rotation, l = o.x / i, u = o.x - n * 2, d = (o.y - n * 2) * .8, f = u / i, p = d / a;
r = Math.min(Math.max(r, 0), Math.min(f, p, l));
let m = i * r, h = a * r, g = Math.sin(c), _ = Math.cos(c), v = o.x / 2 - n, y = -o.y / 2 + n, b = s.x + v * _ - y * g, x = s.y + v * g + y * _, S = m / 2, C = -h / 2, w = S * _ - C * g, T = S * g + C * _;
return lo(b - w, x - T, i, a, r, c, e.elevation);
}
function fj(e) {
if (!e) return !1;
if (!Number.isInteger(+e) || +e != 1 && +e != 0) throw Error("Map roll: setting value is incorrect");
return !!+e;
}
//#endregion
//#region src/engine/utils/rotation.ts
function pj(e, t) {
var n, r;
if (!t) return !1;
let i = Math.cos((n = t.rotation) == null ? 0 : n), a = Math.sin((r = t.rotation) == null ? 0 : r), o = t.size.x / 2, s = t.size.y / 2;
return mj(e, e.rotation + Math.PI / 2).every((e) => {
let n = e.x - t.center.x, r = e.y - t.center.y, c = n * i + r * a, l = r * i - n * a;
return Math.abs(c) <= o && Math.abs(l) <= s;
});
}
function mj(e, t = e.rotation) {
let n = e.size.x / 2, r = e.size.y / 2, i = Math.sin(t), a = Math.cos(t), o = e.center.x, s = e.center.y;
return [
{
x: -n,
y: -r
},
{
x: n,
y: -r
},
{
x: n,
y: r
},
{
x: -n,
y: r
}
].map((e) => ({
x: o + e.x * a - e.y * i,
y: s + e.x * i + e.y * a
}));
}
function hj(e, t) {
let n = e.bounds;
return lj(t, n.rotation) ? (n.rotate(uj(n.rotation) - n.rotation, n), !0) : !1;
}
function gj(e) {
return e.onRoll = ({ roll: t }) => vj(e, t) ? [e] : void 0, e;
}
function _j(e) {
return e.onRoll = ({ roll: t }) => {
let { bounds: n } = e;
if (t !== n.rotation) return n.set(n.center.x, n.center.y, n.size.x, n.size.y, t, n.elevation), [e];
}, e;
}
function vj(e, t) {
let n = e.bounds, r = cj(t, n.rotation);
return r === 0 ? !1 : (n.rotate(r * Math.PI / 2, n), !0);
}
//#endregion
//#region src/store/BoothStore.ts
var yj, bj, xj, Sj, Cj, wj, Tj, Ej, Dj, Oj, kj, Aj, jj, Mj, Nj, Pj, Fj, Ij;
function Lj(e, t, n, r) {
n && Object.defineProperty(e, t, {
enumerable: n.enumerable,
configurable: n.configurable,
writable: n.writable,
value: n.initializer ? n.initializer.call(r) : void 0
});
}
function Rj(e, t, n, r, i) {
var a = {};
return Object.keys(r).forEach(function(e) {
a[e] = r[e];
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) {
return r(e, t, n) || n;
}, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a;
}
var zj = (kj = E({ keepAlive: !0 }), Aj = E({ keepAlive: !0 }), jj = E({ keepAlive: !0 }), Mj = E({ keepAlive: !0 }), Nj = E({ keepAlive: !0 }), Pj = class {
get boothById() {
return new Map(this.booths.map((e) => [e.id, e]));
}
get boothByExternalId() {
return new Map(this.booths.map((e) => [e.externalId, e]));
}
get boothByName() {
return new Map(this.booths.map((e) => [e.name.toLowerCase(), e]));
}
get boothBySlug() {
return new Map(this.booths.map((e) => [e.slug, e]));
}
get borderWidth() {
if (Ja.boothBorderWidth) return Ja.boothBorderWidth;
if (Ja.EXPO === "groomexpo") return .4;
let e = this.booths.filter((e) => e.rect).map((e) => e.rect.size.width + e.rect.size.height);
return e.reduce((e, t) => e + t, 0) / e.length / 80;
}
constructor(e) {
this.rootStore = void 0, Lj(this, "booths", Fj, this), Lj(this, "highlightedByExternalIds", Ij, this), this.rootStore = e;
}
get bookmarked() {
return this.booths.filter((e) => e.bookmarkedDirectly);
}
getNearestBooth(e) {
var t = null;
let n = this.booths.map((t) => ({
lineLength: jn(e, t.rect.center),
name: t.name
})).sort((e, t) => e.lineLength - t.lineLength)[0];
return t = this.booths.find((e) => e.name === n.name), t;
}
getBoothAtPoint(e) {
return this.booths.find((t) => t.rect.containsPoint(e));
}
findBooth(e) {
return this.boothByExternalId.get(e) || this.boothByName.get(e.toLowerCase()) || this.boothBySlug.get(e);
}
replaceBookmarked(e) {
let t = (e || []).map((e) => this.boothById.get(e)).filter((e) => e), n = new Set(t), r = this.bookmarked.filter((e) => !n.has(e));
for (let e of r) e.bookmarkedDirectly = !1;
for (let e of t) e.bookmarkedDirectly = !0;
}
}, Fj = Rj(Pj.prototype, "booths", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return [];
}
}), Ij = Rj(Pj.prototype, "highlightedByExternalIds", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return [];
}
}), Rj(Pj.prototype, "boothById", [kj], Object.getOwnPropertyDescriptor(Pj.prototype, "boothById"), Pj.prototype), Rj(Pj.prototype, "boothByExternalId", [Aj], Object.getOwnPropertyDescriptor(Pj.prototype, "boothByExternalId"), Pj.prototype), Rj(Pj.prototype, "boothByName", [jj], Object.getOwnPropertyDescriptor(Pj.prototype, "boothByName"), Pj.prototype), Rj(Pj.prototype, "boothBySlug", [Mj], Object.getOwnPropertyDescriptor(Pj.prototype, "boothBySlug"), Pj.prototype), Rj(Pj.prototype, "borderWidth", [Nj], Object.getOwnPropertyDescriptor(Pj.prototype, "borderWidth"), Pj.prototype), Rj(Pj.prototype, "bookmarked", [E], Object.getOwnPropertyDescriptor(Pj.prototype, "bookmarked"), Pj.prototype), Rj(Pj.prototype, "replaceBookmarked", [A], Object.getOwnPropertyDescriptor(Pj.prototype, "replaceBookmarked"), Pj.prototype), Pj), Bj = (yj = E({ keepAlive: !0 }), bj = E({ keepAlive: !0 }), xj = E({ keepAlive: !0 }), Sj = E({ keepAlive: !0 }), Cj = E({ keepAlive: !0 }), wj = E({ keepAlive: !0 }), Tj = E({ keepAlive: !0 }), Ej = class {
constructor() {
this.store = void 0, this.id = void 0, this.name = void 0, this.externalId = void 0, this.title = void 0, this.rect = void 0, this.borderWidth = void 0, this.borderColor = void 0, this.noLabels = void 0, this.rotate = void 0, this.elevation = void 0, this.paths = void 0, this.pathsWithRect = void 0, this.slug = void 0, this.error = void 0, this.description = void 0, this.exhibitors = void 0, this.labelColor = void 0, this.schedule = void 0, this.poiTypeId = void 0, this.poiType = void 0, this.poiIcon = void 0, this.meta = void 0, Lj(this, "layer", Dj, this), Lj(this, "bookmarkedDirectly", Oj, this);
}
get bookmarked() {
var e;
return B.disableBookmarked ? !1 : (e = this.schedule) != null && e.some((e) => e.bookmarked) ? !0 : this.exhibitors.length > 0 ? !!this.exhibitors.find((e) => e.bookmarked) : this.bookmarkedDirectly;
}
get uiState() {
return this.store.rootStore.uiState;
}
get fullName() {
let e = this.meta ? Object.entries(this.meta).filter(([e]) => !e.startsWith("_")).map(([e, t]) => `${e} ${t}`).join(" ") : "";
return `${this.name} ${e}`.replace(/\s+/g, " ").trim();
}
get visible() {
var e, t;
return (e = (t = this.layer) == null ? void 0 : t.visible) == null || e;
}
get hover() {
return this.uiState.hoveredBooths.has(this);
}
get selected() {
return this.uiState.selectedBooths.has(this);
}
get skipDim() {
return this.uiState.highlightedBooths.has(this.id.toString());
}
}, Dj = Rj(Ej.prototype, "layer", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), Oj = Rj(Ej.prototype, "bookmarkedDirectly", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), Rj(Ej.prototype, "bookmarked", [yj], Object.getOwnPropertyDescriptor(Ej.prototype, "bookmarked"), Ej.prototype), Rj(Ej.prototype, "uiState", [bj], Object.getOwnPropertyDescriptor(Ej.prototype, "uiState"), Ej.prototype), Rj(Ej.prototype, "fullName", [xj], Object.getOwnPropertyDescriptor(Ej.prototype, "fullName"), Ej.prototype), Rj(Ej.prototype, "visible", [Sj], Object.getOwnPropertyDescriptor(Ej.prototype, "visible"), Ej.prototype), Rj(Ej.prototype, "hover", [Cj], Object.getOwnPropertyDescriptor(Ej.prototype, "hover"), Ej.prototype), Rj(Ej.prototype, "selected", [wj], Object.getOwnPropertyDescriptor(Ej.prototype, "selected"), Ej.prototype), Rj(Ej.prototype, "skipDim", [Tj], Object.getOwnPropertyDescriptor(Ej.prototype, "skipDim"), Ej.prototype), Ej), Vj = class extends Bj {
constructor(...e) {
super(...e), this.buyUrl = void 0, this.reserveUrl = void 0, this.type = void 0, this.status = void 0, this.price = void 0, this.entity = {
type: "booth",
variant: "regular"
}, this.size = void 0, this.availColor = void 0, this.soldColor = void 0, this.holdColor = void 0, this.onHold = void 0, this.reserved = void 0, this.shapes = void 0;
}
}, Hj = class extends Bj {
constructor(...e) {
super(...e), this.color = void 0, this.shapes = void 0, this.entity = {
type: "booth",
variant: "special"
};
}
}, Uj = `${p}fonts/oswald-v17-cyrillic_latin-500.woff`, Wj = `${p}fonts/oswald-v17-cyrillic_latin-300.woff`;
function Gj() {
var e;
let t = s();
return (e = t.customCssFonts) != null && e.length ? t.customCssFonts : [];
}
//#endregion
//#region src/engine/defs.ts
function Kj(e, t) {
return Jj(cr.fromSvg(e), t);
}
function qj(e, t) {
if (!e) throw Error("Create ShapeDef: mesh is not provided");
let n = e.positions.map((e) => {
var t;
return {
x: e[0],
y: Math.abs(e[1]),
z: (t = e[2]) == null ? 0 : t
};
}), r = e.cells;
return Jj(new Rn(n, r), t);
}
function Jj(e, t = "#000") {
if (!e || !(yr(e) || br(e) || xr(e) || Sr(e))) throw Error("Invalid shape definition");
return {
shape: e,
color: t
};
}
function Yj(e, t, n) {
if (!e) throw Error("Image source is not provided");
return {
source: e,
bounds: t,
...n
};
}
function Xj(e, t, n, r, i) {
if (e.length === 0) throw Error("Invalid text lines");
return {
lines: e,
bounds: t,
padding: n,
alignment: r,
...i
};
}
function Zj(e, t, n, r = [void 0, void 0]) {
let [i, a] = e, o = [{
text: i.join("\n"),
fontUrl: r[0] || Uj,
color: t,
fontSize: n
}];
return a.length && o.push({
text: a.join("\n"),
fontUrl: r[1] || Wj,
color: t,
fontSize: n
}), o;
}
function Qj(e, t, n) {
if (!e) throw Error("Layer name is required");
return t || (t = []), {
name: e,
children: t,
...n
};
}
function $j(e, t, n) {
let r = t instanceof cr ? t : cr.fromSvg(t);
return {
rootLayer: Qj("root", e),
background: n,
viewbox: r
};
}
function eM(e, t = "#000", n = tM) {
let r = po(n, t), i = fo(n);
return Yj(r, new Xn(e.center, {
x: i,
y: i
}, e.rotation, e.elevation));
}
var tM = 1.5, nM = fo(tM), rM = 1e6;
function iM() {
return ++rM;
}
//#endregion
//#region src/tools/slug.ts
var aM = /* @__PURE__ */ e((/* @__PURE__ */ t(((e, t) => {
(function(n, r, i) {
typeof e == "object" ? (t.exports = i(), t.exports.default = i()) : typeof define == "function" && define.amd ? define(i) : r[n] = i();
})("slugify", e, function() {
var e = JSON.parse("{\"$\":\"dollar\",\"%\":\"percent\",\"&\":\"and\",\"<\":\"less\",\">\":\"greater\",\"|\":\"or\",\"¢\":\"cent\",\"£\":\"pound\",\"¤\":\"currency\",\"¥\":\"yen\",\"©\":\"(c)\",\"ª\":\"a\",\"®\":\"(r)\",\"º\":\"o\",\"À\":\"A\",\"Á\":\"A\",\"Â\":\"A\",\"Ã\":\"A\",\"Ä\":\"A\",\"Å\":\"A\",\"Æ\":\"AE\",\"Ç\":\"C\",\"È\":\"E\",\"É\":\"E\",\"Ê\":\"E\",\"Ë\":\"E\",\"Ì\":\"I\",\"Í\":\"I\",\"Î\":\"I\",\"Ï\":\"I\",\"Ð\":\"D\",\"Ñ\":\"N\",\"Ò\":\"O\",\"Ó\":\"O\",\"Ô\":\"O\",\"Õ\":\"O\",\"Ö\":\"O\",\"Ø\":\"O\",\"Ù\":\"U\",\"Ú\":\"U\",\"Û\":\"U\",\"Ü\":\"U\",\"Ý\":\"Y\",\"Þ\":\"TH\",\"ß\":\"ss\",\"à\":\"a\",\"á\":\"a\",\"â\":\"a\",\"ã\":\"a\",\"ä\":\"a\",\"å\":\"a\",\"æ\":\"ae\",\"ç\":\"c\",\"è\":\"e\",\"é\":\"e\",\"ê\":\"e\",\"ë\":\"e\",\"ì\":\"i\",\"í\":\"i\",\"î\":\"i\",\"ï\":\"i\",\"ð\":\"d\",\"ñ\":\"n\",\"ò\":\"o\",\"ó\":\"o\",\"ô\":\"o\",\"õ\":\"o\",\"ö\":\"o\",\"ø\":\"o\",\"ù\":\"u\",\"ú\":\"u\",\"û\":\"u\",\"ü\":\"u\",\"ý\":\"y\",\"þ\":\"th\",\"ÿ\":\"y\",\"Ā\":\"A\",\"ā\":\"a\",\"Ă\":\"A\",\"ă\":\"a\",\"Ą\":\"A\",\"ą\":\"a\",\"Ć\":\"C\",\"ć\":\"c\",\"Č\":\"C\",\"č\":\"c\",\"Ď\":\"D\",\"ď\":\"d\",\"Đ\":\"DJ\",\"đ\":\"dj\",\"Ē\":\"E\",\"ē\":\"e\",\"Ė\":\"E\",\"ė\":\"e\",\"Ę\":\"e\",\"ę\":\"e\",\"Ě\":\"E\",\"ě\":\"e\",\"Ğ\":\"G\",\"ğ\":\"g\",\"Ģ\":\"G\",\"ģ\":\"g\",\"Ĩ\":\"I\",\"ĩ\":\"i\",\"Ī\":\"i\",\"ī\":\"i\",\"Į\":\"I\",\"į\":\"i\",\"İ\":\"I\",\"ı\":\"i\",\"Ķ\":\"k\",\"ķ\":\"k\",\"Ļ\":\"L\",\"ļ\":\"l\",\"Ľ\":\"L\",\"ľ\":\"l\",\"Ł\":\"L\",\"ł\":\"l\",\"Ń\":\"N\",\"ń\":\"n\",\"Ņ\":\"N\",\"ņ\":\"n\",\"Ň\":\"N\",\"ň\":\"n\",\"Ō\":\"O\",\"ō\":\"o\",\"Ő\":\"O\",\"ő\":\"o\",\"Œ\":\"OE\",\"œ\":\"oe\",\"Ŕ\":\"R\",\"ŕ\":\"r\",\"Ř\":\"R\",\"ř\":\"r\",\"Ś\":\"S\",\"ś\":\"s\",\"Ş\":\"S\",\"ş\":\"s\",\"Š\":\"S\",\"š\":\"s\",\"Ţ\":\"T\",\"ţ\":\"t\",\"Ť\":\"T\",\"ť\":\"t\",\"Ũ\":\"U\",\"ũ\":\"u\",\"Ū\":\"u\",\"ū\":\"u\",\"Ů\":\"U\",\"ů\":\"u\",\"Ű\":\"U\",\"ű\":\"u\",\"Ų\":\"U\",\"ų\":\"u\",\"Ŵ\":\"W\",\"ŵ\":\"w\",\"Ŷ\":\"Y\",\"ŷ\":\"y\",\"Ÿ\":\"Y\",\"Ź\":\"Z\",\"ź\":\"z\",\"Ż\":\"Z\",\"ż\":\"z\",\"Ž\":\"Z\",\"ž\":\"z\",\"Ə\":\"E\",\"ƒ\":\"f\",\"Ơ\":\"O\",\"ơ\":\"o\",\"Ư\":\"U\",\"ư\":\"u\",\"Lj\":\"LJ\",\"lj\":\"lj\",\"Nj\":\"NJ\",\"nj\":\"nj\",\"Ș\":\"S\",\"ș\":\"s\",\"Ț\":\"T\",\"ț\":\"t\",\"ə\":\"e\",\"˚\":\"o\",\"Ά\":\"A\",\"Έ\":\"E\",\"Ή\":\"H\",\"Ί\":\"I\",\"Ό\":\"O\",\"Ύ\":\"Y\",\"Ώ\":\"W\",\"ΐ\":\"i\",\"Α\":\"A\",\"Β\":\"B\",\"Γ\":\"G\",\"Δ\":\"D\",\"Ε\":\"E\",\"Ζ\":\"Z\",\"Η\":\"H\",\"Θ\":\"8\",\"Ι\":\"I\",\"Κ\":\"K\",\"Λ\":\"L\",\"Μ\":\"M\",\"Ν\":\"N\",\"Ξ\":\"3\",\"Ο\":\"O\",\"Π\":\"P\",\"Ρ\":\"R\",\"Σ\":\"S\",\"Τ\":\"T\",\"Υ\":\"Y\",\"Φ\":\"F\",\"Χ\":\"X\",\"Ψ\":\"PS\",\"Ω\":\"W\",\"Ϊ\":\"I\",\"Ϋ\":\"Y\",\"ά\":\"a\",\"έ\":\"e\",\"ή\":\"h\",\"ί\":\"i\",\"ΰ\":\"y\",\"α\":\"a\",\"β\":\"b\",\"γ\":\"g\",\"δ\":\"d\",\"ε\":\"e\",\"ζ\":\"z\",\"η\":\"h\",\"θ\":\"8\",\"ι\":\"i\",\"κ\":\"k\",\"λ\":\"l\",\"μ\":\"m\",\"ν\":\"n\",\"ξ\":\"3\",\"ο\":\"o\",\"π\":\"p\",\"ρ\":\"r\",\"ς\":\"s\",\"σ\":\"s\",\"τ\":\"t\",\"υ\":\"y\",\"φ\":\"f\",\"χ\":\"x\",\"ψ\":\"ps\",\"ω\":\"w\",\"ϊ\":\"i\",\"ϋ\":\"y\",\"ό\":\"o\",\"ύ\":\"y\",\"ώ\":\"w\",\"Ё\":\"Yo\",\"Ђ\":\"DJ\",\"Є\":\"Ye\",\"І\":\"I\",\"Ї\":\"Yi\",\"Ј\":\"J\",\"Љ\":\"LJ\",\"Њ\":\"NJ\",\"Ћ\":\"C\",\"Џ\":\"DZ\",\"А\":\"A\",\"Б\":\"B\",\"В\":\"V\",\"Г\":\"G\",\"Д\":\"D\",\"Е\":\"E\",\"Ж\":\"Zh\",\"З\":\"Z\",\"И\":\"I\",\"Й\":\"J\",\"К\":\"K\",\"Л\":\"L\",\"М\":\"M\",\"Н\":\"N\",\"О\":\"O\",\"П\":\"P\",\"Р\":\"R\",\"С\":\"S\",\"Т\":\"T\",\"У\":\"U\",\"Ф\":\"F\",\"Х\":\"H\",\"Ц\":\"C\",\"Ч\":\"Ch\",\"Ш\":\"Sh\",\"Щ\":\"Sh\",\"Ъ\":\"U\",\"Ы\":\"Y\",\"Ь\":\"\",\"Э\":\"E\",\"Ю\":\"Yu\",\"Я\":\"Ya\",\"а\":\"a\",\"б\":\"b\",\"в\":\"v\",\"г\":\"g\",\"д\":\"d\",\"е\":\"e\",\"ж\":\"zh\",\"з\":\"z\",\"и\":\"i\",\"й\":\"j\",\"к\":\"k\",\"л\":\"l\",\"м\":\"m\",\"н\":\"n\",\"о\":\"o\",\"п\":\"p\",\"р\":\"r\",\"с\":\"s\",\"т\":\"t\",\"у\":\"u\",\"ф\":\"f\",\"х\":\"h\",\"ц\":\"c\",\"ч\":\"ch\",\"ш\":\"sh\",\"щ\":\"sh\",\"ъ\":\"u\",\"ы\":\"y\",\"ь\":\"\",\"э\":\"e\",\"ю\":\"yu\",\"я\":\"ya\",\"ё\":\"yo\",\"ђ\":\"dj\",\"є\":\"ye\",\"і\":\"i\",\"ї\":\"yi\",\"ј\":\"j\",\"љ\":\"lj\",\"њ\":\"nj\",\"ћ\":\"c\",\"ѝ\":\"u\",\"џ\":\"dz\",\"Ґ\":\"G\",\"ґ\":\"g\",\"Ғ\":\"GH\",\"ғ\":\"gh\",\"Қ\":\"KH\",\"қ\":\"kh\",\"Ң\":\"NG\",\"ң\":\"ng\",\"Ү\":\"UE\",\"ү\":\"ue\",\"Ұ\":\"U\",\"ұ\":\"u\",\"Һ\":\"H\",\"һ\":\"h\",\"Ә\":\"AE\",\"ә\":\"ae\",\"Ө\":\"OE\",\"ө\":\"oe\",\"Ա\":\"A\",\"Բ\":\"B\",\"Գ\":\"G\",\"Դ\":\"D\",\"Ե\":\"E\",\"Զ\":\"Z\",\"Է\":\"E'\",\"Ը\":\"Y'\",\"Թ\":\"T'\",\"Ժ\":\"JH\",\"Ի\":\"I\",\"Լ\":\"L\",\"Խ\":\"X\",\"Ծ\":\"C'\",\"Կ\":\"K\",\"Հ\":\"H\",\"Ձ\":\"D'\",\"Ղ\":\"GH\",\"Ճ\":\"TW\",\"Մ\":\"M\",\"Յ\":\"Y\",\"Ն\":\"N\",\"Շ\":\"SH\",\"Չ\":\"CH\",\"Պ\":\"P\",\"Ջ\":\"J\",\"Ռ\":\"R'\",\"Ս\":\"S\",\"Վ\":\"V\",\"Տ\":\"T\",\"Ր\":\"R\",\"Ց\":\"C\",\"Փ\":\"P'\",\"Ք\":\"Q'\",\"Օ\":\"O''\",\"Ֆ\":\"F\",\"և\":\"EV\",\"ء\":\"a\",\"آ\":\"aa\",\"أ\":\"a\",\"ؤ\":\"u\",\"إ\":\"i\",\"ئ\":\"e\",\"ا\":\"a\",\"ب\":\"b\",\"ة\":\"h\",\"ت\":\"t\",\"ث\":\"th\",\"ج\":\"j\",\"ح\":\"h\",\"خ\":\"kh\",\"د\":\"d\",\"ذ\":\"th\",\"ر\":\"r\",\"ز\":\"z\",\"س\":\"s\",\"ش\":\"sh\",\"ص\":\"s\",\"ض\":\"dh\",\"ط\":\"t\",\"ظ\":\"z\",\"ع\":\"a\",\"غ\":\"gh\",\"ف\":\"f\",\"ق\":\"q\",\"ك\":\"k\",\"ل\":\"l\",\"م\":\"m\",\"ن\":\"n\",\"ه\":\"h\",\"و\":\"w\",\"ى\":\"a\",\"ي\":\"y\",\"ً\":\"an\",\"ٌ\":\"on\",\"ٍ\":\"en\",\"َ\":\"a\",\"ُ\":\"u\",\"ِ\":\"e\",\"ْ\":\"\",\"٠\":\"0\",\"١\":\"1\",\"٢\":\"2\",\"٣\":\"3\",\"٤\":\"4\",\"٥\":\"5\",\"٦\":\"6\",\"٧\":\"7\",\"٨\":\"8\",\"٩\":\"9\",\"پ\":\"p\",\"چ\":\"ch\",\"ژ\":\"zh\",\"ک\":\"k\",\"گ\":\"g\",\"ی\":\"y\",\"۰\":\"0\",\"۱\":\"1\",\"۲\":\"2\",\"۳\":\"3\",\"۴\":\"4\",\"۵\":\"5\",\"۶\":\"6\",\"۷\":\"7\",\"۸\":\"8\",\"۹\":\"9\",\"฿\":\"baht\",\"ა\":\"a\",\"ბ\":\"b\",\"გ\":\"g\",\"დ\":\"d\",\"ე\":\"e\",\"ვ\":\"v\",\"ზ\":\"z\",\"თ\":\"t\",\"ი\":\"i\",\"კ\":\"k\",\"ლ\":\"l\",\"მ\":\"m\",\"ნ\":\"n\",\"ო\":\"o\",\"პ\":\"p\",\"ჟ\":\"zh\",\"რ\":\"r\",\"ს\":\"s\",\"ტ\":\"t\",\"უ\":\"u\",\"ფ\":\"f\",\"ქ\":\"k\",\"ღ\":\"gh\",\"ყ\":\"q\",\"შ\":\"sh\",\"ჩ\":\"ch\",\"ც\":\"ts\",\"ძ\":\"dz\",\"წ\":\"ts\",\"ჭ\":\"ch\",\"ხ\":\"kh\",\"ჯ\":\"j\",\"ჰ\":\"h\",\"Ṣ\":\"S\",\"ṣ\":\"s\",\"Ẁ\":\"W\",\"ẁ\":\"w\",\"Ẃ\":\"W\",\"ẃ\":\"w\",\"Ẅ\":\"W\",\"ẅ\":\"w\",\"ẞ\":\"SS\",\"Ạ\":\"A\",\"ạ\":\"a\",\"Ả\":\"A\",\"ả\":\"a\",\"Ấ\":\"A\",\"ấ\":\"a\",\"Ầ\":\"A\",\"ầ\":\"a\",\"Ẩ\":\"A\",\"ẩ\":\"a\",\"Ẫ\":\"A\",\"ẫ\":\"a\",\"Ậ\":\"A\",\"ậ\":\"a\",\"Ắ\":\"A\",\"ắ\":\"a\",\"Ằ\":\"A\",\"ằ\":\"a\",\"Ẳ\":\"A\",\"ẳ\":\"a\",\"Ẵ\":\"A\",\"ẵ\":\"a\",\"Ặ\":\"A\",\"ặ\":\"a\",\"Ẹ\":\"E\",\"ẹ\":\"e\",\"Ẻ\":\"E\",\"ẻ\":\"e\",\"Ẽ\":\"E\",\"ẽ\":\"e\",\"Ế\":\"E\",\"ế\":\"e\",\"Ề\":\"E\",\"ề\":\"e\",\"Ể\":\"E\",\"ể\":\"e\",\"Ễ\":\"E\",\"ễ\":\"e\",\"Ệ\":\"E\",\"ệ\":\"e\",\"Ỉ\":\"I\",\"ỉ\":\"i\",\"Ị\":\"I\",\"ị\":\"i\",\"Ọ\":\"O\",\"ọ\":\"o\",\"Ỏ\":\"O\",\"ỏ\":\"o\",\"Ố\":\"O\",\"ố\":\"o\",\"Ồ\":\"O\",\"ồ\":\"o\",\"Ổ\":\"O\",\"ổ\":\"o\",\"Ỗ\":\"O\",\"ỗ\":\"o\",\"Ộ\":\"O\",\"ộ\":\"o\",\"Ớ\":\"O\",\"ớ\":\"o\",\"Ờ\":\"O\",\"ờ\":\"o\",\"Ở\":\"O\",\"ở\":\"o\",\"Ỡ\":\"O\",\"ỡ\":\"o\",\"Ợ\":\"O\",\"ợ\":\"o\",\"Ụ\":\"U\",\"ụ\":\"u\",\"Ủ\":\"U\",\"ủ\":\"u\",\"Ứ\":\"U\",\"ứ\":\"u\",\"Ừ\":\"U\",\"ừ\":\"u\",\"Ử\":\"U\",\"ử\":\"u\",\"Ữ\":\"U\",\"ữ\":\"u\",\"Ự\":\"U\",\"ự\":\"u\",\"Ỳ\":\"Y\",\"ỳ\":\"y\",\"Ỵ\":\"Y\",\"ỵ\":\"y\",\"Ỷ\":\"Y\",\"ỷ\":\"y\",\"Ỹ\":\"Y\",\"ỹ\":\"y\",\"–\":\"-\",\"‘\":\"'\",\"’\":\"'\",\"“\":\"\\\"\",\"”\":\"\\\"\",\"„\":\"\\\"\",\"†\":\"+\",\"•\":\"*\",\"…\":\"...\",\"₠\":\"ecu\",\"₢\":\"cruzeiro\",\"₣\":\"french franc\",\"₤\":\"lira\",\"₥\":\"mill\",\"₦\":\"naira\",\"₧\":\"peseta\",\"₨\":\"rupee\",\"₩\":\"won\",\"₪\":\"new shequel\",\"₫\":\"dong\",\"€\":\"euro\",\"₭\":\"kip\",\"₮\":\"tugrik\",\"₯\":\"drachma\",\"₰\":\"penny\",\"₱\":\"peso\",\"₲\":\"guarani\",\"₳\":\"austral\",\"₴\":\"hryvnia\",\"₵\":\"cedi\",\"₸\":\"kazakhstani tenge\",\"₹\":\"indian rupee\",\"₺\":\"turkish lira\",\"₽\":\"russian ruble\",\"₿\":\"bitcoin\",\"℠\":\"sm\",\"™\":\"tm\",\"∂\":\"d\",\"∆\":\"delta\",\"∑\":\"sum\",\"∞\":\"infinity\",\"♥\":\"love\",\"元\":\"yuan\",\"円\":\"yen\",\"﷼\":\"rial\",\"ﻵ\":\"laa\",\"ﻷ\":\"laa\",\"ﻹ\":\"lai\",\"ﻻ\":\"la\"}"), t = JSON.parse("{\"bg\":{\"Й\":\"Y\",\"Ц\":\"Ts\",\"Щ\":\"Sht\",\"Ъ\":\"A\",\"Ь\":\"Y\",\"й\":\"y\",\"ц\":\"ts\",\"щ\":\"sht\",\"ъ\":\"a\",\"ь\":\"y\"},\"de\":{\"Ä\":\"AE\",\"ä\":\"ae\",\"Ö\":\"OE\",\"ö\":\"oe\",\"Ü\":\"UE\",\"ü\":\"ue\",\"ß\":\"ss\",\"%\":\"prozent\",\"&\":\"und\",\"|\":\"oder\",\"∑\":\"summe\",\"∞\":\"unendlich\",\"♥\":\"liebe\"},\"es\":{\"%\":\"por ciento\",\"&\":\"y\",\"<\":\"menor que\",\">\":\"mayor que\",\"|\":\"o\",\"¢\":\"centavos\",\"£\":\"libras\",\"¤\":\"moneda\",\"₣\":\"francos\",\"∑\":\"suma\",\"∞\":\"infinito\",\"♥\":\"amor\"},\"fr\":{\"%\":\"pourcent\",\"&\":\"et\",\"<\":\"plus petit\",\">\":\"plus grand\",\"|\":\"ou\",\"¢\":\"centime\",\"£\":\"livre\",\"¤\":\"devise\",\"₣\":\"franc\",\"∑\":\"somme\",\"∞\":\"infini\",\"♥\":\"amour\"},\"pt\":{\"%\":\"porcento\",\"&\":\"e\",\"<\":\"menor\",\">\":\"maior\",\"|\":\"ou\",\"¢\":\"centavo\",\"∑\":\"soma\",\"£\":\"libra\",\"∞\":\"infinito\",\"♥\":\"amor\"},\"uk\":{\"И\":\"Y\",\"и\":\"y\",\"Й\":\"Y\",\"й\":\"y\",\"Ц\":\"Ts\",\"ц\":\"ts\",\"Х\":\"Kh\",\"х\":\"kh\",\"Щ\":\"Shch\",\"щ\":\"shch\",\"Г\":\"H\",\"г\":\"h\"},\"vi\":{\"Đ\":\"D\",\"đ\":\"d\"},\"da\":{\"Ø\":\"OE\",\"ø\":\"oe\",\"Å\":\"AA\",\"å\":\"aa\",\"%\":\"procent\",\"&\":\"og\",\"|\":\"eller\",\"$\":\"dollar\",\"<\":\"mindre end\",\">\":\"større end\"},\"nb\":{\"&\":\"og\",\"Å\":\"AA\",\"Æ\":\"AE\",\"Ø\":\"OE\",\"å\":\"aa\",\"æ\":\"ae\",\"ø\":\"oe\"},\"it\":{\"&\":\"e\"},\"nl\":{\"&\":\"en\"},\"sv\":{\"&\":\"och\",\"Å\":\"AA\",\"Ä\":\"AE\",\"Ö\":\"OE\",\"å\":\"aa\",\"ä\":\"ae\",\"ö\":\"oe\"}}");
function n(n, r) {
if (typeof n != "string") throw Error("slugify: string argument expected");
r = typeof r == "string" ? { replacement: r } : r || {};
var i = t[r.locale] || {}, a = r.replacement === void 0 ? "-" : r.replacement, o = r.trim === void 0 || r.trim, s = n.normalize().split("").reduce(function(t, n) {
var o = i[n];
return o === void 0 && (o = e[n]), o === void 0 && (o = n), o === a && (o = " "), t + o.replace(r.remove || /[^\w\s$*_+~.()'"!\-:@]+/g, "");
}, "");
return r.strict && (s = s.replace(/[^A-Za-z0-9\s]/g, "")), o && (s = s.trim()), s = s.replace(/\s+/g, a), r.lower && (s = s.toLowerCase()), s;
}
return n.extend = function(t) {
Object.assign(e, t);
}, n;
});
})))(), 1), oM = De(() => /* @__PURE__ */ new Set());
function sM(e) {
let t = oM(), n = 0, r = (0, aM.default)(e, {
remove: /[*+~.()'"!:@]/g,
lower: !0
}), i;
do
i = r + (n++ > 0 || !r ? n : "");
while (t.has(i));
return t.add(i), i;
}
//#endregion
//#region src/utils/urlEncoding.ts
function cM(e) {
if (!e || e.length === 0) return "";
let t = e.map((e) => encodeURIComponent(e.trim())).join(",");
return w.log("URLEncoding: encoding string array:", {
original: e,
encoded: t
}), t;
}
function lM(e) {
if (!e) return [];
try {
let t = e.split(",").map((e) => decodeURIComponent(e.trim())).filter(Boolean);
return w.log("URLEncoding: decoding string array:", {
encoded: e,
decoded: t
}), t;
} catch (t) {
return w.warn("URLEncoding: failed to decode string array:", e, t), [];
}
}
function uM(e) {
if (!e) return null;
let t = encodeURIComponent(e.trim());
return w.log("URLEncoding: encoding string:", {
original: e,
encoded: t
}), t;
}
function dM(e) {
if (!e) return null;
try {
let t = decodeURIComponent(e.trim());
return w.log("URLEncoding: decoding string:", {
encoded: e,
decoded: t
}), t;
} catch (t) {
return w.warn("URLEncoding: failed to decode string:", e, t), null;
}
}
function fM(e) {
return e.map((e) => e.toLowerCase());
}
function pM(e) {
return e ? e.toLowerCase() : null;
}
//#endregion
//#region src/utils/index.ts
function mM(e) {
return e * parseFloat(getComputedStyle(document.documentElement).fontSize);
}
function hM(e, t) {
let n = [];
for (let r = 0; r < e.length; r += t) n.push(e.slice(r, r + t));
return n;
}
function gM(e) {
e.sort(function(e, t) {
var n = e.name.toLowerCase(), r = t.name.toLowerCase();
return n < r ? -1 : +(n > r);
});
}
var _M = document.createElement("canvas"), vM = !!(_M.getContext("webgl") || _M.getContext("experimental-webgl"));
if (!vM) {
let e = document.createElement("div");
e.innerHTML = "<!--no webgl-->", document.body.appendChild(e);
}
function yM(e) {
for (var t = e.length, n, r; t !== 0;) r = Math.floor(Math.random() * t), --t, n = e[t], e[t] = e[r], e[r] = n;
return e;
}
//#endregion
//#region src/utils/entity-storage.ts
var bM = Oe();
function xM(e) {
return `${Ja.EXPO}-${e}`;
}
function SM(e) {
return e;
}
function CM(e) {
return e === "bookmarked" ? {
exhibitors: [],
events: [],
speakers: [],
booths: []
} : {
exhibitors: [],
events: []
};
}
function wM(e, t) {
if (typeof t != "object" || !t) return w.log(`Invalid ${e} data in localStorage - using defaults`), CM(e);
if (Array.isArray(t)) {
let n = e === "bookmarked" ? {
exhibitors: t,
events: [],
speakers: [],
booths: []
} : {
exhibitors: t,
events: []
};
return w.log(`Migrated ${e} data from array to object format`), EM(e, n), n;
}
if (e === "bookmarked") {
let n = t, r = { ...n };
return "speakers" in r || (r.speakers = []), "booths" in r || (r.booths = []), (!n.speakers || !n.booths) && (w.log(`Migrated ${e} data (added speakers or booths field)`), EM(e, r)), r;
}
return e === "visited" ? t : (w.log(`Unsupported ${e} data format - using defaults`), CM(e));
}
function TM(e) {
let t = bM().get(e);
if (t) return t;
let n = CM(e);
if (!m) return w.warn(`localStorage unavailable — using default for ${e}`), bM().set(e, n), n;
let r = xM(e), i = SM(e), a = null;
try {
var o;
a = (o = localStorage.getItem(r)) == null ? localStorage.getItem(i) : o;
} catch (t) {
w.warn(`localStorage access error for ${e}`, t);
}
if (!a) return bM().set(e, n), n;
try {
let t = wM(e, JSON.parse(a));
return bM().set(e, t), t;
} catch (t) {
return w.error(`Error parsing ${e} data`, t), bM().set(e, n), n;
}
}
function EM(e, t) {
if (!m) return;
let n = xM(e);
try {
localStorage.setItem(n, JSON.stringify(t)), bM().set(e, t);
let r = {
exhibitors: t.exhibitors.length,
events: t.events.length
};
t.speakers && (r.speakers = t.speakers.length), t.booths && (r.booths = t.booths.length), w.log(`save${e[0].toUpperCase() + e.slice(1)}ToLocalStorage`, r);
} catch (t) {
w.error(`Failed to save ${e} data`, t);
}
}
//#endregion
//#region src/utils/plan-reactions.ts
function DM(...e) {
S(j(...e));
}
function OM(e, t, n) {
S(k(e, t, n));
}
function kM(e, t, n) {
S(O(e, t, n));
}
//#endregion
//#region src/store/init/init-booths.ts
var AM = /* @__PURE__ */ e(Ho(), 1), jM = Oe();
function MM(e) {
jM().clear();
let t = [];
for (let r of Dr.booths || []) {
var n;
let { text: i, meta: a } = Ma(r.name), o = r.special ? new Hj() : new Vj();
Object.assign(o, r), o.meta = a, o.slug = sM(o.name), jM().set(o.name.toLowerCase(), o), FM(o);
let s = o;
s.exhibitors = [];
for (let t of (n = r.exhibitors) == null ? [] : n) {
let n = e.exhibitorStore.exhibitorById.get(t);
n && (s.exhibitors.push(n), n.booths.push(s));
}
o.schedule = e.eventStore.eventItems.filter((e) => e.boothId === o.id), o.name = i, t.push(o);
}
t.sort((e, t) => e.name.localeCompare(t.name, void 0, {
sensitivity: "base",
numeric: !0
}));
for (let t of e.exhibitorStore.exhibitors) gM(t.booths);
e.boothStore.booths = t, w.log("initBooths", e.boothStore.booths.length), NM(e);
}
function NM(e) {
let t = (TM("bookmarked").booths || []).filter((t) => {
let n = e.boothStore.boothById.get(t);
return n && n.exhibitors.length === 0;
});
e.boothStore.replaceBookmarked(t), DM(() => {
let t = TM("bookmarked"), n = e.boothStore.booths.filter((e) => e.exhibitors.length === 0 && e.bookmarkedDirectly).map((e) => e.id);
EM("bookmarked", {
exhibitors: t.exhibitors,
events: t.events,
speakers: t.speakers,
booths: n
});
});
}
function PM(e, t) {
let n = t.name, { boothStore: r, layerStore: i } = e, a = [], o = Ya(), s = ja(Ha(t)).selectAll(`[data-layer='${n}'] > [data-tagname='efp-booth'], [data-layer='${n}'] > g[id^=b], [data-layer='${n}'] > rect[id^=b]`).nodes();
for (let t of s) {
var c;
let s = t.closest("svg > [data-layer]").getAttribute("data-layer");
if (!s) continue;
let f, p = !1;
t.tagName === "rect" ? f = t : (f = Array.from(t.children).find((e) => e.tagName === "rect"), p = f === t.firstElementChild);
let m = t.id || t.getAttribute("data-name");
if (!m) {
w.error("SVG booth element has neither id nor data-name:", t);
continue;
}
let h = m.substring(1).toLowerCase(), g = jM().get(h), _ = g instanceof Vj ? g : null, v = g instanceof Hj ? g : null;
if (g ? a.push(g) : (w.error("SVG booth rect not found in the event data:", h), g = _ = new Vj(), g.id = iM(), g.name = h.toUpperCase(), g.slug = sM(h), g.error = !0, g.exhibitors = [], jM().set(h, g), a.push(g)), g.layer = o ? i.layers.find((e) => e.name === s) : null, g.borderColor = (f == null ? void 0 : f.getAttribute("stroke")) || (f == null ? void 0 : f.style.stroke) || Ja.boothBorderColor || "#FFFFFF", g.borderWidth = parseFloat((f == null ? void 0 : f.getAttribute("stroke-width")) || (f == null ? void 0 : f.style.strokeWidth)), isNaN(g.borderWidth) && (g.borderWidth = r.borderWidth), !B.heatmap) g.labelColor = f == null ? void 0 : f.getAttribute("data-label-color");
else {
let t = e.heatmapStore.getTotalClicksByBooth(g), n = (0, AM.default)(e.heatmapStore.getColorByClicks(t));
g.labelColor = n.darken(.3).isLight() ? "#555" : "#fff";
}
if (g.rect = f ? cr.fromSvg(f) : null, g.elevation = parseFloat((c = f == null ? void 0 : f.dataset.elev) == null ? "" : c) || 0, g.noLabels = !!(f != null && f.dataset.nolabel) || (f == null ? void 0 : f.id.startsWith("no")), _) _.availColor = t.getAttribute("data-avail-color") || (f == null ? void 0 : f.getAttribute("data-avail-color")) || _.availColor, _.soldColor = t.getAttribute("data-sold-color") || (f == null ? void 0 : f.getAttribute("data-sold-color")) || _.soldColor, _.holdColor = t.getAttribute("data-hold-color") || (f == null ? void 0 : f.getAttribute("data-hold-color")) || _.holdColor, _.size = Dr.dimensionless ? null : _.size || t.getAttribute("data-size"), _.status === "reserved" ? _.reserved = !0 : _.status === "onhold" && (_.onHold = !0);
else if (v) {
var l, u;
v.color = (parseInt((l = f.getAttribute("data-poi-type")) == null ? "" : l) > 0 ? (u = f.style) == null ? void 0 : u.fill : t.getAttribute("data-color") || f.getAttribute("data-color")) || v.color;
}
let y = f == null ? void 0 : f.getAttribute("transform");
if (y) {
let e = y.match(/translate\(([-0-9.]+) ([-0-9.]+)\) rotate\(([-0-9.]+)\)/);
if (e) {
let t = parseFloat(e[3]);
g.rotate = wn(t);
} else {
let e = y.match(/rotate\(([-0-9.]+).*\)/);
if (e) {
let t = parseFloat(e[1]);
g.rotate = wn(t);
} else {
let e = y.match(/matrix\(\s*([-0-9.]+)\s*(?:,|\s)\s*([-0-9.]+)\s*(?:,|\s)\s*([-0-9.]+)\s*(?:,|\s)\s*([-0-9.]+)\s*(?:,|\s)\s*([-0-9.]+)\s*(?:,|\s)\s*([-0-9.]+)\s*\)/);
e && (g.rotate = Math.asin(parseFloat(e[2])));
}
}
if (Math.abs(Tn(g.rotate)) > 180) {
g.rotate += wn(90);
let e = g.rect;
g.rect = new cr(e.center.x - e.size.height / 2, e.center.y - e.size.width / 2, e.size.height, e.size.width);
}
}
if (t.tagName === "g") {
g.paths = [], g.pathsWithRect = p;
let e = [];
for (let r of ja(t).selectAll("path, rect").nodes()) if (r.tagName === "path") {
var d;
let t = r;
if (t.tagName !== "path") continue;
let i = parseInt((d = t.getAttribute("data-index")) == null ? "" : d), a = !!t.getAttribute("data-unblinking");
g.paths.push({
index: i,
color: t.style.fill,
unblinking: a
}), f || e.push(...Ba(i, n));
}
if (e.length) {
let t = e.flatMap((e) => e.map((e) => ({
x: e[0],
y: e[1]
})));
g.rect = cr.fromPoints(t), g.noLabels = !0;
}
}
}
let f = a.filter((e) => e.rect ? !0 : (w.error("event data booth not found in SVG:", e.name, e), !1));
for (let e of f) e.store = r;
return f;
}
function FM(e) {
Ja.EXPO === "cbresupplypartner" && e instanceof Vj && !e.availColor && e.type && (e.type.indexOf("Premium A - 2m height restriction Passport") === -1 ? e.type.indexOf("No free-standing") === -1 ? e.type.endsWith("Passport") ? e.availColor = "#939393" : e.type.startsWith("Premium A - 2m") ? e.availColor = "#FF9E4E" : e.type.startsWith("Premium A - 4m") ? e.availColor = "#EA4335" : e.type.startsWith("Premium B - 2m") ? e.availColor = "#523BC0" : e.type.startsWith("Premium C - 2.4m") && (e.availColor = "#3ECC78") : e.availColor = "#BA3DC8" : e.availColor = "#939393");
}
//#endregion
//#region ../../node_modules/.pnpm/d3-dispatch@3.0.1/node_modules/d3-dispatch/src/dispatch.js
var IM = { value: () => {} };
function LM() {
for (var e = 0, t = arguments.length, n = {}, r; e < t; ++e) {
if (!(r = arguments[e] + "") || r in n || /[\s.]/.test(r)) throw Error("illegal type: " + r);
n[r] = [];
}
return new RM(n);
}
function RM(e) {
this._ = e;
}
function zM(e, t) {
return e.trim().split(/^|\s+/).map(function(e) {
var n = "", r = e.indexOf(".");
if (r >= 0 && (n = e.slice(r + 1), e = e.slice(0, r)), e && !t.hasOwnProperty(e)) throw Error("unknown type: " + e);
return {
type: e,
name: n
};
});
}
RM.prototype = LM.prototype = {
constructor: RM,
on: function(e, t) {
var n = this._, r = zM(e + "", n), i, a = -1, o = r.length;
if (arguments.length < 2) {
for (; ++a < o;) if ((i = (e = r[a]).type) && (i = BM(n[i], e.name))) return i;
return;
}
if (t != null && typeof t != "function") throw Error("invalid callback: " + t);
for (; ++a < o;) if (i = (e = r[a]).type) n[i] = VM(n[i], e.name, t);
else if (t == null) for (i in n) n[i] = VM(n[i], e.name, null);
return this;
},
copy: function() {
var e = {}, t = this._;
for (var n in t) e[n] = t[n].slice();
return new RM(e);
},
call: function(e, t) {
if ((i = arguments.length - 2) > 0) for (var n = Array(i), r = 0, i, a; r < i; ++r) n[r] = arguments[r + 2];
if (!this._.hasOwnProperty(e)) throw Error("unknown type: " + e);
for (a = this._[e], r = 0, i = a.length; r < i; ++r) a[r].value.apply(t, n);
},
apply: function(e, t, n) {
if (!this._.hasOwnProperty(e)) throw Error("unknown type: " + e);
for (var r = this._[e], i = 0, a = r.length; i < a; ++i) r[i].value.apply(t, n);
}
};
function BM(e, t) {
for (var n = 0, r = e.length, i; n < r; ++n) if ((i = e[n]).name === t) return i.value;
}
function VM(e, t, n) {
for (var r = 0, i = e.length; r < i; ++r) if (e[r].name === t) {
e[r] = IM, e = e.slice(0, r).concat(e.slice(r + 1));
break;
}
return n != null && e.push({
name: t,
value: n
}), e;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/define.js
function HM(e, t, n) {
e.prototype = t.prototype = n, n.constructor = e;
}
function UM(e, t) {
var n = Object.create(e.prototype);
for (var r in t) n[r] = t[r];
return n;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-color@3.1.0/node_modules/d3-color/src/color.js
function WM() {}
var GM = .7, KM = 1 / GM, qM = "\\s*([+-]?\\d+)\\s*", JM = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*", YM = "\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*", XM = /^#([0-9a-f]{3,8})$/, ZM = RegExp(`^rgb\\(${qM},${qM},${qM}\\)$`), QM = RegExp(`^rgb\\(${YM},${YM},${YM}\\)$`), $M = RegExp(`^rgba\\(${qM},${qM},${qM},${JM}\\)$`), eN = RegExp(`^rgba\\(${YM},${YM},${YM},${JM}\\)$`), tN = RegExp(`^hsl\\(${JM},${YM},${YM}\\)$`), nN = RegExp(`^hsla\\(${JM},${YM},${YM},${JM}\\)$`), rN = {
aliceblue: 15792383,
antiquewhite: 16444375,
aqua: 65535,
aquamarine: 8388564,
azure: 15794175,
beige: 16119260,
bisque: 16770244,
black: 0,
blanchedalmond: 16772045,
blue: 255,
blueviolet: 9055202,
brown: 10824234,
burlywood: 14596231,
cadetblue: 6266528,
chartreuse: 8388352,
chocolate: 13789470,
coral: 16744272,
cornflowerblue: 6591981,
cornsilk: 16775388,
crimson: 14423100,
cyan: 65535,
darkblue: 139,
darkcyan: 35723,
darkgoldenrod: 12092939,
darkgray: 11119017,
darkgreen: 25600,
darkgrey: 11119017,
darkkhaki: 12433259,
darkmagenta: 9109643,
darkolivegreen: 5597999,
darkorange: 16747520,
darkorchid: 10040012,
darkred: 9109504,
darksalmon: 15308410,
darkseagreen: 9419919,
darkslateblue: 4734347,
darkslategray: 3100495,
darkslategrey: 3100495,
darkturquoise: 52945,
darkviolet: 9699539,
deeppink: 16716947,
deepskyblue: 49151,
dimgray: 6908265,
dimgrey: 6908265,
dodgerblue: 2003199,
firebrick: 11674146,
floralwhite: 16775920,
forestgreen: 2263842,
fuchsia: 16711935,
gainsboro: 14474460,
ghostwhite: 16316671,
gold: 16766720,
goldenrod: 14329120,
gray: 8421504,
green: 32768,
greenyellow: 11403055,
grey: 8421504,
honeydew: 15794160,
hotpink: 16738740,
indianred: 13458524,
indigo: 4915330,
ivory: 16777200,
khaki: 15787660,
lavender: 15132410,
lavenderblush: 16773365,
lawngreen: 8190976,
lemonchiffon: 16775885,
lightblue: 11393254,
lightcoral: 15761536,
lightcyan: 14745599,
lightgoldenrodyellow: 16448210,
lightgray: 13882323,
lightgreen: 9498256,
lightgrey: 13882323,
lightpink: 16758465,
lightsalmon: 16752762,
lightseagreen: 2142890,
lightskyblue: 8900346,
lightslategray: 7833753,
lightslategrey: 7833753,
lightsteelblue: 11584734,
lightyellow: 16777184,
lime: 65280,
limegreen: 3329330,
linen: 16445670,
magenta: 16711935,
maroon: 8388608,
mediumaquamarine: 6737322,
mediumblue: 205,
mediumorchid: 12211667,
mediumpurple: 9662683,
mediumseagreen: 3978097,
mediumslateblue: 8087790,
mediumspringgreen: 64154,
mediumturquoise: 4772300,
mediumvioletred: 13047173,
midnightblue: 1644912,
mintcream: 16121850,
mistyrose: 16770273,
moccasin: 16770229,
navajowhite: 16768685,
navy: 128,
oldlace: 16643558,
olive: 8421376,
olivedrab: 7048739,
orange: 16753920,
orangered: 16729344,
orchid: 14315734,
palegoldenrod: 15657130,
palegreen: 10025880,
paleturquoise: 11529966,
palevioletred: 14381203,
papayawhip: 16773077,
peachpuff: 16767673,
peru: 13468991,
pink: 16761035,
plum: 14524637,
powderblue: 11591910,
purple: 8388736,
rebeccapurple: 6697881,
red: 16711680,
rosybrown: 12357519,
royalblue: 4286945,
saddlebrown: 9127187,
salmon: 16416882,
sandybrown: 16032864,
seagreen: 3050327,
seashell: 16774638,
sienna: 10506797,
silver: 12632256,
skyblue: 8900331,
slateblue: 6970061,
slategray: 7372944,
slategrey: 7372944,
snow: 16775930,
springgreen: 65407,
steelblue: 4620980,
tan: 13808780,
teal: 32896,
thistle: 14204888,
tomato: 16737095,
turquoise: 4251856,
violet: 15631086,
wheat: 16113331,
white: 16777215,
whitesmoke: 16119285,
yellow: 16776960,
yellowgreen: 10145074
};
HM(WM, cN, {
copy(e) {
return Object.assign(new this.constructor(), this, e);
},
displayable() {
return this.rgb().displayable();
},
hex: iN,
formatHex: iN,
formatHex8: aN,
formatHsl: oN,
formatRgb: sN,
toString: sN
});
function iN() {
return this.rgb().formatHex();
}
function aN() {
return this.rgb().formatHex8();
}
function oN() {
return xN(this).formatHsl();
}
function sN() {
return this.rgb().formatRgb();
}
function cN(e) {
var t, n;
return e = (e + "").trim().toLowerCase(), (t = XM.exec(e)) ? (n = t[1].length, t = parseInt(t[1], 16), n === 6 ? lN(t) : n === 3 ? new pN(t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, (t & 15) << 4 | t & 15, 1) : n === 8 ? uN(t >> 24 & 255, t >> 16 & 255, t >> 8 & 255, (t & 255) / 255) : n === 4 ? uN(t >> 12 & 15 | t >> 8 & 240, t >> 8 & 15 | t >> 4 & 240, t >> 4 & 15 | t & 240, ((t & 15) << 4 | t & 15) / 255) : null) : (t = ZM.exec(e)) ? new pN(t[1], t[2], t[3], 1) : (t = QM.exec(e)) ? new pN(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, 1) : (t = $M.exec(e)) ? uN(t[1], t[2], t[3], t[4]) : (t = eN.exec(e)) ? uN(t[1] * 255 / 100, t[2] * 255 / 100, t[3] * 255 / 100, t[4]) : (t = tN.exec(e)) ? bN(t[1], t[2] / 100, t[3] / 100, 1) : (t = nN.exec(e)) ? bN(t[1], t[2] / 100, t[3] / 100, t[4]) : rN.hasOwnProperty(e) ? lN(rN[e]) : e === "transparent" ? new pN(NaN, NaN, NaN, 0) : null;
}
function lN(e) {
return new pN(e >> 16 & 255, e >> 8 & 255, e & 255, 1);
}
function uN(e, t, n, r) {
return r <= 0 && (e = t = n = NaN), new pN(e, t, n, r);
}
function dN(e) {
return e instanceof WM || (e = cN(e)), e ? (e = e.rgb(), new pN(e.r, e.g, e.b, e.opacity)) : new pN();
}
function fN(e, t, n, r) {
return arguments.length === 1 ? dN(e) : new pN(e, t, n, r == null ? 1 : r);
}
function pN(e, t, n, r) {
this.r = +e, this.g = +t, this.b = +n, this.opacity = +r;
}
HM(pN, fN, UM(WM, {
brighter(e) {
return e = e == null ? KM : KM ** +e, new pN(this.r * e, this.g * e, this.b * e, this.opacity);
},
darker(e) {
return e = e == null ? GM : GM ** +e, new pN(this.r * e, this.g * e, this.b * e, this.opacity);
},
rgb() {
return this;
},
clamp() {
return new pN(vN(this.r), vN(this.g), vN(this.b), _N(this.opacity));
},
displayable() {
return -.5 <= this.r && this.r < 255.5 && -.5 <= this.g && this.g < 255.5 && -.5 <= this.b && this.b < 255.5 && 0 <= this.opacity && this.opacity <= 1;
},
hex: mN,
formatHex: mN,
formatHex8: hN,
formatRgb: gN,
toString: gN
}));
function mN() {
return `#${yN(this.r)}${yN(this.g)}${yN(this.b)}`;
}
function hN() {
return `#${yN(this.r)}${yN(this.g)}${yN(this.b)}${yN((isNaN(this.opacity) ? 1 : this.opacity) * 255)}`;
}
function gN() {
let e = _N(this.opacity);
return `${e === 1 ? "rgb(" : "rgba("}${vN(this.r)}, ${vN(this.g)}, ${vN(this.b)}${e === 1 ? ")" : `, ${e})`}`;
}
function _N(e) {
return isNaN(e) ? 1 : Math.max(0, Math.min(1, e));
}
function vN(e) {
return Math.max(0, Math.min(255, Math.round(e) || 0));
}
function yN(e) {
return e = vN(e), (e < 16 ? "0" : "") + e.toString(16);
}
function bN(e, t, n, r) {
return r <= 0 ? e = t = n = NaN : n <= 0 || n >= 1 ? e = t = NaN : t <= 0 && (e = NaN), new CN(e, t, n, r);
}
function xN(e) {
if (e instanceof CN) return new CN(e.h, e.s, e.l, e.opacity);
if (e instanceof WM || (e = cN(e)), !e) return new CN();
if (e instanceof CN) return e;
e = e.rgb();
var t = e.r / 255, n = e.g / 255, r = e.b / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = NaN, s = a - i, c = (a + i) / 2;
return s ? (o = t === a ? (n - r) / s + (n < r) * 6 : n === a ? (r - t) / s + 2 : (t - n) / s + 4, s /= c < .5 ? a + i : 2 - a - i, o *= 60) : s = c > 0 && c < 1 ? 0 : o, new CN(o, s, c, e.opacity);
}
function SN(e, t, n, r) {
return arguments.length === 1 ? xN(e) : new CN(e, t, n, r == null ? 1 : r);
}
function CN(e, t, n, r) {
this.h = +e, this.s = +t, this.l = +n, this.opacity = +r;
}
HM(CN, SN, UM(WM, {
brighter(e) {
return e = e == null ? KM : KM ** +e, new CN(this.h, this.s, this.l * e, this.opacity);
},
darker(e) {
return e = e == null ? GM : GM ** +e, new CN(this.h, this.s, this.l * e, this.opacity);
},
rgb() {
var e = this.h % 360 + (this.h < 0) * 360, t = isNaN(e) || isNaN(this.s) ? 0 : this.s, n = this.l, r = n + (n < .5 ? n : 1 - n) * t, i = 2 * n - r;
return new pN(EN(e >= 240 ? e - 240 : e + 120, i, r), EN(e, i, r), EN(e < 120 ? e + 240 : e - 120, i, r), this.opacity);
},
clamp() {
return new CN(wN(this.h), TN(this.s), TN(this.l), _N(this.opacity));
},
displayable() {
return (0 <= this.s && this.s <= 1 || isNaN(this.s)) && 0 <= this.l && this.l <= 1 && 0 <= this.opacity && this.opacity <= 1;
},
formatHsl() {
let e = _N(this.opacity);
return `${e === 1 ? "hsl(" : "hsla("}${wN(this.h)}, ${TN(this.s) * 100}%, ${TN(this.l) * 100}%${e === 1 ? ")" : `, ${e})`}`;
}
}));
function wN(e) {
return e = (e || 0) % 360, e < 0 ? e + 360 : e;
}
function TN(e) {
return Math.max(0, Math.min(1, e || 0));
}
function EN(e, t, n) {
return (e < 60 ? t + (n - t) * e / 60 : e < 180 ? n : e < 240 ? t + (n - t) * (240 - e) / 60 : t) * 255;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/constant.js
var DN = (e) => () => e;
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/color.js
function ON(e, t) {
return function(n) {
return e + n * t;
};
}
function kN(e, t, n) {
return e **= +n, t = t ** +n - e, n = 1 / n, function(r) {
return (e + r * t) ** +n;
};
}
function AN(e) {
return (e = +e) == 1 ? jN : function(t, n) {
return n - t ? kN(t, n, e) : DN(isNaN(t) ? n : t);
};
}
function jN(e, t) {
var n = t - e;
return n ? ON(e, n) : DN(isNaN(e) ? t : e);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/rgb.js
var MN = (function e(t) {
var n = AN(t);
function r(e, t) {
var r = n((e = fN(e)).r, (t = fN(t)).r), i = n(e.g, t.g), a = n(e.b, t.b), o = jN(e.opacity, t.opacity);
return function(t) {
return e.r = r(t), e.g = i(t), e.b = a(t), e.opacity = o(t), e + "";
};
}
return r.gamma = e, r;
})(1);
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/number.js
function NN(e, t) {
return e = +e, t = +t, function(n) {
return e * (1 - n) + t * n;
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/string.js
var PN = /[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g, FN = new RegExp(PN.source, "g");
function IN(e) {
return function() {
return e;
};
}
function LN(e) {
return function(t) {
return e(t) + "";
};
}
function RN(e, t) {
var n = PN.lastIndex = FN.lastIndex = 0, r, i, a, o = -1, s = [], c = [];
for (e += "", t += ""; (r = PN.exec(e)) && (i = FN.exec(t));) (a = i.index) > n && (a = t.slice(n, a), s[o] ? s[o] += a : s[++o] = a), (r = r[0]) === (i = i[0]) ? s[o] ? s[o] += i : s[++o] = i : (s[++o] = null, c.push({
i: o,
x: NN(r, i)
})), n = FN.lastIndex;
return n < t.length && (a = t.slice(n), s[o] ? s[o] += a : s[++o] = a), s.length < 2 ? c[0] ? LN(c[0].x) : IN(t) : (t = c.length, function(e) {
for (var n = 0, r; n < t; ++n) s[(r = c[n]).i] = r.x(e);
return s.join("");
});
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/decompose.js
var zN = 180 / Math.PI, BN = {
translateX: 0,
translateY: 0,
rotate: 0,
skewX: 0,
scaleX: 1,
scaleY: 1
};
function VN(e, t, n, r, i, a) {
var o, s, c;
return (o = Math.sqrt(e * e + t * t)) && (e /= o, t /= o), (c = e * n + t * r) && (n -= e * c, r -= t * c), (s = Math.sqrt(n * n + r * r)) && (n /= s, r /= s, c /= s), e * r < t * n && (e = -e, t = -t, c = -c, o = -o), {
translateX: i,
translateY: a,
rotate: Math.atan2(t, e) * zN,
skewX: Math.atan(c) * zN,
scaleX: o,
scaleY: s
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/parse.js
var HN;
function UN(e) {
let t = new (typeof DOMMatrix == "function" ? DOMMatrix : WebKitCSSMatrix)(e + "");
return t.isIdentity ? BN : VN(t.a, t.b, t.c, t.d, t.e, t.f);
}
function WN(e) {
return e == null || (HN || (HN = document.createElementNS("http://www.w3.org/2000/svg", "g")), HN.setAttribute("transform", e), !(e = HN.transform.baseVal.consolidate())) ? BN : (e = e.matrix, VN(e.a, e.b, e.c, e.d, e.e, e.f));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-interpolate@3.0.1/node_modules/d3-interpolate/src/transform/index.js
function GN(e, t, n, r) {
function i(e) {
return e.length ? e.pop() + " " : "";
}
function a(e, r, i, a, o, s) {
if (e !== i || r !== a) {
var c = o.push("translate(", null, t, null, n);
s.push({
i: c - 4,
x: NN(e, i)
}, {
i: c - 2,
x: NN(r, a)
});
} else (i || a) && o.push("translate(" + i + t + a + n);
}
function o(e, t, n, a) {
e === t ? t && n.push(i(n) + "rotate(" + t + r) : (e - t > 180 ? t += 360 : t - e > 180 && (e += 360), a.push({
i: n.push(i(n) + "rotate(", null, r) - 2,
x: NN(e, t)
}));
}
function s(e, t, n, a) {
e === t ? t && n.push(i(n) + "skewX(" + t + r) : a.push({
i: n.push(i(n) + "skewX(", null, r) - 2,
x: NN(e, t)
});
}
function c(e, t, n, r, a, o) {
if (e !== n || t !== r) {
var s = a.push(i(a) + "scale(", null, ",", null, ")");
o.push({
i: s - 4,
x: NN(e, n)
}, {
i: s - 2,
x: NN(t, r)
});
} else (n !== 1 || r !== 1) && a.push(i(a) + "scale(" + n + "," + r + ")");
}
return function(t, n) {
var r = [], i = [];
return t = e(t), n = e(n), a(t.translateX, t.translateY, n.translateX, n.translateY, r, i), o(t.rotate, n.rotate, r, i), s(t.skewX, n.skewX, r, i), c(t.scaleX, t.scaleY, n.scaleX, n.scaleY, r, i), t = n = null, function(e) {
for (var t = -1, n = i.length, a; ++t < n;) r[(a = i[t]).i] = a.x(e);
return r.join("");
};
};
}
var KN = GN(UN, "px, ", "px)", "deg)"), qN = GN(WN, ", ", ")", ")"), JN = 0, YN = 0, XN = 0, ZN = 1e3, QN, $N, eP = 0, tP = 0, nP = 0, rP = typeof performance == "object" && performance.now ? performance : Date, iP = typeof window == "object" && window.requestAnimationFrame ? window.requestAnimationFrame.bind(window) : function(e) {
setTimeout(e, 17);
};
function aP() {
return tP || (iP(oP), tP = rP.now() + nP);
}
function oP() {
tP = 0;
}
function sP() {
this._call = this._time = this._next = null;
}
sP.prototype = cP.prototype = {
constructor: sP,
restart: function(e, t, n) {
if (typeof e != "function") throw TypeError("callback is not a function");
n = (n == null ? aP() : +n) + (t == null ? 0 : +t), !this._next && $N !== this && ($N ? $N._next = this : QN = this, $N = this), this._call = e, this._time = n, pP();
},
stop: function() {
this._call && (this._call = null, this._time = Infinity, pP());
}
};
function cP(e, t, n) {
var r = new sP();
return r.restart(e, t, n), r;
}
function lP() {
aP(), ++JN;
for (var e = QN, t; e;) (t = tP - e._time) >= 0 && e._call.call(void 0, t), e = e._next;
--JN;
}
function uP() {
tP = (eP = rP.now()) + nP, JN = YN = 0;
try {
lP();
} finally {
JN = 0, fP(), tP = 0;
}
}
function dP() {
var e = rP.now(), t = e - eP;
t > ZN && (nP -= t, eP = e);
}
function fP() {
for (var e, t = QN, n, r = Infinity; t;) t._call ? (r > t._time && (r = t._time), e = t, t = t._next) : (n = t._next, t._next = null, t = e ? e._next = n : QN = n);
$N = e, pP(r);
}
function pP(e) {
JN || (YN && (YN = clearTimeout(YN)), e - tP > 24 ? (e < Infinity && (YN = setTimeout(uP, e - rP.now() - nP)), XN && (XN = clearInterval(XN))) : (XN || (eP = rP.now(), XN = setInterval(dP, ZN)), JN = 1, iP(uP)));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-timer@3.0.1/node_modules/d3-timer/src/timeout.js
function mP(e, t, n) {
var r = new sP();
return t = t == null ? 0 : +t, r.restart((n) => {
r.stop(), e(n + t);
}, t, n), r;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/schedule.js
var hP = LM("start", "end", "cancel", "interrupt"), gP = [];
function _P(e, t, n, r, i, a) {
var o = e.__transition;
if (!o) e.__transition = {};
else if (n in o) return;
xP(e, n, {
name: t,
index: r,
group: i,
on: hP,
tween: gP,
time: a.time,
delay: a.delay,
duration: a.duration,
ease: a.ease,
timer: null,
state: 0
});
}
function vP(e, t) {
var n = bP(e, t);
if (n.state > 0) throw Error("too late; already scheduled");
return n;
}
function yP(e, t) {
var n = bP(e, t);
if (n.state > 3) throw Error("too late; already running");
return n;
}
function bP(e, t) {
var n = e.__transition;
if (!n || !(n = n[t])) throw Error("transition not found");
return n;
}
function xP(e, t, n) {
var r = e.__transition, i;
r[t] = n, n.timer = cP(a, 0, n.time);
function a(e) {
n.state = 1, n.timer.restart(o, n.delay, n.time), n.delay <= e && o(e - n.delay);
}
function o(a) {
var l, u, d, f;
if (n.state !== 1) return c();
for (l in r) if (f = r[l], f.name === n.name) {
if (f.state === 3) return mP(o);
f.state === 4 ? (f.state = 6, f.timer.stop(), f.on.call("interrupt", e, e.__data__, f.index, f.group), delete r[l]) : +l < t && (f.state = 6, f.timer.stop(), f.on.call("cancel", e, e.__data__, f.index, f.group), delete r[l]);
}
if (mP(function() {
n.state === 3 && (n.state = 4, n.timer.restart(s, n.delay, n.time), s(a));
}), n.state = 2, n.on.call("start", e, e.__data__, n.index, n.group), n.state === 2) {
for (n.state = 3, i = Array(d = n.tween.length), l = 0, u = -1; l < d; ++l) (f = n.tween[l].value.call(e, e.__data__, n.index, n.group)) && (i[++u] = f);
i.length = u + 1;
}
}
function s(t) {
for (var r = t < n.duration ? n.ease.call(null, t / n.duration) : (n.timer.restart(c), n.state = 5, 1), a = -1, o = i.length; ++a < o;) i[a].call(e, r);
n.state === 5 && (n.on.call("end", e, e.__data__, n.index, n.group), c());
}
function c() {
for (var i in n.state = 6, n.timer.stop(), delete r[t], r) return;
delete e.__transition;
}
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/interrupt.js
function SP(e, t) {
var n = e.__transition, r, i, a = !0, o;
if (n) {
for (o in t = t == null ? null : t + "", n) {
if ((r = n[o]).name !== t) {
a = !1;
continue;
}
i = r.state > 2 && r.state < 5, r.state = 6, r.timer.stop(), r.on.call(i ? "interrupt" : "cancel", e, e.__data__, r.index, r.group), delete n[o];
}
a && delete e.__transition;
}
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/interrupt.js
function CP(e) {
return this.each(function() {
SP(this, e);
});
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/tween.js
function wP(e, t) {
var n, r;
return function() {
var i = yP(this, e), a = i.tween;
if (a !== n) {
r = n = a;
for (var o = 0, s = r.length; o < s; ++o) if (r[o].name === t) {
r = r.slice(), r.splice(o, 1);
break;
}
}
i.tween = r;
};
}
function TP(e, t, n) {
var r, i;
if (typeof n != "function") throw Error();
return function() {
var a = yP(this, e), o = a.tween;
if (o !== r) {
i = (r = o).slice();
for (var s = {
name: t,
value: n
}, c = 0, l = i.length; c < l; ++c) if (i[c].name === t) {
i[c] = s;
break;
}
c === l && i.push(s);
}
a.tween = i;
};
}
function EP(e, t) {
var n = this._id;
if (e += "", arguments.length < 2) {
for (var r = bP(this.node(), n).tween, i = 0, a = r.length, o; i < a; ++i) if ((o = r[i]).name === e) return o.value;
return null;
}
return this.each((t == null ? wP : TP)(n, e, t));
}
function DP(e, t, n) {
var r = e._id;
return e.each(function() {
var e = yP(this, r);
(e.value || (e.value = {}))[t] = n.apply(this, arguments);
}), function(e) {
return bP(e, r).value[t];
};
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/interpolate.js
function OP(e, t) {
var n;
return (typeof t == "number" ? NN : t instanceof cN ? MN : (n = cN(t)) ? (t = n, MN) : RN)(e, t);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/attr.js
function kP(e) {
return function() {
this.removeAttribute(e);
};
}
function AP(e) {
return function() {
this.removeAttributeNS(e.space, e.local);
};
}
function jP(e, t, n) {
var r, i = n + "", a;
return function() {
var o = this.getAttribute(e);
return o === i ? null : o === r ? a : a = t(r = o, n);
};
}
function MP(e, t, n) {
var r, i = n + "", a;
return function() {
var o = this.getAttributeNS(e.space, e.local);
return o === i ? null : o === r ? a : a = t(r = o, n);
};
}
function NP(e, t, n) {
var r, i, a;
return function() {
var o, s = n(this), c;
return s == null ? void this.removeAttribute(e) : (o = this.getAttribute(e), c = s + "", o === c ? null : o === r && c === i ? a : (i = c, a = t(r = o, s)));
};
}
function PP(e, t, n) {
var r, i, a;
return function() {
var o, s = n(this), c;
return s == null ? void this.removeAttributeNS(e.space, e.local) : (o = this.getAttributeNS(e.space, e.local), c = s + "", o === c ? null : o === r && c === i ? a : (i = c, a = t(r = o, s)));
};
}
function FP(e, t) {
var n = Pr(e), r = n === "transform" ? qN : OP;
return this.attrTween(e, typeof t == "function" ? (n.local ? PP : NP)(n, r, DP(this, "attr." + e, t)) : t == null ? (n.local ? AP : kP)(n) : (n.local ? MP : jP)(n, r, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/attrTween.js
function IP(e, t) {
return function(n) {
this.setAttribute(e, t.call(this, n));
};
}
function LP(e, t) {
return function(n) {
this.setAttributeNS(e.space, e.local, t.call(this, n));
};
}
function RP(e, t) {
var n, r;
function i() {
var i = t.apply(this, arguments);
return i !== r && (n = (r = i) && LP(e, i)), n;
}
return i._value = t, i;
}
function zP(e, t) {
var n, r;
function i() {
var i = t.apply(this, arguments);
return i !== r && (n = (r = i) && IP(e, i)), n;
}
return i._value = t, i;
}
function BP(e, t) {
var n = "attr." + e;
if (arguments.length < 2) return (n = this.tween(n)) && n._value;
if (t == null) return this.tween(n, null);
if (typeof t != "function") throw Error();
var r = Pr(e);
return this.tween(n, (r.local ? RP : zP)(r, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/delay.js
function VP(e, t) {
return function() {
vP(this, e).delay = +t.apply(this, arguments);
};
}
function HP(e, t) {
return t = +t, function() {
vP(this, e).delay = t;
};
}
function UP(e) {
var t = this._id;
return arguments.length ? this.each((typeof e == "function" ? VP : HP)(t, e)) : bP(this.node(), t).delay;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/duration.js
function WP(e, t) {
return function() {
yP(this, e).duration = +t.apply(this, arguments);
};
}
function GP(e, t) {
return t = +t, function() {
yP(this, e).duration = t;
};
}
function KP(e) {
var t = this._id;
return arguments.length ? this.each((typeof e == "function" ? WP : GP)(t, e)) : bP(this.node(), t).duration;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/ease.js
function qP(e, t) {
if (typeof t != "function") throw Error();
return function() {
yP(this, e).ease = t;
};
}
function JP(e) {
var t = this._id;
return arguments.length ? this.each(qP(t, e)) : bP(this.node(), t).ease;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/easeVarying.js
function YP(e, t) {
return function() {
var n = t.apply(this, arguments);
if (typeof n != "function") throw Error();
yP(this, e).ease = n;
};
}
function XP(e) {
if (typeof e != "function") throw Error();
return this.each(YP(this._id, e));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/filter.js
function ZP(e) {
typeof e != "function" && (e = Kr(e));
for (var t = this._groups, n = t.length, r = Array(n), i = 0; i < n; ++i) for (var a = t[i], o = a.length, s = r[i] = [], c, l = 0; l < o; ++l) (c = a[l]) && e.call(c, c.__data__, l, a) && s.push(c);
return new EF(r, this._parents, this._name, this._id);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/merge.js
function QP(e) {
if (e._id !== this._id) throw Error();
for (var t = this._groups, n = e._groups, r = t.length, i = n.length, a = Math.min(r, i), o = Array(r), s = 0; s < a; ++s) for (var c = t[s], l = n[s], u = c.length, d = o[s] = Array(u), f, p = 0; p < u; ++p) (f = c[p] || l[p]) && (d[p] = f);
for (; s < r; ++s) o[s] = t[s];
return new EF(o, this._parents, this._name, this._id);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/on.js
function $P(e) {
return (e + "").trim().split(/^|\s+/).every(function(e) {
var t = e.indexOf(".");
return t >= 0 && (e = e.slice(0, t)), !e || e === "start";
});
}
function eF(e, t, n) {
var r, i, a = $P(t) ? vP : yP;
return function() {
var o = a(this, e), s = o.on;
s !== r && (i = (r = s).copy()).on(t, n), o.on = i;
};
}
function tF(e, t) {
var n = this._id;
return arguments.length < 2 ? bP(this.node(), n).on.on(e) : this.each(eF(n, e, t));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/remove.js
function nF(e) {
return function() {
var t = this.parentNode;
for (var n in this.__transition) if (+n !== e) return;
t && t.removeChild(this);
};
}
function rF() {
return this.on("end.remove", nF(this._id));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/select.js
function iF(e) {
var t = this._name, n = this._id;
typeof e != "function" && (e = zr(e));
for (var r = this._groups, i = r.length, a = Array(i), o = 0; o < i; ++o) for (var s = r[o], c = s.length, l = a[o] = Array(c), u, d, f = 0; f < c; ++f) (u = s[f]) && (d = e.call(u, u.__data__, f, s)) && ("__data__" in u && (d.__data__ = u.__data__), l[f] = d, _P(l[f], t, n, f, l, bP(u, n)));
return new EF(a, this._parents, t, n);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/selectAll.js
function aF(e) {
var t = this._name, n = this._id;
typeof e != "function" && (e = Ur(e));
for (var r = this._groups, i = r.length, a = [], o = [], s = 0; s < i; ++s) for (var c = r[s], l = c.length, u, d = 0; d < l; ++d) if (u = c[d]) {
for (var f = e.call(u, u.__data__, d, c), p, m = bP(u, n), h = 0, g = f.length; h < g; ++h) (p = f[h]) && _P(p, t, n, h, f, m);
a.push(f), o.push(u);
}
return new EF(a, o, t, n);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/selection.js
var oF = ka.prototype.constructor;
function sF() {
return new oF(this._groups, this._parents);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/style.js
function cF(e, t) {
var n, r, i;
return function() {
var a = Ii(this, e), o = (this.style.removeProperty(e), Ii(this, e));
return a === o ? null : a === n && o === r ? i : i = t(n = a, r = o);
};
}
function lF(e) {
return function() {
this.style.removeProperty(e);
};
}
function uF(e, t, n) {
var r, i = n + "", a;
return function() {
var o = Ii(this, e);
return o === i ? null : o === r ? a : a = t(r = o, n);
};
}
function dF(e, t, n) {
var r, i, a;
return function() {
var o = Ii(this, e), s = n(this), c = s + "";
return s == null && (c = s = (this.style.removeProperty(e), Ii(this, e))), o === c ? null : o === r && c === i ? a : (i = c, a = t(r = o, s));
};
}
function fF(e, t) {
var n, r, i, a = "style." + t, o = "end." + a, s;
return function() {
var c = yP(this, e), l = c.on, u = c.value[a] == null ? s || (s = lF(t)) : void 0;
(l !== n || i !== u) && (r = (n = l).copy()).on(o, i = u), c.on = r;
};
}
function pF(e, t, n) {
var r = (e += "") == "transform" ? KN : OP;
return t == null ? this.styleTween(e, cF(e, r)).on("end.style." + e, lF(e)) : typeof t == "function" ? this.styleTween(e, dF(e, r, DP(this, "style." + e, t))).each(fF(this._id, e)) : this.styleTween(e, uF(e, r, t), n).on("end.style." + e, null);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/styleTween.js
function mF(e, t, n) {
return function(r) {
this.style.setProperty(e, t.call(this, r), n);
};
}
function hF(e, t, n) {
var r, i;
function a() {
var a = t.apply(this, arguments);
return a !== i && (r = (i = a) && mF(e, a, n)), r;
}
return a._value = t, a;
}
function gF(e, t, n) {
var r = "style." + (e += "");
if (arguments.length < 2) return (r = this.tween(r)) && r._value;
if (t == null) return this.tween(r, null);
if (typeof t != "function") throw Error();
return this.tween(r, hF(e, t, n == null ? "" : n));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/text.js
function _F(e) {
return function() {
this.textContent = e;
};
}
function vF(e) {
return function() {
var t = e(this);
this.textContent = t == null ? "" : t;
};
}
function yF(e) {
return this.tween("text", typeof e == "function" ? vF(DP(this, "text", e)) : _F(e == null ? "" : e + ""));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/textTween.js
function bF(e) {
return function(t) {
this.textContent = e.call(this, t);
};
}
function xF(e) {
var t, n;
function r() {
var r = e.apply(this, arguments);
return r !== n && (t = (n = r) && bF(r)), t;
}
return r._value = e, r;
}
function SF(e) {
var t = "text";
if (arguments.length < 1) return (t = this.tween(t)) && t._value;
if (e == null) return this.tween(t, null);
if (typeof e != "function") throw Error();
return this.tween(t, xF(e));
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/transition.js
function CF() {
for (var e = this._name, t = this._id, n = OF(), r = this._groups, i = r.length, a = 0; a < i; ++a) for (var o = r[a], s = o.length, c, l = 0; l < s; ++l) if (c = o[l]) {
var u = bP(c, t);
_P(c, e, n, l, o, {
time: u.time + u.delay + u.duration,
delay: 0,
duration: u.duration,
ease: u.ease
});
}
return new EF(r, this._parents, e, n);
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/end.js
function wF() {
var e, t, n = this, r = n._id, i = n.size();
return new Promise(function(a, o) {
var s = { value: o }, c = { value: function() {
--i === 0 && a();
} };
n.each(function() {
var n = yP(this, r), i = n.on;
i !== e && (t = (e = i).copy(), t._.cancel.push(s), t._.interrupt.push(s), t._.end.push(c)), n.on = t;
}), i === 0 && a();
});
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/transition/index.js
var TF = 0;
function EF(e, t, n, r) {
this._groups = e, this._parents = t, this._name = n, this._id = r;
}
function DF(e) {
return ka().transition(e);
}
function OF() {
return ++TF;
}
var kF = ka.prototype;
EF.prototype = DF.prototype = {
constructor: EF,
select: iF,
selectAll: aF,
selectChild: kF.selectChild,
selectChildren: kF.selectChildren,
filter: ZP,
merge: QP,
selection: sF,
transition: CF,
call: kF.call,
nodes: kF.nodes,
node: kF.node,
size: kF.size,
empty: kF.empty,
each: kF.each,
on: tF,
attr: FP,
attrTween: BP,
style: pF,
styleTween: gF,
text: yF,
textTween: SF,
remove: rF,
tween: EP,
delay: UP,
duration: KP,
ease: JP,
easeVarying: XP,
end: wF,
[Symbol.iterator]: kF[Symbol.iterator]
};
//#endregion
//#region ../../node_modules/.pnpm/d3-ease@3.0.1/node_modules/d3-ease/src/quad.js
function AF(e) {
return ((e *= 2) <= 1 ? e * e : --e * (2 - e) + 1) / 2;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-ease@3.0.1/node_modules/d3-ease/src/cubic.js
function jF(e) {
return ((e *= 2) <= 1 ? e * e * e : (e -= 2) * e * e + 2) / 2;
}
//#endregion
//#region ../../node_modules/.pnpm/d3-transition@3.0.1_d3-selection@3.0.0/node_modules/d3-transition/src/selection/transition.js
var MF = {
time: null,
delay: 0,
duration: 250,
ease: jF
};
function NF(e, t) {
for (var n; !(n = e.__transition) || !(n = n[t]);) if (!(e = e.parentNode)) throw Error(`transition ${t} not found`);
return n;
}
function PF(e) {
var t, n;
e instanceof EF ? (t = e._id, e = e._name) : (t = OF(), (n = MF).time = aP(), e = e == null ? null : e + "");
for (var r = this._groups, i = r.length, a = 0; a < i; ++a) for (var o = r[a], s = o.length, c, l = 0; l < s; ++l) (c = o[l]) && _P(c, e, t, l, o, n || NF(c, t));
return new EF(r, this._parents, e, t);
}
ka.prototype.interrupt = CP, ka.prototype.transition = PF;
//#endregion
//#region ../../node_modules/.pnpm/d3-brush@3.0.0/node_modules/d3-brush/src/brush.js
var { abs: FF, max: IF, min: LF } = Math;
["w", "e"].map(RF), ["n", "s"].map(RF), [
"n",
"w",
"e",
"s",
"nw",
"ne",
"sw",
"se"
].map(RF);
function RF(e) {
return { type: e };
}
//#endregion
//#region ../../node_modules/.pnpm/d3-zoom@3.0.0/node_modules/d3-zoom/src/transform.js
function zF(e, t, n) {
this.k = e, this.x = t, this.y = n;
}
zF.prototype = {
constructor: zF,
scale: function(e) {
return e === 1 ? this : new zF(this.k * e, this.x, this.y);
},
translate: function(e, t) {
return e === 0 & t === 0 ? this : new zF(this.k, this.x + this.k * e, this.y + this.k * t);
},
apply: function(e) {
return [e[0] * this.k + this.x, e[1] * this.k + this.y];
},
applyX: function(e) {
return e * this.k + this.x;
},
applyY: function(e) {
return e * this.k + this.y;
},
invert: function(e) {
return [(e[0] - this.x) / this.k, (e[1] - this.y) / this.k];
},
invertX: function(e) {
return (e - this.x) / this.k;
},
invertY: function(e) {
return (e - this.y) / this.k;
},
rescaleX: function(e) {
return e.copy().domain(e.range().map(this.invertX, this).map(e.invert, e));
},
rescaleY: function(e) {
return e.copy().domain(e.range().map(this.invertY, this).map(e.invert, e));
},
toString: function() {
return "translate(" + this.x + "," + this.y + ") scale(" + this.k + ")";
}
};
var BF = new zF(1, 0, 0);
VF.prototype = zF.prototype;
function VF(e) {
for (; !e.__zoom;) if (!(e = e.parentNode)) return BF;
return e.__zoom;
}
//#endregion
//#region src/utils/is-pathway-layer.ts
function HF(e) {
return e.toLowerCase().includes(o);
}
//#endregion
//#region src/store/init/init-layers.ts
var UF = 1e3;
function WF(e) {
return e == null || yr(e) ? e : cr.fromMinMax({
x: e.x1,
y: e.y1
}, {
x: e.x2,
y: e.y2
});
}
function GF(e, t, n) {
let r = [], i = t;
return ja(Ha(e)).selectAll(`svg [data-layer="${e.name}"] > [data-layer]`).nodes().filter((e) => e.childNodes.length).forEach((t) => {
let a = t.getAttribute("data-layer"), o = new mz();
o.name = t.getAttribute("data-layer"), o.visible = e.visible, o.description = t.getAttribute("data-layer-description") || a, o.frozen = t.getAttribute("data-layer-isfrozen") === "true", o.rect = e.rect, o.viewbox = e.viewbox, o.mode = pz.Unset, o.rootParent = e.rootParent ? e.rootParent : e;
let s = GF(o, i, n);
i = s.priority + n, o.basePriority = i, s.layers.length && (o.childLayers = s.layers, r.push(...s.layers)), r.push(o);
}), {
layers: r,
priority: i
};
}
function KF(e) {
let { layerStore: t } = e, n = Or().__fpLayers;
t.mode = Or().__fpLayersMode || fz.Default;
let r = new URLSearchParams(window.location.search).get("layer"), i = (e, n) => r ? n.toLowerCase() === r.toLowerCase() : t.mode === fz.Default ? e.visible : e.mode == pz.TurnedOn, a = [], o = 0;
n ? n.forEach((e) => {
o += UF;
let t = new mz();
t.name = e.name, t.description = e.description, t.frozen = e.frozen, t.visible = i(e, t.shortName), t.rect = WF(e.rect), t.viewbox = WF(e.viewbox), t.mode = e.mode || pz.Unset, t.basePriority = o, t.floorIndex = e.floorIndex, a.push(t);
}) : ja(Ha()).selectAll("svg > [data-layer]").nodes().filter((e) => e.childNodes.length).forEach((e) => {
let t = e.getAttribute("data-layer");
if (!t.startsWith("WF")) {
var n;
o += UF;
let r = new mz();
r.name = t, r.visible = !0, r.description = e.getAttribute("data-layer-description") || t, r.frozen = e.getAttribute("data-layer-isfrozen") === "true", r.rect = (n = za().filter((e) => e.name === r.name || e.name === r.description)[0]) == null ? void 0 : n.rect, r.mode = pz.Unset, r.basePriority = o, a.push(r);
}
}), t.mode !== fz.Default && a.forEach((e) => {
e.mode === pz.AlwaysHidden ? (e.frozen = !0, e.visible = !1) : e.mode === pz.AlwaysVisible ? e.frozen = e.visible = !0 : e.mode === pz.TurnedOff ? (e.frozen = !1, e.visible = !1) : e.mode === pz.TurnedOn && (e.frozen = !1, e.visible = !0);
});
try {
a.forEach((e) => {
HF(e.name) && (e.frozen = !1, e.visible = !1, e.pathway = !0);
});
} catch (e) {
console.warn(e);
}
a = a.filter((e) => e.pathway || !e.frozen || e.frozen && e.visible), t.defaultLayer = a.find((e) => e.name === Or().__fpDefaultLayer), t.layers = [...t.layers, ...a];
}
//#endregion
//#region src/utils/loadBlob.ts
async function qF(e) {
try {
let t = await fetch(e, {
mode: "cors",
credentials: "omit"
});
if (!t.ok) return null;
let n = await t.blob();
return n.type.startsWith("image/") ? n : null;
} catch {
return null;
}
}
//#endregion
//#region src/utils/rasterize-svg.ts
function JF(e) {
return e.type.startsWith("image/svg+xml");
}
async function YF(e) {
let t = URL.createObjectURL(e);
try {
let e = await P(t);
if (!(e != null && e.naturalWidth) || !e.naturalHeight) return null;
let n = document.createElement("canvas");
n.width = e.naturalWidth, n.height = e.naturalHeight;
let r = n.getContext("2d");
return r ? (r.drawImage(e, 0, 0), n) : null;
} finally {
URL.revokeObjectURL(t);
}
}
async function XF(e) {
let t = await YF(e);
return t ? ZF(t) : null;
}
function ZF(e) {
return new Promise((t) => {
try {
e.toBlob((e) => t(e), "image/png");
} catch {
t(null);
}
});
}
//#endregion
//#region src/utils/loadLayerImages.ts
async function QF(e) {
let t = /* @__PURE__ */ new Map(), n = (e) => {
let n = t.get(e);
return n || (n = $F(e), t.set(e, n)), n;
};
return (await Promise.all(e.map(async (e) => {
var t, r, i, a;
let o = (t = e.getAttribute("xlink:href")) == null ? e.getAttribute("href") : t, s = o ? await n(o) : null;
if (!s) return null;
let c = cr.fromSvg(e), l = (r = (i = e.transform) == null || (i = i.animVal[0]) == null ? void 0 : i.angle) == null ? 0 : r, u = parseFloat((a = e.dataset.elev) == null ? "" : a) || 0;
return {
bounds: Xn.fromMinMax(c.min, c.max, wn(l), u),
source: s,
booth: null
};
}))).filter((e) => e !== null);
}
async function $F(e) {
let t = await qF(e);
return t ? JF(t) ? XF(t) : t : null;
}
async function eI(e) {
var t;
let n = [], r = [], i = [], a = ja(Ha(e)).select(`[data-layer="${e.name}"]`), o = a.selectAll(":scope > *:not([data-tagname='efp-booth']):not(g[data-is-editable='false']) path, :scope > path").nodes(), s = a.selectAll(":scope g[data-layer] > g[data-is-editable='false'] path, :scope > g[data-is-editable='false'] path, :scope > path[data-tagname='ptext']").nodes(), c = z.layerStore.mode === fz.Default ? "" : ((t = e.rootParent) == null ? void 0 : t.name) || e.name;
for (let e of o) {
let t = +e.getAttribute("data-index"), r;
e.tagName === "path" && t !== -1 ? r = tI({
color: e.style.fill,
index: t
}, c) : e.tagName === "rect" && (r = Kj(e)), r && n.push(r);
}
for (let e of s) {
let t = +e.getAttribute("data-index"), n;
e.tagName === "path" && t !== -1 ? n = tI({
color: e.style.fill,
index: t
}, c) : e.tagName === "rect" && (n = Kj(e)), n && r.push(n);
}
return i.push({
name: "bg",
children: n
}), i.push({
name: "fg",
children: r
}), Promise.resolve({
name: e.name,
children: i.filter((e) => e.children.length)
});
}
function tI(e, t) {
if (e.index === -1 || Number.isNaN(e.index)) return;
(!e.color || e.color === "none") && (e.color = "transparent");
let n = qj(Va(parseInt(e.index.toString()), t), e.color);
return n.unblinking = e.unblinking, n;
}
//#endregion
//#region src/utils/is-mobile.ts
var nI = /Android|webOS|iPhone|iPad|iPod|BlackBerry|Opera Mini/i.test(navigator.userAgent), rI = nI || N, iI = rI ? 8 : 512, aI = rI ? 100 : 0;
async function oI(e, t) {
return (e.preferred ? await t(e.preferred) : null) || (e.fallback ? t(e.fallback) : null);
}
async function sI(e, t, n, r) {
if (!e.size) return /* @__PURE__ */ new Map();
let i = Array.from(e.entries()), a = /* @__PURE__ */ new Map();
for (let e = 0; e < i.length; e += n) {
let o = i.slice(e, e + n), s = await Promise.all(o.map(async ([e, n]) => [e, await oI(n, t)]));
for (let [e, t] of s) t && a.set(e, t);
r && await new Promise((e) => setTimeout(e, r));
}
return a;
}
async function cI(e, t = iI, n = aI) {
return sI(e, P, t, n);
}
async function lI(e, t = iI, n = aI) {
let r = /* @__PURE__ */ new Map();
return sI(e, (e) => {
let t = r.get(e);
return t || (t = qF(e), r.set(e, t)), t;
}, t, n);
}
//#endregion
//#region src/components/Maplibre/utils/poi-marker-hit-test.ts
var uI = null, dI = {
set(e) {
uI = e;
},
test(e, t) {
return uI ? uI(e, t) : !1;
}
}, fI = De(() => ({
segments: [],
segmentToHitAreas: /* @__PURE__ */ new Map(),
prevSegment: null,
boothsWithPaths: []
}));
function pI() {
let e = Ee.booths.filter((e) => e.visible && e.rect && e.rect.size.width > 0 && e.rect.size.height > 0), t = fI();
if (t.segments = [], t.prevSegment = null, t.segmentToHitAreas = /* @__PURE__ */ new Map(), t.boothsWithPaths = e.filter((e) => e.paths), !e.length) return;
let n = [], r = Infinity, i = Infinity, a = -Infinity, o = -Infinity;
for (let t of e) {
let e = t.rotate ? new Xn(t.rect.center, t.rect.size, t.rotate) : null, s = e ? e.bounds : t.rect;
n.push({
booth: t,
shape: e == null ? t.rect : e,
bounds: s
}), s.min.x < r && (r = s.min.x), s.min.y < i && (i = s.min.y), s.max.x > a && (a = s.max.x), s.max.y > o && (o = s.max.y);
}
let s = cr.fromMinMax({
x: r,
y: i
}, {
x: a,
y: o
}), c = Math.ceil(s.size.width / 2), l = Math.ceil(s.size.height / 2);
for (let e = 0; e < 2; e++) for (let r = 0; r < 2; r++) {
let i = new cr(s.min.x + e * c, s.min.y + r * l, c, l);
t.segments.push(i), t.segmentToHitAreas.set(i, n.filter((e) => i.intersects(e.bounds)));
}
w.log("hover segmentToHitAreas", t.segmentToHitAreas);
}
function mI() {
OM(() => [
Ee.booths,
Ce.loaded,
Ce.visible
], () => pI(), { fireImmediately: !0 });
}
function hI(e, t) {
let n = fI(), r = {
x: e,
y: t
}, i;
i = n.prevSegment && n.prevSegment.containsPoint(r) ? n.prevSegment : n.segments.find((e) => e.containsPoint(r)), i && (n.prevSegment = i);
let a = i ? n.segmentToHitAreas.get(i) : void 0;
if (a) {
let e = a.filter((e) => e.booth.visible && e.shape.containsPoint(r));
if (e.length) return (e.length > 1 ? e.sort((e, t) => e.booth.rect.area - t.booth.rect.area)[0] : e[0]).booth;
}
for (let e of n.boothsWithPaths) if (e.visible) for (let t of e.paths) for (let n of Ba(t.index, Ce.mode === fz.Default ? "" : e.layer.name)) {
let t = n.map((e) => ({
x: e[0],
y: e[1]
}));
if (Gn.fromConvexRing(t).containsPoint(r)) return e;
}
return null;
}
function gI(e, t) {
return hI(e, t);
}
//#endregion
//#region src/components/Map/pointer.ts
function _I(e) {
AI = e;
}
function vI(e) {
kI = e;
}
function yI(e, t) {
for (let n of t) OI.set(n, e);
}
function bI(e) {
var t;
return (t = OI.get(e)) == null ? null : t;
}
function xI(e) {
B.setKioskModeEnabled || (e.stopPropagation(), B.hoveredBooth = TI(e.point, e.def));
}
function SI() {
B.setKioskModeEnabled || (B.hoveredBooth = null);
}
function CI(e) {
e.stopPropagation(), EI(e.point, e.nativeEvent) && z.clickBooth(TI(e.point, e.def));
}
function wI(e) {
EI(e.point, e.nativeEvent) && z.clickBooth(TI(e.point));
}
function TI(e, t) {
return (t ? bI(t) : null) || gI(e.x, e.y);
}
function EI(e, t) {
if (!B.rootElement) return !1;
if (DI(), AI == null || AI(e), B.overlayPosition === "bottom" && B.overlaySize === "full" && z.showMap(), B.onGetCoordsClick) {
let t = z.layerStore.layers.find((e) => e.visible && (e.mode === pz.TurnedOn || e.mode === pz.TurnedOff));
B.onGetCoordsClick({
x: e.x,
y: e.y,
z: (t == null ? void 0 : t.name) || null
});
}
if (B.setKioskModeEnabled || dI.test(t.clientX, t.clientY)) return !1;
if (B.onMarkerClick) {
var n;
let t = (n = kI == null ? void 0 : kI(e.x, e.y)) == null ? null : n;
B.onMarkerClick(t);
}
return !0;
}
function DI() {
if (typeof window > "u") return;
let e = window.__resett;
e == null || e();
}
var OI = /* @__PURE__ */ new WeakMap(), kI, AI;
//#endregion
//#region src/utils/blob-image-size.ts
async function jI(e) {
try {
let t = await createImageBitmap(e), n = {
width: t.width,
height: t.height
};
return t.close(), n;
} catch {
return null;
}
}
//#endregion
//#region src/components/Map/drawing/config/booth-logos.ts
function MI(e) {
return e.exhibitors.find((e) => e.logoInBooth && e.logo);
}
function NI(e) {
var t;
let n = (t = MI(e)) == null ? void 0 : t.logoAspectRatio;
return typeof n == "number" && Number.isFinite(n) && n > 0 ? n : void 0;
}
function PI() {
let e = /* @__PURE__ */ new Map(), t = (t) => {
let n = e.get(t);
return n || (n = FI(t), e.set(t, n)), n;
}, n = /* @__PURE__ */ new Map(), r = (e) => {
let t = n.get(e);
return t || (t = II(e), n.set(e, t)), t;
};
return async (e, n) => {
var i;
let a = await t(n);
if (!a) return null;
let o = (i = NI(e)) == null ? await r(a) : i;
return o === null ? null : {
blob: a,
aspectRatio: o
};
};
}
async function FI(e) {
return JF(e) ? XF(e) : e;
}
async function II(e) {
let t = await jI(e);
return t != null && t.height ? t.width / t.height : null;
}
//#endregion
//#region ../../node_modules/.pnpm/color-parse@1.4.3/node_modules/color-parse/index.js
var LI = /* @__PURE__ */ t(((e, t) => {
var n = Po();
t.exports = i;
var r = {
red: 0,
orange: 60,
yellow: 120,
green: 180,
blue: 240,
purple: 300
};
function i(e) {
var t, i = [], a = 1, o;
if (typeof e == "string") if (e = e.toLowerCase(), n[e]) i = n[e].slice(), o = "rgb";
else if (e === "transparent") a = 0, o = "rgb", i = [
0,
0,
0
];
else if (/^#[A-Fa-f0-9]+$/.test(e)) {
var s = e.slice(1), c = s.length, l = c <= 4;
a = 1, l ? (i = [
parseInt(s[0] + s[0], 16),
parseInt(s[1] + s[1], 16),
parseInt(s[2] + s[2], 16)
], c === 4 && (a = parseInt(s[3] + s[3], 16) / 255)) : (i = [
parseInt(s[0] + s[1], 16),
parseInt(s[2] + s[3], 16),
parseInt(s[4] + s[5], 16)
], c === 8 && (a = parseInt(s[6] + s[7], 16) / 255)), i[0] || (i[0] = 0), i[1] || (i[1] = 0), i[2] || (i[2] = 0), o = "rgb";
} else if (t = /^((?:rgb|hs[lvb]|hwb|cmyk?|xy[zy]|gray|lab|lchu?v?|[ly]uv|lms)a?)\s*\(([^\)]*)\)/.exec(e)) {
var u = t[1], d = u === "rgb", s = u.replace(/a$/, "");
o = s;
var c = s === "cmyk" ? 4 : s === "gray" ? 1 : 3;
i = t[2].trim().split(/\s*[,\/]\s*|\s+/).map(function(e, t) {
if (/%$/.test(e)) return t === c ? parseFloat(e) / 100 : s === "rgb" ? parseFloat(e) * 255 / 100 : parseFloat(e);
if (s[t] === "h") {
if (/deg$/.test(e)) return parseFloat(e);
if (r[e] !== void 0) return r[e];
}
return parseFloat(e);
}), u === s && i.push(1), a = d || i[c] === void 0 ? 1 : i[c], i = i.slice(0, c);
} else e.length > 10 && /[0-9](?:\s|\/)/.test(e) && (i = e.match(/([0-9]+)/g).map(function(e) {
return parseFloat(e);
}), o = e.match(/([a-z])/gi).join("").toLowerCase());
else isNaN(e) ? Array.isArray(e) || e.length ? (i = [
e[0],
e[1],
e[2]
], o = "rgb", a = e.length === 4 ? e[3] : 1) : e instanceof Object && (e.r != null || e.red != null || e.R != null ? (o = "rgb", i = [
e.r || e.red || e.R || 0,
e.g || e.green || e.G || 0,
e.b || e.blue || e.B || 0
]) : (o = "hsl", i = [
e.h || e.hue || e.H || 0,
e.s || e.saturation || e.S || 0,
e.l || e.lightness || e.L || e.b || e.brightness
]), a = e.a || e.alpha || e.opacity || 1, e.opacity != null && (a /= 100)) : (o = "rgb", i = [
e >>> 16,
(e & 65280) >>> 8,
e & 255
]);
return {
space: o,
values: i,
alpha: a
};
}
})), RI = /* @__PURE__ */ t(((e, t) => {
t.exports = {
name: "rgb",
min: [
0,
0,
0
],
max: [
255,
255,
255
],
channel: [
"red",
"green",
"blue"
],
alias: ["RGB"]
};
})), zI = /* @__PURE__ */ t(((e, t) => {
var n = RI();
t.exports = {
name: "hsl",
min: [
0,
0,
0
],
max: [
360,
100,
100
],
channel: [
"hue",
"saturation",
"lightness"
],
alias: ["HSL"],
rgb: function(e) {
var t = e[0] / 360, n = e[1] / 100, r = e[2] / 100, i, a, o, s, c;
if (n === 0) return c = r * 255, [
c,
c,
c
];
a = r < .5 ? r * (1 + n) : r + n - r * n, i = 2 * r - a, s = [
0,
0,
0
];
for (var l = 0; l < 3; l++) o = t + 1 / 3 * -(l - 1), o < 0 ? o++ : o > 1 && o--, c = 6 * o < 1 ? i + (a - i) * 6 * o : 2 * o < 1 ? a : 3 * o < 2 ? i + (a - i) * (2 / 3 - o) * 6 : i, s[l] = c * 255;
return s;
}
}, n.hsl = function(e) {
var t = e[0] / 255, n = e[1] / 255, r = e[2] / 255, i = Math.min(t, n, r), a = Math.max(t, n, r), o = a - i, s, c, l;
return a === i ? s = 0 : t === a ? s = (n - r) / o : n === a ? s = 2 + (r - t) / o : r === a && (s = 4 + (t - n) / o), s = Math.min(s * 60, 360), s < 0 && (s += 360), l = (i + a) / 2, c = a === i ? 0 : l <= .5 ? o / (a + i) : o / (2 - a - i), [
s,
c * 100,
l * 100
];
};
})), BI = /* @__PURE__ */ t(((e, t) => {
var n = LI(), r = zI();
function i(e, t, n) {
return t < n ? e < t ? t : e > n ? n : e : e < n ? n : e > t ? t : e;
}
function a(e, t, n) {
return e * (1 - n) + t * n;
}
t.exports = o;
function o(e) {
return e = e.map(function(e) {
if (e = n(e), e.space != "rgb") {
if (e.space != "hsl") throw "c.spacespace is not supported.";
e.values = r.rgb(e.values);
}
return e.values.push(e.alpha), e.values;
}), function(t, n) {
n = n || a, t = i(t, 0, 1);
var r = (e.length - 1) * t, o = Math.floor(r), s = Math.ceil(r);
t = r - o;
var c = e[o], l = e[s], u = c.map(function(e, r) {
return e = n(e, l[r], t), r < 3 && (e = Math.round(e)), e;
});
return u[3] === 1 ? "rgb(" + u.slice(0, 3) + ")" : "rgba(" + u + ")";
};
}
})), VI = "rt";
function HI() {
return new URLSearchParams(u(window.location.search)).get(VI);
}
function UI() {
let e = HI();
return e || (e = sessionStorage.getItem(VI)), e;
}
function WI(e, t) {
let n = new URL(e, "https://app.expofp.com/");
for (let [e, r] of Object.entries(t)) n.searchParams.set(e, r);
return n.href;
}
//#endregion
//#region src/store/ExhibitorStore.ts
var GI, KI, qI, JI, YI, XI, ZI, QI, $I, eL, tL, nL, rL, iL, aL;
function oL(e, t, n, r) {
n && Object.defineProperty(e, t, {
enumerable: n.enumerable,
configurable: n.configurable,
writable: n.writable,
value: n.initializer ? n.initializer.call(r) : void 0
});
}
function sL(e, t, n, r, i) {
var a = {};
return Object.keys(r).forEach(function(e) {
a[e] = r[e];
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) {
return r(e, t, n) || n;
}, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a;
}
var cL = /*#__PURE__*/ function(e) {
return e[e.Unasked = 0] = "Unasked", e[e.Accepted = 1] = "Accepted", e[e.Rejected = 2] = "Rejected", e[e.Undecided = 3] = "Undecided", e;
}({}), lL = (ZI = E({ keepAlive: !0 }), QI = E({ keepAlive: !0 }), $I = E({ keepAlive: !0 }), eL = E({ keepAlive: !0 }), tL = E({ keepAlive: !0 }), nL = class {
constructor(e) {
this.rootStore = void 0, this.exhibitors = [], this.timeout = void 0, oL(this, "highlightedByExternalIds", rL, this), oL(this, "rebookingStateChangeRequested", iL, this), oL(this, "rebookingStateSaved", aL, this), this.rootStore = e;
}
get exhibitorById() {
return new Map(this.exhibitors.map((e) => [e.id, e]));
}
get exhibitorByExternalId() {
return new Map(this.exhibitors.map((e) => [e.externalId, e]));
}
get exhibitorByName() {
return new Map(this.exhibitors.map((e) => [e.name.toLowerCase(), e]));
}
get exhibitorBySlug() {
return new Map(this.exhibitors.map((e) => [e.slug, e]));
}
get bookmarked() {
return this.exhibitors.filter((e) => e.bookmarked);
}
get visited() {
return this.exhibitors.filter((e) => e.visited);
}
get advertised() {
return this.exhibitors.filter((e) => {
var t;
return e.advertise && ((t = e.logo) == null ? void 0 : t.url);
});
}
replaceBookmarked(e) {
if (!Array.isArray(e)) return;
let t = (e || []).map((e) => this.exhibitorById.get(e)).filter((e) => e), n = new Set(t), r = this.bookmarked.filter((e) => !n.has(e));
for (let e of r) e.bookmarked = !1;
for (let e of t) e.bookmarked = !0;
}
replaceVisited(e) {
if (!Array.isArray(e)) return;
let t = (e || []).map((e) => this.exhibitorById.get(e)).filter((e) => e), n = new Set(t), r = this.visited.filter((e) => !n.has(e));
for (let e of r) e.visited = !1;
for (let e of t) e.visited = !0;
}
setRebookingState(e, t, n) {
clearTimeout(this.timeout), this.rebookingStateChangeRequested = !1, e.rebookingState = t, e.rebookingNote = n;
let r = WI("api/v1/set-rebooking-state", {
rt: UI(),
expoKey: this.rootStore.fp.eventId
});
fetch(r, {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
expoKey: Ja.EXPO,
exhibitorId: e.id,
rebookingState: t,
rebookingNote: n
})
}).then((t) => {
t.ok && (this.rebookingStateSaved = !0), !t.ok && !T && (e.rebookingState = cL.Unasked, this.rebookingStateSaved = !1);
}).catch(() => {
e.rebookingState = cL.Unasked, this.rebookingStateSaved = !1;
}).finally(() => {
this.rebookingStateChangeRequested = !0, this.timeout = setTimeout(() => {
this.rebookingStateChangeRequested = !1;
}, 5e3);
});
}
findExhibitor(e) {
return this.exhibitorByExternalId.get(e) || this.exhibitorByName.get(e.toLowerCase()) || this.exhibitorBySlug.get(e);
}
}, rL = sL(nL.prototype, "highlightedByExternalIds", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return [];
}
}), iL = sL(nL.prototype, "rebookingStateChangeRequested", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), aL = sL(nL.prototype, "rebookingStateSaved", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), sL(nL.prototype, "exhibitorById", [ZI], Object.getOwnPropertyDescriptor(nL.prototype, "exhibitorById"), nL.prototype), sL(nL.prototype, "exhibitorByExternalId", [QI], Object.getOwnPropertyDescriptor(nL.prototype, "exhibitorByExternalId"), nL.prototype), sL(nL.prototype, "exhibitorByName", [$I], Object.getOwnPropertyDescriptor(nL.prototype, "exhibitorByName"), nL.prototype), sL(nL.prototype, "exhibitorBySlug", [eL], Object.getOwnPropertyDescriptor(nL.prototype, "exhibitorBySlug"), nL.prototype), sL(nL.prototype, "bookmarked", [E], Object.getOwnPropertyDescriptor(nL.prototype, "bookmarked"), nL.prototype), sL(nL.prototype, "visited", [E], Object.getOwnPropertyDescriptor(nL.prototype, "visited"), nL.prototype), sL(nL.prototype, "advertised", [tL], Object.getOwnPropertyDescriptor(nL.prototype, "advertised"), nL.prototype), sL(nL.prototype, "replaceBookmarked", [A], Object.getOwnPropertyDescriptor(nL.prototype, "replaceBookmarked"), nL.prototype), sL(nL.prototype, "replaceVisited", [A], Object.getOwnPropertyDescriptor(nL.prototype, "replaceVisited"), nL.prototype), sL(nL.prototype, "setRebookingState", [A], Object.getOwnPropertyDescriptor(nL.prototype, "setRebookingState"), nL.prototype), nL), uL = (GI = class {
constructor() {
this.store = void 0, this.id = void 0, this.name = void 0, this.externalId = void 0, oL(this, "featured", KI, this), this.advertise = void 0, this.description = void 0, this.address = void 0, this.address2 = void 0, this.city = void 0, this.state = void 0, this.zip = void 0, this.country = void 0, this.phone1 = void 0, this.website = void 0, this.facebook = void 0, this.instagram = void 0, this.linkedin = void 0, this.twitter = void 0, this.googlePlus = void 0, this.xing = void 0, this.youtube = void 0, this.email = void 0, this.privateEmail = void 0, this.customButtonTitle = void 0, this.customButtonUrl = void 0, this.customButton2Title = void 0, this.customButton2Url = void 0, this.customButton3Title = void 0, this.customButton3Url = void 0, this.leadingImageUrl = void 0, this.leadingImageLinkUrl = void 0, this.videoUrl = void 0, this.order = void 0, this.logo = void 0, this.logoInBooth = void 0, this.logoAspectRatio = void 0, this.gallery = void 0, this.marketMaterials = void 0, this.slug = void 0, oL(this, "bookmarked", qI, this), oL(this, "visited", JI, this), oL(this, "rebookingState", YI, this), oL(this, "rebookingNote", XI, this), this.booths = void 0, this.categories = void 0, this.schedule = void 0, this.entity = { type: "exhibitor" };
}
}, KI = sL(GI.prototype, "featured", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), qI = sL(GI.prototype, "bookmarked", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), JI = sL(GI.prototype, "visited", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), YI = sL(GI.prototype, "rebookingState", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), XI = sL(GI.prototype, "rebookingNote", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), GI), dL = {
[cL.Unasked]: {
iconName: "icon-question-mark",
color: {
primary: "#8E99AB",
secondary: "#EAEFF9"
}
},
[cL.Accepted]: {
iconName: "icon-checkmark",
color: {
primary: "#32B175",
secondary: "#E4FFF2"
}
},
[cL.Rejected]: {
iconName: "icon-close",
color: {
primary: "#E1463C",
secondary: "#FFEDEB"
}
},
[cL.Undecided]: {
iconName: "icon-switch-horizontal",
color: {
primary: "#FABA27",
secondary: "#FFF7E5"
}
}
}, fL = (e) => {
if (!e || e === "transparent" || e === "none") return !1;
try {
return (0, AM.default)(e), !0;
} catch {
return !1;
}
};
function pL(e) {
if (e.length === 0) return null;
let t = e[0];
return e.every((e) => e === t) ? t : null;
}
function mL(e) {
let t = Ja.colors.booths.default;
if (e instanceof Hj) t = e.color || Ja.colors.booths.empty;
else if (e instanceof Vj) {
if (Dr.isRebooking) {
var n, r;
if (!((n = e.exhibitors) != null && n.length)) return dL[cL.Unasked].color.primary;
let t = pL(((r = e.exhibitors) == null ? [] : r).map((e) => e.rebookingState));
return t === null ? "#000000" : dL[t].color.primary;
}
let i = Ja.colors.booths;
t = e.onHold ? e.holdColor || i.defaultHold : e.exhibitors.length || e.reserved ? e.soldColor || i.defaultSold : e.availColor || i.empty;
}
try {
t === "none" && (t = Ja.colors.booths.default), (0, AM.default)(t);
} catch (e) {
t = Ja.colors.booths.default, console.error("Booth: defaultColor", e);
}
return t;
}
function hL(e) {
var t;
if (B.heatmap) return Te.getHeatmapColorForBooth(e).rgb().string();
let n = (t = e.paths) == null || (t = t[0]) == null ? void 0 : t.color, r = fL(n) ? n : mL(e);
return B.monochrome || B.heatmapYah ? (0, AM.default)(r).grayscale().rgb().string() : r;
}
//#endregion
//#region src/components/Map/drawing/config/BoothShape.ts
var gL, _L;
function vL(e, t, n, r) {
n && Object.defineProperty(e, t, {
enumerable: n.enumerable,
configurable: n.configurable,
writable: n.writable,
value: n.initializer ? n.initializer.call(r) : void 0
});
}
function yL(e, t, n, r, i) {
var a = {};
return Object.keys(r).forEach(function(e) {
a[e] = r[e];
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) {
return r(e, t, n) || n;
}, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a;
}
var bL = Oe(), xL = (gL = class e {
constructor(e) {
vL(this, "selectBgAnimationPart", _L, this), SL(() => e.selected, (e) => this.selectBgAnimationPart = AF(e), 1e3, 8, !0);
}
static get(t) {
let n = bL().get(t);
return n || (n = new e(t), bL().set(t, n)), n;
}
}, _L = yL(gL.prototype, "selectBgAnimationPart", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return 0;
}
}), gL);
function SL(e, t, n, r, i) {
let a = i ? s : o;
r % 2 == 1 && r++, S(k(e, () => {
if (e()) {
let i = performance.now(), o = i + r * n, s = () => {
if (e()) {
if (performance.now() >= o) {
t(1);
return;
}
t(a(i, n)), window.requestAnimationFrame(s);
}
};
s();
} else t(0);
}, { fireImmediately: !0 }));
function o(e, t) {
return (performance.now() - e) % t / 1e3;
}
function s(e, t) {
let n = ((performance.now() - e) % (t * 2) - t) / 1e3;
return 1 - Math.abs(Math.abs(n) - t / 1e3) / (t / 1e3);
}
}
//#endregion
//#region src/components/Map/drawing/config/BoothDrawerBase.ts
var CL = class {
constructor(e) {
this.booth = void 0, this.boothShape = void 0, this.booth = e, this.boothShape = xL.get(e);
}
}, wL = /* @__PURE__ */ e(BI(), 1), TL, EL, DL;
function OL(e, t, n, r, i) {
var a = {};
return Object.keys(r).forEach(function(e) {
a[e] = r[e];
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) {
return r(e, t, n) || n;
}, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a;
}
function kL(e) {
return new jL(e);
}
function AL(e, t) {
let n = [];
for (let r of e) {
let e = tI({
index: r.index,
color: r.color,
unblinking: r.unblinking
}, t);
e && n.push(e);
}
return n;
}
var jL = (TL = E({ keepAlive: !0 }), EL = E({ keepAlive: !0 }), DL = class extends CL {
constructor(e) {
if (super(e), e.paths) e.shapes = AL(e.paths, z.layerStore.mode === fz.Default ? "" : e.layer.name).map((e) => {
let t = B.monochrome ? (0, AM.default)(e.color).grayscale().rgb().string() : this.getBoothColor().string();
return e.color === "transparent" ? e.color = t : e.defaultColor = e.color, e;
});
else {
let t = e.borderColor === "none" ? 0 : isNaN(e.borderWidth) ? Ee.borderWidth : e.borderWidth, n = this.booth.rect.expand(-t / 2), r = this.getBoothColor().string();
e.shapes = [Jj(new Xn(n.center, n.size, this.booth.rotate, this.booth.elevation), r)];
}
OM(() => this.booth.hover, () => !this.booth.selected && this.update()), OM(() => [
Ce.layersLoaded,
this.booth.skipDim,
this.booth.selected,
this.boothShape.selectBgAnimationPart
], () => this.update());
}
getShape() {
return this.booth.shapes;
}
update() {
if (Ce.layersLoaded) for (let e of this.booth.shapes) e.dim = this.booth.skipDim ? 0 : void 0, e.color && !e.unblinking && (e.color = (e.defaultColor ? this.getBoothPathColor(e.defaultColor) : this.getBoothColor()).string()), ud(e);
}
get poiHighlighted() {
let e = this.booth;
return !e.selected && e.poiTypeId != null && e.skipDim;
}
getBoothPathColor(e) {
if (B.heatmap) return this.getHeatmapColor();
let t = this.booth, n = Ja.colors.booths.selected, r = (0, AM.default)(this.poiHighlighted ? n : e).hsl();
if (t.selected) {
var i;
if ((i = Or().__fpSettings) != null && i.fpVer) {
let e = this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart), t = (0, AM.default)(e === "none" ? n : e);
return B.monochrome ? t.grayscale() : t;
}
let e = (0, AM.default)(n).hsl(), t = e.lightness() * this.boothShape.selectBgAnimationPart;
r = r.hue(e.hue()).lightness(t);
} else t.hover && (r = r.darken(.1));
return B.monochrome && (r = r.grayscale()), r;
}
getHeatmapColor() {
let e = this.booth, t = Te.getHeatmapColorForBooth(e);
if (e.selected) {
let e = this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart);
return (0, AM.default)(e === "none" ? "#f33" : e);
}
return e.hover ? t.darken(.2).alpha(t.alpha() * 1.5) : t;
}
get defaultColor() {
return mL(this.booth);
}
get selectedColorInterpolateFunc() {
var e, t;
return (0, wL.default)([Ja.colors.booths.seectedLight || ((0, AM.default)(this.booth.labelColor || Ja.boothLabelColor).isLight() ? "#000" : "#fff"), B.selectedRoute ? Ja == null || (e = Ja.colors) == null || (e = e.booths) == null || (e = e.wayfinding) == null ? void 0 : e.selected : Ja == null || (t = Ja.colors) == null || (t = t.booths) == null ? void 0 : t.selected]);
}
getBoothColor() {
let e = this.booth;
if (B.heatmap) return this.getHeatmapColor();
let t;
t = e.error ? "#f33" : Dr.isRebooking ? this.defaultColor : e.selected ? this.selectedColorInterpolateFunc(this.boothShape.selectBgAnimationPart) : this.poiHighlighted ? Ja.colors.booths.selected : this.defaultColor;
let n;
try {
n = (0, AM.default)(t === "none" ? "#f33" : t);
} catch {
n = (0, AM.default)(this.defaultColor);
}
return (e.hover && !e.selected || e.selected && Dr.isRebooking) && (n = n.darken(.2).alpha(n.alpha() * 1.5)), (B.monochrome || B.heatmapYah) && (n = n.grayscale()), n;
}
}, OL(DL.prototype, "defaultColor", [TL], Object.getOwnPropertyDescriptor(DL.prototype, "defaultColor"), DL.prototype), OL(DL.prototype, "selectedColorInterpolateFunc", [EL], Object.getOwnPropertyDescriptor(DL.prototype, "selectedColorInterpolateFunc"), DL.prototype), DL);
//#endregion
//#region src/components/Map/drawing/config/config-booth-bookmark.ts
function ML(e) {
if (!B.kiosk) return new NL(e);
}
var NL = class extends CL {
constructor(e) {
super(e), this.shape = void 0, this.bookmarkId = void 0, this.canvas = void 0, this.rect = void 0, this.padding = void 0, this.getShape = () => this.shape, this.padding = this.booth.borderWidth / 2, this.rect = new Xn(this.booth.rect.center, this.booth.rect.size, this.booth.rotate, this.booth.elevation), this.canvas = ho(PL, devicePixelRatio), this.bookmarkId = `bookmark-${this.booth.id}`, this.shape = Yj(this.canvas, this.rect, { hidden: !e.bookmarked }), this.shape.onScale = ({ pixelSize: e }) => this.layOutBookmark(e), OM(() => [
e.bookmarked,
Ce.layersLoaded,
this.booth.skipDim
], () => this.update(e.bookmarked), { fireImmediately: e.bookmarked }), OM(() => B.mapSettings, ({ roll: e }) => {
fj(e == null ? 0 : e) && (this.shape.onRoll = ({ roll: e, pixelSize: t }) => {
let n = cj(e, this.rect.rotation);
if (n !== 0) return this.rect = sj(this.rect, n), this.layOutBookmark(t), [this.shape];
});
}, { fireImmediately: !0 });
}
update(e) {
Ce.layersLoaded && (this.shape.hidden = !e, this.shape.dim = this.booth.skipDim ? 0 : void 0, ud(this.shape));
}
layOutBookmark(e) {
return this.shape.bounds = dj(this.rect, mo(PL), this.padding, e), this.shape.hidden ? [] : [this.shape];
}
}, PL = 11;
//#endregion
//#region src/components/Map/drawing/config/config-booth-border.ts
function FL(e) {
if (Ja.EXPO !== "confex20" && !(e.poiType || e.borderColor === "none" || e.borderWidth === 0 && !Ee.borderWidth || e.paths && !e.pathsWithRect)) return new IL(e);
}
var IL = class extends CL {
constructor(e) {
super(e), this.shape = void 0;
let t = this.booth.rect, { x: n, y: r } = t.center, { width: i, height: a } = t.size, o = e.borderWidth || Ee.borderWidth, s = [], c = (t, i, a, o) => {
var c;
let l = new Xn({
x: t,
y: i
}, {
x: a,
y: o
}, 0, e.elevation).toPolygon();
s.push(l.rotate((c = e.rotate) == null ? 0 : c, {
x: n,
y: r
}));
};
c(n, r - a / 2, i + o, o), c(n, r + a / 2, i + o, o), c(n - i / 2, r, o, a + o), c(n + i / 2, r, o, a + o);
let l = Gn.merge(...s), u = this.getBorderColor();
this.shape = Jj(l, u.string()), OM(() => [
this.booth.skipDim,
Ce.layersLoaded,
this.booth.hover,
this.booth.selected,
B.heatmap
], () => {
Ce.layersLoaded && (this.shape.dim = this.booth.skipDim ? 0 : void 0, this.shape.color = this.getBorderColor().string(), ud(this.shape));
});
}
getBorderColor() {
let e = this.booth;
if (B.heatmap) {
let t = Te.getHeatmapColorForBooth(e);
if (e.selected) {
let e = Ja.colors.booths.selectedBorder;
return e ? (0, AM.default)(e) : t.darken(.4);
}
return e.hover ? t.darken(.3) : t.darken(.2);
}
return (0, AM.default)((e.selected ? Ja.colors.booths.selectedBorder : e.borderColor) || Ja.colors.booths.default);
}
getShape() {
return this.shape;
}
}, LL = /[\u0600-\u06FF\u0750-\u077F\u08A0-\u08FF\uFB50-\uFDFF\uFE70-\uFEFF]/u;
function RL(e) {
return LL.test(e);
}
//#endregion
//#region src/components/Map/drawing/config/label-inset.ts
var zL = .05;
function BL(e, t) {
let n = zL * Math.min(t.width, t.height);
return e > 0 && n > 0 ? Math.min(e / 2, n) : 0;
}
//#endregion
//#region src/components/Map/drawing/config/config-booth-labels.ts
function VL() {
return Ja.EXPO === "tqs2021" ? "#000" : Ja.boothLabelColor;
}
var HL = nI || N, UL = (e) => e.replace(" ", "").substring(0, 4).replace(/[0-9]/g, "3").replace(/[A-Z]/gi, "A"), WL = document.createElement("canvas").getContext("2d");
function GL(e) {
if (!(!(e instanceof Vj) || e.noLabels)) return new eR(e);
}
function KL(e) {
return Array.isArray(e) && e.length > 0 ? Math.max(...e.map((e) => e)) : typeof e == "number" ? e : -0;
}
var qL = () => {
var e, t;
return !!((e = B.selectedRoute) != null && e.from && (t = B.selectedRoute) != null && t.to);
};
function JL(e, t = [], n = "normal") {
let r = [
...t,
{
weight: 500,
url: Uj,
style: "normal"
},
{
weight: 300,
url: Wj,
style: "normal"
}
].find((t) => +t.weight === e && t.style === n);
return (r == null ? void 0 : r.url) || Uj;
}
function YL(e, t) {
return Number(getComputedStyle(document.body).getPropertyValue(e)) || t;
}
function XL() {
return {
main: YL(v, 500),
details: YL(_, 300)
};
}
function ZL() {
return {
main: YL(c, 500),
details: YL(l, 300)
};
}
function QL() {
return XL().main;
}
var $L = "Details", eR = class extends CL {
constructor(e) {
super(e), this.canvasRect = void 0, this.paddingScaled = void 0, this.padding = void 0, this.minZoomDotVisible = 0, this.maxZoomDotVisible = 0, this.exh = [], this.shapeLabel = void 0, this.shapeDot = void 0, this.fontSizes = [[], []], this.lines = [[], []], this.topLeftAlignment = void 0, this.centerAlignment = void 0, this.prefixes = void 0, this.fontUrls = ["", ""], this.canvasRect = new Xn(e.rect.center, e.rect.size, e.rotate, e.elevation), this.paddingScaled = [4, 4], this.padding = BL(e.borderWidth || Ee.borderWidth, e.rect.size), this.topLeftAlignment = {
horizontal: B.rtl ? "right" : "left",
vertical: "top"
}, this.centerAlignment = {
horizontal: "center",
vertical: "center"
}, this.prefixes = HL ? [
{
fontSize: 7,
name: "XS",
short: !0
},
{
fontSize: 10,
name: "S",
short: !0
},
{
fontSize: 16,
name: $L,
short: !1
}
] : [
{
fontSize: 7,
name: "XS",
short: !0
},
{
fontSize: 10,
name: "S",
short: !0
},
{
fontSize: 12,
name: "M",
short: !0
},
{
fontSize: 14,
name: "L",
short: !0
},
{
fontSize: 18,
name: $L,
short: !1
}
], !(e instanceof Hj) && (this.exh = Dr.hideExhibitors ? [] : Dr.onlyFeaturedExhibitors ? e.exhibitors.filter((e) => e.featured) : e.exhibitors, HL && this.optimizationLevel() >= 3 && (this.prefixes = this.prefixes.filter((e) => e.name !== "S")), this.createLines(), this.calculateFontSizeFactors(), this.shapeLabel = Xj(Zj(this.lines, this.booth.labelColor || VL(), 0, this.fontUrls), new Xn(this.booth.rect.center, this.booth.rect.size, this.booth.rotate, this.booth.elevation), [...this.paddingScaled], {
horizontal: "left",
vertical: "top"
}), this.shapeLabel.onScale = ({ pixelSize: e }) => this.layOutLabel(e), this.getShapeDot(), OM(() => Ce.layersLoaded && this.booth.skipDim === !0, (e) => {
this.shapeLabel.dim = e ? 0 : void 0, this.shapeDot.dim = e ? 0 : void 0, ud(this.shapeLabel, this.shapeDot);
}), OM(() => B.mapSettings, ({ roll: e }) => {
fj(e == null ? 0 : e) && (this.shapeLabel.onRoll = ({ roll: e, pixelSize: t }) => {
let n = cj(e, this.shapeLabel.bounds.rotation);
if (n === 0) return;
let { size: r } = this.canvasRect;
return this.shapeLabel = oj(this.shapeLabel, n), !this.shapeLabel.hidden && !this.exh.length && r.x !== r.y && (this.canvasRect = sj(this.canvasRect, n), this.calculateFontSizeFactors(), this.layOutLabel(t), this.layOutDot(t)), [this.shapeLabel, this.shapeDot];
});
}, { fireImmediately: !0 }));
}
getShape() {
return [this.shapeLabel, this.shapeDot];
}
layOutLabel(e) {
var t, n;
let r = (t = this.lines[1]) == null ? [] : t, i = (n = this.fontSizes[1]) == null ? [] : n;
if (Ja.EXPO !== "wineparis2026") {
let t = this.exh.length ? this.topLeftAlignment : r.length ? e < i[i.length - 1].scaleFactor ? this.topLeftAlignment : this.centerAlignment : this.topLeftAlignment;
this.shapeLabel.alignment = t;
}
return aj(this.shapeLabel.lines, e, this.fontSizes) ? (this.shapeLabel.padding[0] = this.paddingScaled[0] * e + this.padding, this.shapeLabel.padding[1] = this.paddingScaled[1] * e + this.padding, [this.shapeLabel]) : [];
}
layOutDot(e) {
let t = e >= this.minZoomDotVisible && e <= this.maxZoomDotVisible;
if (!t && this.shapeDot.hidden) return [];
let n = this.shapeDot.bounds;
return n.scale({
x: nM * e / n.size.x,
y: nM * e / n.size.y
}, n.center, n), this.shapeDot.hidden = !t, [this.shapeDot];
}
getShapeDot() {
this.shapeDot = eM(this.canvasRect, this.booth.labelColor || VL()), this.shapeDot.hidden = !0, this.shapeDot.onScale = ({ pixelSize: e }) => this.layOutDot(e), this.maxZoomDotVisible = Math.min(this.canvasRect.size.x / nM, this.canvasRect.size.y / nM);
}
createLines() {
let e = this.booth, t = [], n = [], r = HL && this.optimizationLevel() >= 3 ? 1 : 3;
if (this.exh.length) {
let i = e.exhibitors.filter((e) => e.order === 0), a = e.exhibitors.filter((e) => e.order);
if (i.length > 0) t.push(...i.map((e) => e.name));
else if (Dr.onlyFeaturedExhibitors) t.push(...e.exhibitors.filter((e) => e.featured).map((e) => e.name));
else if (a.length > 0) {
t.push(...a.map((e) => e.name));
let n = e.exhibitors.filter((e) => e.order === void 0);
n.length > 0 && t.push(g("and {{moreCount}} more", { moreCount: n.length }));
} else e.exhibitors.length > r ? t.push(`${e.exhibitors.length} ${Dr.exhibitorTermPlural}`) : t.push(...e.exhibitors.map((e) => e.name));
n.push(e.title || e.name);
} else {
let r = !!e.exhibitors.length;
t.push(e.title || e.name), e.onHold ? n.push(g("On Hold")) : e.reserved ? n.push(g("Reserved")) : r || n.push(...e.exhibitors.map((e) => e.name).sort((e, t) => e > t ? 1 : -1)), e.size && n.push(e.size.indexOf("/") > -1 ? e.size.substring(0, e.size.indexOf("/")).trim() : e.size), e.price && e.price !== "0" && !B.previewMode && n.push(e.price);
}
B.rtl && t.forEach((e, n) => {
(e.endsWith(".") || e.endsWith("!") || e.endsWith("?")) && (t[n] = t[n] + ""), RL(e) && (t[n] = t[n] + " ");
}), this.lines = [t, n];
}
calculateFontSizeFactors() {
let e = this.lines[0], t, n = this.canvasRect, r = [], i = [], a = this.prefixes.slice(0, this.exh.length ? this.prefixes.length : this.prefixes.length - 1), { main: o, details: s } = this.exh.length ? ZL() : XL();
for (let { fontSize: c, short: l } of a) {
let a = c, u = .9 * c, d = uo(a, o), f = uo(u, s), p = Dr.hideExhibitorBoothNumber || l, m, h, g, _;
if (this.exh.length) t = l ? [] : this.lines[1], g = Math.max(...e.map((e) => this.measureText(e, d).width), ...t.map((e) => this.measureText(e, f).width)), m = Math.max(...e.map((e) => this.exh.length ? this.measureText(UL(e), d).width : this.measureText(UL(e), d).width + 3 + 3), ...t.map((e) => this.measureText(UL(e), f).width)), _ = a * e.length + u * t.length + (e.length + t.length) + 3, h = p ? _ / e.length : null;
else {
let t = e[0].replace(/[0-9]/g, "3").replace(/[A-Z]/g, "A");
g = this.measureText(t, d).width + 3 + 3, _ = a + 4;
}
let v = n.size.x / (m || g), y = n.size.y / (h || _), b = Math.min(v, y);
r.push({
scaleFactor: b,
value: a,
lines: []
}), p || i.push({
scaleFactor: b,
value: u,
lines: []
});
}
if (!this.exh.length) {
let e = r[r.length - 1], t = this.prefixes.find((e) => e.name === $L);
t && (r.push({
scaleFactor: e.scaleFactor / 1.8,
value: t.fontSize,
lines: []
}), i.push({
scaleFactor: e.scaleFactor / 1.8,
value: t.fontSize * (HL ? 1 : .9),
lines: []
}));
}
let c = Gj();
this.fontUrls = [JL(o, c), JL(s, c)], this.minZoomDotVisible = KL(r.map((e) => e.scaleFactor)), this.fontSizes = [r, i];
}
calcArea(e, t) {
return Math.floor(Math.max(0, e) * Math.max(0, t) / 1e3);
}
optimizationLevel() {
return Math.min(Dr.viewOptimizationLevel ? Dr.viewOptimizationLevel : Math.floor(this.calcArea(this.canvasRect.size.x, this.canvasRect.size.y) / 5e3), 3);
}
measureText(e, t) {
return WL.font = t, WL.measureText(e);
}
}, tR = document.createElement("canvas").getContext("2d"), nR = class {
constructor(e, t, n) {
this.maxMultilineFontSize = void 0, this.baseFontSize = void 0, this.fontSizes = void 0, this.ctx = void 0, this.spaceWidth = void 0, this.baseFontSize = this.maxMultilineFontSize = n, this.fontSizes = t, this.ctx = tR, this.ctx.textAlign = "center", this.ctx.textBaseline = "alphabetic", this.ctx.font = e(this.baseFontSize), this.spaceWidth = this.ctx.measureText(" ").width;
}
getStepsForRect(e, t, n) {
let r = e.split(/\s+/), i = r.map((e) => this.ctx.measureText(e).width), a = [], o = Infinity, s = 0;
for (let e of this.fontSizes) {
let c = e, l = e / this.baseFontSize, u = i.map((e) => e * l), d = this.spaceWidth * l, f = rR(u, d, e > this.maxMultilineFontSize ? 1 : Infinity).filter((e) => e);
for (let i = 0; i < f.length; i++) {
let l = f[i], p = l, m = i + 1, h = c * m, g = p / t, _ = h / n, v = Math.max(_, g);
if (v > o || m < s) continue;
o = v, s = m;
let y = oR(aR(l, m, u, d), u, d);
if (!y) continue;
let b = cR(y, r);
a.push({
scaleFactor: v,
value: e,
lines: b
});
}
}
return a;
}
};
function rR(e, t, n) {
let r = [], i = 0, a = 1, o = Infinity, s;
for (; (s = iR(o, e, t)) && s.length <= n;) a !== s.length && (r[a - 1] = i), a = s.length, i = Math.max(...s), o = i - 1;
return r[a - 1] = i, r;
}
function iR(e, t, n) {
let r = [], i = 0, a = -1;
function o() {
a++, i = 0;
}
o();
for (let s of t) {
let t = i + (i > 0 ? n : 0) + s;
if (t > e) {
if (s > e) return null;
o(), i = s;
} else i = t;
r[a] = i;
}
return r;
}
function aR(e, t, n, r) {
return i(t, 0);
function i(e, t) {
let r = a(t), o = [];
for (let a of r) {
let r = t + a.length;
if (r >= n.length) {
o.push([a]);
break;
}
if (e > 0) {
let t = i(e - 1, r);
for (let n of t) n.length === e - 1 && o.push([a, ...n]);
}
}
return o;
}
function a(t) {
if (t >= n.length) throw Error("From exceed blocks length");
let i = [0, -1], a = 0, o = 0;
for (; n.length > t + o && (a += (o > 0 ? r : 0) + n[t + o]) && a / e < 1.001;) o++;
return i.map((e) => o + e).filter((e) => e > 0).map((e) => s(t, e));
function s(e, t) {
let n = Array(t);
for (; t--;) n[t] = t + e;
return n;
}
}
}
function oR(e, t, n) {
let r = e.map((e) => ({
ll: e,
dd: sR(e.map((e) => e.map((e) => t[e]).reduce((e, t, r) => e + (r > 0 ? n : 0) + t), 0))
}));
return r.sort((e, t) => e.dd - t.dd), r.map((e) => e.ll)[0];
}
function sR(e) {
let t = e.length, n = e.reduce((e, t) => e + t) / t;
return Math.sqrt(e.map((e) => (e - n) ** 2).reduce((e, t) => e + t) / t);
}
function cR(e, t) {
return e.map((e) => e.map((e) => t[e]).reduce((e, t, n) => e + (n > 0 ? " " : "") + t), "");
}
//#endregion
//#region src/components/Map/drawing/config/config-booth-labels-special.ts
var lR = [
18,
16,
14,
12,
10,
7
], uR = 14;
function dR(e) {
if (!(!(e instanceof Hj) || e.noLabels)) return new fR(e);
}
var fR = class extends eR {
constructor(e) {
super(e), this.steps = [], this.labelIsVertical = void 0, this.text = "";
let t = this.booth.rect, n = JL(Number(getComputedStyle(document.body).getPropertyValue("--expofp-booth-special-weight")) || Number(getComputedStyle(document.body).getPropertyValue("--expofp-booth-main-weight")) || 500, Gj()), r = t.expand({
x: -(t.size.width * zL + this.padding),
y: -(t.size.height * zL + this.padding)
});
this.setText(), this.canvasRect = new Xn(r.center, r.size, e.rotate, e.elevation), this.setFactors(this.text), this.labelIsVertical = Math.abs(Math.abs(e.rotate) - Math.PI / 2) < .01, this.fontSizes = [this.steps, []], this.minZoomDotVisible = KL(this.steps.map((e) => e.scaleFactor)), this.shapeLabel = Xj([{
text: this.text,
color: e.labelColor || Ja.boothLabelColor,
fontUrl: n,
fontSize: 0
}], new Xn(r.center, r.size, e.rotate, e.elevation), [this.padding, this.padding], {
horizontal: "center",
text: "center",
vertical: "center"
}), this.shapeLabel.onScale = ({ pixelSize: e }) => this.layOutLabel(e), this.getShapeDot(), k(() => Ce.layersLoaded && this.booth.skipDim === !0, (e) => {
this.shapeLabel.dim = e ? 0 : void 0, this.shapeDot.dim = e ? 0 : void 0, ud(this.shapeLabel, this.shapeDot);
}), k(() => B.mapSettings, ({ roll: e }) => {
fj(e == null ? 0 : e) && (this.shapeLabel.onRoll = ({ roll: e, pixelSize: t }) => {
let n = this.shapeLabel.bounds.rotation;
if (this.labelIsVertical) return lj(e, n) ? (this.shapeLabel.bounds.rotate(-2 * n, this.shapeLabel.bounds), [this.shapeLabel, this.shapeDot]) : void 0;
let r = cj(e, n);
if (r === 0) return;
let { size: i } = this.canvasRect;
return this.shapeLabel = oj(this.shapeLabel, r), i.x !== i.y && !this.shapeLabel.hidden && (this.canvasRect = sj(this.canvasRect, r), this.setFactors(this.text), this.layOutLabel(t), this.layOutDot(t)), [this.shapeLabel, this.shapeDot];
});
}, { fireImmediately: !0 });
}
getShape() {
return [this.shapeLabel, this.shapeDot];
}
layOutLabel(e) {
let t = this.steps.find((t) => t.scaleFactor < 1 / e);
return t ? (this.shapeLabel.lines[0].fontSize = t.value * e, this.shapeLabel.lines[0].text = t.lines.join("\n"), this.shapeLabel.padding = [this.paddingScaled[0] * e + this.padding, this.paddingScaled[1] * e + this.padding], [this.shapeLabel]) : (this.shapeLabel.lines[0].fontSize = 0, [this.shapeLabel]);
}
layOutDot(e) {
let t = this.steps.find((t) => t.scaleFactor < 1 / e), n = this.shapeDot.bounds;
return n.scale({
x: nM * e / n.size.x,
y: nM * e / n.size.y
}, n.center, n), this.shapeDot.hidden = !!t, [this.shapeDot];
}
setFactors(e) {
this.steps = new nR(uo, lR, uR).getStepsForRect(e, this.canvasRect.size.x, this.canvasRect.size.y);
}
setText() {
let e = this.booth.title || this.booth.name, t = `Clicks: ${Te.getTotalClicksByBooth(this.booth)}`;
this.text = B.heatmap ? `${e} - ${t}` : e;
}
}, pR = Oe();
function mR(e, t) {
return pR().set(e, t), () => {
pR().get(e) === t && pR().delete(e);
};
}
function hR() {
return [...pR().values()].map((e) => e());
}
//#endregion
//#region src/utils/getLogoUrl.ts
function gR(e) {
var t, n, r;
let i = _R();
return i === "tiny" ? (t = (n = e.tinyUrl) == null ? e.smallUrl : n) == null ? e.url : t : i === "small" ? (r = e.smallUrl) == null ? e.url : r : e.url;
}
function _R() {
if (nI || N) return Dr.viewOptimizationLevel ? Dr.viewOptimizationLevel >= 5 ? "tiny" : "small" : void 0;
}
function vR(e) {
var t, n;
return wn((t = (n = e.transform) == null || (n = n.animVal[0]) == null ? void 0 : n.angle) == null ? 0 : t);
}
function yR(e) {
var t;
let n = cr.fromSvg(e);
return {
url: (t = e.getAttribute("data-model-3d")) == null ? "" : t,
bounds: Xn.fromMinMax(n.min, n.max, vR(e))
};
}
//#endregion
//#region src/components/Map/drawing/config/loadBoothsImages.ts
async function bR() {
let e = hR();
await Promise.all(e.map(async (e) => {
let t = await e;
if (!(t != null && t.children.length)) return;
let { layer: n, children: r } = t;
n.children.push(...r), ud(n);
}));
}
var xR = (e) => `${e}:images`, SR = (e) => `${e}:models`;
function CR(e) {
let t = /* @__PURE__ */ new Map();
for (let r of e) {
var n;
if (!r.rect) continue;
let e = (n = MI(r)) == null ? void 0 : n.logo;
e && t.set(r.id, {
preferred: gR(e),
fallback: e.url
});
}
return t;
}
function wR(e) {
var t;
let n = ja(Ha(e)).select(`[data-layer="${e.name}"]`), r = (((t = Or().__fpVersion) == null ? 0 : t) > 5 ? n.selectAll(":scope > image, :scope > g:not([data-layer]) image").nodes() : n.selectAll(":scope > g[data-is-editable='false'] image").nodes()).filter(Boolean), i = [], a = [];
for (let e of r) (e.hasAttribute("data-model-3d") ? a : i).push(e);
return {
icons: i,
models: a
};
}
function TR(e, t) {
let n = e.rect, r = n.size.width, i = n.size.height, a = i ? r / i : 1, o, s, c, l = .9;
a > t ? (s = i * l, o = s * t) : (o = r * l, s = o / t);
let u = e.rotate || 0;
return t >= 2 && !u && i >= r * 2 ? (s = r * l, o = s * t, c = -90) : c = Tn(u), o > r && (o = r, s = o / t), s > i && (s = i, o = s * t), {
name: e.slug,
bounds: new Xn(n.center, {
x: o,
y: s
}, wn(c), e.elevation),
booth: e
};
}
//#endregion
//#region src/components/Map/drawing/config/config-booths.ts
var ER = (0, Zc.default)("efp:booth-logos");
function DR(e, t) {
return ((t) => {
let n = e, r = [], i = [], a = [], o = [], s = [], c = xR(n), l = {
name: c,
children: []
};
for (let e of t) {
var u, d, f, p;
let t = (u = kL(e)) == null ? void 0 : u.getShape();
t && (r.push(...t), yI(e, t));
let n = (d = GL(e)) == null ? void 0 : d.getShape();
n && i.push(...n);
let c = (f = dR(e)) == null ? void 0 : f.getShape();
if (c && a.push(...c), !Ja.borderless) {
var m;
let t = (m = FL(e)) == null ? void 0 : m.getShape();
t && o.push(t);
}
let l = (p = ML(e)) == null ? void 0 : p.getShape();
l && s.push(l);
}
let h = i.filter((e) => e.lines), g = a.filter((e) => e.lines), _ = i.filter((e) => e.source), v = a.filter((e) => e.source);
if (!B.hideLogoInBooth) {
let e = CR(t), n = C();
mR(c, async () => {
let t = await lI(e, 350);
if (C() !== n) return;
let r = [], i = PI(), a = await Promise.all([...t].map(async ([e, t]) => {
let n = Ee.boothById.get(e);
return [
e,
n,
n ? await i(n, t) : null
];
}));
if (C() === n) {
for (let [e, t, n] of a) {
if (!t) {
ER("dropped a logo: no booth has id %s", e);
continue;
}
if (!n) {
ER("dropped the logo of booth %s: the image could not be read", e);
continue;
}
let { blob: i, aspectRatio: a } = n, { bounds: o } = TR(t, a), s = Yj(i, o), c = t.borderWidth || Ee.borderWidth, l = t.rect.expand(-c), u = new Xn(l.center, l.size, t.rotate);
s.onRoll = pj(s.bounds, u) ? ({ roll: e }) => vj(s, e) ? [s] : void 0 : ({ roll: e }) => hj(s, e) ? [s] : void 0, t.shapes.push(s), r.push(s);
}
return {
layer: l,
children: r
};
}
});
}
let y = {
name: `${n}:labelGroup`,
children: [
{
name: `${n}:labels`,
children: h
},
{
name: `${n}:specialLabels`,
children: g
},
{
name: `${n}:dots`,
children: _
},
{
name: `${n}:specialDots`,
children: v
}
]
};
OM(() => Ce.layersLoaded && qL(), (e) => {
y.dim = e ? 0 : void 0, ud(y);
}, { fireImmediately: !0 });
let b = [];
if (t.length) {
let e = n + ":";
b = [
{
name: `${e}boothBackground`,
children: r,
onPointerMove: xI,
onPointerOut: SI,
onClick: CI
},
y,
l,
{
name: `${e}boothsBookmark`,
children: s
},
{
name: `${n}:boothBorder`,
children: o
}
];
}
return {
name: n,
children: b
};
})(t);
}
//#endregion
//#region src/components/Map/drawing/config/poi-pin-shape.ts
var OR = {
frame: {
width: 82,
height: 96
},
bodyWidth: 70,
outline: "M41 86.13C41.68 85.63 76 61.93 76 36.1A35 35 0 0 0 6 36.1C6 61.93 40.32 85.63 41 86.13Z",
strokeWidth: 0,
tipApexY: 86.13,
head: {
x: 41,
y: 36.1,
innerRadius: 29.3
},
shadow: {
offsetY: 2,
blur: 4
}
}, kR = {
frame: {
width: 102,
height: 137
},
bodyWidth: 90,
outline: "M51 125.88C56.54 123.07 94.5 77 94.5 47A43.5 43.5 0 0 0 7.5 47C7.5 77 45.46 123.07 51 125.88Z",
strokeWidth: 3,
tipApexY: 125.88,
head: {
x: 51,
y: 47,
innerRadius: 19
},
shadow: {
offsetY: 2.5,
blur: 5
}
};
function AR(e, t, n) {
let r = t / e.bodyWidth * n, i = Math.ceil(e.frame.height * r), a = (e.tipApexY + e.strokeWidth / 2) * r;
return {
scale: r,
canvasWidth: Math.ceil(e.frame.width * r),
canvasHeight: i,
tipOffset: (i - a) / n
};
}
function jR(e) {
try {
return (0, AM.default)(e).darken(.41).desaturate(.4).hex();
} catch {
return e;
}
}
//#endregion
//#region src/components/Map/drawing/config/poi-pin.ts
var MR = .6, NR = "#ffffff", PR = "rgba(0, 0, 0, 0.35)";
function FR(e, t) {
let n = document.createElement("canvas");
n.width = t.canvasWidth, n.height = t.canvasHeight;
let r = n.getContext("2d");
return r.scale(t.scale, t.scale), {
canvas: n,
ctx: r,
path: new Path2D(e.outline)
};
}
function IR(e, t, n) {
e.shadowColor = PR, e.shadowOffsetY = t.shadow.offsetY * n, e.shadowBlur = t.shadow.blur * n;
}
function LR(e) {
e.shadowColor = "transparent", e.shadowOffsetY = 0, e.shadowBlur = 0;
}
function RR(e) {
return e.getContext("2d").getImageData(0, 0, e.width, e.height);
}
function zR(e, t, n, i) {
let a = OR, o = AR(a, t, n), { canvas: s, ctx: c, path: l } = FR(a, o), { x: u, y: d } = a.head;
if (IR(c, a, o.scale), c.fillStyle = NR, c.fill(l), LR(c), c.beginPath(), c.arc(u, d, a.head.innerRadius, 0, 2 * Math.PI), c.fillStyle = r, c.fillStyle = i, c.fill(), e) {
let t = 2 * a.head.innerRadius * MR * o.scale, n = bo(e, t, t, 1), r = n.getContext("2d");
r.globalCompositeOperation = "source-in", r.fillStyle = NR, r.fillRect(0, 0, n.width, n.height);
let i = n.width / o.scale, s = n.height / o.scale;
c.drawImage(n, u - i / 2, d - s / 2, i, s);
}
return RR(s);
}
function BR(e, t, n) {
let r = kR, i = AR(r, e, t), { canvas: a, ctx: o, path: s } = FR(r, i), c = jR(n);
return IR(o, r, i.scale), o.fillStyle = n, o.fill(s), LR(o), o.strokeStyle = c, o.lineWidth = r.strokeWidth, o.lineJoin = "round", o.stroke(s), o.beginPath(), o.arc(r.head.x, r.head.y, r.head.innerRadius, 0, 2 * Math.PI), o.fillStyle = c, o.fill(), RR(a);
}
//#endregion
//#region src/components/Map/drawing/config/config-outdoor-poi.ts
var VR = (e) => !!e && e !== "transparent" && e !== "none";
function HR(e) {
var t, n, r;
let i = ((t = e.paths) == null ? [] : t).map((e) => e.color).find(VR), a = ((n = e.shapes) == null ? [] : n).map((e) => e.color).find(VR), o = (r = i == null ? a : i) == null ? null : r;
if (!o) return null;
try {
return B.monochrome ? (0, AM.default)(o).grayscale().rgb().string() : o;
} catch {
return o;
}
}
function UR() {
return Dr.enableExperimentalOutdoorMarkers === !0;
}
function WR(e) {
return e.name.toLowerCase().startsWith(a.toLowerCase());
}
async function GR(e) {
var t, n;
let i = z.poiMarkerStore.generation, a = window.devicePixelRatio || 1, o = [], s = new Map(((t = (n = z.poiTypeStore) == null ? void 0 : n.poiTypes) == null ? [] : t).map((e) => [e.id, e])), c = /* @__PURE__ */ new Map(), l = (e) => {
let t = c.get(e);
return t || (t = P(e), c.set(e, t)), t;
};
await Promise.all(e.map(async (e) => {
var t, n;
let i = e.poiTypeId == null || (t = s.get(e.poiTypeId)) == null ? void 0 : t.iconUrl, c = i ? await l(i) : null;
i && !c && console.warn("PoI icon failed to load", e.name, i);
let u = e.rect.center;
o.push({
boothId: e.id,
center: {
x: u.x,
y: u.y
},
icon: zR(c, 40, a, (n = HR(e)) == null ? r : n)
});
})), z.poiMarkerStore.generation === i && z.poiMarkerStore.addMany(o);
}
function KR(e, t) {
return !UR() || !WR(e) ? !1 : (z.maplibreStore.showMaplibre && GR(t.filter((e) => e.poiTypeId && e.rect)), !0);
}
//#endregion
//#region src/components/Map/drawing/config/config-load-layer.ts
function qR(e) {
return e.childLayers.length ? e.childLayers : GF(e, e.basePriority, 15).layers;
}
async function JR(e, t) {
let n = [], r = PM(z, e);
if (KR(e, r)) return e.loaded = !0, e.configured = !0, e.children = [], Qj(e.name, [], { hidden: !0 });
let i = await eI(e), a = [], o = hM(r, 350), s = Ee.booths.filter((t) => t.rect && (!t.layer || t.layer === e || t.layer.childLayers.includes(e)) && t.exhibitors.find((e) => {
var t;
return !!e.logoInBooth && !!((t = e.logo) != null && t.url);
}) && !B.hideLogoInBooth), c = new Map(s.map((e) => [e, e.noLabels]));
s.forEach((e) => e.noLabels = !0), r.length && o.forEach((t, n) => {
a.push(DR(`${e.name}:${f}:${n}`, t));
});
for (let [e, t] of c) e.noLabels = t;
e.loaded = !0;
let l = i.children.find((e) => e.name === "bg"), u = i.children.find((e) => e.name === "fg"), d = xR(e.name), { icons: p, models: m } = wR(e), h = {
name: d,
children: []
}, g = {
name: SR(e.name),
children: m.map(yR)
};
p.length && mR(d, async () => {
let e = await QF(p), t = [];
for (let { bounds: n, source: r } of e) t.push(Yj(r, n));
return {
layer: h,
children: t
};
}), l && n.push({
...l,
name: `${i.name}:bg`
}), a.length && n.push(...a), u && n.push({
...u,
name: `${i.name}:fg`
}), p.length && n.push(h), g.children.length && n.push(g);
let _ = await Promise.all(e.childLayers.sort((e, t) => e.basePriority - t.basePriority).map((e) => JR(e, !0)));
return n.push(..._), e.children = n, e.configured = !0, Qj(e.name, n, { hidden: !t });
}
async function YR(e) {
if (e.configured) return Qj(e.name, e.children, { hidden: !e.visible });
if (z.layerStore.mode !== fz.Default && !jr(e.name) && !e.rootParent) try {
let t = s().fpSvgLayerJsRefs[e.name];
t && await h(t);
} catch (t) {
console.warn(`Layer data not loaded: ${e.name}`, t);
}
let t = qR(e);
t.length && (e.childLayers = t);
let { layers: n } = z.layerStore;
return z.layerStore.layers = [...n, ...t.filter((e) => !n.some((t) => t.name === e.name))], JR(e, e.visible);
}
//#endregion
//#region src/utils/shortenName.ts
function XR(e) {
return typeof e == "string" ? e.split(" ").map((e) => {
let t = e.replace(/[^A-Z0-9+-]/gi, ""), n = t.match(/^[-+]?\d+$/);
return n ? n[0] : /^[A-Z]{2,4}$/.test(t) ? t : t.charAt(0).toUpperCase();
}).join("") : e;
}
//#endregion
//#region src/store/LayerStore.ts
var ZR, QR, $R, ez, tz, nz, rz, iz, $, az, oz, sz, cz;
function lz(e, t, n, r) {
n && Object.defineProperty(e, t, {
enumerable: n.enumerable,
configurable: n.configurable,
writable: n.writable,
value: n.initializer ? n.initializer.call(r) : void 0
});
}
function uz(e, t, n, r, i) {
var a = {};
return Object.keys(r).forEach(function(e) {
a[e] = r[e];
}), a.enumerable = !!a.enumerable, a.configurable = !!a.configurable, ("value" in a || a.initializer) && (a.writable = !0), a = n.slice().reverse().reduce(function(n, r) {
return r(e, t, n) || n;
}, a), i && a.initializer !== void 0 && (a.value = a.initializer ? a.initializer.call(i) : void 0, a.initializer = void 0), a.initializer === void 0 ? (Object.defineProperty(e, t, a), null) : a;
}
var dz = [
"money2020usa",
"rodion2",
"possible2025",
"2025virtuosotravelweek",
"zscalerskofy26",
"gamescom2025"
], fz = /*#__PURE__*/ function(e) {
return e[e.Default = 0] = "Default", e[e.Separated = 1] = "Separated", e[e.Radio = 2] = "Radio", e[e.CheckBox = 3] = "CheckBox", e;
}({}), pz = /*#__PURE__*/ function(e) {
return e[e.Unset = 0] = "Unset", e[e.AlwaysVisible = 1] = "AlwaysVisible", e[e.AlwaysHidden = 2] = "AlwaysHidden", e[e.TurnedOn = 3] = "TurnedOn", e[e.TurnedOff = 4] = "TurnedOff", e;
}({}), mz = (ZR = class {
constructor() {
this.basePriority = 0, this.name = "", this.description = "", this.frozen = !1, this.rect = null, this.viewbox = null, this.configured = !1, this.childLayers = [], this.rootParent = null, this.mode = pz.Unset, this.children = [], this.pathway = void 0, this.floorIndex = void 0, lz(this, "loaded", QR, this), lz(this, "visible", $R, this);
}
get shortName() {
return XR(this.description);
}
}, QR = uz(ZR.prototype, "loaded", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), $R = uz(ZR.prototype, "visible", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), ZR), hz = (ez = E({ keepAlive: !0 }), tz = E({ keepAlive: !0 }), nz = E({ keepAlive: !0 }), rz = E({ keepAlive: !0 }), iz = E({ keepAlive: !0 }), $ = class {
constructor() {
lz(this, "layers", az, this), lz(this, "defaultLayer", oz, this), lz(this, "mode", sz, this), lz(this, "layersLoaded", cz, this), this.updateVisibilityTimeout = 0, this.selectFloorTimeout = 0;
}
get visible() {
return this.layers.filter((e) => e.frozen || e.visible);
}
get loaded() {
return this.layers.filter((e) => e.loaded);
}
get rectangle() {
let e = this.visible.filter((e) => !e.frozen).map((e) => {
var t;
return (t = e.viewbox) == null ? e.rect : t;
}).filter((e) => !!e);
return this.mode !== fz.Radio || !e.length ? null : cr.fromUnion(...e) || null;
}
get bounds() {
let e = this.visible.map((e) => {
var t;
return (t = e.viewbox) == null ? e.rect : t;
}).filter(Boolean);
return e.length ? cr.fromUnion(...e) : void 0;
}
get viewboxRectangle() {
let e = this.visible.filter((e) => !e.frozen).map((e) => e.viewbox).filter((e) => !!e);
return e.length && cr.fromUnion(...e) || null;
}
get pathwayLayers() {
return this.layers.filter((e) => e.pathway);
}
get floors() {
if (!Ya()) return [];
let e = new Set(this.layers.filter((e) => e && !e.frozen && !e.rootParent && !e.pathway).concat(z.routeStore.layers.filter((e) => e && e.mode !== pz.AlwaysHidden && e.mode !== pz.AlwaysVisible))), t = Array.from(e).reverse();
return t.map((e, n) => {
var r;
let i = z.routeStore.layers.length > 0 && z.routeStore.layers.indexOf(e) === -1, a = z.toursStore.tourLayers.length > 0 && z.toursStore.tourLayers.indexOf(e) === -1;
return {
layer: e,
name: e.name,
shortName: e.shortName,
description: e.description,
active: e.visible,
disabled: !!(i || a),
index: (r = e.floorIndex) == null ? t.length - n - 1 : r
};
});
}
selectFloor(e) {
if (this.selectFloorTimeout) return;
this.selectFloorTimeout = window.setTimeout(() => this.selectFloorTimeout = 0, 500);
let t = this.layers.find((t) => t.description === e.description);
if (!t) return;
if (this.mode === fz.Radio) {
var n;
if (this.updateVisibility(t, !0), z.maplibreStore.showMaplibre) return;
if ((n = Or().__fpSettings) != null && n.fpVer || dz.includes(Ja.EXPO)) {
var r;
let e = (r = t.viewbox) == null ? t.rect : r;
z.uiState.moveToRect = e;
} else {
let e = this.layers.indexOf(this.layers.filter((e) => !e.frozen && e.visible)[0]), n = this.layers.indexOf(t);
if (e === n) return;
z.uiState.zoomBy = n < e ? .95 : 1.05;
}
} else this.updateVisibility(t, !t.visible);
let i = z.toursStore.getTourLayerInfo(t.name) || z.toursStore.getTourLayerInfo(t.description);
if (i) {
this.showPathWay(i.id);
return;
}
z.toursStore.stopTour();
}
updateVisibility(e, t) {
if (this.mode === fz.Radio && !t) return;
let n = e instanceof mz ? e : this.findLayer(e);
if (!n || n.visible === t) {
n && z.routeStore.currentRouteLayer !== n && (z.routeStore.currentRouteLayer = n);
return;
}
YR(n).then(() => {
this.mode === fz.Radio && this.layers.filter((e) => !e.pathway).forEach((e) => {
e.name !== n.name && !e.frozen && e.visible && (e.visible = !1, e.childLayers.forEach((e) => {
e.visible = !1;
}));
}), n && (n.visible = t, n.childLayers.forEach((e) => {
e.visible = t;
}), t && (z.routeStore.currentRouteLayer = n), typeof z.fp.onFloorActivated == "function" && (clearTimeout(this.updateVisibilityTimeout), this.updateVisibilityTimeout = window.setTimeout(() => {
let e = z.fp.getFloors();
z.fp.onFloorActivated(e.find((e) => e.name === n.name));
})));
});
}
findLayer(e) {
var t;
if (e == null) return null;
let n = this.layers.filter((e) => !e.rootParent);
if (typeof e == "number") {
let t = n.filter((e) => !e.frozen)[e];
if (t) return t;
}
let r = e.toString().toLowerCase();
return n.find((e) => {
let t = (e.name.match(/(-?[0-9]+)/) || "")[0];
return r === (e == null ? void 0 : e.name.toLowerCase()) || r === (e == null ? void 0 : e.description.toLowerCase()) || r === (e == null ? void 0 : e.shortName.toLowerCase()) || r === t;
}) || (/\D/.test(r) || (t = n.filter((e) => !e.frozen)[parseInt(r)]) == null ? null : t);
}
getPathwayList() {
return this.layers.filter((e) => e.pathway);
}
async showPathWay(e) {
try {
let t = this.findLayer(e);
if (!t) throw Error(`There is no pathway with this name. ${e}`);
await YR(t);
let n = this.getPathwayList();
M(() => {
n.forEach((t) => {
let n = t.name === e;
t.visible = n, t.childLayers.forEach((e) => {
e.visible = n;
});
});
});
} catch (e) {
console.error("showPathWay", e);
}
}
hidePathways() {
this.getPathwayList().forEach((e) => {
e.visible = !1, e.childLayers.forEach((e) => {
e.visible = !1;
});
});
}
}, az = uz($.prototype, "layers", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return [];
}
}), oz = uz($.prototype, "defaultLayer", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: null
}), sz = uz($.prototype, "mode", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return fz.Default;
}
}), cz = uz($.prototype, "layersLoaded", [D], {
configurable: !0,
enumerable: !0,
writable: !0,
initializer: function() {
return !1;
}
}), uz($.prototype, "visible", [ez], Object.getOwnPropertyDescriptor($.prototype, "visible"), $.prototype), uz($.prototype, "loaded", [tz], Object.getOwnPropertyDescriptor($.prototype, "loaded"), $.prototype), uz($.prototype, "rectangle", [nz], Object.getOwnPropertyDescriptor($.prototype, "rectangle"), $.prototype), uz($.prototype, "bounds", [rz], Object.getOwnPropertyDescriptor($.prototype, "bounds"), $.prototype), uz($.prototype, "viewboxRectangle", [iz], Object.getOwnPropertyDescriptor($.prototype, "viewboxRectangle"), $.prototype), uz($.prototype, "pathwayLayers", [E], Object.getOwnPropertyDescriptor($.prototype, "pathwayLayers"), $.prototype), uz($.prototype, "floors", [E], Object.getOwnPropertyDescriptor($.prototype, "floors"), $.prototype), uz($.prototype, "selectFloor", [A], Object.getOwnPropertyDescriptor($.prototype, "selectFloor"), $.prototype), uz($.prototype, "updateVisibility", [A], Object.getOwnPropertyDescriptor($.prototype, "updateVisibility"), $.prototype), uz($.prototype, "showPathWay", [A], Object.getOwnPropertyDescriptor($.prototype, "showPathWay"), $.prototype), uz($.prototype, "hidePathways", [A], Object.getOwnPropertyDescriptor($.prototype, "hidePathways"), $.prototype), $);
//#endregion
export { Gj as $, cr as $t, MM as A, To as At, lM as B, Ya as Bt, _I as C, so as Ct, nI as D, bo as Dt, cI as E, So as Et, EM as F, io as Ft, sM as G, Ra as Gt, cM as H, Ha as Ht, vM as I, $a as It, $j as J, Dr as Jt, Yj as K, Or as Kt, mM as L, Qa as Lt, OM as M, lo as Mt, kM as N, uo as Nt, KF as O, Mo as Ot, TM as P, yo as Pt, Uj as Q, yr as Qt, yM as R, Xa as Rt, vI as S, wo as St, dI as T, No as Tt, fM as U, La as Ut, uM as V, Ja as Vt, pM as W, Ba as Wt, Xj as X, Tr as Xt, Jj as Y, Cr as Yt, Zj as Z, wr as Zt, lL as _, Gc as _t, UR as a, jn as an, _j as at, wI as b, Ho as bt, kR as c, wn as cn, tj as ct, gR as d, Tn as dn, If as dt, pr as en, Bj as et, QL as f, jf as ft, uL as g, Uc as gt, dL as h, ud as ht, YR as i, An as in, gj as it, DM as j, co as jt, HF as k, Co as kt, AR as l, En as ln, ej as lt, hL as m, Mf as mt, hz as n, Xn as nn, Vj as nt, BR as o, Mn as on, cj as ot, JL as p, Af as pt, Qj as q, Mr as qt, fz as r, Gn as rn, Hj as rt, OR as s, Fn as sn, fj as st, pz as t, ir as tn, zj as tt, bR as u, Dn as un, zp as ut, cL as v, Vc as vt, mI as w, po as wt, DI as x, fo as xt, HI as y, Rc as yt, dM as z, Za as zt };