perfect-gui 4.9.9 → 4.11.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,200 +1,325 @@
1
- function A(y) {
2
- return (
3
- /* css */
4
- `
5
- .p-gui {
6
- --main-border-radius: 5px;
7
- --color-bg: #121212;
8
- --color-border: #484848;
9
- --color-border-2: rgba(255,255,255,.1);
10
- --color-accent: #1681ca;
11
- --color-accent-hover: #218fda;
12
-
13
- position: ${y};
14
- top: 0;
15
- left: 0;
16
- transform: translate3d(0,0,0);
17
- padding-top: 21px;
18
- background: var(--color-bg);
19
- display: flex;
20
- justify-content: center;
21
- flex-wrap: wrap;
22
- font-family: Verdana, Arial, sans-serif;
23
- width: 290px;
24
- overflow: auto;
25
- box-shadow: 0 0 2px black;
26
- box-sizing: border-box;
27
- z-index: 99999;
28
- user-select: none;
29
- border-bottom-right-radius: 3px;
30
- border-bottom-left-radius: 3px;
31
- cursor: auto;
32
- border-radius: var(--main-border-radius);
33
- border: 1px solid var(--color-border);
34
- line-height: normal;
35
- }
36
-
37
- .p-gui * {
38
- font-size: 11px;
39
- }
40
-
41
- .p-gui::-webkit-scrollbar,
42
- .p-gui *::-webkit-scrollbar {
43
- width: 10px;
44
- }
45
-
46
- .p-gui::-webkit-scrollbar-track,
47
- .p-gui *::-webkit-scrollbar-track {
48
- background: #2f2f2f;
49
- border-radius: 3px;
50
- }
51
-
52
- .p-gui::-webkit-scrollbar-thumb,
53
- .p-gui *::-webkit-scrollbar-thumb {
54
- background: #757576;
55
- border-radius: 10px;
56
- box-sizing: border-box;
57
- border: 1px solid #2f2f2f;
58
- }
59
-
60
- .p-gui--collapsed {
61
- height: 0;
62
- padding: 21px 10px 0 10px;
63
- overflow: hidden;
64
- }
65
-
66
- .p-gui__header {
67
- position: absolute;
68
- top: 0;
69
- left: 0;
70
- width: 100%;
71
- height: 20px;
72
- background-color: rgba(0, 0, 0, .8);
73
- cursor: grab;
74
- color: grey;
75
- font-size: 10px;
76
- line-height: 20px;
77
- padding-left: 12px;
78
- box-sizing: border-box;
79
- touch-action: none;
80
- }
81
-
82
- .p-gui__header-close {
83
- width: 20px;
84
- height: 20px;
85
- position: absolute;
86
- top: 0;
87
- right: 5px;
88
- cursor: pointer;
89
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
90
- background-size: 50% 50%;
91
- background-position: center;
92
- background-repeat: no-repeat;
93
- }
94
-
95
- .p-gui--collapsed .p-gui__header-close {
96
- background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
97
- }
98
-
99
- .p-gui__image-container {
100
- width: 100%;
101
- padding: 3px;
102
- display: flex;
103
- justify-content: flex-start;
104
- flex-wrap: wrap;
105
- }
106
-
107
- .p-gui__image {
108
- background-size: cover;
109
- cursor: pointer;
110
- position: relative;
111
- margin: 1px 2.5px 19px 2.5px;
112
- border-radius: var(--main-border-radius);
113
- flex: 0 0 calc(33.333% - 5px);
114
- height: 90px;
115
- background-position: center;
1
+ class A {
2
+ constructor(e = {}, t) {
3
+ if (this.propReferences = [], typeof e != "object")
4
+ throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
5
+ let o = typeof e.name == "string" && e.name || " ";
6
+ this.isObject = !1;
7
+ let a = null;
8
+ this.obj = e.obj, this.prop = e.prop;
9
+ let l = typeof e.value == "number" ? e.value : null;
10
+ if (this.min = e.min ?? 0, this.max = e.max ?? 1, this.step = e.step || (this.max - this.min) / 100, l !== null)
11
+ (this.prop != null || this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
12
+ else if (this.prop != null && this.obj != null) {
13
+ if (typeof this.prop != "string")
14
+ throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof this.prop}.`);
15
+ if (typeof this.obj != "object")
16
+ throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof this.obj}.`);
17
+ o == " " && (o = this.prop), a = this.propReferences.push(this.obj[this.prop]) - 1, this.isObject = !0;
18
+ } else
19
+ (this.prop != null && this.obj == null || this.prop == null && this.obj != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), l = (this.max - this.min) / 2;
20
+ this.imageContainer = null;
21
+ const i = document.createElement("div");
22
+ i.className = "p-gui__slider";
23
+ const r = document.createElement("div");
24
+ r.className = "p-gui__slider-name", r.textContent = o, i.append(r), 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), i.append(this.ctrlDiv);
25
+ const n = document.createElement("div");
26
+ return n.className = "p-gui__slider-bar", this.ctrlDiv.append(n), 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", n.append(this.filling), this.valueInput = document.createElement("input"), this.valueInput.className = "p-gui__slider-value", this.valueInput.value = this.isObject ? this.obj[this.prop] : l, i.append(this.valueInput), setTimeout(() => {
27
+ const s = this.handle.offsetWidth;
28
+ this.handle.position = this._mapLinear(this.valueInput.value, this.min, this.max, s / 2, 88 - s / 2), this.handle.style.transform = `translate(-50%, -50%) translateX(${this.handle.position}px)`, this.filling.style.width = `${this.handle.position}px`;
29
+ }, 0), this.valueInput.addEventListener("change", () => {
30
+ this._updateHandlePositionFromValue(), this._triggerCallbacks();
31
+ }), this.ctrlDiv.addEventListener("pointerdown", (s) => {
32
+ this.ctrlDiv.pointerDown = !0, this.ctrlDiv.prevPosition = s.clientX, this._updateHandlePositionFromPointer(s, !0);
33
+ }), window.addEventListener("pointerup", (s) => {
34
+ this.ctrlDiv.pointerDown = !1;
35
+ }), window.addEventListener("pointermove", (s) => {
36
+ this.ctrlDiv.pointerDown && (this.ctrlDiv.pointerDelta = s.clientX - this.ctrlDiv.prevPosition, this._updateHandlePositionFromPointer(s));
37
+ }), this.isObject && Object.defineProperty(this.obj, this.prop, {
38
+ set: (s) => {
39
+ this.propReferences[a] = s, this.valueInput.value = s, this._updateHandlePositionFromValue(), typeof t == "function" && t(parseFloat(this.valueInput.value));
40
+ },
41
+ get: () => this.propReferences[a]
42
+ }), i;
43
+ }
44
+ _updateHandlePositionFromPointer(e, t = !1) {
45
+ const o = this.ctrlDiv.offsetWidth, a = this.handle.offsetWidth, l = e.clientX - this.ctrlDiv.prevPosition;
46
+ let i;
47
+ const r = parseFloat(this.valueInput.value);
48
+ t ? i = e.offsetX : i = this.handle.position + l, i = Math.max(a / 2, Math.min(i, o - a / 2));
49
+ let n = this.min + (this.max - this.min) * (i - a / 2) / (o - a);
50
+ n > r ? n = this._quantizeFloor(n, this.step) : n = this._quantizeCeil(n, this.step), n = parseFloat(n.toFixed(9));
51
+ const s = parseFloat((r + this.step).toFixed(9)), d = parseFloat((r - this.step).toFixed(9));
52
+ if (n >= s || n <= d) {
53
+ const f = this._countDecimals(this.step);
54
+ n = n.toFixed(f), this.valueInput.value = n, this.ctrlDiv.prevPosition = e.clientX, this.handle.style.transform = `translate(-50%, -50%) translateX(${i}px)`, this.handle.position = i, this.filling.style.width = this.handle.position + "px", this._triggerCallbacks();
116
55
  }
56
+ }
57
+ _countDecimals(e) {
58
+ const t = e.toString(), o = t.indexOf(".");
59
+ return o === -1 ? 0 : t.length - o - 1;
60
+ }
61
+ _updateHandlePositionFromValue() {
62
+ const e = this.ctrlDiv.offsetWidth, t = this.handle.offsetWidth;
63
+ let o = this._mapLinear(this.valueInput.value, this.min, this.max, t / 2, e - t / 2);
64
+ o = Math.max(t / 2, Math.min(o, e - t / 2)), this.handle.style.transform = `translate(-50%, -50%) translateX(${o}px)`, this.handle.position = o, this.filling.style.width = this.handle.position + "px";
65
+ }
66
+ _triggerCallbacks() {
67
+ this.isObject ? this.obj[this.prop] = parseFloat(this.valueInput.value) : typeof callback == "function" && callback(parseFloat(this.valueInput.value)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
68
+ }
69
+ _mapLinear(e, t, o, a, l) {
70
+ return a + (e - t) * (l - a) / (o - t);
71
+ }
72
+ _quantize(e, t) {
73
+ return t * Math.round(e / t);
74
+ }
75
+ _quantizeCeil(e, t) {
76
+ return t * Math.ceil(e / t);
77
+ }
78
+ _quantizeFloor(e, t) {
79
+ return t * Math.floor(e / t);
80
+ }
81
+ }
82
+ const E = (
83
+ /* css */
84
+ `
85
+ .p-gui__button {
86
+ background: var(--color-accent);
87
+ text-align: center;
88
+ color: white;
89
+ border: none;
90
+ border: 1px solid transparent;
91
+ box-sizing: border-box;
92
+ transition: var(--transition) background, var(--transition) border-color;
93
+ }
117
94
 
118
- .p-gui__image--selected::after {
119
- position: absolute;
120
- top: 0;
121
- left: 0;
122
- width: 100%;
123
- height: 100%;
124
- content: '';
125
- border: 1px solid #06FF89;
126
- box-sizing: border-box;
127
- border-radius: var(--main-border-radius);
128
- }
129
-
130
- .p-gui__image-text {
131
- position: absolute;
132
- bottom: -15px;
133
- color: #eee;
134
- text-shadow: 0 -1px 0 #111;
135
- white-space: nowrap;
136
- width: 100%;
137
- overflow: hidden;
138
- text-overflow: ellipsis;
139
- }
140
-
141
- .p-gui__button,
142
- .p-gui__switch,
143
- .p-gui__list,
144
- .p-gui__vector2,
145
- .p-gui__color {
146
- width: 100%;
147
- padding: 7px 13px;
148
- color: white;
149
- cursor: pointer;
150
- position: relative;
151
- box-sizing: border-box;
152
- margin-bottom: 3px;
153
- margin: 3px;
154
-
155
- border: 1px solid var(--color-border-2);
156
- border-radius: var(--main-border-radius);
157
- }
95
+ .p-gui__button:hover {
96
+ background: var(--color-accent-hover);
97
+ color: var(--color-text-light);
98
+ border-color: rgba(255, 255, 255, 0.2);
99
+ }
158
100
 
159
- .p-gui__vector2 {
160
- padding: 7px;
161
- }
162
-
163
- .p-gui__button,
164
- .p-gui__switch {
165
- margin-right: 4px;
166
- margin-left: 4px;
167
- }
168
-
169
- .p-gui__button {
170
- background: var(--color-accent);
171
- text-align: center;
172
- color: white;
173
- border: none;
174
- }
175
-
176
- .p-gui__button:hover {
177
- background: var(--color-accent-hover);
178
- }
179
-
180
- .p-gui__switch {
181
- background: rgba(255, 255, 255, .05);
182
- }
101
+ .p-gui__folder .p-gui__button {
102
+ margin-inline: 0;
103
+ }
104
+ `
105
+ ), U = (
106
+ /* css */
107
+ `
108
+ .p-gui__slider {
109
+ position: relative;
110
+ min-height: 14px;
111
+ display: flex;
112
+ align-items: center;
113
+ justify-content: space-between;
114
+ gap: 10px;
115
+ color: var(--color-text-dark);
116
+ transition: color var(--transition);
117
+ }
183
118
 
184
- .p-gui__switch:hover {
185
- background: rgba(255, 255, 255, .1);
186
- }
187
-
188
- .p-gui__folder .p-gui__button,
189
- .p-gui__folder .p-gui__switch {
190
- margin-right: 0;
191
- margin-left: 0;
192
- }
193
-
119
+ .p-gui__slider:hover {
120
+ color: var(--color-text-light);
121
+ }
122
+
123
+ .p-gui__slider-name {
124
+ width: 50%;
125
+ text-overflow: ellipsis;
126
+ overflow: hidden;
127
+ }
128
+
129
+ .p-gui__slider-ctrl {
130
+ -webkit-appearance: none;
131
+ padding: 0;
132
+ font: inherit;
133
+ outline: none;
134
+ box-sizing: border-box;
135
+ cursor: pointer;
136
+ position: relative;
137
+ right: 0;
138
+ height: 14px;
139
+ margin: 0 0 0 auto;
140
+ width: 37%;
141
+ }
142
+
143
+ .p-gui__slider-bar {
144
+ position: absolute;
145
+ top: 50%;
146
+ left: 0;
147
+ height: 2px;
148
+ background: rgba(255, 255, 255, .2);
149
+ width: 100%;
150
+ transform: translateY(-50%);
151
+ }
152
+
153
+ .p-gui__slider-filling {
154
+ position: absolute;
155
+ top: -25%;
156
+ left: 0;
157
+ height: 150%;
158
+ background: var(--color-accent);
159
+ width: 0;
160
+ }
161
+
162
+ .p-gui__slider:hover .p-gui__slider-filling {
163
+ background: var(--color-accent-hover);
164
+ }
165
+
166
+ .p-gui__slider-handle {
167
+ width: 15px;
168
+ height: 8px;
169
+ position: absolute;
170
+ top: 50%;
171
+ left: 0;
172
+ border-radius: 2px;
173
+ transform: translate(-50%, -50%);
174
+ pointer-events: none;
175
+ background: var(--color-text-dark);
176
+ box-shadow: 0 0 2px rgba(0, 0, 0, .5);
177
+ }
178
+
179
+ .p-gui__slider:hover .p-gui__slider-handle {
180
+ background: var(--color-text-light);
181
+ }
182
+
183
+ .p-gui__slider-value {
184
+ display: inline-block;
185
+ right: 7px;
186
+ width: 13%;
187
+ border: none;
188
+ color: white;
189
+ border-radius: 2px;
190
+ background: rgba(255, 255, 255, 0.1);
191
+ padding: 2px 4px;
192
+ color: inherit;
193
+ }
194
+
195
+ .p-gui__slider-value:focus {
196
+ outline: none;
197
+ }
198
+ `
199
+ ), j = (
200
+ /* css */
201
+ `
202
+ .p-gui__list {
203
+ cursor: default;
204
+ color: var(--color-text-dark);
205
+ transition: var(--transition) color;
206
+ }
207
+
208
+ .p-gui__list:hover {
209
+ color: var(--color-text-light);
210
+ }
211
+
212
+ .p-gui__list-dropdown {
213
+ background: rgba(255, 255, 255,.05);
214
+ color: white;
215
+ padding: 0 12px 0 5px;
216
+ top: 0px;
217
+ }
218
+
219
+ .p-gui__list-dropdown {
220
+ position: absolute;
221
+ right: 5px;
222
+ top: 0;
223
+ bottom: 0;
224
+ margin: auto;
225
+ height: 21px;
226
+ cursor: pointer;
227
+ border-radius: 3px;
228
+ border: 1px solid var(--color-border-2);
229
+ outline: none;
230
+ }
231
+
232
+ .p-gui__list-dropdown:hover {
233
+ background: rgba(255, 255, 255, .1);
234
+ }
235
+ `
236
+ ), k = (
237
+ /* css */
238
+ `
239
+ .p-gui__switch {
240
+ background: rgba(255, 255, 255, .05);
241
+ color: var(--color-text-dark);
242
+ transition: var(--transition) background, var(--transition) color;
243
+ }
244
+
245
+ .p-gui__switch:hover {
246
+ background: rgba(255, 255, 255, .1);
247
+ color: var(--color-text-light);
248
+ }
249
+
250
+ .p-gui__folder .p-gui__switch {
251
+ margin-inline: 0;
252
+ }
253
+
254
+ .p-gui__switch-checkbox {
255
+ width: 5px;
256
+ height: 5px;
257
+ background-color: rgba(0, 0, 0, .5);
258
+ border: 1px solid grey;
259
+ position: absolute;
260
+ top: 0;
261
+ right: 10px;
262
+ bottom: 0;
263
+ margin: auto;
264
+ border-radius: 50%;
265
+ pointer-events: none;
266
+ }
267
+
268
+ .p-gui__switch-checkbox--active {
269
+ background-color: #00ff89;
270
+ box-shadow: 0 0 7px #00ff89;
271
+ }
272
+ `
273
+ ), I = (
274
+ /* css */
275
+ `
276
+ .p-gui__color {
277
+ cursor: default;
278
+ color: var(--color-text-dark);
279
+ transition: var(--transition) color;
280
+ }
281
+
282
+ .p-gui__color:hover {
283
+ color: var(--color-text-light);
284
+ }
285
+
286
+ .p-gui__color-picker {
287
+ position: absolute;
288
+ right: 5px;
289
+ top: 0;
290
+ bottom: 0;
291
+ margin: auto;
292
+ height: 21px;
293
+ cursor: pointer;
294
+ border-radius: 3px;
295
+ border: 1px solid var(--color-border-2);
296
+ outline: none;
297
+ -webkit-appearance: none;
298
+ padding: 0;
299
+ background-color: transparent;
300
+ border: 1px solid #222222;
301
+ overflow: hidden;
302
+ }
303
+
304
+ .p-gui__color-picker::-webkit-color-swatch-wrapper {
305
+ padding: 0;
306
+ }
307
+ .p-gui__color-picker::-webkit-color-swatch {
308
+ border: none;
309
+ }
310
+ `
311
+ ), C = (
312
+ /* css */
313
+ `
194
314
  .p-gui__vector2 {
195
315
  background: transparent;
196
316
  aspect-ratio: 1;
197
317
  padding-bottom: 0;
318
+ color: var(--color-text-dark);
319
+ }
320
+
321
+ .p-gui__vector2:hover {
322
+ color: var(--color-text-light);
198
323
  }
199
324
 
200
325
  .p-gui__vector2-area {
@@ -242,125 +367,71 @@ function A(y) {
242
367
  pointer-events: none;
243
368
  }
244
369
 
245
- .p-gui__switch-checkbox {
246
- width: 5px;
247
- height: 5px;
248
- background-color: rgba(0, 0, 0, .5);
249
- border: 1px solid grey;
370
+ .p-gui__vector-value {
371
+ display: inline-block;
372
+ right: 7px;
250
373
  position: absolute;
251
- top: 0;
252
- right: 10px;
253
- bottom: 0;
254
- margin: auto;
255
- border-radius: 50%;
256
- pointer-events: none;
257
- }
258
-
259
- .p-gui__switch-checkbox--active {
260
- background-color: #00ff89;
261
- box-shadow: 0 0 7px #00ff89;
262
374
  }
263
-
264
- .p-gui__list,
265
- .p-gui__color {
266
- cursor: default;
375
+ `
376
+ ), R = (
377
+ /* css */
378
+ `
379
+ .p-gui__image-container {
380
+ width: 100%;
381
+ padding: 3px;
382
+ display: flex;
383
+ justify-content: flex-start;
384
+ flex-wrap: wrap;
385
+ box-sizing: border-box;
267
386
  }
268
387
 
269
- .p-gui__list-dropdown,
270
- .p-gui__color-picker {
271
- position: absolute;
272
- right: 5px;
273
- top: 0;
274
- bottom: 0;
275
- margin: auto;
276
- height: 21px;
388
+ .p-gui__image {
389
+ background-size: cover;
277
390
  cursor: pointer;
278
- border-radius: 3px;
279
- border: 1px solid var(--color-border-2);
280
- outline: none;
281
- }
282
-
283
- .p-gui__list-dropdown {
284
- background: rgba(255, 255, 255,.05);
285
- color: white;
286
- padding: 0 12px;
287
- top: 0px;
288
- }
289
-
290
- .p-gui__list-dropdown:hover {
291
- background: rgba(255, 255, 255, .1);
292
- }
293
-
294
- .p-gui__color-picker {
295
- -webkit-appearance: none;
296
- padding: 0;
297
- background-color: transparent;
298
- border: 1px solid #222222;
299
- overflow: hidden;
300
- }
301
-
302
- .p-gui__color-picker::-webkit-color-swatch-wrapper {
303
- padding: 0;
304
- }
305
- .p-gui__color-picker::-webkit-color-swatch {
306
- border: none;
307
- }
308
-
309
- .p-gui__slider {
310
- box-sizing: border-box;
311
- width: calc(100% - 10px);
312
- margin: 0 auto 10px auto;
313
- padding: 7px 0;
314
- color: white;
315
391
  position: relative;
316
- min-height: 14px;
392
+ margin: 1px 2.5px 19px 2.5px;
393
+ border-radius: var(--main-border-radius);
394
+ flex: 0 0 calc(33.333% - 5px);
395
+ height: 90px;
396
+ background-position: center;
397
+ color: var(--color-text-dark);
398
+ transition: var(--transition) color;
317
399
  }
318
-
319
- .p-gui__slider-ctrl {
320
- -webkit-appearance: none;
321
- padding: 0;
322
- font: inherit;
323
- outline: none;
324
- opacity: .8;
325
- background: var(--color-accent);
326
- box-sizing: border-box;
327
- cursor: pointer;
400
+
401
+ .p-gui__image:hover {
402
+ color: var(--color-text-light);
403
+ }
404
+
405
+ .p-gui__image::after {
328
406
  position: absolute;
329
- bottom: -4px; /* 5px height -1px de dépassement du curseur */
330
- right: 0;
331
- height: 5px;
407
+ top: 0;
408
+ left: 0;
332
409
  width: 100%;
333
- margin: 0;
410
+ height: 100%;
411
+ content: '';
412
+ border: 1px solid transparent;
413
+ box-sizing: border-box;
334
414
  border-radius: var(--main-border-radius);
415
+ transition: var(--transition) border-color;
335
416
  }
336
-
337
- /* la zone de déplacement */
338
- .p-gui__slider-ctrl::-webkit-slider-runnable-track {
339
- height: 13px;
340
- border: none;
341
- border-radius: 0;
342
- background-color: transparent; /* supprimé définie sur l'input */
343
- }
344
-
345
- /* Curseur */
346
- .p-gui__slider-ctrl::-webkit-slider-thumb {
347
- -webkit-appearance: none; /* également nécessaire sur le curseur */
348
- width: 15px;
349
- height: 7px;
350
- border: none; /* pris en compte sur Webkit et Edge */
351
- background: white; /* pris en compte sur Webkit only */
352
- position: relative;
353
- top: 3px;
354
- border-radius: 1px;
417
+ .p-gui__image--selected::after {
418
+ border-color: #06FF89;
355
419
  }
356
420
 
357
- .p-gui__slider-value,
358
- .p-gui__vector-value {
359
- display: inline-block;
421
+ .p-gui__image-text {
360
422
  position: absolute;
361
- right: 7px;
423
+ bottom: -15px;
424
+ text-shadow: 0 -1px 0 #111;
425
+ white-space: nowrap;
426
+ width: 100%;
427
+ overflow: hidden;
428
+ text-overflow: ellipsis;
429
+
362
430
  }
363
-
431
+ `
432
+ ), P = (
433
+ /* css */
434
+ `
364
435
  .p-gui__folder {
365
436
  width: 100%;
366
437
  position: relative;
@@ -372,6 +443,7 @@ function A(y) {
372
443
  border: 1px solid grey;
373
444
  padding: 0 3px 3px 3px;
374
445
  border-radius: var(--main-border-radius);
446
+ box-sizing: border-box;
375
447
  }
376
448
 
377
449
  .p-gui__folder:last-of-type {
@@ -414,16 +486,166 @@ function A(y) {
414
486
  .p-gui__folder--closed .p-gui__folder-arrow {
415
487
  transform: rotate(0deg);
416
488
  }
489
+ `
490
+ );
491
+ function F(v) {
492
+ return (
493
+ /* css */
417
494
  `
495
+ .p-gui {
496
+ --main-border-radius: 5px;
497
+ --color-bg: #121212;
498
+ --color-border: #484848;
499
+ --color-border-2: rgba(255,255,255,.1);
500
+ --color-text-light: #ffffff;
501
+ --color-text-dark: #bbbbbb;
502
+ --color-accent: #1681ca;
503
+ --color-accent-hover: #218fda;
504
+ --transition: .1s linear;
505
+
506
+ position: ${v};
507
+ top: 0;
508
+ left: 0;
509
+ transform: translate3d(0,0,0);
510
+ padding-top: 21px;
511
+ padding-inline: 3px;
512
+ background: var(--color-bg);
513
+ display: block;
514
+ justify-content: center;
515
+ flex-wrap: wrap;
516
+ font-family: "Arial Rounded MT Bold", Arial, sans-serif;
517
+ width: 290px;
518
+ overflow: auto;
519
+ box-shadow: 0 0 2px black;
520
+ box-sizing: border-box;
521
+ z-index: 99999;
522
+ user-select: none;
523
+ border-bottom-right-radius: 3px;
524
+ border-bottom-left-radius: 3px;
525
+ cursor: auto;
526
+ border-radius: var(--main-border-radius);
527
+ border: 1px solid var(--color-border);
528
+ line-height: normal;
529
+ transition: var(--transition) opacity;
530
+ }
531
+
532
+ .p-gui:hover {
533
+ opacity: 1!important;
534
+ }
535
+
536
+ .p-gui * {
537
+ font-size: 11px;
538
+ }
539
+
540
+ .p-gui::-webkit-scrollbar,
541
+ .p-gui *::-webkit-scrollbar {
542
+ width: 10px;
543
+ }
544
+
545
+ .p-gui::-webkit-scrollbar-track,
546
+ .p-gui *::-webkit-scrollbar-track {
547
+ background: #2f2f2f;
548
+ border-radius: 3px;
549
+ }
550
+
551
+ .p-gui::-webkit-scrollbar-thumb,
552
+ .p-gui *::-webkit-scrollbar-thumb {
553
+ background: #757576;
554
+ border-radius: 10px;
555
+ box-sizing: border-box;
556
+ border: 1px solid #2f2f2f;
557
+ }
558
+
559
+ .p-gui--collapsed {
560
+ height: 0;
561
+ padding: 21px 10px 0 10px;
562
+ overflow: hidden;
563
+ }
564
+
565
+ .p-gui__header {
566
+ position: absolute;
567
+ top: 0;
568
+ left: 0;
569
+ width: 100%;
570
+ height: 20px;
571
+ background-color: rgba(0, 0, 0, .8);
572
+ cursor: grab;
573
+ color: grey;
574
+ font-size: 10px;
575
+ line-height: 20px;
576
+ padding-left: 12px;
577
+ box-sizing: border-box;
578
+ touch-action: none;
579
+ }
580
+
581
+ .p-gui__header-close {
582
+ width: 20px;
583
+ height: 20px;
584
+ position: absolute;
585
+ top: 0;
586
+ right: 5px;
587
+ cursor: pointer;
588
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABFJREFUCNdjIAb8//8BjIkAAOrOBd3TR0jRAAAAAElFTkSuQmCC);
589
+ background-size: 50% 50%;
590
+ background-position: center;
591
+ background-repeat: no-repeat;
592
+ }
593
+
594
+ .p-gui--collapsed .p-gui__header-close {
595
+ background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABQAAAAUAQMAAAC3R49OAAAABlBMVEUAAAD///+l2Z/dAAAAAXRSTlMAQObYZgAAABVJREFUCNdjYEhgIIj///8AwsSoBQD43QydY5mb0QAAAABJRU5ErkJggg==);
596
+ }
597
+
598
+ .p-gui__slider,
599
+ .p-gui__button,
600
+ .p-gui__switch,
601
+ .p-gui__list,
602
+ .p-gui__vector2,
603
+ .p-gui__color {
604
+ width: 100%;
605
+ padding: 7px;
606
+ cursor: pointer;
607
+ position: relative;
608
+ box-sizing: border-box;
609
+ margin-block: 3px;
610
+ border: 1px solid var(--color-border-2);
611
+ border-radius: var(--main-border-radius);
612
+ transition: var(--transition) border-color;
613
+ }
614
+
615
+ .p-gui__slider:hover,
616
+ .p-gui__button:hover,
617
+ .p-gui__switch:hover,
618
+ .p-gui__list:hover,
619
+ .p-gui__vector2:hover,
620
+ .p-gui__color:hover {
621
+ border-color: rgba(255,255,255,.2);
622
+ }
623
+
624
+ ${E}
625
+
626
+ ${R}
627
+
628
+ ${j}
629
+
630
+ ${k}
631
+
632
+ ${U}
633
+
634
+ ${I}
635
+
636
+ ${C}
637
+
638
+ ${P}
639
+ `
418
640
  );
419
641
  }
420
- class v {
642
+ class y {
421
643
  constructor(e = {}) {
422
644
  if (this.firstParent = this, e.container ? (this.container = typeof e.container == "string" ? document.querySelector(e.container) : e.container, this.position_type = "absolute") : (this.container = document.body, this.position_type = "fixed"), this.propReferences = [], this.folders = [], e.isFolder) {
423
645
  this._folderConstructor(e.folderOptions);
424
646
  return;
425
647
  }
426
- typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = e.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(`${A(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), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
648
+ typeof e.onUpdate == "function" && (this.onUpdate = e.onUpdate), this.name = e != null && typeof e.name == "string" ? e.name : "", this.backgroundColor = e.color || null, this.opacity = e.opacity || 1, this.container == document.body ? this.maxHeight = window.innerHeight : this.maxHeight = Math.min(this.container.clientHeight, window.innerHeight), e.maxHeight && (this.initMaxHeight = e.maxHeight, this.maxHeight = Math.min(this.initMaxHeight, this.maxHeight)), this.screenCorner = this._parseScreenCorner(e.position), window.perfectGUI || (window.perfectGUI = {}), window.perfectGUI.instanceCounter == null ? window.perfectGUI.instanceCounter = 0 : window.perfectGUI.instanceCounter++, this.instanceId = window.perfectGUI.instanceCounter, this.wrapperWidth = e.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(`${F(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), e.autoRepositioning != !1 && window.addEventListener("resize", this._handleResize.bind(this)), this._handleResize(), this.hasBeenDragged = !1, e.draggable == !0 && this._makeDraggable(), this.closed = !1, e.closed && this.toggleClose();
427
649
  }
428
650
  _styleInstance() {
429
651
  let e = this._getScrollbarWidth(this.container);
@@ -443,6 +665,7 @@ class v {
443
665
  transform: translate3d(${this.xOffset}px,${this.yOffset}px,0);
444
666
  ${this.screenCorner.y == "top" ? "" : "top: auto; bottom: 0;"}
445
667
  ${this.backgroundColor ? "background: " + this.backgroundColor + ";" : ""}
668
+ opacity: ${this.opacity};
446
669
  }`);
447
670
  }
448
671
  _folderConstructor(e) {
@@ -490,86 +713,94 @@ class v {
490
713
  o = e.path;
491
714
  else
492
715
  throw typeof e.path == null ? Error("[GUI] image() path must be provided.") : Error("[GUI] image() path must be a string.");
493
- let a = o.replace(/^.*[\\\/]/, ""), p;
494
- e.name == null ? p = a : p = typeof e.name == "string" && e.name || " ";
495
- const r = e.selected === !0, i = e.selectionBorder !== !1;
716
+ let a = o.replace(/^.*[\\\/]/, ""), l;
717
+ e.name == null ? l = a : l = typeof e.name == "string" && e.name || " ";
718
+ const i = e.selected === !0, r = e.selectionBorder !== !1;
496
719
  let n = "";
497
720
  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}; `), this.imageContainer || (this.imageContainer = document.createElement("div"), this.imageContainer.className = "p-gui__image-container", this.wrapper.append(this.imageContainer));
498
721
  const s = document.createElement("div");
499
- s.className = "p-gui__image", s.style = "background-image: url(" + o + "); " + n, this.imageContainer.append(s), r && i && s.classList.add("p-gui__image--selected");
500
- const l = document.createElement("div");
501
- return l.className = "p-gui__image-text", l.textContent = p, s.append(l), s.addEventListener("click", () => {
502
- let h = s.parentElement.querySelectorAll(".p-gui__image--selected");
503
- for (let c = 0; c < h.length; c++)
504
- h[c].classList.remove("p-gui__image--selected");
505
- i && s.classList.add("p-gui__image--selected"), typeof t == "function" && t({ path: o, text: p }), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
722
+ s.className = "p-gui__image", s.style = "background-image: url(" + o + "); " + n, this.imageContainer.append(s), i && r && s.classList.add("p-gui__image--selected");
723
+ const d = document.createElement("div");
724
+ return d.className = "p-gui__image-text", d.textContent = l, s.append(d), s.addEventListener("click", () => {
725
+ let f = s.parentElement.querySelectorAll(".p-gui__image--selected");
726
+ for (let c = 0; c < f.length; c++)
727
+ f[c].classList.remove("p-gui__image--selected");
728
+ r && s.classList.add("p-gui__image--selected"), typeof t == "function" && t({ path: o, text: l }), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
506
729
  }), s;
507
730
  }
508
731
  slider(e = {}, t) {
732
+ const o = new A(e, t);
733
+ this.wrapper.append(o);
734
+ }
735
+ sliderOld(e = {}, t) {
509
736
  if (typeof e != "object")
510
737
  throw Error(`[GUI] slider() first parameter must be an object. Received: ${typeof e}.`);
511
- let o = typeof e.name == "string" && e.name || " ", a = !1, p = null, r = e.obj, i = e.prop, n = typeof e.value == "number" ? e.value : null, s = e.min ?? 0, l = e.max ?? 1, h = e.step || (l - s) / 100;
738
+ let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n = typeof e.value == "number" ? e.value : null, s = e.min ?? 0, d = e.max ?? 1, f = e.step || (d - s) / 100;
512
739
  if (n !== null)
513
- (i != null || r != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
514
- else if (i != null && r != null) {
515
- if (typeof i != "string")
516
- throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof i}.`);
517
- if (typeof r != "object")
518
- throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof r}.`);
519
- o == " " && (o = i), p = this.propReferences.push(r[i]) - 1, a = !0;
740
+ (r != null || i != null) && console.warn('[GUI] slider() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
741
+ else if (r != null && i != null) {
742
+ if (typeof r != "string")
743
+ throw Error(`[GUI] slider() "prop" parameter must be an string. Received: ${typeof r}.`);
744
+ if (typeof i != "object")
745
+ throw Error(`[GUI] slider() "obj" parameter must be an object. Received: ${typeof i}.`);
746
+ o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
520
747
  } else
521
- (i != null && r == null || i == null && r != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), n = (l - s) / 2;
748
+ (r != null && i == null || r == null && i != null) && console.warn('[GUI] slider() "obj" and "prop" parameters must be used together.'), n = (d - s) / 2;
522
749
  this.imageContainer = null;
523
750
  const c = document.createElement("div");
524
- c.className = "p-gui__slider", c.textContent = o, this.wrapper.append(c);
525
- const d = document.createElement("input");
526
- d.className = "p-gui__slider-ctrl", d.setAttribute("type", "range"), d.setAttribute("min", s), d.setAttribute("max", l), d.setAttribute("step", h), d.setAttribute("value", a ? r[i] : n), c.append(d);
527
- const f = document.createElement("div");
528
- f.className = "p-gui__slider-value", f.textContent = String(a ? r[i] : n), c.append(f), d.addEventListener("input", () => {
529
- f.textContent = d.value, a ? r[i] = parseFloat(d.value) : typeof t == "function" && t(parseFloat(d.value)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
530
- }), a && Object.defineProperty(r, i, {
531
- set: (g) => {
532
- this.propReferences[p] = g, d.value = g, f.textContent = String(g), typeof t == "function" && t(parseFloat(d.value));
751
+ c.className = "p-gui__slider", this.wrapper.append(c);
752
+ const u = document.createElement("div");
753
+ u.className = "p-gui__slider-name", u.textContent = o, c.append(u);
754
+ const p = document.createElement("input");
755
+ p.className = "p-gui__slider-ctrl", p.setAttribute("type", "range"), p.setAttribute("min", s), p.setAttribute("max", d), p.setAttribute("step", f), p.setAttribute("value", a ? i[r] : n), c.append(p);
756
+ const g = document.createElement("input");
757
+ g.className = "p-gui__slider-value", g.value = String(a ? i[r] : n), c.append(g), g.addEventListener("change", () => {
758
+ p.value = parseFloat(g.value);
759
+ }), p.addEventListener("input", () => {
760
+ g.value = p.value, a ? i[r] = parseFloat(p.value) : typeof t == "function" && t(parseFloat(p.value)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
761
+ }), a && Object.defineProperty(i, r, {
762
+ set: (h) => {
763
+ this.propReferences[l] = h, p.value = h, g.textContent = String(h), typeof t == "function" && t(parseFloat(p.value));
533
764
  },
534
- get: () => this.propReferences[p]
765
+ get: () => this.propReferences[l]
535
766
  });
536
767
  }
537
768
  toggle(e = {}, t) {
538
769
  if (typeof e != "object")
539
770
  throw Error(`[GUI] toggle() first parameter must be an object. Received: ${typeof e}.`);
540
- let o = typeof e.name == "string" && e.name || " ", a = !1, p = null, r = e.obj, i = e.prop, n = typeof e.value == "boolean" ? e.value : null;
771
+ let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n = typeof e.value == "boolean" ? e.value : null;
541
772
  if (n !== null)
542
- (i != null || r != null) && console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
543
- else if (i != null && r != null) {
544
- if (typeof i != "string")
545
- throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof i}.`);
546
- if (typeof r != "object")
547
- throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof r}.`);
548
- o == " " && (o = i), p = this.propReferences.push(r[i]) - 1, a = !0;
773
+ (r != null || i != null) && console.warn('[GUI] toggle() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
774
+ else if (r != null && i != null) {
775
+ if (typeof r != "string")
776
+ throw Error(`[GUI] toggle() "prop" parameter must be an string. Received: ${typeof r}.`);
777
+ if (typeof i != "object")
778
+ throw Error(`[GUI] toggle() "obj" parameter must be an object. Received: ${typeof i}.`);
779
+ o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
549
780
  } else
550
- (i != null && r == null || i == null && r == null) && console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');
781
+ (r != null && i == null || r == null && i == null) && console.warn('[GUI] toggle() "obj" and "prop" parameters must be used together.');
551
782
  this.imageContainer = null;
552
783
  const s = document.createElement("div");
553
784
  s.textContent = o, s.className = "p-gui__switch", this.wrapper.append(s), s.addEventListener("click", (c) => {
554
- const d = c.target.childNodes[1];
555
- let f = !0;
556
- d.classList.contains("p-gui__switch-checkbox--active") && (f = !1), d.classList.toggle("p-gui__switch-checkbox--active"), a ? r[i] = f : typeof t == "function" && t(f), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
785
+ const u = c.target.childNodes[1];
786
+ let p = !0;
787
+ u.classList.contains("p-gui__switch-checkbox--active") && (p = !1), u.classList.toggle("p-gui__switch-checkbox--active"), a ? i[r] = p : typeof t == "function" && t(p), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
557
788
  });
558
- let l = (() => a ? r[i] ? " p-gui__switch-checkbox--active" : "" : n ? " p-gui__switch-checkbox--active" : "")();
559
- const h = document.createElement("div");
560
- h.className = "p-gui__switch-checkbox" + l, s.append(h), a && Object.defineProperty(r, i, {
789
+ let d = (() => a ? i[r] ? " p-gui__switch-checkbox--active" : "" : n ? " p-gui__switch-checkbox--active" : "")();
790
+ const f = document.createElement("div");
791
+ f.className = "p-gui__switch-checkbox" + d, s.append(f), a && Object.defineProperty(i, r, {
561
792
  set: (c) => {
562
- this.propReferences[p] = c, c ? h.classList.add("p-gui__switch-checkbox--active") : h.classList.remove("p-gui__switch-checkbox--active"), typeof t == "function" && t(c);
793
+ this.propReferences[l] = c, c ? f.classList.add("p-gui__switch-checkbox--active") : f.classList.remove("p-gui__switch-checkbox--active"), typeof t == "function" && t(c);
563
794
  },
564
- get: () => this.propReferences[p]
795
+ get: () => this.propReferences[l]
565
796
  });
566
797
  }
567
798
  list(e = {}, t) {
568
799
  if (typeof e != "object")
569
800
  throw Error(`[GUI] list() first parameter must be an object. Received: ${typeof e}.`);
570
- let o = typeof e.name == "string" ? e.name : " ", a = !1, p = null, r = e.obj, i = e.prop, n = Array.isArray(e.values) ? e.values : null, s, l = typeof n[0] != "string";
571
- if (t = typeof t == "function" ? t : null, e.value !== void 0 || e.value === void 0 && r === void 0 && i === void 0)
572
- (i != null || r != null) && console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'), s = (() => {
801
+ let o = typeof e.name == "string" ? e.name : " ", a = !1, l = null, i = e.obj, r = e.prop, n = Array.isArray(e.values) ? e.values : null, s, d = typeof n[0] != "string";
802
+ if (t = typeof t == "function" ? t : null, e.value !== void 0 || e.value === void 0 && i === void 0 && r === void 0)
803
+ (r != null || i != null) && console.warn('[GUI] list() "obj" and "prop" parameters are ignored when a "value" parameter is used.'), s = (() => {
573
804
  if (!n)
574
805
  return null;
575
806
  if (typeof e.value == "string")
@@ -577,137 +808,137 @@ class v {
577
808
  if (typeof e.value == "number")
578
809
  return e.value;
579
810
  })();
580
- else if (i != null && r != null) {
581
- if (typeof i != "string")
582
- throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof i}.`);
583
- if (typeof r != "object")
584
- throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof r}.`);
811
+ else if (r != null && i != null) {
812
+ if (typeof r != "string")
813
+ throw Error(`[GUI] list() "prop" parameter must be an string. Received: ${typeof r}.`);
814
+ if (typeof i != "object")
815
+ throw Error(`[GUI] list() "obj" parameter must be an object. Received: ${typeof i}.`);
585
816
  s = (() => {
586
817
  if (!n)
587
818
  return null;
588
- if (typeof r[i] == "string")
589
- return l ? n.find((d) => d.value === r[i]).value : n.indexOf(r[i]);
590
- if (typeof r[i] == "number")
591
- return l ? n.find((d) => d.value === r[i]).value : r[i];
592
- })(), p = this.propReferences.push(r[i]) - 1, a = !0;
819
+ if (typeof i[r] == "string")
820
+ return d ? n.find((u) => u.value === i[r]).value : n.indexOf(i[r]);
821
+ if (typeof i[r] == "number")
822
+ return d ? n.find((u) => u.value === i[r]).value : i[r];
823
+ })(), l = this.propReferences.push(i[r]) - 1, a = !0;
593
824
  } else
594
- (i != null && r == null || i == null && r == null) && console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');
825
+ (r != null && i == null || r == null && i == null) && console.warn('[GUI] list() "obj" and "prop" parameters must be used together.');
595
826
  this.imageContainer = null;
596
- let h = document.createElement("div");
597
- h.className = "p-gui__list", h.textContent = o, this.wrapper.append(h);
827
+ let f = document.createElement("div");
828
+ f.className = "p-gui__list", f.textContent = o, this.wrapper.append(f);
598
829
  let c = document.createElement("select");
599
- h.append(c), c.className = "p-gui__list-dropdown", c.addEventListener("change", (d) => {
600
- a ? r[i] = d.target.value : t && t(d.target.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
601
- }), n && n.forEach((d, f) => {
602
- const g = l ? d.name : d, u = l ? d.value : d;
830
+ f.append(c), c.className = "p-gui__list-dropdown", c.addEventListener("change", (u) => {
831
+ a ? i[r] = u.target.value : t && t(u.target.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
832
+ }), n && n.forEach((u, p) => {
833
+ const g = d ? u.name : u, h = d ? u.value : u;
603
834
  let m = document.createElement("option");
604
- m.setAttribute("value", u), m.textContent = g, c.append(m), (!l && s == f || l && s == u) && m.setAttribute("selected", "");
605
- }), a && Object.defineProperty(r, i, {
606
- set: (d) => {
607
- let f, g, u;
608
- l ? (u = n.find((_) => _.value == d), g = (u == null ? void 0 : u.value) || n[0].value, f = n.indexOf(u)) : (typeof d == "string" && (f = n.indexOf(d), g = d), typeof d == "number" && (f = d, g = n[d])), this.propReferences[p] = l ? g : d;
835
+ m.setAttribute("value", h), m.textContent = g, c.append(m), (!d && s == p || d && s == h) && m.setAttribute("selected", "");
836
+ }), a && Object.defineProperty(i, r, {
837
+ set: (u) => {
838
+ let p, g, h;
839
+ d ? (h = n.find((x) => x.value == u), g = (h == null ? void 0 : h.value) || n[0].value, p = n.indexOf(h)) : (typeof u == "string" && (p = n.indexOf(u), g = u), typeof u == "number" && (p = u, g = n[u])), this.propReferences[l] = d ? g : u;
609
840
  const m = c.querySelector("[selected]");
610
- m && m.removeAttribute("selected"), c.querySelectorAll("option")[f].setAttribute("selected", ""), typeof t == "function" && t(l ? u : g, f);
841
+ m && m.removeAttribute("selected"), c.querySelectorAll("option")[p].setAttribute("selected", ""), typeof t == "function" && t(d ? h : g, p);
611
842
  },
612
- get: () => this.propReferences[p]
843
+ get: () => this.propReferences[l]
613
844
  });
614
845
  }
615
846
  vector2(e = {}, t) {
616
847
  if (typeof e != "object")
617
848
  throw Error(`[GUI] vector2() first parameter must be an object. Received: ${typeof e}.`);
618
849
  let o = typeof e.name == "string" && e.name || " ";
619
- const a = e.x.min ?? 0, p = e.x.max ?? 1, r = e.y.min ?? 0, i = e.y.max ?? 1, n = e.x.obj, s = e.x.prop, l = this.propReferences.push(n[s]) - 1, h = e.y.obj, c = e.y.prop, d = this.propReferences.push(h[c]) - 1;
850
+ const a = e.x.min ?? 0, l = e.x.max ?? 1, i = e.y.min ?? 0, r = e.y.max ?? 1, n = e.x.obj, s = e.x.prop, d = this.propReferences.push(n[s]) - 1, f = e.y.obj, c = e.y.prop, u = this.propReferences.push(f[c]) - 1;
620
851
  t = typeof t == "function" ? t : null, this.imageContainer = null;
621
- const f = document.createElement("div");
622
- f.className = "p-gui__vector2", f.textContent = o, this.wrapper.append(f);
852
+ const p = document.createElement("div");
853
+ p.className = "p-gui__vector2", p.textContent = o, this.wrapper.append(p);
623
854
  const g = document.createElement("div");
624
- g.className = "p-gui__vector-value", g.textContent = n[s] + ", " + h[c], f.append(g);
625
- const u = document.createElement("div");
626
- u.className = "p-gui__vector2-area", f.append(u), u.addEventListener("click", (b) => {
627
- n[s] = parseFloat(this._mapLinear(b.offsetX, 0, u.clientWidth, a, p).toFixed(2)), h[c] = parseFloat(this._mapLinear(b.offsetY, 0, u.clientHeight, i, r).toFixed(2)), t && t(n[s], n[c]), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
855
+ g.className = "p-gui__vector-value", g.textContent = n[s] + ", " + f[c], p.append(g);
856
+ const h = document.createElement("div");
857
+ h.className = "p-gui__vector2-area", p.append(h), h.addEventListener("click", (b) => {
858
+ n[s] = parseFloat(this._mapLinear(b.offsetX, 0, h.clientWidth, a, l).toFixed(2)), f[c] = parseFloat(this._mapLinear(b.offsetY, 0, h.clientHeight, r, i).toFixed(2)), t && t(n[s], n[c]), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
628
859
  });
629
860
  let m = !1;
630
- u.addEventListener("pointerdown", (b) => {
861
+ h.addEventListener("pointerdown", (b) => {
631
862
  m = !0;
632
- }), u.addEventListener("pointerup", () => {
863
+ }), h.addEventListener("pointerup", () => {
633
864
  m = !1;
634
- }), u.addEventListener("pointermove", (b) => {
635
- m && (n[s] = parseFloat(this._mapLinear(b.offsetX, 0, u.clientWidth, a, p).toFixed(2)), h[c] = parseFloat(this._mapLinear(b.offsetY, 0, u.clientHeight, i, r).toFixed(2)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate(), t && t(n[s], n[c]));
865
+ }), h.addEventListener("pointermove", (b) => {
866
+ m && (n[s] = parseFloat(this._mapLinear(b.offsetX, 0, h.clientWidth, a, l).toFixed(2)), f[c] = parseFloat(this._mapLinear(b.offsetY, 0, h.clientHeight, r, i).toFixed(2)), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate(), t && t(n[s], n[c]));
636
867
  });
637
- const _ = document.createElement("div");
638
- _.className = "p-gui__vector2-line p-gui__vector2-line-x", u.append(_);
639
- const w = document.createElement("div");
640
- w.className = "p-gui__vector2-line p-gui__vector2-line-y", u.append(w);
641
868
  const x = document.createElement("div");
642
- x.className = "p-gui__vector2-dot", u.append(x), x.style.left = this._mapLinear(n[s], a, p, 0, u.clientWidth) + "px", x.style.top = this._mapLinear(h[c], r, i, u.clientHeight, 0) + "px", Object.defineProperty(n, s, {
869
+ x.className = "p-gui__vector2-line p-gui__vector2-line-x", h.append(x);
870
+ const w = document.createElement("div");
871
+ w.className = "p-gui__vector2-line p-gui__vector2-line-y", h.append(w);
872
+ const _ = document.createElement("div");
873
+ _.className = "p-gui__vector2-dot", h.append(_), _.style.left = this._mapLinear(n[s], a, l, 0, h.clientWidth) + "px", _.style.top = this._mapLinear(f[c], i, r, h.clientHeight, 0) + "px", Object.defineProperty(n, s, {
643
874
  set: (b) => {
644
- this.propReferences[l] = b, x.style.left = this._mapLinear(b, a, p, 0, u.clientWidth) + "px", g.textContent = String(b) + ", " + h[c];
875
+ this.propReferences[d] = b, _.style.left = this._mapLinear(b, a, l, 0, h.clientWidth) + "px", g.textContent = String(b) + ", " + f[c];
645
876
  },
646
- get: () => this.propReferences[l]
647
- }), Object.defineProperty(h, c, {
877
+ get: () => this.propReferences[d]
878
+ }), Object.defineProperty(f, c, {
648
879
  set: (b) => {
649
- this.propReferences[d] = b, x.style.top = this._mapLinear(b, r, i, u.clientHeight, 0) + "px", g.textContent = n[s] + ", " + String(b);
880
+ this.propReferences[u] = b, _.style.top = this._mapLinear(b, i, r, h.clientHeight, 0) + "px", g.textContent = n[s] + ", " + String(b);
650
881
  },
651
- get: () => this.propReferences[d]
882
+ get: () => this.propReferences[u]
652
883
  });
653
884
  }
654
885
  color(e = {}, t) {
655
886
  if (typeof e != "object")
656
887
  throw Error(`[GUI] color() first parameter must be an object. Received: ${typeof e}.`);
657
- let o = typeof e.name == "string" && e.name || " ", a = !1, p = null, r = e.obj, i = e.prop, n;
888
+ let o = typeof e.name == "string" && e.name || " ", a = !1, l = null, i = e.obj, r = e.prop, n;
658
889
  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}".`) : n = e.value), n || (n = "#000000"), e.value !== void 0)
659
- (i != null || r != null) && console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
660
- else if (i != null && r != null) {
661
- if (typeof i != "string")
662
- throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof i}.`);
663
- if (typeof r != "object")
664
- throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof r}.`);
665
- o == " " && (o = i), p = this.propReferences.push(r[i]) - 1, a = !0;
890
+ (r != null || i != null) && console.warn('[GUI] color() "obj" and "prop" parameters are ignored when a "value" parameter is used.');
891
+ else if (r != null && i != null) {
892
+ if (typeof r != "string")
893
+ throw Error(`[GUI] color() "prop" parameter must be an string. Received: ${typeof r}.`);
894
+ if (typeof i != "object")
895
+ throw Error(`[GUI] color() "obj" parameter must be an object. Received: ${typeof i}.`);
896
+ o == " " && (o = r), l = this.propReferences.push(i[r]) - 1, a = !0;
666
897
  } else
667
- (i != null && r == null || i == null && r == null) && console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');
898
+ (r != null && i == null || r == null && i == null) && console.warn('[GUI] color() "obj" and "prop" parameters must be used together.');
668
899
  this.imageContainer = null;
669
900
  const s = document.createElement("div");
670
901
  s.className = "p-gui__color", s.textContent = o, this.wrapper.append(s);
671
- const l = document.createElement("input");
672
- l.className = "p-gui__color-picker", l.setAttribute("type", "color"), l.value = n, s.append(l), typeof t == "function" && l.addEventListener("input", () => {
673
- a ? r[i] = l.value : typeof t == "function" && t(l.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
674
- }), a && Object.defineProperty(r, i, {
675
- set: (h) => {
676
- this.propReferences[p] = h, l.value = h, typeof t == "function" && t(h);
902
+ const d = document.createElement("input");
903
+ d.className = "p-gui__color-picker", d.setAttribute("type", "color"), d.value = n, s.append(d), typeof t == "function" && d.addEventListener("input", () => {
904
+ a ? i[r] = d.value : typeof t == "function" && t(d.value), this.onUpdate ? this.onUpdate() : this.isFolder && this.firstParent.onUpdate && this.firstParent.onUpdate();
905
+ }), a && Object.defineProperty(i, r, {
906
+ set: (f) => {
907
+ this.propReferences[l] = f, d.value = f, typeof t == "function" && t(f);
677
908
  },
678
- get: () => this.propReferences[p]
909
+ get: () => this.propReferences[l]
679
910
  });
680
911
  }
681
912
  folder(e = {}) {
682
- let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null, p = e.maxHeight || null;
913
+ let t = typeof e.closed == "boolean" ? e.closed : !1, o = e.name || "", a = e.color || null, l = e.maxHeight || null;
683
914
  this.imageContainer = null;
684
- let r = "p-gui__folder";
685
- this.folders.length == 0 && (r += " p-gui__folder--first"), t && (r += " p-gui__folder--closed");
686
- let i = a ? `background-color: ${a};` : "";
687
- i += p ? `max-height: ${p}px;` : "";
915
+ let i = "p-gui__folder";
916
+ this.folders.length == 0 && (i += " p-gui__folder--first"), t && (i += " p-gui__folder--closed");
917
+ let r = a ? `background-color: ${a};` : "";
918
+ r += l ? `max-height: ${l}px;` : "";
688
919
  const n = document.createElement("div");
689
- n.className = r, n.style = i, this.wrapper.append(n);
920
+ n.className = i, n.style = r, this.wrapper.append(n);
690
921
  const s = document.createElement("div");
691
922
  s.innerHTML = `<span class="p-gui__folder-arrow"></span>${o}`, s.className = "p-gui__folder-header", n.append(s), s.addEventListener("click", () => {
692
923
  n.classList.toggle("p-gui__folder--closed");
693
924
  });
694
- let l = new v({ isFolder: !0, folderOptions: {
925
+ let d = new y({ isFolder: !0, folderOptions: {
695
926
  wrapper: n,
696
927
  parent: this,
697
928
  firstParent: this.firstParent
698
929
  } });
699
- return this.folders.push(l), l;
930
+ return this.folders.push(d), d;
700
931
  }
701
932
  _makeDraggable() {
702
933
  var e = this;
703
934
  this.header.addEventListener("pointerdown", t), this.header.addEventListener("pointerup", a);
704
- function t(p) {
705
- p.preventDefault(), e.position.initX = e.position.x, e.position.initY = e.position.y, e.position.prevX = p.clientX, e.position.prevY = p.clientY, document.addEventListener("pointermove", o);
935
+ function t(l) {
936
+ l.preventDefault(), e.position.initX = e.position.x, e.position.initY = e.position.y, e.position.prevX = l.clientX, e.position.prevY = l.clientY, document.addEventListener("pointermove", o);
706
937
  }
707
- function o(p) {
708
- p.preventDefault(), e.hasBeenDragged || (e.hasBeenDragged = !0, e.wrapper.setAttribute("data-dragged", "true")), e.position.x = e.position.initX + p.clientX - e.position.prevX, e.position.y = e.position.initY + p.clientY - e.position.prevY, e.wrapper.style.transform = "translate3d(" + e.position.x + "px," + e.position.y + "px,0)";
938
+ function o(l) {
939
+ l.preventDefault(), e.hasBeenDragged || (e.hasBeenDragged = !0, e.wrapper.setAttribute("data-dragged", "true")), e.position.x = e.position.initX + l.clientX - e.position.prevX, e.position.y = e.position.initY + l.clientY - e.position.prevY, e.wrapper.style.transform = "translate3d(" + e.position.x + "px," + e.position.y + "px,0)";
709
940
  }
710
- function a(p) {
941
+ function a(l) {
711
942
  document.removeEventListener("pointermove", o);
712
943
  }
713
944
  }
@@ -717,10 +948,10 @@ class v {
717
948
  kill() {
718
949
  this.wrapper.remove();
719
950
  }
720
- _mapLinear(e, t, o, a, p) {
721
- return a + (e - t) * (p - a) / (o - t);
951
+ _mapLinear(e, t, o, a, l) {
952
+ return a + (e - t) * (l - a) / (o - t);
722
953
  }
723
954
  }
724
955
  export {
725
- v as default
956
+ y as default
726
957
  };