perfect-gui 5.1.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,373 +1,242 @@
1
- class W {
2
- constructor(t, e = {}) {
3
- if (this.parent = t, this.callback = null, typeof e != "object")
4
- throw Error(
5
- `[GUI] button() first parameter must be an object. Received: ${typeof e}.`
6
- );
7
- let r = e.label || " ";
8
- const d = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? r : null, i = document.createElement("div");
9
- i.className = "p-gui__button", i.textContent = r, d && i.setAttribute("title", d), i.addEventListener("click", () => {
10
- this.callback && this.callback(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
11
- }), typeof e.color == "string" && (i.style.setProperty("--color-accent", e.color), i.style.setProperty(
12
- "--color-accent-hover",
13
- e.hoverColor || e.color
14
- )), this.parent.wrapper.append(i), this.element = i;
15
- }
16
- onClick(t) {
17
- return this.callback = t, this;
18
- }
19
- }
20
- class Y {
21
- constructor(t, e, r, d) {
22
- this.parent = t, this.propReferences = [];
23
- let i = {}, p = null;
24
- if (e && typeof e == "object" && typeof r == "string")
25
- this.obj = e, this.prop = r, this.isObject = !0, i = d || {}, this.callback = null;
26
- else if (e && typeof e == "object")
27
- this.isObject = !1, i = e, p = typeof i.value == "number" ? i.value : null;
28
- else
29
- throw Error("[GUI] slider() invalid parameters.");
30
- let l = typeof i.label == "string" && i.label || " ";
31
- this.isObject && l == " " && (l = this.prop), this.min = i.min ?? 0, this.max = i.max ?? 1, this.step = i.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
32
- let o = null;
33
- this.isObject ? o = this.propReferences.push(this.obj[this.prop]) - 1 : p === null && (p = (this.max - this.min) / 2);
34
- const s = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null, a = document.createElement("div");
35
- a.className = "p-gui__slider", s && a.setAttribute("title", s), this.parent.wrapper.append(a), this.element = a;
36
- const h = document.createElement("div");
37
- h.className = "p-gui__slider-name", h.textContent = l, a.append(h), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", this.min), this.ctrlDiv.setAttribute("max", this.max), a.append(this.ctrlDiv);
38
- const c = document.createElement("div");
39
- c.className = "p-gui__slider-bar", this.ctrlDiv.append(c), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", c.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : p, a.append(this.valueInput), setTimeout(() => {
40
- const n = this.handle.offsetWidth;
41
- this.handle.position = this._mapLinear(
42
- this.valueInput.value,
43
- this.min,
44
- this.max,
45
- n / 2,
46
- 88 - n / 2
47
- ), this.handle.position = Math.min(
48
- this.handle.position,
49
- 88 - n / 2
50
- ), this.handle.position = Math.max(
51
- this.handle.position,
52
- n / 2
53
- ), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
54
- }, 0), this.valueInput.addEventListener("change", () => {
55
- this._updateHandlePositionFromValue(), this._triggerCallbacks();
56
- }), this.ctrlDiv.addEventListener("pointerdown", (n) => {
57
- this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = n.clientX, this._updateHandlePositionFromPointer(n, !0);
58
- }), window.addEventListener("pointerup", (n) => {
59
- this.ctrlDiv.pointerDown = !1;
60
- }), window.addEventListener("pointermove", (n) => {
61
- this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = n.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(n));
62
- }), this.isObject && Object.defineProperty(this.obj, this.prop, {
63
- set: (n) => {
64
- this.propReferences[o] = n, this.valueInput.value = n, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
65
- },
66
- get: () => this.propReferences[o]
67
- });
68
- }
69
- _updateHandlePositionFromPointer(t, e = !1) {
70
- const r = this.ctrlDiv.offsetWidth, d = this.handle.offsetWidth, i = t.clientX - this.ctrlDiv.prevPosition, p = parseFloat(this.valueInput.value);
71
- let l;
72
- e ? l = t.offsetX : l = this.handle.position + i, l = Math.max(
73
- d / 2,
74
- Math.min(l, r - d / 2)
75
- );
76
- let o = this.min + (this.max - this.min) * (l - d / 2) / (r - d);
77
- o > p ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
78
- const s = parseFloat((p + this.step).toFixed(9)), a = parseFloat((p - this.step).toFixed(9));
79
- (o >= s || o <= a) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${l}px)`, this.handle.position = l, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
80
- }
81
- _updateHandlePositionFromValue() {
82
- const t = this.ctrlDiv.offsetWidth, e = this.handle.offsetWidth;
83
- let r = this._mapLinear(
84
- this.valueInput.value,
85
- this.min,
86
- this.max,
87
- e / 2,
88
- t - e / 2
89
- );
90
- r = Math.max(
91
- e / 2,
92
- Math.min(r, t - e / 2)
93
- ), this.handle.style.transform = `translate(-50%, -50%) translateX(${r}px)`, this.handle.position = r, this.filling.style.width = this.handle.position + "px";
94
- }
95
- _triggerCallbacks() {
96
- this.isObject ? this.obj[this.prop] = parseFloat(this.valueInput.value) : this.callback && this.callback(parseFloat(this.valueInput.value)), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
97
- }
98
- _mapLinear(t, e, r, d, i) {
99
- return d + (t - e) * (i - d) / (r - e);
100
- }
101
- _quantize(t, e) {
102
- return e * Math.round(t / e);
103
- }
104
- _quantizeCeil(t, e) {
105
- return e * Math.ceil(t / e);
106
- }
107
- _quantizeFloor(t, e) {
108
- return e * Math.floor(t / e);
109
- }
110
- onChange(t) {
111
- return this.callback = t, this;
112
- }
113
- }
114
- class z {
115
- constructor(t, e = {}) {
116
- if (this.parent = t, this.callback = null, typeof e != "object")
117
- throw Error(
118
- `[GUI] image() first parameter must be an object. Received: ${typeof e}.`
119
- );
120
- let r;
121
- if (typeof e.path == "string")
122
- r = e.path;
123
- else
124
- throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
125
- let d = r.replace(/^.*[\\\/]/, ""), i;
126
- e.label == null ? i = d : i = typeof e.label == "string" && e.label || " ";
127
- const p = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, l = e.selected === !0, o = e.selectionBorder !== !1;
128
- let s = "";
129
- e.width && (typeof e.width == "number" && (e.width += "px"), s += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), s += `height: ${e.height}; `);
130
- const a = document.createElement("div");
131
- a.className = "p-gui__image", a.style = "background-image: url(" + r + "); " + s, p && a.setAttribute("title", p), this.parent.imageContainer.append(a), this.element = a, l && o && a.classList.add("p-gui__image--selected");
132
- const h = document.createElement("div");
133
- h.className = "p-gui__image-text", h.textContent = i, a.append(h), a.addEventListener("click", () => {
134
- let c = a.parentElement.querySelectorAll(
135
- ".p-gui__image--selected"
136
- );
137
- for (let n = 0; n < c.length; n++)
138
- c[n].classList.remove("p-gui__image--selected");
139
- o && a.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({ path: r, text: i }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
140
- });
141
- }
142
- onClick(t) {
143
- return this.callback = t, this;
144
- }
145
- }
146
- class B {
147
- constructor(t, e, r, d) {
148
- this.parent = t, this.callback = null;
149
- let i = {}, p = null, l = !1, o, s;
150
- if (e && typeof e == "object" && typeof r == "string")
151
- o = e, s = r, l = !0, i = d || {};
152
- else if (e && typeof e == "object")
153
- l = !1, i = e, p = typeof i.value == "boolean" ? i.value : null;
154
- else
155
- throw Error("[GUI] toggle() invalid parameters.");
156
- let a = typeof i.label == "string" && i.label || " ", h = null;
157
- l && a == " " && (a = s), l && (h = this.parent.propReferences.push(o[s]) - 1);
158
- const c = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null, n = document.createElement("div");
159
- n.textContent = a, n.className = "p-gui__toggle", c && n.setAttribute("title", c), this.parent.wrapper.append(n), this.element = n, n.addEventListener("click", (f) => {
160
- const u = f.target.childNodes[1];
161
- let m = !0;
162
- u.classList.contains("p-gui__toggle-checkbox--active") && (m = !1), u.classList.toggle("p-gui__toggle-checkbox--active"), l ? o[s] = m : typeof this.callback == "function" && this.callback(m), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
163
- });
164
- let g = l ? o[s] ? " p-gui__toggle-checkbox--active" : "" : p ? " p-gui__toggle-checkbox--active" : "";
165
- const b = document.createElement("div");
166
- b.className = "p-gui__toggle-checkbox" + g, n.append(b), l && Object.defineProperty(o, s, {
167
- set: (f) => {
168
- this.parent.propReferences[h] = f, f ? b.classList.add(
169
- "p-gui__toggle-checkbox--active"
170
- ) : b.classList.remove(
171
- "p-gui__toggle-checkbox--active"
172
- ), typeof this.callback == "function" && this.callback(f);
173
- },
174
- get: () => this.parent.propReferences[h]
175
- });
176
- }
177
- onChange(t) {
178
- return this.callback = t, this;
179
- }
180
- }
181
- class T {
182
- constructor(t, e, r, d) {
183
- this.parent = t, this.callback = null;
184
- let i = {}, p = null, l = !1, o, s;
185
- if (e && typeof e == "object" && typeof r == "string")
186
- o = e, s = r, l = !0, i = d || {};
187
- else if (e && typeof e == "object")
188
- l = !1, i = e;
189
- else
190
- throw Error("[GUI] list() invalid parameters.");
191
- let a = typeof i.label == "string" ? i.label : " ", h = null, c = Array.isArray(i.values) ? i.values : null, n = c && c.length > 0 && typeof c[0] == "object";
192
- const g = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
193
- l ? (p = (() => {
194
- if (!c)
195
- return null;
196
- if (typeof o[s] == "string")
197
- return n ? c.find((u) => u.value === o[s]).value : c.indexOf(o[s]);
198
- if (typeof o[s] == "number")
199
- return n ? c.find((u) => u.value === o[s]).value : o[s];
200
- })(), h = this.parent.propReferences.push(o[s]) - 1) : p = (() => {
201
- if (!c)
202
- return null;
203
- if (typeof i.value == "string")
204
- return c.indexOf(i.value);
205
- if (typeof i.value == "number")
206
- return i.value;
207
- })();
208
- let b = document.createElement("div");
209
- b.className = "p-gui__list", b.textContent = a, g && b.setAttribute("title", g), this.parent.wrapper.append(b), this.element = b;
210
- let f = document.createElement("select");
211
- b.append(f), f.className = "p-gui__list-dropdown", f.addEventListener("change", (u) => {
212
- l ? o[s] = u.target.value : this.callback && this.callback(u.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
213
- }), c && c.forEach((u, m) => {
214
- const x = n ? u.label : u, w = n ? u.value : u;
215
- let y = document.createElement("option");
216
- y.setAttribute("value", w), y.textContent = x, f.append(y), (!n && p == m || n && p == w) && y.setAttribute("selected", "");
217
- }), l && Object.defineProperty(o, s, {
218
- set: (u) => {
219
- let m, x, w;
220
- n ? (w = c.find((U) => U.value == u), x = w?.value || c[0].value, m = c.indexOf(w)) : (typeof u == "string" && (m = c.indexOf(u), x = u), typeof u == "number" && (m = u, x = c[u])), this.parent.propReferences[h] = n ? x : u;
221
- const y = f.querySelector("[selected]");
222
- y && y.removeAttribute("selected"), f.querySelectorAll("option")[m].setAttribute("selected", ""), typeof this.callback == "function" && (n ? this.callback(w, m) : this.callback(x, m));
223
- },
224
- get: () => this.parent.propReferences[h]
225
- });
226
- }
227
- onChange(t) {
228
- return this.callback = t, this;
229
- }
230
- }
231
- class V {
232
- constructor(t, e, r, d) {
233
- this.parent = t, this.callback = null;
234
- let i = {}, p = null, l = !1, o, s;
235
- if (e && typeof e == "object" && typeof r == "string")
236
- o = e, s = r, l = !0, i = d || {};
237
- else if (e && typeof e == "object")
238
- l = !1, i = e;
239
- else
240
- throw Error("[GUI] color() invalid parameters.");
241
- let a = typeof i.label == "string" && i.label || " ", h = null;
242
- const c = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null;
243
- l ? (a == " " && (a = s), h = this.parent.propReferences.push(o[s]) - 1, p = o[s] || "#000000") : (typeof i.value == "string" && (i.value.length != 7 || i.value[0] != "#" ? console.error(
244
- `[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${i.value}".`
245
- ) : p = i.value), p || (p = "#000000"));
246
- const n = document.createElement("div");
247
- n.className = "p-gui__color", n.textContent = a, c && n.setAttribute("title", c), this.parent.wrapper.append(n), this.element = n;
248
- const g = document.createElement("input");
249
- g.className = "p-gui__color-picker", g.setAttribute("type", "color"), g.value = p, n.append(g), g.addEventListener("input", () => {
250
- l ? o[s] = g.value : typeof this.callback == "function" && this.callback(g.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
251
- }), l && Object.defineProperty(o, s, {
252
- set: (b) => {
253
- this.parent.propReferences[h] = b, g.value = b, typeof this.callback == "function" && this.callback(b);
254
- },
255
- get: () => this.parent.propReferences[h]
256
- });
257
- }
258
- onChange(t) {
259
- return this.callback = t, this;
260
- }
261
- }
262
- class G {
263
- constructor(t, e, r, d, i) {
264
- this.parent = t, this.callback = null;
265
- let p = {}, l, o, s, a;
266
- if (e && typeof e == "object" && typeof r == "string" && typeof d == "string")
267
- l = e, o = e, s = r, a = d, p = i || {};
268
- else if (e && typeof e == "object" && e.x && e.x.obj)
269
- p = e, l = p.x.obj, s = p.x.prop, o = p.y.obj, a = p.y.prop;
270
- else
271
- throw Error(
272
- "[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', params)"
273
- );
274
- let h = typeof p.label == "string" && p.label || " ";
275
- h === " " && (h = s + " / " + a);
276
- const c = p.x || {}, n = p.y || {}, g = c.min ?? p.min ?? 0, b = c.max ?? p.max ?? 1, f = n.min ?? p.min ?? 0, u = n.max ?? p.max ?? 1, m = c.step || p.step || (b - g) / 100, x = n.step || p.step || (u - f) / 100, w = this.parent._countDecimals(m), y = this.parent._countDecimals(x), U = this.parent.propReferences.push(l[s]) - 1, L = this.parent.propReferences.push(o[a]) - 1, N = typeof p.tooltip == "string" ? p.tooltip : p.tooltip === !0 ? h : null, A = document.createElement("div");
277
- A.className = "p-gui__vector2", A.textContent = h, N && A.setAttribute("title", N), this.parent.wrapper.append(A);
278
- const E = document.createElement("div");
279
- E.className = "p-gui__vector-value", E.textContent = l[s] + ", " + o[a], A.append(E);
280
- const _ = document.createElement("div");
281
- _.className = "p-gui__vector2-area", A.append(_), _.addEventListener("click", (v) => {
282
- const j = parseFloat(
283
- this.parent._mapLinear(
284
- v.offsetX,
285
- 0,
286
- _.clientWidth,
287
- g,
288
- b
289
- )
290
- ), R = parseFloat(
291
- this.parent._mapLinear(
292
- v.offsetY,
293
- 0,
294
- _.clientHeight,
295
- u,
296
- f
297
- )
298
- );
299
- l[s] = j.toFixed(w), o[a] = R.toFixed(y), this.callback && this.callback(l[s], l[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
300
- });
301
- const O = (v) => {
302
- const j = _.getBoundingClientRect(), R = v.clientX - j.left, H = v.clientY - j.top, M = this.parent._mapLinear(
303
- R,
304
- 0,
305
- _.clientWidth,
306
- g,
307
- b
308
- ), X = this.parent._mapLinear(
309
- H,
310
- 0,
311
- _.clientHeight,
312
- u,
313
- f
314
- ), $ = Math.max(g, Math.min(b, M)), S = Math.max(f, Math.min(u, X));
315
- l[s] = parseFloat($.toFixed(w)), o[a] = parseFloat(S.toFixed(y)), this.callback && this.callback(l[s], o[a]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
316
- };
317
- _.addEventListener("pointerdown", (v) => {
318
- O(v), document.addEventListener("pointermove", O), document.addEventListener(
319
- "pointerup",
320
- () => {
321
- document.removeEventListener(
322
- "pointermove",
323
- O
324
- );
325
- },
326
- { once: !0 }
327
- );
328
- });
329
- const D = document.createElement("div");
330
- D.className = "p-gui__vector2-line p-gui__vector2-line-x", _.append(D);
331
- const F = document.createElement("div");
332
- F.className = "p-gui__vector2-line p-gui__vector2-line-y", _.append(F);
333
- const I = document.createElement("div");
334
- I.className = "p-gui__vector2-dot", _.append(I);
335
- const P = () => {
336
- I.style.left = this.parent._mapLinear(
337
- l[s],
338
- g,
339
- b,
340
- 0,
341
- _.clientWidth
342
- ) + "px", I.style.top = this.parent._mapLinear(
343
- o[a],
344
- f,
345
- u,
346
- _.clientHeight,
347
- 0
348
- ) + "px";
349
- };
350
- P(), new ResizeObserver(() => {
351
- P();
352
- }).observe(_), Object.defineProperty(l, s, {
353
- set: (v) => {
354
- this.parent.propReferences[U] = v, P(), E.textContent = String(v) + ", " + o[a];
355
- },
356
- get: () => this.parent.propReferences[U]
357
- }), Object.defineProperty(o, a, {
358
- set: (v) => {
359
- this.parent.propReferences[L] = v, P(), E.textContent = l[s] + ", " + String(v);
360
- },
361
- get: () => this.parent.propReferences[L]
362
- });
363
- }
364
- onChange(t) {
365
- return this.callback = t, this;
366
- }
367
- }
368
- const Q = ".p-gui__button{background:var(--color-accent);text-align:center;color:var(--color-bg);border:1px solid transparent;box-sizing:border-box;transition:var(--transition) background,var(--transition) border-color}.p-gui__button:hover{background:var(--color-accent-hover);border-color:#fff3}.p-gui__folder .p-gui__button{margin-inline:0}", q = ".p-gui__slider{position:relative;min-height:14px;display:flex;align-items:center;justify-content:space-between;gap:10px;color:var(--color-text-dark);transition:color var(--transition);padding:3px}.p-gui__slider:hover{color:var(--color-text-light)}.p-gui__slider-name{width:50%;text-overflow:ellipsis;overflow:hidden}.p-gui__slider-ctrl{-webkit-appearance:none;padding:0;font:inherit;outline:none;box-sizing:border-box;cursor:pointer;position:relative;right:0;height:14px;margin:0 0 0 auto;width:37%}.p-gui__slider-bar{position:absolute;top:50%;left:0;height:2px;background:#fff3;width:100%;transform:translateY(-50%)}.p-gui__slider-filling{position:absolute;top:-25%;left:0;height:100%;background:var(--color-accent);width:0}.p-gui__slider:hover .p-gui__slider-filling{background:var(--color-accent-hover)}.p-gui__slider-handle{width:9px;height:9px;position:absolute;top:50%;left:0;border-radius:2px;transform:translate(-50%,-50%);pointer-events:none;background:var(--color-text-dark);box-shadow:0 0 2px #00000080}.p-gui__slider:hover .p-gui__slider-handle{background:var(--color-text-light)}.p-gui__slider-value{display:inline-block;right:7px;width:13%;border:none;color:#fff;border-radius:2px;background:#ffffff1a;padding:2px 4px;color:inherit}.p-gui__slider-value:focus{outline:none}", J = ".p-gui__list{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__list:hover{color:var(--color-text-light)}.p-gui__list-dropdown{background:#ffffff0d;color:#fff;padding:0 12px 0 5px;top:0}.p-gui__list-dropdown{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none}.p-gui__list-dropdown option{background:#fff;color:#000}.p-gui__list-dropdown:hover{background:#ffffff1a}", Z = ".p-gui__toggle{color:var(--color-text-dark);transition:var(--transition) background,var(--transition) color}.p-gui__toggle:hover{background:#ffffff1a;color:var(--color-text-light)}.p-gui__folder .p-gui__toggle{margin-inline:0}.p-gui__toggle-checkbox{width:10px;height:10px;background-color:#ffffff1a;position:absolute;top:0;right:10px;bottom:0;margin:auto;border-radius:2px;pointer-events:none;transition:.5s all ease}.p-gui__toggle-checkbox--active{background-color:#ddd;box-shadow:0 0 5px #ddd}", K = ".p-gui__color{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__color:hover{color:var(--color-text-light)}.p-gui__color-picker{position:absolute;right:5px;top:0;bottom:0;margin:auto;height:calc(100% - 4px);cursor:pointer;border-radius:3px;border:1px solid var(--color-border-2);outline:none;-webkit-appearance:none;padding:0;background-color:transparent;border:1px solid #222222;overflow:hidden}.p-gui__color-picker::-webkit-color-swatch-wrapper{padding:0}.p-gui__color-picker::-webkit-color-swatch{border:none}", ee = ".p-gui__vector2{background:transparent;aspect-ratio:1;padding-bottom:0;color:var(--color-text-dark)}.p-gui__vector2:hover{color:var(--color-text-light)}.p-gui__vector2-area{position:relative;background:#0000004d;margin-top:8px;width:100%;height:calc(100% - 28px);touch-action:none}.p-gui__vector2-line{position:absolute;background:#fff;opacity:.3;pointer-events:none}.p-gui__vector2-line-x{width:100%;height:1px;left:0;top:50%;transform:translateY(-50%)}.p-gui__vector2-line-y{width:1px;height:100%;top:0;left:50%;transform:translate(-50%)}.p-gui__vector2-dot{position:absolute;top:0;left:0;width:8px;height:8px;border-radius:50%;background:#d5d5d5;border:2px solid #ff9999;transform:translate(-50%,-50%);pointer-events:none}.p-gui__vector-value{display:inline-block;right:7px;position:absolute}", te = '.p-gui__image-container{width:100%;padding:3px;display:flex;justify-content:flex-start;flex-wrap:wrap;box-sizing:border-box}.p-gui__image{background-size:cover;cursor:pointer;position:relative;margin:1px 2.5px 19px;border-radius:var(--main-border-radius);flex:0 0 calc(33.333% - 5px);height:90px;background-position:center;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__image:hover{color:var(--color-text-light)}.p-gui__image:after{position:absolute;top:0;left:0;width:100%;height:100%;content:"";border:1px solid transparent;box-sizing:border-box;border-radius:var(--main-border-radius);transition:var(--transition) border-color}.p-gui__image--selected:after{border-color:#06ff89}.p-gui__image-text{position:absolute;bottom:-15px;text-shadow:0 -1px 0 #111;white-space:nowrap;width:100%;overflow:hidden;text-overflow:ellipsis}', ie = ".p-gui__folder{width:100%;position:relative;background:var(--color-bg);margin-bottom:2px;display:flex;flex-wrap:wrap;border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbbbbb}.p-gui__folder--first{margin-top:0}.p-gui__folder-content{display:grid;grid-template-rows:1fr;transition:.25s grid-template-rows ease;width:100%}.p-gui__folder-inner{overflow:hidden;padding-left:3px;padding-right:2px}.p-gui__folder--closed .p-gui__folder-content{grid-template-rows:0fr}.p-gui__folder-header{padding:5px 3px;background-color:#00000080;color:#fff;cursor:pointer;width:100%;box-sizing:border-box;border-top-right-radius:var(--main-border-radius);border-bottom-right-radius:var(--main-border-radius)}.p-gui__folder-header:hover{background-color:#000000bf}.p-gui__folder-arrow{width:8px;height:8px;display:inline-block;background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);background-size:contain;margin-right:5px;transform:rotate(90deg)}.p-gui__folder--closed .p-gui__folder-arrow{transform:rotate(0)}", re = ".p-gui__tabs{width:100%;position:relative;background:var(--color-bg);margin-bottom:2px;border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbbbbb;padding-block:0}.p-gui__tabs--first{margin-top:0}.p-gui__tabs-header{display:flex;background-color:#00000080;border-top-left-radius:var(--main-border-radius);border-top-right-radius:var(--main-border-radius)}.p-gui__tab-button{padding:7px 10px;background:transparent;color:#bbb;cursor:pointer;border:none;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;flex:1;font-family:inherit}.p-gui__tab-button:last-child{border-right:none}.p-gui__tab-button:hover{color:#fff}.p-gui__tab-button--active{background-color:var(--color-bg);color:#fff;border-bottom:1px solid transparent}.p-gui__tabs-content{position:relative;width:100%}.p-gui__tab-pane{display:none;width:100%;padding-top:4px;box-sizing:border-box}.p-gui__tab-pane--active{display:block}";
369
- function oe(k) {
370
- return `
1
+ //#region src/components/Button.ts
2
+ var e = class {
3
+ constructor(e, t = {}) {
4
+ if (this.callback = null, this.parent = e, typeof t != "object") throw Error(`[GUI] button() first parameter must be an object. Received: ${typeof t}.`);
5
+ let n = t.label || "\xA0", r = typeof t.tooltip == "string" ? t.tooltip : t.tooltip === !0 ? n : null, i = document.createElement("div");
6
+ i.className = "p-gui__button", i.textContent = n, r && i.setAttribute("title", r), i.addEventListener("click", () => {
7
+ this.callback && this.callback(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
8
+ }), typeof t.color == "string" && (i.style.setProperty("--color-accent", t.color), i.style.setProperty("--color-accent-hover", t.hoverColor || t.color)), this.parent.wrapper.append(i), this.element = i;
9
+ }
10
+ onClick(e) {
11
+ return this.callback = e, this;
12
+ }
13
+ }, t = class {
14
+ constructor(e, t, n, r = {}) {
15
+ if (this.callback = null, this.parent = e, this.propReferences = [], t && typeof t == "object" && typeof n == "string") this.obj = t, this.prop = n;
16
+ else throw Error("[GUI] slider() invalid parameters.");
17
+ let i = typeof r.label == "string" && r.label || "\xA0";
18
+ i == "\xA0" && (i = this.prop), this.min = r.min ?? 0, this.max = r.max ?? 1, this.step = r.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step);
19
+ let a = this.propReferences.push(this.obj[this.prop]) - 1, o = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, s = document.createElement("div");
20
+ s.className = "p-gui__slider", o && s.setAttribute("title", o), this.parent.wrapper.append(s), this.element = s;
21
+ let c = document.createElement("div");
22
+ c.className = "p-gui__slider-name", c.textContent = i, s.append(c), this.ctrlDiv = document.createElement("div"), this.ctrlDiv.prevPosition = 0, this.ctrlDiv.className = "p-gui__slider-ctrl", this.ctrlDiv.setAttribute("type", "range"), this.ctrlDiv.setAttribute("min", String(this.min)), this.ctrlDiv.setAttribute("max", String(this.max)), s.append(this.ctrlDiv);
23
+ let l = document.createElement("div");
24
+ l.className = "p-gui__slider-bar", this.ctrlDiv.append(l), this.handle = document.createElement("div"), this.handle.className = "p-gui__slider-handle", this.ctrlDiv.append(this.handle), this.filling = document.createElement("div"), this.filling.className = "p-gui__slider-filling", l.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.obj[this.prop], s.append(this.valueInput), setTimeout(() => {
25
+ let e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth;
26
+ this.handle.position = this.parent._mapLinear(parseFloat(this.valueInput.value), this.min, this.max, t / 2, e - t / 2), this.handle.position = Math.min(this.handle.position, e - t / 2), this.handle.position = Math.max(this.handle.position, t / 2), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
27
+ }, 0), this.valueInput.addEventListener("change", () => {
28
+ this._updateHandlePositionFromValue(), this._triggerCallbacks();
29
+ }), this.ctrlDiv.addEventListener("pointerdown", (e) => {
30
+ this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = e.clientX, this._updateHandlePositionFromPointer(e, !0);
31
+ }), window.addEventListener("pointerup", (e) => {
32
+ this.ctrlDiv.pointerDown = !1;
33
+ }), window.addEventListener("pointercancel", (e) => {
34
+ this.ctrlDiv.pointerDown = !1;
35
+ }), window.addEventListener("pointermove", (e) => {
36
+ this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = e.clientX - (this.ctrlDiv.prevPosition ?? 0), this._updateHandlePositionFromPointer(e));
37
+ }), Object.defineProperty(this.obj, this.prop, {
38
+ set: (e) => {
39
+ this.propReferences[a] = e, this.valueInput.value = e, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
40
+ },
41
+ get: () => this.propReferences[a]
42
+ });
43
+ }
44
+ _updateHandlePositionFromPointer(e, t = !1) {
45
+ let n = this.ctrlDiv.getBoundingClientRect(), r = n.width, i = this.handle.offsetWidth, a = e.clientX - (this.ctrlDiv.prevPosition ?? 0), o = parseFloat(this.valueInput.value), s;
46
+ s = t ? e.clientX - n.left : (this.handle.position ?? 0) + a, s = Math.max(i / 2, Math.min(s, r - i / 2));
47
+ let c = this.min + (this.max - this.min) * (s - i / 2) / (r - i);
48
+ c = c > o ? this._quantizeFloor(c, this.step) : this._quantizeCeil(c, this.step), c = parseFloat(c.toFixed(9));
49
+ let l = parseFloat((o + this.step).toFixed(9)), u = parseFloat((o - this.step).toFixed(9));
50
+ (c >= l || c <= u) && (c = parseFloat(c.toFixed(this.decimals)), this.valueInput.value = String(c), this.ctrlDiv.prevPosition = e.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${s}px)`, this.handle.position = s, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
51
+ }
52
+ _updateHandlePositionFromValue() {
53
+ let e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth, n = this.parent._mapLinear(parseFloat(this.valueInput.value), this.min, this.max, t / 2, e - t / 2);
54
+ n = Math.max(t / 2, Math.min(n, e - t / 2)), this.handle.style.transform = `translate(-50%, -50%) translateX(${n}px)`, this.handle.position = n, this.filling.style.width = this.handle.position + "px";
55
+ }
56
+ _triggerCallbacks() {
57
+ this.obj[this.prop] = parseFloat(this.valueInput.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
58
+ }
59
+ _quantize(e, t) {
60
+ return t * Math.round(e / t);
61
+ }
62
+ _quantizeCeil(e, t) {
63
+ return t * Math.ceil(e / t);
64
+ }
65
+ _quantizeFloor(e, t) {
66
+ return t * Math.floor(e / t);
67
+ }
68
+ onChange(e) {
69
+ return this.callback = e, this;
70
+ }
71
+ }, n = class {
72
+ constructor(e, t, n = {}) {
73
+ if (this.callback = null, this.parent = e, t === void 0) throw Error("[GUI] image() path must be provided.");
74
+ if (typeof t != "string") throw Error("[GUI] image() path must be a string.");
75
+ if (typeof n != "object") throw Error(`[GUI] image() second parameter must be an object. Received: ${typeof n}.`);
76
+ let r = t.replace(/^.*[\\\/]/, ""), i;
77
+ i = n.label == null ? r : typeof n.label == "string" && n.label || "\xA0";
78
+ let a = typeof n.tooltip == "string" ? n.tooltip : n.tooltip === !0 ? i : null, o = n.selected === !0, s = n.selectionBorder !== !1, c = "";
79
+ if (n.width) {
80
+ let e = n.width;
81
+ typeof e == "number" && (e = `${e}px`), c += `flex: 0 0 calc(${e} - 5px); `;
82
+ }
83
+ if (n.height) {
84
+ let e = n.height;
85
+ typeof e == "number" && (e = `${e}px`), c += `height: ${e}; `;
86
+ }
87
+ let l = document.createElement("div");
88
+ l.className = "p-gui__image", l.style = "background-image: url(" + t + "); " + c, a && l.setAttribute("title", a), this.parent.imageContainer.append(l), this.element = l, o && s && l.classList.add("p-gui__image--selected");
89
+ let u = document.createElement("div");
90
+ u.className = "p-gui__image-text", u.textContent = i, l.append(u), l.addEventListener("click", () => {
91
+ let e = l.parentElement?.querySelectorAll(".p-gui__image--selected") || [];
92
+ for (let t = 0; t < e.length; t++) e[t].classList.remove("p-gui__image--selected");
93
+ s && l.classList.add("p-gui__image--selected"), typeof this.callback == "function" && this.callback({
94
+ path: t,
95
+ text: i
96
+ }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
97
+ });
98
+ }
99
+ onClick(e) {
100
+ return this.callback = e, this;
101
+ }
102
+ }, r = class {
103
+ constructor(e, t, n, r = {}) {
104
+ if (this.parent = e, this.callback = null, !t || typeof t != "object" || typeof n != "string") throw Error("[GUI] toggle() invalid parameters.");
105
+ let i = typeof r.label == "string" && r.label !== "" ? r.label : n, a = this.parent.propReferences.push(t[n]) - 1, o = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, s = document.createElement("div");
106
+ s.textContent = i, s.className = "p-gui__toggle", o && s.setAttribute("title", o), this.parent.wrapper.append(s), this.element = s;
107
+ let c = t[n] ? " p-gui__toggle-checkbox--active" : "", l = document.createElement("div");
108
+ l.className = "p-gui__toggle-checkbox" + c, s.append(l), s.addEventListener("click", (e) => {
109
+ if (!e.target || !(e.target instanceof HTMLElement)) return;
110
+ let r = !0;
111
+ l.classList.contains("p-gui__toggle-checkbox--active") && (r = !1), l.classList.toggle("p-gui__toggle-checkbox--active"), t[n] = r, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
112
+ }), Object.defineProperty(t, n, {
113
+ set: (e) => {
114
+ this.parent.propReferences[a] = e, e ? l.classList.add("p-gui__toggle-checkbox--active") : l.classList.remove("p-gui__toggle-checkbox--active"), typeof this.callback == "function" && this.callback(e);
115
+ },
116
+ get: () => this.parent.propReferences[a]
117
+ });
118
+ }
119
+ onChange(e) {
120
+ return this.callback = e, this;
121
+ }
122
+ }, i = class {
123
+ constructor(e, t, n, r, i = {}) {
124
+ if (this.parent = e, this.callback = null, !t || typeof t != "object" || typeof n != "string") throw Error("[GUI] list() invalid parameters.");
125
+ let a = typeof i.label == "string" ? i.label : n, o = Array.isArray(r) ? r : null;
126
+ if (!o) throw Error("[GUI] list() Third argument must be an array.");
127
+ let s = o && o.length > 0 && typeof o[0] == "object", c = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? a : null, l = (() => {
128
+ if (!o) return null;
129
+ if (typeof t[n] == "string") return s ? o.find((e) => e.value === t[n])?.value : o.indexOf(t[n]);
130
+ if (typeof t[n] == "number") return s ? o.find((e) => e.value === t[n])?.value : t[n];
131
+ })(), u = this.parent.propReferences.push(t[n]) - 1, d = document.createElement("div");
132
+ d.className = "p-gui__list", d.textContent = a, c && d.setAttribute("title", c), this.parent.wrapper.append(d), this.element = d;
133
+ let f = document.createElement("select");
134
+ d.append(f), f.className = "p-gui__list-dropdown", f.addEventListener("change", (e) => {
135
+ t[n] = e.target.value, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
136
+ }), o && o.forEach((e, t) => {
137
+ let n = s ? e.label : e, r = s ? e.value : e, i = document.createElement("option");
138
+ i.setAttribute("value", String(r)), i.textContent = String(n), f.append(i), (!s && l == t || s && l == r) && i.setAttribute("selected", "");
139
+ }), Object.defineProperty(t, n, {
140
+ set: (e) => {
141
+ let t, n, r;
142
+ if (s) {
143
+ if (r = o?.find((t) => t.value == e), !r) {
144
+ console.error(`[GUI] list() value ${e} not found in values`);
145
+ return;
146
+ }
147
+ n = r?.value || o[0].value, t = o.indexOf(r);
148
+ } else typeof e == "string" && (t = o.indexOf(e), n = e), typeof e == "number" && (t = e, n = o[e]);
149
+ if (t === void 0 || n === void 0) {
150
+ console.error("[GUI] list() newIndex or newValue is undefined");
151
+ return;
152
+ }
153
+ this.parent.propReferences[u] = s ? n : e;
154
+ let i = f.querySelector("[selected]");
155
+ i && i.removeAttribute("selected"), f.querySelectorAll("option")[t].setAttribute("selected", ""), typeof this.callback == "function" && (s && r ? this.callback(r, t) : this.callback(n, t));
156
+ },
157
+ get: () => this.parent.propReferences[u]
158
+ });
159
+ }
160
+ onChange(e) {
161
+ return this.callback = e, this;
162
+ }
163
+ }, a = class {
164
+ constructor(e, t, n, r = {}) {
165
+ if (this.callback = null, this.parent = e, typeof t != "object" || typeof n != "string") throw Error("[GUI] color() invalid parameters. Expected (object, string, options).");
166
+ let i = typeof r.label == "string" && r.label || "\xA0";
167
+ i === "\xA0" && (i = n);
168
+ let a = typeof r.tooltip == "string" ? r.tooltip : r.tooltip === !0 ? i : null, o = this.parent.propReferences.push(t[n]) - 1, s = t[n] || "#000000", c = document.createElement("div");
169
+ c.className = "p-gui__color", c.textContent = i, a && c.setAttribute("title", a), this.parent.wrapper.append(c), this.element = c;
170
+ let l = document.createElement("input");
171
+ l.className = "p-gui__color-picker", l.setAttribute("type", "color"), l.value = s, c.append(l), l.addEventListener("input", () => {
172
+ t[n] = l.value, this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
173
+ }), Object.defineProperty(t, n, {
174
+ set: (e) => {
175
+ this.parent.propReferences[o] = e, l.value = e, typeof this.callback == "function" && this.callback(e);
176
+ },
177
+ get: () => this.parent.propReferences[o]
178
+ });
179
+ }
180
+ onChange(e) {
181
+ return this.callback = e, this;
182
+ }
183
+ }, o = class {
184
+ constructor(e, t, n, r, i = {}) {
185
+ this.parent = e, this.callback = null;
186
+ let a, o;
187
+ if (t && typeof t == "object" && typeof n == "string" && typeof r == "string") a = t, o = t, n = n, r = r;
188
+ else throw Error("[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', options)");
189
+ let s = typeof i.label == "string" && i.label || "\xA0";
190
+ s === "\xA0" && (s = n + " / " + r);
191
+ let c = i.x || {}, l = i.y || {}, u = c.min ?? i.min ?? 0, d = c.max ?? i.max ?? 1, f = l.min ?? i.min ?? 0, p = l.max ?? i.max ?? 1, m = c.step || i.step || (d - u) / 100, h = l.step || i.step || (p - f) / 100, g = this.parent._countDecimals(m), _ = this.parent._countDecimals(h), v = this.parent.propReferences.push(a[n]) - 1, y = this.parent.propReferences.push(o[r]) - 1, b = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, x = document.createElement("div");
192
+ x.className = "p-gui__vector2", x.textContent = s, b && x.setAttribute("title", b), this.parent.wrapper.append(x);
193
+ let S = document.createElement("div");
194
+ S.className = "p-gui__vector-value", S.textContent = a[n] + ", " + o[r], x.append(S);
195
+ let C = document.createElement("div");
196
+ C.className = "p-gui__vector2-area", x.append(C), C.addEventListener("click", (e) => {
197
+ let t = parseFloat(this.parent._mapLinear(e.offsetX, 0, C.clientWidth, u, d)), i = parseFloat(this.parent._mapLinear(e.offsetY, 0, C.clientHeight, p, f));
198
+ a[n] = t.toFixed(g), o[r] = i.toFixed(_), this.callback && this.callback(a[n], a[r]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
199
+ });
200
+ let w = (e) => {
201
+ let t = C.getBoundingClientRect(), i = e.clientX - t.left, s = e.clientY - t.top, c = this.parent._mapLinear(i, 0, C.clientWidth, u, d), l = this.parent._mapLinear(s, 0, C.clientHeight, p, f), m = Math.max(u, Math.min(d, c)), h = Math.max(f, Math.min(p, l));
202
+ a[n] = parseFloat(m.toFixed(g)), o[r] = parseFloat(h.toFixed(_)), this.callback && this.callback(a[n], o[r]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
203
+ };
204
+ C.addEventListener("pointerdown", (e) => {
205
+ w(e), document.addEventListener("pointermove", w), document.addEventListener("pointerup", () => {
206
+ document.removeEventListener("pointermove", w);
207
+ }, { once: !0 });
208
+ });
209
+ let T = document.createElement("div");
210
+ T.className = "p-gui__vector2-line p-gui__vector2-line-x", C.append(T);
211
+ let E = document.createElement("div");
212
+ E.className = "p-gui__vector2-line p-gui__vector2-line-y", C.append(E);
213
+ let D = document.createElement("div");
214
+ D.className = "p-gui__vector2-dot", C.append(D);
215
+ let O = () => {
216
+ D.style.left = this.parent._mapLinear(a[n], u, d, 0, C.clientWidth) + "px", D.style.top = this.parent._mapLinear(o[r], f, p, C.clientHeight, 0) + "px";
217
+ };
218
+ O(), new ResizeObserver(() => {
219
+ O();
220
+ }).observe(C), Object.defineProperty(a, n, {
221
+ set: (e) => {
222
+ this.parent.propReferences[v] = e, O(), S.textContent = String(e) + ", " + o[r];
223
+ },
224
+ get: () => this.parent.propReferences[v]
225
+ }), Object.defineProperty(o, r, {
226
+ set: (e) => {
227
+ this.parent.propReferences[y] = e, O(), S.textContent = a[n] + ", " + String(e);
228
+ },
229
+ get: () => this.parent.propReferences[y]
230
+ });
231
+ }
232
+ onChange(e) {
233
+ return this.callback = e, this;
234
+ }
235
+ }, s = ".p-gui__button{background:var(--color-accent);text-align:center;color:var(--color-bg);box-sizing:border-box;transition:var(--transition) background, var(--transition) border-color;border:1px solid #0000}.p-gui__button:hover{background:var(--color-accent-hover);border-color:#fff3}.p-gui__folder .p-gui__button{margin-inline:0}", c = ".p-gui__slider{min-height:14px;color:var(--color-text-dark);transition:color var(--transition);touch-action:none;justify-content:space-between;align-items:center;gap:10px;padding:3px;display:flex;position:relative}.p-gui__slider:hover{color:var(--color-text-light)}.p-gui__slider-name{text-overflow:ellipsis;width:50%;overflow:hidden}.p-gui__slider-ctrl{-webkit-appearance:none;font:inherit;box-sizing:border-box;cursor:pointer;touch-action:none;outline:none;width:37%;height:14px;margin:0 0 0 auto;padding:0;position:relative;right:0}.p-gui__slider-bar{background:#fff3;width:100%;height:2px;position:absolute;top:50%;left:0;transform:translateY(-50%)}.p-gui__slider-filling{background:var(--color-accent);pointer-events:none;width:0;height:100%;position:absolute;top:-25%;left:0}.p-gui__slider:hover .p-gui__slider-filling{background:var(--color-accent-hover)}.p-gui__slider-handle{pointer-events:none;background:var(--color-text-dark);border-radius:2px;width:9px;height:9px;position:absolute;top:50%;left:0;transform:translate(-50%,-50%);box-shadow:0 0 2px #00000080}.p-gui__slider:hover .p-gui__slider-handle{background:var(--color-text-light)}.p-gui__slider-value{color:inherit;width:13%;background:#ffffff1a;border:none;border-radius:2px;padding:2px 4px;display:inline-block;right:7px}.p-gui__slider-value:focus{outline:none}", l = ".p-gui__list{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__list:hover{color:var(--color-text-light)}.p-gui__list-dropdown{color:#fff;background:#ffffff0d;padding:0 12px 0 5px;top:0}.p-gui__list-dropdown{cursor:pointer;border:1px solid var(--color-border-2);border-radius:3px;outline:none;height:calc(100% - 4px);margin:auto;position:absolute;top:0;bottom:0;right:5px}.p-gui__list-dropdown option{color:#000;background:#fff}.p-gui__list-dropdown:hover{background:#ffffff1a}", u = ".p-gui__toggle{color:var(--color-text-dark);transition:var(--transition) background, var(--transition) color}.p-gui__toggle:hover{color:var(--color-text-light);background:#ffffff1a}.p-gui__folder .p-gui__toggle{margin-inline:0}.p-gui__toggle-checkbox{pointer-events:none;background-color:#ffffff1a;border-radius:2px;width:10px;height:10px;margin:auto;transition:all .5s;position:absolute;top:0;bottom:0;right:10px}.p-gui__toggle-checkbox--active{background-color:#ddd;box-shadow:0 0 5px #ddd}", d = ".p-gui__color{cursor:default;color:var(--color-text-dark);transition:var(--transition) color}.p-gui__color:hover{color:var(--color-text-light)}.p-gui__color-picker{cursor:pointer;border:1px solid var(--color-border-2);-webkit-appearance:none;background-color:#0000;border:1px solid #222;border-radius:3px;outline:none;height:calc(100% - 4px);margin:auto;padding:0;position:absolute;top:0;bottom:0;right:5px;overflow:hidden}.p-gui__color-picker::-webkit-color-swatch-wrapper{padding:0}.p-gui__color-picker::-webkit-color-swatch{border:none}", f = ".p-gui__vector2{aspect-ratio:1;color:var(--color-text-dark);background:0 0;padding-bottom:0}.p-gui__vector2:hover{color:var(--color-text-light)}.p-gui__vector2-area{touch-action:none;background:#0000004d;width:100%;height:calc(100% - 28px);margin-top:8px;position:relative}.p-gui__vector2-line{opacity:.3;pointer-events:none;background:#fff;position:absolute}.p-gui__vector2-line-x{width:100%;height:1px;top:50%;left:0;transform:translateY(-50%)}.p-gui__vector2-line-y{width:1px;height:100%;top:0;left:50%;transform:translate(-50%)}.p-gui__vector2-dot{pointer-events:none;background:#d5d5d5;border:2px solid #f99;border-radius:50%;width:8px;height:8px;position:absolute;top:0;left:0;transform:translate(-50%,-50%)}.p-gui__vector-value{display:inline-block;position:absolute;right:7px}", p = ".p-gui__image-container{box-sizing:border-box;flex-wrap:wrap;justify-content:flex-start;width:100%;padding:3px;display:flex}.p-gui__image{cursor:pointer;border-radius:var(--main-border-radius);height:90px;color:var(--color-text-dark);transition:var(--transition) color;background-position:50%;background-size:cover;flex:0 0 calc(33.333% - 5px);margin:1px 2.5px 19px;position:relative}.p-gui__image:hover{color:var(--color-text-light)}.p-gui__image:after{content:\"\";box-sizing:border-box;border-radius:var(--main-border-radius);width:100%;height:100%;transition:var(--transition) border-color;border:1px solid #0000;position:absolute;top:0;left:0}.p-gui__image--selected:after{border-color:#06ff89}.p-gui__image-text{text-shadow:0 -1px #111;white-space:nowrap;text-overflow:ellipsis;width:100%;position:absolute;bottom:-15px;overflow:hidden}", m = ".p-gui__folder{background:var(--color-bg);border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbb;flex-wrap:wrap;width:100%;margin-bottom:2px;display:flex;position:relative}.p-gui__folder--first{margin-top:0}.p-gui__folder-content{grid-template-rows:1fr;width:100%;transition:grid-template-rows .25s;display:grid}.p-gui__folder-inner{padding-left:3px;padding-right:2px;overflow:hidden}.p-gui__folder--closed .p-gui__folder-content{grid-template-rows:0fr}.p-gui__folder-header{color:#fff;cursor:pointer;box-sizing:border-box;border-top-right-radius:var(--main-border-radius);border-bottom-right-radius:var(--main-border-radius);background-color:#00000080;width:100%;padding:5px 3px}.p-gui__folder-header:hover{background-color:#000000bf}.p-gui__folder-arrow{background-image:url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQBAMAAADt3eJSAAAAHlBMVEUAAAD///////////////////////////////////8kfJuVAAAACXRSTlMA9Z1fCdMo1yxEJnA0AAAAK0lEQVQI12PABlRgjKkJUMZMYRhjpgqMAZSEMICSaIzpDWiKhdENhEhgAgATSg5jyWnYewAAAABJRU5ErkJggg==);background-size:contain;width:8px;height:8px;margin-right:5px;display:inline-block;transform:rotate(90deg)}.p-gui__folder--closed .p-gui__folder-arrow{transform:rotate(0)}", h = ".p-gui__tabs{background:var(--color-bg);border:1px solid var(--color-border-2);border-radius:var(--main-border-radius);box-sizing:border-box;border-left:1px solid #bbb;width:100%;margin-bottom:2px;padding-block:0;position:relative}.p-gui__tabs--first{margin-top:0}.p-gui__tabs-header{border-top-left-radius:var(--main-border-radius);border-top-right-radius:var(--main-border-radius);background-color:#00000080;display:flex}.p-gui__tab-button{color:#bbb;cursor:pointer;white-space:nowrap;text-overflow:ellipsis;background:0 0;border:none;flex:1;padding:7px 10px;font-family:inherit;overflow:hidden}.p-gui__tab-button:last-child{border-right:none}.p-gui__tab-button:hover{color:#fff}.p-gui__tab-button--active{background-color:var(--color-bg);color:#fff;border-bottom:1px solid #0000}.p-gui__tabs-content{width:100%;position:relative}.p-gui__tab-pane{box-sizing:border-box;width:100%;padding-top:4px;display:none}.p-gui__tab-pane--active{display:block}";
236
+ //#endregion
237
+ //#region src/styles/styles.js
238
+ function g(e) {
239
+ return `
371
240
  .p-gui {
372
241
  --main-border-radius: 6px;
373
242
  --color-bg: #161616;
@@ -379,7 +248,7 @@ function oe(k) {
379
248
  --color-accent-hover: #dddddd;
380
249
  --transition: .1s linear;
381
250
 
382
- position: ${k};
251
+ position: ${e};
383
252
  top: 0;
384
253
  left: 0;
385
254
  transform: translate3d(0,0,0);
@@ -515,49 +384,70 @@ function oe(k) {
515
384
  border-color: rgba(255,255,255,.2);
516
385
  }
517
386
 
518
- ${Q}
387
+ ${s}
519
388
 
520
- ${te}
389
+ ${p}
521
390
 
522
- ${J}
391
+ ${l}
523
392
 
524
- ${Z}
393
+ ${u}
525
394
 
526
- ${q}
395
+ ${c}
527
396
 
528
- ${K}
397
+ ${d}
529
398
 
530
- ${ee}
399
+ ${f}
531
400
 
532
- ${ie}
401
+ ${m}
533
402
 
534
- ${re}
403
+ ${h}
535
404
  `;
536
405
  }
537
- class C {
538
- constructor(t = {}) {
539
- if (this.firstParent = this, t.container ? (this.container = typeof t.container == "string" ? document.querySelector(t.container) : t.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], this.tabsArray = [], t.isFolder) {
540
- this._folderConstructor(t.folderOptions);
541
- return;
542
- }
543
- typeof t.onUpdate == "function" && (this.onUpdate = t.onUpdate), this.label = t != null && typeof t.label == "string" ? t.label : "", this.backgroundColor = t.color || null, this.opacity = t.opacity || 1, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(
544
- this.container.clientHeight,
545
- window.innerHeight
546
- ), t.maxHeight && (this.initMaxHeight = t.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(t.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = t.width || 290, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${oe(this.position_type)}`), this._styleInstance(), this.closed = !!t.closed, this._addWrapper(), this.domElement.setAttribute("data-corner-x", this.screenCorner.x), this.domElement.setAttribute("data-corner-y", this.screenCorner.y), t.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, t.draggable == !0 && this._makeDraggable();
547
- }
548
- _styleInstance() {
549
- let t = this._getScrollbarWidth(this.container);
550
- if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
551
- let e = this.container.querySelectorAll(".p-gui");
552
- for (let r = 0; r < e.length; r++)
553
- this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
554
- }
555
- this.yOffset = 0, this.position = {
556
- prevX: this.xOffset,
557
- prevY: this.yOffset,
558
- x: this.xOffset,
559
- y: this.yOffset
560
- }, this._addStyles(`#p-gui-${this.instanceId} {
406
+ //#endregion
407
+ //#region src/index.ts
408
+ var _ = class s {
409
+ constructor(e = {}, t = !1) {
410
+ if (this.container = document.body, this.label = "", this.backgroundColor = null, this.opacity = 1, this.maxHeight = window.innerHeight, this.initMaxHeight = null, this.instanceId = 0, this.wrapperWidth = 290, this.stylesheet = null, this.closed = !1, this.domElement = null, this.hasBeenDragged = !1, this.xOffset = 0, this.yOffset = 0, this.position = {
411
+ initX: 0,
412
+ initY: 0,
413
+ prevX: 0,
414
+ prevY: 0,
415
+ x: 0,
416
+ y: 0
417
+ }, this.isFolder = !1, this.parent = null, this.imageContainer = null, this.previousInnerScroll = 0, this.onUpdate = null, this._onPointerDown = (e) => {
418
+ e.preventDefault(), this.position.initX = this.position.x, this.position.initY = this.position.y, this.position.prevX = e.clientX, this.position.prevY = e.clientY, this.container.addEventListener("pointermove", this._onPointerMove), document.addEventListener("pointerup", this._onPointerUp);
419
+ }, this._onPointerMove = (e) => {
420
+ e.preventDefault(), this.hasBeenDragged || (this.hasBeenDragged = !0, this.domElement?.setAttribute("data-dragged", "true")), this.position.x = this.position.initX + e.clientX - this.position.prevX, this.position.y = this.position.initY + e.clientY - this.position.prevY, this.domElement && (this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`);
421
+ }, this._onPointerUp = () => {
422
+ this.container.removeEventListener("pointermove", this._onPointerMove), document.removeEventListener("pointerup", this._onPointerUp);
423
+ }, this.firstParent = this, this.folders = [], this.tabsArray = [], this.propReferences = [], e.isFolder) {
424
+ this._folderConstructor(e.folderOptions);
425
+ return;
426
+ }
427
+ if (t) return;
428
+ let n = "fixed";
429
+ if (e.container) {
430
+ let t = typeof e.container == "string" ? document.querySelector(e.container) : e.container;
431
+ t instanceof HTMLElement && (this.container = t, n = "absolute");
432
+ }
433
+ this.screenCorner = this._parseScreenCorner(e.position), e.width && (this.wrapperWidth = e.width), typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.label = typeof e.label == "string" ? e.label : "", this.backgroundColor = e.color || null, this.opacity = e.opacity || 1, this.container && this.container !== document.body && (this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight)), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.stylesheet = document.createElement("style"), this.stylesheet.setAttribute("type", "text/css"), this.stylesheet.setAttribute("id", "lm-gui-stylesheet"), document.head.append(this.stylesheet), this.instanceId == 0 && this._addStyles(`${g(n)}`), this._styleInstance(), this.closed = !!e.closed;
434
+ let [r, i] = this._addWrapper();
435
+ this.domElement = r, this.wrapper = i, this.domElement.setAttribute("data-corner-x", this.screenCorner.x), this.domElement.setAttribute("data-corner-y", this.screenCorner.y), e.autoRepositioning != 0 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), e.draggable == 1 && this._makeDraggable();
436
+ }
437
+ _styleInstance() {
438
+ let e = this._getScrollbarWidth(this.container);
439
+ if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - e, this.instanceId > 0) {
440
+ let e = this.container.querySelectorAll(".p-gui");
441
+ for (let t = 0; t < e.length; t++) this.screenCorner.y == e[t].dataset.cornerY && (this.screenCorner.x == "left" && e[t].dataset.cornerX == "left" ? this.xOffset += e[t].offsetWidth : this.screenCorner.x == "right" && e[t].dataset.cornerX == "right" && (this.xOffset -= e[t].offsetWidth));
442
+ }
443
+ this.yOffset = 0, this.position = {
444
+ initX: this.xOffset,
445
+ initY: this.yOffset,
446
+ prevX: this.xOffset,
447
+ prevY: this.yOffset,
448
+ x: this.xOffset,
449
+ y: this.yOffset
450
+ }, this._addStyles(`#p-gui-${this.instanceId} {
561
451
  width: ${this.wrapperWidth}px;
562
452
  max-height: ${this.maxHeight}px;
563
453
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
@@ -565,183 +455,164 @@ class C {
565
455
  ${this.backgroundColor ? "background: " + this.backgroundColor + ";" : ""}
566
456
  opacity: ${this.opacity};
567
457
  }`);
568
- }
569
- _folderConstructor(t) {
570
- this.domElement = t.wrapper, this.isFolder = !0, this.parent = t.parent, this.firstParent = t.firstParent, this.wrapper = t.inner;
571
- }
572
- _parseScreenCorner(t) {
573
- let e = { x: "right", y: "top" };
574
- return t == null || (typeof t != "string" && console.error("[perfect-gui] Position must be a string."), t.includes("left") && (e.x = "left"), t.includes("bottom") && (e.y = "bottom")), e;
575
- }
576
- _getScrollbarWidth(t) {
577
- return t === document.body ? window.innerWidth - document.documentElement.clientWidth : t.offsetWidth - t.clientWidth;
578
- }
579
- _handleResize() {
580
- if (this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(
581
- this.container.clientHeight,
582
- window.innerHeight
583
- ), this.initMaxHeight && (this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.wrapper.style.maxHeight = this.maxHeight + "px", this.hasBeenDragged)
584
- return;
585
- let t = this._getScrollbarWidth(this.container);
586
- if (this.xOffset = this.screenCorner.x == "left" ? 0 : this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
587
- let e = this.container.querySelectorAll(
588
- `.p-gui:not(#${this.domElement.id}):not([data-dragged])`
589
- );
590
- for (let r = 0; r < e.length && !(parseInt(
591
- e[r].id.replace("p-gui-", "")
592
- ) > this.instanceId); r++)
593
- this.screenCorner.y == e[r].dataset.cornerY && (this.screenCorner.x == "left" && e[r].dataset.cornerX == "left" ? this.xOffset += e[r].offsetWidth : this.screenCorner.x == "right" && e[r].dataset.cornerX == "right" && (this.xOffset -= e[r].offsetWidth));
594
- }
595
- this.position = {
596
- prevX: this.xOffset,
597
- prevY: this.yOffset,
598
- x: this.xOffset,
599
- y: this.yOffset
600
- }, this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
601
- }
602
- _addStyles(t) {
603
- this.stylesheet.innerHTML += t;
604
- }
605
- _addWrapper() {
606
- this.domElement = document.createElement("div"), this.domElement.id = "p-gui-" + this.instanceId, this.domElement.className = "p-gui" + (this.closed ? " p-gui--collapsed" : ""), this.domElement.setAttribute("data-lenis-prevent", ""), this.container.append(this.domElement), this.header = document.createElement("div"), this.header.className = "p-gui__header", this.header.textContent = this.label, this.header.style = `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`, this.domElement.append(this.header);
607
- const t = document.createElement("div");
608
- t.className = "p-gui__header-close", t.addEventListener("click", this.toggleClose.bind(this)), this.header.append(t);
609
- const e = document.createElement("div");
610
- e.className = "p-gui__content", this.domElement.append(e), this.wrapper = document.createElement("div"), this.wrapper.className = "p-gui__inner", e.append(this.wrapper);
611
- }
612
- button(t = {}) {
613
- return this.imageContainer = null, new W(this, t);
614
- }
615
- image(t = {}) {
616
- return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new z(this, t);
617
- }
618
- slider(t, e, r) {
619
- return this.imageContainer = null, new Y(this, t, e, r);
620
- }
621
- toggle(t, e, r) {
622
- return this.imageContainer = null, new B(this, t, e, r);
623
- }
624
- list(t, e, r) {
625
- return this.imageContainer = null, new T(this, t, e, r);
626
- }
627
- color(t, e, r) {
628
- return this.imageContainer = null, new V(this, t, e, r);
629
- }
630
- vector2(t, e, r, d) {
631
- return this.imageContainer = null, new G(this, t, e, r, d);
632
- }
633
- folder(t = {}) {
634
- let e = typeof t.closed == "boolean" ? t.closed : !1, r = t.label || "", d = t.color || null, i = t.maxHeight || null;
635
- this.imageContainer = null;
636
- let p = "p-gui__folder";
637
- this.folders.length == 0 && (p += " p-gui__folder--first"), e && (p += " p-gui__folder--closed");
638
- let l = d ? `background-color: ${d};` : "";
639
- l += i ? `max-height: ${i}px; overflow-y: auto;` : "";
640
- const o = document.createElement("div");
641
- o.className = p, o.style = l, this.wrapper.append(o);
642
- const s = document.createElement("div");
643
- s.innerHTML = `<span class="p-gui__folder-arrow"></span>${r}`, s.className = "p-gui__folder-header", o.append(s);
644
- const a = document.createElement("div");
645
- a.className = "p-gui__folder-content", o.append(a);
646
- const h = document.createElement("div");
647
- h.className = "p-gui__folder-inner", a.append(h), s.addEventListener("click", () => {
648
- o.classList.toggle("p-gui__folder--closed");
649
- });
650
- let c = new C({
651
- isFolder: !0,
652
- folderOptions: {
653
- wrapper: o,
654
- inner: h,
655
- parent: this,
656
- firstParent: this.firstParent
657
- }
658
- });
659
- return this.folders.push(c), c;
660
- }
661
- tabs(t = {}) {
662
- const e = Array.isArray(t.tabs) ? t.tabs : [], r = t.active || 0, d = t.color || null, i = t.maxHeight || null;
663
- this.imageContainer = null;
664
- let p = "p-gui__tabs";
665
- this.tabsArray.length == 0 && (p += " p-gui__tabs--first");
666
- let l = d ? `background-color: ${d};` : "";
667
- l += i ? `max-height: ${i}px; overflow-y: auto;` : "";
668
- const o = document.createElement("div");
669
- o.className = p, o.style = l, this.wrapper.append(o);
670
- const s = document.createElement("div");
671
- s.className = "p-gui__tabs-header", o.append(s);
672
- const a = document.createElement("div");
673
- a.className = "p-gui__tabs-content", o.append(a);
674
- const h = [];
675
- e.forEach((n, g) => {
676
- const b = typeof n == "string" ? n : n.label || `Tab ${g + 1}`, f = document.createElement("button");
677
- f.className = "p-gui__tab-button", g === r && (f.className += " p-gui__tab-button--active"), f.textContent = b, s.append(f);
678
- const u = document.createElement("div");
679
- u.className = "p-gui__tab-pane", g === r && (u.className += " p-gui__tab-pane--active"), a.append(u);
680
- const m = new C({
681
- isFolder: !0,
682
- folderOptions: {
683
- wrapper: o,
684
- inner: u,
685
- parent: this,
686
- firstParent: this.firstParent
687
- }
688
- });
689
- h.push({
690
- gui: m,
691
- button: f,
692
- pane: u
693
- }), f.addEventListener("click", () => {
694
- h.forEach((x) => {
695
- x.button.classList.remove("p-gui__tab-button--active"), x.pane.classList.remove("p-gui__tab-pane--active");
696
- }), f.classList.add("p-gui__tab-button--active"), u.classList.add("p-gui__tab-pane--active");
697
- });
698
- });
699
- const c = new C({
700
- isFolder: !0,
701
- folderOptions: {
702
- wrapper: o,
703
- inner: h[r]?.pane || document.createElement("div"),
704
- parent: this,
705
- firstParent: this.firstParent
706
- }
707
- });
708
- return c.getTab = (n) => h[n]?.gui || null, c.getTabElement = (n) => h[n]?.button || null, c.setActiveTab = (n) => {
709
- n >= 0 && n < h.length && h[n].button.click();
710
- }, c.getActiveTab = () => h.findIndex(
711
- (n) => n.button.classList.contains("p-gui__tab-button--active")
712
- ), c.element = o, this.tabsArray.push(c), c;
713
- }
714
- _makeDraggable() {
715
- var t = this;
716
- this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup", d);
717
- function e(i) {
718
- i.preventDefault(), t.position.initX = t.position.x, t.position.initY = t.position.y, t.position.prevX = i.clientX, t.position.prevY = i.clientY, document.addEventListener("pointermove", r);
719
- }
720
- function r(i) {
721
- i.preventDefault(), t.hasBeenDragged || (t.hasBeenDragged = !0, t.domElement.setAttribute("data-dragged", "true")), t.position.x = t.position.initX + i.clientX - t.position.prevX, t.position.y = t.position.initY + i.clientY - t.position.prevY, t.domElement.style.transform = "translate3d(" + t.position.x + "px," + t.position.y + "px,0)";
722
- }
723
- function d(i) {
724
- document.removeEventListener("pointermove", r);
725
- }
726
- }
727
- toggleClose() {
728
- this.closed = !this.closed, this.closed ? (this.previousInnerScroll = this.wrapper.scrollTop, this.wrapper.scrollTo(0, 0)) : this.wrapper.scrollTo(0, this.previousInnerScroll), this.domElement.classList.toggle("p-gui--collapsed");
729
- }
730
- kill() {
731
- this.domElement.remove();
732
- }
733
- _mapLinear(t, e, r, d, i) {
734
- return d + (t - e) * (i - d) / (r - e);
735
- }
736
- _countDecimals(t) {
737
- const e = t.toString(), r = e.indexOf(".");
738
- return r === -1 ? 0 : e.length - r - 1;
739
- }
740
- static registerPlugin(t) {
741
- for (let e in t)
742
- C.prototype[e] = t[e];
743
- }
744
- }
745
- export {
746
- C as default
458
+ }
459
+ _folderConstructor(e) {
460
+ if (!e) throw Error("[perfect-gui] folderOptions is undefined");
461
+ this.domElement = e.container, this.isFolder = !0, this.parent = e.parent, this.firstParent = e.firstParent, this.wrapper = e.wrapper;
462
+ }
463
+ _parseScreenCorner(e) {
464
+ let t = {
465
+ x: "right",
466
+ y: "top"
467
+ };
468
+ return e == null ? t : (typeof e != "string" && console.error("[perfect-gui] Position must be a string."), e.includes("left") && (t.x = "left"), e.includes("bottom") && (t.y = "bottom"), t);
469
+ }
470
+ _getScrollbarWidth(e) {
471
+ return e === document.body ? window.innerWidth - document.documentElement.clientWidth : e.offsetWidth - e.clientWidth;
472
+ }
473
+ _handleResize() {
474
+ if (!this.domElement || (this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), this.initMaxHeight && (this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.wrapper.style.maxHeight = this.maxHeight + "px", this.hasBeenDragged)) return;
475
+ let e = this._getScrollbarWidth(this.container);
476
+ if (this.xOffset = this.screenCorner.x == "left" ? 0 : this.container.clientWidth - this.wrapperWidth - e, this.instanceId > 0) {
477
+ let e = this.container.querySelectorAll(`.p-gui:not(#${this.domElement.id}):not([data-dragged])`);
478
+ for (let t = 0; t < e.length && !(parseInt(e[t].id.replace("p-gui-", "")) > this.instanceId); t++) this.screenCorner.y == e[t].dataset.cornerY && (this.screenCorner.x == "left" && e[t].dataset.cornerX == "left" ? this.xOffset += e[t].offsetWidth : this.screenCorner.x == "right" && e[t].dataset.cornerX == "right" && (this.xOffset -= e[t].offsetWidth));
479
+ }
480
+ this.position = {
481
+ initX: this.xOffset,
482
+ initY: this.yOffset,
483
+ prevX: this.xOffset,
484
+ prevY: this.yOffset,
485
+ x: this.xOffset,
486
+ y: this.yOffset
487
+ }, this.domElement.style.transform = `translate3d(${this.position.x}px, ${this.position.y}px, 0)`;
488
+ }
489
+ _addStyles(e) {
490
+ this.stylesheet && (this.stylesheet.innerHTML += e);
491
+ }
492
+ _addWrapper() {
493
+ let e = document.createElement("div");
494
+ e.id = "p-gui-" + this.instanceId, e.className = "p-gui" + (this.closed ? " p-gui--collapsed" : ""), e.setAttribute("data-lenis-prevent", ""), this.container.append(e), this.header = document.createElement("div"), this.header.className = "p-gui__header", this.header.textContent = this.label, this.header.style = `${this.backgroundColor ? "border-color: " + this.backgroundColor + ";" : ""}`, e.append(this.header);
495
+ let t = document.createElement("div");
496
+ t.className = "p-gui__header-close", t.addEventListener("click", this.toggleClose.bind(this)), this.header.append(t);
497
+ let n = document.createElement("div");
498
+ n.className = "p-gui__content", e.append(n);
499
+ let r = document.createElement("div");
500
+ return r.className = "p-gui__inner", n.append(r), [e, r];
501
+ }
502
+ button(t = {}) {
503
+ return this.imageContainer = null, new e(this, t);
504
+ }
505
+ image(e, t = {}) {
506
+ return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new n(this, e, t);
507
+ }
508
+ slider(e, n, r) {
509
+ return this.imageContainer = null, new t(this, e, n, r);
510
+ }
511
+ toggle(e, t, n) {
512
+ return this.imageContainer = null, new r(this, e, t, n);
513
+ }
514
+ list(e, t, n, r) {
515
+ return this.imageContainer = null, new i(this, e, t, n, r);
516
+ }
517
+ color(e, t, n) {
518
+ return this.imageContainer = null, new a(this, e, t, n);
519
+ }
520
+ vector2(e, t, n, r) {
521
+ return this.imageContainer = null, new o(this, e, t, n, r);
522
+ }
523
+ folder(e) {
524
+ let t = typeof e.closed == "boolean" ? e.closed : !1, n = e.label || "", r = e.color || null, i = e.maxHeight || null;
525
+ this.imageContainer = null;
526
+ let a = "p-gui__folder";
527
+ this.folders.length == 0 && (a += " p-gui__folder--first"), t && (a += " p-gui__folder--closed");
528
+ let o = r ? `background-color: ${r};` : "";
529
+ o += i ? `max-height: ${i}px; overflow-y: auto;` : "";
530
+ let s = document.createElement("div");
531
+ s.className = a, s.style = o, this.wrapper.append(s);
532
+ let c = document.createElement("div");
533
+ c.innerHTML = `<span class="p-gui__folder-arrow"></span>${n}`, c.className = "p-gui__folder-header", s.append(c);
534
+ let l = document.createElement("div");
535
+ l.className = "p-gui__folder-content", s.append(l);
536
+ let u = document.createElement("div");
537
+ u.className = "p-gui__folder-inner", l.append(u), c.addEventListener("click", () => {
538
+ s.classList.toggle("p-gui__folder--closed");
539
+ });
540
+ let d = new v({
541
+ container: s,
542
+ wrapper: u,
543
+ parent: this,
544
+ firstParent: this.firstParent
545
+ });
546
+ return this.folders.push(d), d;
547
+ }
548
+ tabs(e = {}) {
549
+ let t = Array.isArray(e.tabs) ? e.tabs : [], n = e.active || 0, r = e.color || null, i = e.maxHeight || null;
550
+ this.imageContainer = null;
551
+ let a = "p-gui__tabs";
552
+ this.tabsArray.length == 0 && (a += " p-gui__tabs--first");
553
+ let o = r ? `background-color: ${r};` : "";
554
+ o += i ? `max-height: ${i}px; overflow-y: auto;` : "";
555
+ let s = document.createElement("div");
556
+ s.className = a, s.style = o, this.wrapper.append(s);
557
+ let c = document.createElement("div");
558
+ c.className = "p-gui__tabs-header", s.append(c);
559
+ let l = document.createElement("div");
560
+ l.className = "p-gui__tabs-content", s.append(l);
561
+ let u = [];
562
+ t.forEach((e, t) => {
563
+ let r = typeof e == "string" ? e : e.label || `Tab ${t + 1}`, i = document.createElement("button");
564
+ i.className = "p-gui__tab-button", t === n && (i.className += " p-gui__tab-button--active"), i.textContent = r, c.append(i);
565
+ let a = document.createElement("div");
566
+ a.className = "p-gui__tab-pane", t === n && (a.className += " p-gui__tab-pane--active"), l.append(a);
567
+ let o = new v({
568
+ container: s,
569
+ wrapper: a,
570
+ parent: this,
571
+ firstParent: this.firstParent
572
+ });
573
+ u.push({
574
+ gui: o,
575
+ button: i,
576
+ pane: a
577
+ }), i.addEventListener("click", () => {
578
+ u.forEach((e) => {
579
+ e.button.classList.remove("p-gui__tab-button--active"), e.pane.classList.remove("p-gui__tab-pane--active");
580
+ }), i.classList.add("p-gui__tab-button--active"), a.classList.add("p-gui__tab-pane--active");
581
+ });
582
+ });
583
+ let d = new v({
584
+ container: s,
585
+ wrapper: u[n]?.pane || document.createElement("div"),
586
+ parent: this,
587
+ firstParent: this.firstParent
588
+ });
589
+ return d.getTab = (e) => u[e]?.gui || null, d.getTabElement = (e) => u[e]?.button || null, d.setActiveTab = (e) => {
590
+ e >= 0 && e < u.length && u[e].button.click();
591
+ }, d.getActiveTab = () => u.findIndex((e) => e.button.classList.contains("p-gui__tab-button--active")), d.element = s, this.tabsArray.push(d), d;
592
+ }
593
+ _makeDraggable() {
594
+ !this.domElement || !this.header || this.header.addEventListener("pointerdown", this._onPointerDown);
595
+ }
596
+ toggleClose() {
597
+ this.domElement && (this.closed = !this.closed, this.closed ? (this.previousInnerScroll = this.wrapper.scrollTop, this.wrapper.scrollTo(0, 0)) : this.wrapper.scrollTo(0, this.previousInnerScroll), this.domElement.classList.toggle("p-gui--collapsed"));
598
+ }
599
+ kill() {
600
+ this.domElement && this.domElement.remove();
601
+ }
602
+ _mapLinear(e, t, n, r, i) {
603
+ return r + (e - t) * (i - r) / (n - t);
604
+ }
605
+ _countDecimals(e) {
606
+ let t = e.toString(), n = t.indexOf(".");
607
+ return n === -1 ? 0 : t.length - n - 1;
608
+ }
609
+ static registerPlugin(e) {
610
+ for (let t in e) s.prototype[t] = e[t];
611
+ }
612
+ }, v = class extends _ {
613
+ constructor(e) {
614
+ super({}, !0), this.isFolder = !0, this.domElement = e.container, this.wrapper = e.wrapper, this.parent = e.parent, this.firstParent = e.firstParent;
615
+ }
747
616
  };
617
+ //#endregion
618
+ export { v as Folder, _ as default };