perfect-gui 4.12.9 → 5.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,75 +1,102 @@
1
- let M = class {
2
- constructor(t, e = {}, i) {
3
- this.parent = t;
4
- let s = "";
5
- typeof e != "string" ? typeof e == "object" && e?.hasOwnProperty("label") ? s = e.label == "" ? " " : e.label : s = " " : s = e == "" ? " " : e;
6
- const l = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null, a = document.createElement("div");
7
- return a.className = "p-gui__button", a.textContent = s, l && a.setAttribute("title", l), a.addEventListener("click", () => {
8
- i && i(), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
9
- }), typeof e.color == "string" && (a.style.setProperty("--color-accent", e.color), a.style.setProperty("--color-accent-hover", e.hoverColor || e.color)), this.parent.wrapper.append(a), a;
1
+ class $ {
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 c = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? r : null, i = document.createElement("div");
9
+ i.className = "p-gui__button", i.textContent = r, c && i.setAttribute("title", c), 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);
15
+ }
16
+ onClick(t) {
17
+ return this.callback = t, this;
10
18
  }
11
- };
12
- class N {
13
- constructor(t, e = {}, i) {
14
- if (this.parent = t, this.propReferences = [], typeof e != "object")
15
- throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
16
- let s = typeof e.label == "string" && e.label || " ";
17
- this.isObject = !1;
18
- let l = null;
19
- this.obj = e.obj, this.prop = e.prop;
20
- let a = typeof e.value == "number" ? e.value : null;
21
- if (this.min = e.min ?? 0, this.max = e.max ?? 1, this.step = e.step || (this.max - this.min) / 100, this.decimals = this.parent._countDecimals(this.step), this.callback = typeof i == "function" ? i : null, a !== null)
22
- (this.prop != null || this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
23
- else if (this.prop != null && this.obj != null) {
24
- if (typeof this.prop != "string")
25
- throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof this.prop}.`);
26
- if (typeof this.obj != "object")
27
- throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof this.obj}.`);
28
- s == " " && (s = this.prop), l = this.propReferences.push(this.obj[this.prop]) - 1, this.isObject = !0;
29
- } else
30
- (this.prop != null && this.obj == null || this.prop == null && this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), a = (this.max - this.min) / 2;
31
- const o = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null, r = document.createElement("div");
32
- r.className = "p-gui__slider", o && r.setAttribute("title", o), this.parent.wrapper.append(r);
19
+ }
20
+ class Y {
21
+ constructor(t, e, r, c) {
22
+ this.parent = t, this.propReferences = [];
23
+ let i = {}, a = null;
24
+ if (e && typeof e == "object" && typeof r == "string")
25
+ this.obj = e, this.prop = r, this.isObject = !0, i = c || {}, this.callback = null;
26
+ else if (e && typeof e == "object")
27
+ this.isObject = !1, i = e, a = typeof i.value == "number" ? i.value : null;
28
+ else
29
+ throw Error("[GUI] slider() invalid parameters.");
30
+ let s = typeof i.label == "string" && i.label || " ";
31
+ this.isObject && s == " " && (s = 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 : a === null && (a = (this.max - this.min) / 2);
34
+ const n = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? s : null, l = document.createElement("div");
35
+ l.className = "p-gui__slider", n && l.setAttribute("title", n), this.parent.wrapper.append(l);
36
+ const u = document.createElement("div");
37
+ u.className = "p-gui__slider-name", u.textContent = s, l.append(u), 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), l.append(this.ctrlDiv);
33
38
  const d = document.createElement("div");
34
- d.className = "p-gui__slider-name", d.textContent = s, r.append(d), 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), r.append(this.ctrlDiv);
35
- const c = document.createElement("div");
36
- return 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] : a, r.append(this.valueInput), setTimeout(() => {
37
- const n = this.handle.offsetWidth;
38
- this.handle.position = this._mapLinear(this.valueInput.value, this.min, this.max, n / 2, 88 - n / 2), this.handle.position = Math.min(this.handle.position, 88 - n / 2), this.handle.position = Math.max(this.handle.position, n / 2), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
39
+ d.className = "p-gui__slider-bar", this.ctrlDiv.append(d), 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", d.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : a, l.append(this.valueInput), setTimeout(() => {
40
+ const p = this.handle.offsetWidth;
41
+ this.handle.position = this._mapLinear(
42
+ this.valueInput.value,
43
+ this.min,
44
+ this.max,
45
+ p / 2,
46
+ 88 - p / 2
47
+ ), this.handle.position = Math.min(
48
+ this.handle.position,
49
+ 88 - p / 2
50
+ ), this.handle.position = Math.max(
51
+ this.handle.position,
52
+ p / 2
53
+ ), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
39
54
  }, 0), this.valueInput.addEventListener("change", () => {
40
55
  this._updateHandlePositionFromValue(), this._triggerCallbacks();
41
- }), this.ctrlDiv.addEventListener("pointerdown", (n) => {
42
- this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = n.clientX, this._updateHandlePositionFromPointer(n, !0);
43
- }), window.addEventListener("pointerup", (n) => {
56
+ }), this.ctrlDiv.addEventListener("pointerdown", (p) => {
57
+ this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = p.clientX, this._updateHandlePositionFromPointer(p, !0);
58
+ }), window.addEventListener("pointerup", (p) => {
44
59
  this.ctrlDiv.pointerDown = !1;
45
- }), window.addEventListener("pointermove", (n) => {
46
- this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = n.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(n));
60
+ }), window.addEventListener("pointermove", (p) => {
61
+ this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = p.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(p));
47
62
  }), this.isObject && Object.defineProperty(this.obj, this.prop, {
48
- set: (n) => {
49
- this.propReferences[l] = n, this.valueInput.value = n, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
63
+ set: (p) => {
64
+ this.propReferences[o] = p, this.valueInput.value = p, this._updateHandlePositionFromValue(), this.callback && this.callback(parseFloat(this.valueInput.value));
50
65
  },
51
- get: () => this.propReferences[l]
52
- }), r;
66
+ get: () => this.propReferences[o]
67
+ });
53
68
  }
54
69
  _updateHandlePositionFromPointer(t, e = !1) {
55
- const i = this.ctrlDiv.offsetWidth, s = this.handle.offsetWidth, l = t.clientX - this.ctrlDiv.prevPosition, a = parseFloat(this.valueInput.value);
56
- let o;
57
- e ? o = t.offsetX : o = this.handle.position + l, o = Math.max(s / 2, Math.min(o, i - s / 2));
58
- let r = this.min + (this.max - this.min) * (o - s / 2) / (i - s);
59
- r > a ? r = this._quantizeFloor(r, this.step) : r = this._quantizeCeil(r, this.step), r = parseFloat(r.toFixed(9));
60
- const d = parseFloat((a + this.step).toFixed(9)), c = parseFloat((a - this.step).toFixed(9));
61
- (r >= d || r <= c) && (r = r.toFixed(this.decimals), this.valueInput.value = r, this.ctrlDiv.prevPosition = t.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${o}px)`, this.handle.position = o, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks());
70
+ const r = this.ctrlDiv.offsetWidth, c = this.handle.offsetWidth, i = t.clientX - this.ctrlDiv.prevPosition, a = parseFloat(this.valueInput.value);
71
+ let s;
72
+ e ? s = t.offsetX : s = this.handle.position + i, s = Math.max(
73
+ c / 2,
74
+ Math.min(s, r - c / 2)
75
+ );
76
+ let o = this.min + (this.max - this.min) * (s - c / 2) / (r - c);
77
+ o > a ? o = this._quantizeFloor(o, this.step) : o = this._quantizeCeil(o, this.step), o = parseFloat(o.toFixed(9));
78
+ const n = parseFloat((a + this.step).toFixed(9)), l = parseFloat((a - this.step).toFixed(9));
79
+ (o >= n || o <= l) && (o = o.toFixed(this.decimals), this.valueInput.value = o, this.ctrlDiv.prevPosition = t.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());
62
80
  }
63
81
  _updateHandlePositionFromValue() {
64
82
  const t = this.ctrlDiv.offsetWidth, e = this.handle.offsetWidth;
65
- let i = this._mapLinear(this.valueInput.value, this.min, this.max, e / 2, t - e / 2);
66
- i = Math.max(e / 2, Math.min(i, t - e / 2)), this.handle.style.transform = `translate(-50%, -50%) translateX(${i}px)`, this.handle.position = i, this.filling.style.width = this.handle.position + "px";
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";
67
94
  }
68
95
  _triggerCallbacks() {
69
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();
70
97
  }
71
- _mapLinear(t, e, i, s, l) {
72
- return s + (t - e) * (l - s) / (i - e);
98
+ _mapLinear(t, e, r, c, i) {
99
+ return c + (t - e) * (i - c) / (r - e);
73
100
  }
74
101
  _quantize(t, e) {
75
102
  return e * Math.round(t / e);
@@ -80,193 +107,266 @@ class N {
80
107
  _quantizeFloor(t, e) {
81
108
  return e * Math.floor(t / e);
82
109
  }
110
+ onChange(t) {
111
+ return this.callback = t, this;
112
+ }
83
113
  }
84
- class H {
85
- constructor(t, e = {}, i) {
86
- if (this.parent = t, typeof e != "object")
87
- throw Error(`[GUI] image() first parameter must be an object. Received: ${typeof e}.`);
88
- let s;
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;
89
121
  if (typeof e.path == "string")
90
- s = e.path;
122
+ r = e.path;
91
123
  else
92
124
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
93
- let l = s.replace(/^.*[\\\/]/, ""), a;
94
- e.label == null ? a = l : a = typeof e.label == "string" && e.label || " ";
95
- const o = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? a : null, r = e.selected === !0, d = e.selectionBorder !== !1;
96
- let c = "";
97
- e.width && (typeof e.width == "number" && (e.width += "px"), c += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), c += `height: ${e.height}; `);
98
- const n = document.createElement("div");
99
- n.className = "p-gui__image", n.style = "background-image: url(" + s + "); " + c, o && n.setAttribute("title", o), this.parent.imageContainer.append(n), r && d && n.classList.add("p-gui__image--selected");
100
- const f = document.createElement("div");
101
- return f.className = "p-gui__image-text", f.textContent = a, n.append(f), n.addEventListener("click", () => {
102
- let p = n.parentElement.querySelectorAll(".p-gui__image--selected");
103
- for (let h = 0; h < p.length; h++)
104
- p[h].classList.remove("p-gui__image--selected");
105
- d && n.classList.add("p-gui__image--selected"), typeof i == "function" && i({ path: s, text: a }), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
106
- }), n;
125
+ let c = r.replace(/^.*[\\\/]/, ""), i;
126
+ e.label == null ? i = c : i = typeof e.label == "string" && e.label || " ";
127
+ const a = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? i : null, s = e.selected === !0, o = e.selectionBorder !== !1;
128
+ let n = "";
129
+ e.width && (typeof e.width == "number" && (e.width += "px"), n += `flex: 0 0 calc(${e.width} - 5px); `), e.height && (typeof e.height == "number" && (e.height += "px"), n += `height: ${e.height}; `);
130
+ const l = document.createElement("div");
131
+ l.className = "p-gui__image", l.style = "background-image: url(" + r + "); " + n, a && l.setAttribute("title", a), this.parent.imageContainer.append(l), s && o && l.classList.add("p-gui__image--selected");
132
+ const u = document.createElement("div");
133
+ u.className = "p-gui__image-text", u.textContent = i, l.append(u), l.addEventListener("click", () => {
134
+ let d = l.parentElement.querySelectorAll(
135
+ ".p-gui__image--selected"
136
+ );
137
+ for (let p = 0; p < d.length; p++)
138
+ d[p].classList.remove("p-gui__image--selected");
139
+ o && l.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;
107
144
  }
108
145
  }
109
- class S {
110
- constructor(t, e = {}, i) {
111
- if (this.parent = t, typeof e != "object")
112
- throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);
113
- let s = typeof e.label == "string" && e.label || " ", l = !1, a = null, o = e.obj, r = e.prop, d = typeof e.value == "boolean" ? e.value : null;
114
- if (d !== null)
115
- (r != null || o != null) && console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
116
- else if (r != null && o != null) {
117
- if (typeof r != "string")
118
- throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof r}.`);
119
- if (typeof o != "object")
120
- throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof o}.`);
121
- s == " " && (s = r), a = this.parent.propReferences.push(o[r]) - 1, l = !0;
122
- } else
123
- (r != null && o == null || r == null && o == null) && console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');
124
- const c = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null, n = document.createElement("div");
125
- n.textContent = s, n.className = "p-gui__toggle", c && n.setAttribute("title", c), n.addEventListener("click", (h) => {
126
- const u = h.target.childNodes[1];
127
- let g = !0;
128
- u.classList.contains("p-gui__toggle-checkbox--active") && (g = !1), u.classList.toggle("p-gui__toggle-checkbox--active"), l ? o[r] = g : typeof i == "function" && i(g), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
146
+ class B {
147
+ constructor(t, e, r, c) {
148
+ this.parent = t, this.callback = null;
149
+ let i = {}, a = null, s = !1, o, n;
150
+ if (e && typeof e == "object" && typeof r == "string")
151
+ o = e, n = r, s = !0, i = c || {};
152
+ else if (e && typeof e == "object")
153
+ s = !1, i = e, a = typeof i.value == "boolean" ? i.value : null;
154
+ else
155
+ throw Error("[GUI] toggle() invalid parameters.");
156
+ let l = typeof i.label == "string" && i.label || " ", u = null;
157
+ s && l == " " && (l = n), s && (u = this.parent.propReferences.push(o[n]) - 1);
158
+ const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null, p = document.createElement("div");
159
+ p.textContent = l, p.className = "p-gui__toggle", d && p.setAttribute("title", d), this.parent.wrapper.append(p), p.addEventListener("click", (b) => {
160
+ const h = b.target.childNodes[1];
161
+ let _ = !0;
162
+ h.classList.contains("p-gui__toggle-checkbox--active") && (_ = !1), h.classList.toggle("p-gui__toggle-checkbox--active"), s ? o[n] = _ : typeof this.callback == "function" && this.callback(_), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
129
163
  });
130
- let f = l ? o[r] ? " p-gui__toggle-checkbox--active" : "" : d ? " p-gui__toggle-checkbox--active" : "";
131
- const p = document.createElement("div");
132
- return p.className = "p-gui__toggle-checkbox" + f, n.append(p), l && Object.defineProperty(o, r, {
133
- set: (h) => {
134
- this.parent.propReferences[a] = h, h ? p.classList.add("p-gui__toggle-checkbox--active") : p.classList.remove("p-gui__toggle-checkbox--active"), typeof i == "function" && i(h);
164
+ let g = s ? o[n] ? " p-gui__toggle-checkbox--active" : "" : a ? " p-gui__toggle-checkbox--active" : "";
165
+ const f = document.createElement("div");
166
+ f.className = "p-gui__toggle-checkbox" + g, p.append(f), s && Object.defineProperty(o, n, {
167
+ set: (b) => {
168
+ this.parent.propReferences[u] = b, b ? f.classList.add(
169
+ "p-gui__toggle-checkbox--active"
170
+ ) : f.classList.remove(
171
+ "p-gui__toggle-checkbox--active"
172
+ ), typeof this.callback == "function" && this.callback(b);
135
173
  },
136
- get: () => this.parent.propReferences[a]
137
- }), n;
174
+ get: () => this.parent.propReferences[u]
175
+ });
176
+ }
177
+ onChange(t) {
178
+ return this.callback = t, this;
138
179
  }
139
180
  }
140
- class X {
141
- constructor(t, e = {}, i) {
142
- if (this.parent = t, typeof e != "object")
143
- throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);
144
- let s = typeof e.label == "string" ? e.label : " ", l = !1, a = null, o = e.obj, r = e.prop, d = Array.isArray(e.values) ? e.values : null, c, n = typeof d[0] != "string";
145
- const f = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null;
146
- if (i = typeof i == "function" ? i : null, e.value !== void 0 || e.value === void 0 && o === void 0 && r === void 0)
147
- (r != null || o != null) && console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'), c = (() => {
148
- if (!d)
149
- return null;
150
- if (typeof e.value == "string")
151
- return d.indexOf(e.value);
152
- if (typeof e.value == "number")
153
- return e.value;
154
- })();
155
- else if (r != null && o != null) {
156
- if (typeof r != "string")
157
- throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof r}.`);
158
- if (typeof o != "object")
159
- throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof o}.`);
160
- c = (() => {
161
- if (!d)
162
- return null;
163
- if (typeof o[r] == "string")
164
- return n ? d.find((u) => u.value === o[r]).value : d.indexOf(o[r]);
165
- if (typeof o[r] == "number")
166
- return n ? d.find((u) => u.value === o[r]).value : o[r];
167
- })(), a = this.parent.propReferences.push(o[r]) - 1, l = !0;
168
- } else
169
- (r != null && o == null || r == null && o == null) && console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');
170
- let p = document.createElement("div");
171
- p.className = "p-gui__list", p.textContent = s, f && p.setAttribute("title", f), this.parent.wrapper.append(p);
172
- let h = document.createElement("select");
173
- return p.append(h), h.className = "p-gui__list-dropdown", h.addEventListener("change", (u) => {
174
- l ? o[r] = u.target.value : i && i(u.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
175
- }), d && d.forEach((u, g) => {
176
- const b = n ? u.label : u, v = n ? u.value : u;
177
- let x = document.createElement("option");
178
- x.setAttribute("value", v), x.textContent = b, h.append(x), (!n && c == g || n && c == v) && x.setAttribute("selected", "");
179
- }), l && Object.defineProperty(o, r, {
180
- set: (u) => {
181
- let g, b, v;
182
- n ? (v = d.find((w) => w.value == u), b = v?.value || d[0].value, g = d.indexOf(v)) : (typeof u == "string" && (g = d.indexOf(u), b = u), typeof u == "number" && (g = u, b = d[u])), this.parent.propReferences[a] = n ? b : u;
183
- const x = h.querySelector("[selected]");
184
- x && x.removeAttribute("selected"), h.querySelectorAll("option")[g].setAttribute("selected", ""), typeof i == "function" && i(n ? v : b, g);
181
+ class V {
182
+ constructor(t, e, r, c) {
183
+ this.parent = t, this.callback = null;
184
+ let i = {}, a = null, s = !1, o, n;
185
+ if (e && typeof e == "object" && typeof r == "string")
186
+ o = e, n = r, s = !0, i = c || {};
187
+ else if (e && typeof e == "object")
188
+ s = !1, i = e;
189
+ else
190
+ throw Error("[GUI] list() invalid parameters.");
191
+ let l = typeof i.label == "string" ? i.label : " ", u = null, d = Array.isArray(i.values) ? i.values : null, p = d && d.length > 0 && typeof d[0] == "object";
192
+ const g = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
193
+ s ? (a = (() => {
194
+ if (!d)
195
+ return null;
196
+ if (typeof o[n] == "string")
197
+ return p ? d.find((h) => h.value === o[n]).value : d.indexOf(o[n]);
198
+ if (typeof o[n] == "number")
199
+ return p ? d.find((h) => h.value === o[n]).value : o[n];
200
+ })(), u = this.parent.propReferences.push(o[n]) - 1) : a = (() => {
201
+ if (!d)
202
+ return null;
203
+ if (typeof i.value == "string")
204
+ return d.indexOf(i.value);
205
+ if (typeof i.value == "number")
206
+ return i.value;
207
+ })();
208
+ let f = document.createElement("div");
209
+ f.className = "p-gui__list", f.textContent = l, g && f.setAttribute("title", g), this.parent.wrapper.append(f);
210
+ let b = document.createElement("select");
211
+ f.append(b), b.className = "p-gui__list-dropdown", b.addEventListener("change", (h) => {
212
+ s ? o[n] = h.target.value : this.callback && this.callback(h.target.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
213
+ }), d && d.forEach((h, _) => {
214
+ const y = p ? h.label : h, v = p ? h.value : h;
215
+ let w = document.createElement("option");
216
+ w.setAttribute("value", v), w.textContent = y, b.append(w), (!p && a == _ || p && a == v) && w.setAttribute("selected", "");
217
+ }), s && Object.defineProperty(o, n, {
218
+ set: (h) => {
219
+ let _, y, v;
220
+ p ? (v = d.find((C) => C.value == h), y = v?.value || d[0].value, _ = d.indexOf(v)) : (typeof h == "string" && (_ = d.indexOf(h), y = h), typeof h == "number" && (_ = h, y = d[h])), this.parent.propReferences[u] = p ? y : h;
221
+ const w = b.querySelector("[selected]");
222
+ w && w.removeAttribute("selected"), b.querySelectorAll("option")[_].setAttribute("selected", ""), typeof this.callback == "function" && (p ? this.callback(v, _) : this.callback(y, _));
185
223
  },
186
- get: () => this.parent.propReferences[a]
187
- }), p;
224
+ get: () => this.parent.propReferences[u]
225
+ });
226
+ }
227
+ onChange(t) {
228
+ return this.callback = t, this;
188
229
  }
189
230
  }
190
- class W {
191
- constructor(t, e = {}, i) {
192
- if (this.parent = t, typeof e != "object")
193
- throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);
194
- let s = typeof e.label == "string" && e.label || " ", l = !1, a = null, o = e.obj, r = e.prop, d;
195
- const c = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null;
196
- if (typeof e.value == "string" && (e.value.length != 7 || e.value[0] != "#" ? console.error(`[GUI] color() 'value' parameter must be an hexadecimal string in the format "#ffffff". Received: "${e.value}".`) : d = e.value), d || (d = "#000000"), e.value !== void 0)
197
- (r != null || o != null) && console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
198
- else if (r != null && o != null) {
199
- if (typeof r != "string")
200
- throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof r}.`);
201
- if (typeof o != "object")
202
- throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof o}.`);
203
- s == " " && (s = r), a = this.parent.propReferences.push(o[r]) - 1, l = !0;
204
- } else
205
- (r != null && o == null || r == null && o == null) && console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');
206
- const n = document.createElement("div");
207
- n.className = "p-gui__color", n.textContent = s, c && n.setAttribute("title", c), this.parent.wrapper.append(n);
208
- const f = document.createElement("input");
209
- return f.className = "p-gui__color-picker", f.setAttribute("type", "color"), f.value = d, n.append(f), typeof i == "function" && f.addEventListener("input", () => {
210
- l ? o[r] = f.value : typeof i == "function" && i(f.value), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
211
- }), l && Object.defineProperty(o, r, {
212
- set: (p) => {
213
- this.parent.propReferences[a] = p, f.value = p, typeof i == "function" && i(p);
231
+ class G {
232
+ constructor(t, e, r, c) {
233
+ this.parent = t, this.callback = null;
234
+ let i = {}, a = null, s = !1, o, n;
235
+ if (e && typeof e == "object" && typeof r == "string")
236
+ o = e, n = r, s = !0, i = c || {};
237
+ else if (e && typeof e == "object")
238
+ s = !1, i = e;
239
+ else
240
+ throw Error("[GUI] color() invalid parameters.");
241
+ let l = typeof i.label == "string" && i.label || " ", u = null;
242
+ const d = typeof i.tooltip == "string" ? i.tooltip : i.tooltip === !0 ? l : null;
243
+ s ? (l == " " && (l = n), u = this.parent.propReferences.push(o[n]) - 1, a = o[n] || "#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
+ ) : a = i.value), a || (a = "#000000"));
246
+ const p = document.createElement("div");
247
+ p.className = "p-gui__color", p.textContent = l, d && p.setAttribute("title", d), this.parent.wrapper.append(p);
248
+ const g = document.createElement("input");
249
+ g.className = "p-gui__color-picker", g.setAttribute("type", "color"), g.value = a, p.append(g), g.addEventListener("input", () => {
250
+ s ? o[n] = 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
+ }), s && Object.defineProperty(o, n, {
252
+ set: (f) => {
253
+ this.parent.propReferences[u] = f, g.value = f, typeof this.callback == "function" && this.callback(f);
214
254
  },
215
- get: () => this.parent.propReferences[a]
216
- }), n;
255
+ get: () => this.parent.propReferences[u]
256
+ });
257
+ }
258
+ onChange(t) {
259
+ return this.callback = t, this;
217
260
  }
218
261
  }
219
- class G {
220
- constructor(t, e = {}, i) {
221
- if (this.parent = t, typeof e != "object")
222
- throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
223
- let s = typeof e.label == "string" && e.label || " ";
224
- const l = e.x.min ?? 0, a = e.x.max ?? 1, o = e.y.min ?? 0, r = e.y.max ?? 1, d = e.x.step || (a - l) / 100, c = e.y.step || (r - o) / 100, n = this.parent._countDecimals(d), f = this.parent._countDecimals(c), p = e.x.obj, h = e.x.prop, u = this.parent.propReferences.push(p[h]) - 1, g = e.y.obj, b = e.y.prop, v = this.parent.propReferences.push(g[b]) - 1, x = typeof e.tooltip == "string" ? e.tooltip : e.tooltip === !0 ? s : null;
225
- i = typeof i == "function" ? i : null;
226
- const w = document.createElement("div");
227
- w.className = "p-gui__vector2", w.textContent = s, x && w.setAttribute("title", x), this.parent.wrapper.append(w);
228
- const A = document.createElement("div");
229
- A.className = "p-gui__vector-value", A.textContent = p[h] + ", " + g[b], w.append(A);
230
- const _ = document.createElement("div");
231
- _.className = "p-gui__vector2-area", w.append(_), _.addEventListener("click", (m) => {
232
- const U = parseFloat(this.parent._mapLinear(m.offsetX, 0, _.clientWidth, l, a)), I = parseFloat(this.parent._mapLinear(m.offsetY, 0, _.clientHeight, r, o));
233
- p[h] = U.toFixed(n), g[b] = I.toFixed(f), i && i(p[h], p[b]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
262
+ class T {
263
+ constructor(t, e, r, c, i) {
264
+ this.parent = t, this.callback = null;
265
+ let a = {}, s, o, n, l;
266
+ if (e && typeof e == "object" && typeof r == "string" && typeof c == "string")
267
+ s = e, o = e, n = r, l = c, a = i || {};
268
+ else if (e && typeof e == "object" && e.x && e.x.obj)
269
+ a = e, s = a.x.obj, n = a.x.prop, o = a.y.obj, l = a.y.prop;
270
+ else
271
+ throw Error(
272
+ "[GUI] vector2() invalid parameters. Use: gui.vector2(obj, 'propX', 'propY', params)"
273
+ );
274
+ let u = typeof a.label == "string" && a.label || " ";
275
+ u === " " && (u = n + " / " + l);
276
+ const d = a.x || {}, p = a.y || {}, g = d.min ?? a.min ?? 0, f = d.max ?? a.max ?? 1, b = p.min ?? a.min ?? 0, h = p.max ?? a.max ?? 1, _ = d.step || a.step || (f - g) / 100, y = p.step || a.step || (h - b) / 100, v = this.parent._countDecimals(_), w = this.parent._countDecimals(y), C = this.parent.propReferences.push(s[n]) - 1, D = this.parent.propReferences.push(o[l]) - 1, L = typeof a.tooltip == "string" ? a.tooltip : a.tooltip === !0 ? u : null, A = document.createElement("div");
277
+ A.className = "p-gui__vector2", A.textContent = u, L && A.setAttribute("title", L), this.parent.wrapper.append(A);
278
+ const E = document.createElement("div");
279
+ E.className = "p-gui__vector-value", E.textContent = s[n] + ", " + o[l], A.append(E);
280
+ const m = document.createElement("div");
281
+ m.className = "p-gui__vector2-area", A.append(m), m.addEventListener("click", (x) => {
282
+ const j = parseFloat(
283
+ this.parent._mapLinear(
284
+ x.offsetX,
285
+ 0,
286
+ m.clientWidth,
287
+ g,
288
+ f
289
+ )
290
+ ), R = parseFloat(
291
+ this.parent._mapLinear(
292
+ x.offsetY,
293
+ 0,
294
+ m.clientHeight,
295
+ h,
296
+ b
297
+ )
298
+ );
299
+ s[n] = j.toFixed(v), o[l] = R.toFixed(w), this.callback && this.callback(s[n], s[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
234
300
  });
235
- const j = (m) => {
236
- const U = _.getBoundingClientRect(), I = m.clientX - U.left, O = m.clientY - U.top, $ = this.parent._mapLinear(I, 0, _.clientWidth, l, a), D = this.parent._mapLinear(O, 0, _.clientHeight, r, o), L = Math.max(l, Math.min(a, $)), F = Math.max(o, Math.min(r, D));
237
- p[h] = parseFloat(L.toFixed(n)), g[b] = parseFloat(F.toFixed(f)), i && i(p[h], g[b]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
301
+ const P = (x) => {
302
+ const j = m.getBoundingClientRect(), R = x.clientX - j.left, N = x.clientY - j.top, H = this.parent._mapLinear(
303
+ R,
304
+ 0,
305
+ m.clientWidth,
306
+ g,
307
+ f
308
+ ), X = this.parent._mapLinear(
309
+ N,
310
+ 0,
311
+ m.clientHeight,
312
+ h,
313
+ b
314
+ ), S = Math.max(g, Math.min(f, H)), W = Math.max(b, Math.min(h, X));
315
+ s[n] = parseFloat(S.toFixed(v)), o[l] = parseFloat(W.toFixed(w)), this.callback && this.callback(s[n], o[l]), this.parent.onUpdate ? this.parent.onUpdate() : this.parent.isFolder && this.parent.firstParent.onUpdate && this.parent.firstParent.onUpdate();
238
316
  };
239
- _.addEventListener("pointerdown", (m) => {
240
- j(m), document.addEventListener("pointermove", j), document.addEventListener("pointerup", () => {
241
- document.removeEventListener("pointermove", j);
242
- }, { once: !0 });
317
+ m.addEventListener("pointerdown", (x) => {
318
+ P(x), document.addEventListener("pointermove", P), document.addEventListener(
319
+ "pointerup",
320
+ () => {
321
+ document.removeEventListener(
322
+ "pointermove",
323
+ P
324
+ );
325
+ },
326
+ { once: !0 }
327
+ );
243
328
  });
244
- const R = document.createElement("div");
245
- R.className = "p-gui__vector2-line p-gui__vector2-line-x", _.append(R);
246
- const P = document.createElement("div");
247
- P.className = "p-gui__vector2-line p-gui__vector2-line-y", _.append(P);
248
- const E = document.createElement("div");
249
- E.className = "p-gui__vector2-dot", _.append(E);
250
- const k = () => {
251
- E.style.left = this.parent._mapLinear(p[h], l, a, 0, _.clientWidth) + "px", E.style.top = this.parent._mapLinear(g[b], o, r, _.clientHeight, 0) + "px";
329
+ const F = document.createElement("div");
330
+ F.className = "p-gui__vector2-line p-gui__vector2-line-x", m.append(F);
331
+ const M = document.createElement("div");
332
+ M.className = "p-gui__vector2-line p-gui__vector2-line-y", m.append(M);
333
+ const U = document.createElement("div");
334
+ U.className = "p-gui__vector2-dot", m.append(U);
335
+ const I = () => {
336
+ U.style.left = this.parent._mapLinear(
337
+ s[n],
338
+ g,
339
+ f,
340
+ 0,
341
+ m.clientWidth
342
+ ) + "px", U.style.top = this.parent._mapLinear(
343
+ o[l],
344
+ b,
345
+ h,
346
+ m.clientHeight,
347
+ 0
348
+ ) + "px";
252
349
  };
253
- return k(), new ResizeObserver(() => {
254
- k();
255
- }).observe(_), Object.defineProperty(p, h, {
256
- set: (m) => {
257
- this.parent.propReferences[u] = m, k(), A.textContent = String(m) + ", " + g[b];
350
+ I(), new ResizeObserver(() => {
351
+ I();
352
+ }).observe(m), Object.defineProperty(s, n, {
353
+ set: (x) => {
354
+ this.parent.propReferences[C] = x, I(), E.textContent = String(x) + ", " + o[l];
258
355
  },
259
- get: () => this.parent.propReferences[u]
260
- }), Object.defineProperty(g, b, {
261
- set: (m) => {
262
- this.parent.propReferences[v] = m, k(), A.textContent = p[h] + ", " + String(m);
356
+ get: () => this.parent.propReferences[C]
357
+ }), Object.defineProperty(o, l, {
358
+ set: (x) => {
359
+ this.parent.propReferences[D] = x, I(), E.textContent = s[n] + ", " + String(x);
263
360
  },
264
- get: () => this.parent.propReferences[v]
265
- }), w;
361
+ get: () => this.parent.propReferences[D]
362
+ });
363
+ }
364
+ onChange(t) {
365
+ return this.callback = t, this;
266
366
  }
267
367
  }
268
- const Y = ".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}", z = ".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}", B = ".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}", V = ".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}", T = ".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}", Q = ".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}", q = '.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}', J = ".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)}";
269
- function Z(y) {
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)}";
369
+ function re(k) {
270
370
  return `
271
371
  .p-gui {
272
372
  --main-border-radius: 6px;
@@ -279,7 +379,7 @@ function Z(y) {
279
379
  --color-accent-hover: #dddddd;
280
380
  --transition: .1s linear;
281
381
 
282
- position: ${y};
382
+ position: ${k};
283
383
  top: 0;
284
384
  left: 0;
285
385
  transform: translate3d(0,0,0);
@@ -297,6 +397,7 @@ function Z(y) {
297
397
  border: 1px solid var(--color-border);
298
398
  line-height: normal;
299
399
  transition: var(--transition) opacity;
400
+ overflow: hidden;
300
401
  }
301
402
 
302
403
  .p-gui__content {
@@ -412,24 +513,24 @@ function Z(y) {
412
513
  border-color: rgba(255,255,255,.2);
413
514
  }
414
515
 
415
- ${Y}
516
+ ${Q}
416
517
 
417
- ${q}
518
+ ${te}
418
519
 
419
- ${B}
520
+ ${J}
420
521
 
421
- ${V}
522
+ ${Z}
422
523
 
423
- ${z}
524
+ ${q}
424
525
 
425
- ${T}
526
+ ${K}
426
527
 
427
- ${Q}
528
+ ${ee}
428
529
 
429
- ${J}
530
+ ${ie}
430
531
  `;
431
532
  }
432
- class C {
533
+ class O {
433
534
  constructor(t = {}) {
434
535
  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 = [], t.isFolder) {
435
536
  this._folderConstructor(t.folderOptions);
@@ -438,14 +539,14 @@ class C {
438
539
  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(
439
540
  this.container.clientHeight,
440
541
  window.innerHeight
441
- ), 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(`${Z(this.position_type)}`), this._styleInstance(), this._addWrapper(), this.wrapper.setAttribute("data-corner-x", this.screenCorner.x), this.wrapper.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(), this.closed = !1, t.closed && this.toggleClose();
542
+ ), 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(`${re(this.position_type)}`), this._styleInstance(), 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(), this.closed = !1, t.closed && this.toggleClose();
442
543
  }
443
544
  _styleInstance() {
444
545
  let t = this._getScrollbarWidth(this.container);
445
546
  if (this.screenCorner.x == "left" ? this.xOffset = 0 : this.xOffset = this.container.clientWidth - this.wrapperWidth - t, this.instanceId > 0) {
446
547
  let e = this.container.querySelectorAll(".p-gui");
447
- for (let i = 0; i < e.length; i++)
448
- this.screenCorner.y == e[i].dataset.cornerY && (this.screenCorner.x == "left" && e[i].dataset.cornerX == "left" ? this.xOffset += e[i].offsetWidth : this.screenCorner.x == "right" && e[i].dataset.cornerX == "right" && (this.xOffset -= e[i].offsetWidth));
548
+ for (let r = 0; r < e.length; r++)
549
+ 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));
449
550
  }
450
551
  this.yOffset = 0, this.position = {
451
552
  prevX: this.xOffset,
@@ -482,10 +583,10 @@ class C {
482
583
  let e = this.container.querySelectorAll(
483
584
  `.p-gui:not(#${this.domElement.id}):not([data-dragged])`
484
585
  );
485
- for (let i = 0; i < e.length && !(parseInt(
486
- e[i].id.replace("p-gui-", "")
487
- ) > this.instanceId); i++)
488
- this.screenCorner.y == e[i].dataset.cornerY && (this.screenCorner.x == "left" && e[i].dataset.cornerX == "left" ? this.xOffset += e[i].offsetWidth : this.screenCorner.x == "right" && e[i].dataset.cornerX == "right" && (this.xOffset -= e[i].offsetWidth));
586
+ for (let r = 0; r < e.length && !(parseInt(
587
+ e[r].id.replace("p-gui-", "")
588
+ ) > this.instanceId); r++)
589
+ 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));
489
590
  }
490
591
  this.position = {
491
592
  prevX: this.xOffset,
@@ -504,68 +605,66 @@ class C {
504
605
  const e = document.createElement("div");
505
606
  e.className = "p-gui__content", this.domElement.append(e), this.wrapper = document.createElement("div"), this.wrapper.className = "p-gui__inner", e.append(this.wrapper);
506
607
  }
507
- button(t = {}, e) {
508
- return this.imageContainer = null, new M(this, t, e);
608
+ button(t = {}) {
609
+ return this.imageContainer = null, new $(this, t);
509
610
  }
510
- image(t = {}, e) {
511
- return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new H(this, t, e);
611
+ image(t = {}) {
612
+ return this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer)), new z(this, t);
512
613
  }
513
- slider(t = {}, e) {
514
- return this.imageContainer = null, new N(this, t, e);
614
+ slider(t, e, r) {
615
+ return this.imageContainer = null, new Y(this, t, e, r);
515
616
  }
516
- toggle(t = {}, e) {
517
- this.imageContainer = null;
518
- const i = new S(this, t, e);
519
- return this.wrapper.append(i), i;
617
+ toggle(t, e, r) {
618
+ return this.imageContainer = null, new B(this, t, e, r);
520
619
  }
521
- list(t = {}, e) {
522
- return this.imageContainer = null, new X(this, t, e);
620
+ list(t, e, r) {
621
+ return this.imageContainer = null, new V(this, t, e, r);
523
622
  }
524
- color(t = {}, e) {
525
- return this.imageContainer = null, new W(this, t, e);
623
+ color(t, e, r) {
624
+ return this.imageContainer = null, new G(this, t, e, r);
526
625
  }
527
- vector2(t = {}, e) {
528
- return this.imageContainer = null, new G(this, t, e);
626
+ vector2(t, e, r, c) {
627
+ return this.imageContainer = null, new T(this, t, e, r, c);
529
628
  }
530
629
  folder(t = {}) {
531
- let e = typeof t.closed == "boolean" ? t.closed : !1, i = t.label || "", s = t.color || null, l = t.maxHeight || null;
630
+ let e = typeof t.closed == "boolean" ? t.closed : !1, r = t.label || "", c = t.color || null, i = t.maxHeight || null;
532
631
  this.imageContainer = null;
533
632
  let a = "p-gui__folder";
534
633
  this.folders.length == 0 && (a += " p-gui__folder--first"), e && (a += " p-gui__folder--closed");
535
- let o = s ? `background-color: ${s};` : "";
536
- o += l ? `max-height: ${l}px;` : "";
537
- const r = document.createElement("div");
538
- r.className = a, r.style = o, this.wrapper.append(r);
539
- const d = document.createElement("div");
540
- d.innerHTML = `<span class="p-gui__folder-arrow"></span>${i}`, d.className = "p-gui__folder-header", r.append(d);
541
- const c = document.createElement("div");
542
- c.className = "p-gui__folder-content", r.append(c);
634
+ let s = c ? `background-color: ${c};` : "";
635
+ s += i ? `max-height: ${i}px;` : "";
636
+ const o = document.createElement("div");
637
+ o.className = a, o.style = s, this.wrapper.append(o);
543
638
  const n = document.createElement("div");
544
- n.className = "p-gui__folder-inner", c.append(n), d.addEventListener("click", () => {
545
- r.classList.toggle("p-gui__folder--closed");
639
+ n.innerHTML = `<span class="p-gui__folder-arrow"></span>${r}`, n.className = "p-gui__folder-header", o.append(n);
640
+ const l = document.createElement("div");
641
+ l.className = "p-gui__folder-content", o.append(l);
642
+ const u = document.createElement("div");
643
+ u.className = "p-gui__folder-inner", l.append(u), n.addEventListener("click", () => {
644
+ o.classList.toggle("p-gui__folder--closed");
546
645
  });
547
- let f = new C({
646
+ let d = new O({
548
647
  isFolder: !0,
549
648
  folderOptions: {
550
- wrapper: r,
551
- inner: n,
649
+ wrapper: o,
650
+ inner: u,
552
651
  parent: this,
553
652
  firstParent: this.firstParent
554
653
  }
555
654
  });
556
- return this.folders.push(f), f;
655
+ return this.folders.push(d), d;
557
656
  }
558
657
  _makeDraggable() {
559
658
  var t = this;
560
- this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup", s);
561
- function e(l) {
562
- l.preventDefault(), t.position.initX = t.position.x, t.position.initY = t.position.y, t.position.prevX = l.clientX, t.position.prevY = l.clientY, document.addEventListener("pointermove", i);
659
+ this.header.addEventListener("pointerdown", e), this.header.addEventListener("pointerup", c);
660
+ function e(i) {
661
+ 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);
563
662
  }
564
- function i(l) {
565
- l.preventDefault(), t.hasBeenDragged || (t.hasBeenDragged = !0, t.domElement.setAttribute("data-dragged", "true")), t.position.x = t.position.initX + l.clientX - t.position.prevX, t.position.y = t.position.initY + l.clientY - t.position.prevY, t.domElement.style.transform = "translate3d(" + t.position.x + "px," + t.position.y + "px,0)";
663
+ function r(i) {
664
+ 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)";
566
665
  }
567
- function s(l) {
568
- document.removeEventListener("pointermove", i);
666
+ function c(i) {
667
+ document.removeEventListener("pointermove", r);
569
668
  }
570
669
  }
571
670
  toggleClose() {
@@ -574,18 +673,18 @@ class C {
574
673
  kill() {
575
674
  this.domElement.remove();
576
675
  }
577
- _mapLinear(t, e, i, s, l) {
578
- return s + (t - e) * (l - s) / (i - e);
676
+ _mapLinear(t, e, r, c, i) {
677
+ return c + (t - e) * (i - c) / (r - e);
579
678
  }
580
679
  _countDecimals(t) {
581
- const e = t.toString(), i = e.indexOf(".");
582
- return i === -1 ? 0 : e.length - i - 1;
680
+ const e = t.toString(), r = e.indexOf(".");
681
+ return r === -1 ? 0 : e.length - r - 1;
583
682
  }
584
683
  static registerPlugin(t) {
585
684
  for (let e in t)
586
- C.prototype[e] = t[e];
685
+ O.prototype[e] = t[e];
587
686
  }
588
687
  }
589
688
  export {
590
- C as default
689
+ O as default
591
690
  };