bridgeapp-ai-chat-widget 0.2.14 → 0.2.16

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.
@@ -0,0 +1,1263 @@
1
+ class u {
2
+ constructor(t, i, e, n, a = "div") {
3
+ this.parent = t, this.object = i, this.property = e, this._disabled = !1, this._hidden = !1, this.initialValue = this.getValue(), this.domElement = document.createElement(a), this.domElement.classList.add("lil-controller"), this.domElement.classList.add(n), this.$name = document.createElement("div"), this.$name.classList.add("lil-name"), u.nextNameID = u.nextNameID || 0, this.$name.id = `lil-gui-name-${++u.nextNameID}`, this.$widget = document.createElement("div"), this.$widget.classList.add("lil-widget"), this.$disable = this.$widget, this.domElement.appendChild(this.$name), this.domElement.appendChild(this.$widget), this.domElement.addEventListener("keydown", (o) => o.stopPropagation()), this.domElement.addEventListener("keyup", (o) => o.stopPropagation()), this.parent.children.push(this), this.parent.controllers.push(this), this.parent.$children.appendChild(this.domElement), this._listenCallback = this._listenCallback.bind(this), this.name(e);
4
+ }
5
+ /**
6
+ * Sets the name of the controller and its label in the GUI.
7
+ * @param {string} name
8
+ * @returns {this}
9
+ */
10
+ name(t) {
11
+ return this._name = t, this.$name.textContent = t, this;
12
+ }
13
+ /**
14
+ * Pass a function to be called whenever the value is modified by this controller.
15
+ * The function receives the new value as its first parameter. The value of `this` will be the
16
+ * controller.
17
+ *
18
+ * For function controllers, the `onChange` callback will be fired on click, after the function
19
+ * executes.
20
+ * @param {Function} callback
21
+ * @returns {this}
22
+ * @example
23
+ * const controller = gui.add( object, 'property' );
24
+ *
25
+ * controller.onChange( function( v ) {
26
+ * console.log( 'The value is now ' + v );
27
+ * console.assert( this === controller );
28
+ * } );
29
+ */
30
+ onChange(t) {
31
+ return this._onChange = t, this;
32
+ }
33
+ /**
34
+ * Calls the onChange methods of this controller and its parent GUI.
35
+ * @protected
36
+ */
37
+ _callOnChange() {
38
+ this.parent._callOnChange(this), this._onChange !== void 0 && this._onChange.call(this, this.getValue()), this._changed = !0;
39
+ }
40
+ /**
41
+ * Pass a function to be called after this controller has been modified and loses focus.
42
+ * @param {Function} callback
43
+ * @returns {this}
44
+ * @example
45
+ * const controller = gui.add( object, 'property' );
46
+ *
47
+ * controller.onFinishChange( function( v ) {
48
+ * console.log( 'Changes complete: ' + v );
49
+ * console.assert( this === controller );
50
+ * } );
51
+ */
52
+ onFinishChange(t) {
53
+ return this._onFinishChange = t, this;
54
+ }
55
+ /**
56
+ * Should be called by Controller when its widgets lose focus.
57
+ * @protected
58
+ */
59
+ _callOnFinishChange() {
60
+ this._changed && (this.parent._callOnFinishChange(this), this._onFinishChange !== void 0 && this._onFinishChange.call(this, this.getValue())), this._changed = !1;
61
+ }
62
+ /**
63
+ * Sets the controller back to its initial value.
64
+ * @returns {this}
65
+ */
66
+ reset() {
67
+ return this.setValue(this.initialValue), this._callOnFinishChange(), this;
68
+ }
69
+ /**
70
+ * Enables this controller.
71
+ * @param {boolean} enabled
72
+ * @returns {this}
73
+ * @example
74
+ * controller.enable();
75
+ * controller.enable( false ); // disable
76
+ * controller.enable( controller._disabled ); // toggle
77
+ */
78
+ enable(t = !0) {
79
+ return this.disable(!t);
80
+ }
81
+ /**
82
+ * Disables this controller.
83
+ * @param {boolean} disabled
84
+ * @returns {this}
85
+ * @example
86
+ * controller.disable();
87
+ * controller.disable( false ); // enable
88
+ * controller.disable( !controller._disabled ); // toggle
89
+ */
90
+ disable(t = !0) {
91
+ return t === this._disabled ? this : (this._disabled = t, this.domElement.classList.toggle("lil-disabled", t), this.$disable.toggleAttribute("disabled", t), this);
92
+ }
93
+ /**
94
+ * Shows the Controller after it's been hidden.
95
+ * @param {boolean} show
96
+ * @returns {this}
97
+ * @example
98
+ * controller.show();
99
+ * controller.show( false ); // hide
100
+ * controller.show( controller._hidden ); // toggle
101
+ */
102
+ show(t = !0) {
103
+ return this._hidden = !t, this.domElement.style.display = this._hidden ? "none" : "", this;
104
+ }
105
+ /**
106
+ * Hides the Controller.
107
+ * @returns {this}
108
+ */
109
+ hide() {
110
+ return this.show(!1);
111
+ }
112
+ /**
113
+ * Changes this controller into a dropdown of options.
114
+ *
115
+ * Calling this method on an option controller will simply update the options. However, if this
116
+ * controller was not already an option controller, old references to this controller are
117
+ * destroyed, and a new controller is added to the end of the GUI.
118
+ * @example
119
+ * // safe usage
120
+ *
121
+ * gui.add( obj, 'prop1' ).options( [ 'a', 'b', 'c' ] );
122
+ * gui.add( obj, 'prop2' ).options( { Big: 10, Small: 1 } );
123
+ * gui.add( obj, 'prop3' );
124
+ *
125
+ * // danger
126
+ *
127
+ * const ctrl1 = gui.add( obj, 'prop1' );
128
+ * gui.add( obj, 'prop2' );
129
+ *
130
+ * // calling options out of order adds a new controller to the end...
131
+ * const ctrl2 = ctrl1.options( [ 'a', 'b', 'c' ] );
132
+ *
133
+ * // ...and ctrl1 now references a controller that doesn't exist
134
+ * assert( ctrl2 !== ctrl1 )
135
+ * @param {object|Array} options
136
+ * @returns {Controller}
137
+ */
138
+ options(t) {
139
+ const i = this.parent.add(this.object, this.property, t);
140
+ return i.name(this._name), this.destroy(), i;
141
+ }
142
+ /**
143
+ * Sets the minimum value. Only works on number controllers.
144
+ * @param {number} min
145
+ * @returns {this}
146
+ */
147
+ min(t) {
148
+ return this;
149
+ }
150
+ /**
151
+ * Sets the maximum value. Only works on number controllers.
152
+ * @param {number} max
153
+ * @returns {this}
154
+ */
155
+ max(t) {
156
+ return this;
157
+ }
158
+ /**
159
+ * Values set by this controller will be rounded to multiples of `step`. Only works on number
160
+ * controllers.
161
+ * @param {number} step
162
+ * @returns {this}
163
+ */
164
+ step(t) {
165
+ return this;
166
+ }
167
+ /**
168
+ * Rounds the displayed value to a fixed number of decimals, without affecting the actual value
169
+ * like `step()`. Only works on number controllers.
170
+ * @example
171
+ * gui.add( object, 'property' ).listen().decimals( 4 );
172
+ * @param {number} decimals
173
+ * @returns {this}
174
+ */
175
+ decimals(t) {
176
+ return this;
177
+ }
178
+ /**
179
+ * Calls `updateDisplay()` every animation frame. Pass `false` to stop listening.
180
+ * @param {boolean} listen
181
+ * @returns {this}
182
+ */
183
+ listen(t = !0) {
184
+ return this._listening = t, this._listenCallbackID !== void 0 && (cancelAnimationFrame(this._listenCallbackID), this._listenCallbackID = void 0), this._listening && this._listenCallback(), this;
185
+ }
186
+ _listenCallback() {
187
+ this._listenCallbackID = requestAnimationFrame(this._listenCallback);
188
+ const t = this.save();
189
+ t !== this._listenPrevValue && this.updateDisplay(), this._listenPrevValue = t;
190
+ }
191
+ /**
192
+ * Returns `object[ property ]`.
193
+ * @returns {any}
194
+ */
195
+ getValue() {
196
+ return this.object[this.property];
197
+ }
198
+ /**
199
+ * Sets the value of `object[ property ]`, invokes any `onChange` handlers and updates the display.
200
+ * @param {any} value
201
+ * @returns {this}
202
+ */
203
+ setValue(t) {
204
+ return this.getValue() !== t && (this.object[this.property] = t, this._callOnChange(), this.updateDisplay()), this;
205
+ }
206
+ /**
207
+ * Updates the display to keep it in sync with the current value. Useful for updating your
208
+ * controllers when their values have been modified outside of the GUI.
209
+ * @returns {this}
210
+ */
211
+ updateDisplay() {
212
+ return this;
213
+ }
214
+ load(t) {
215
+ return this.setValue(t), this._callOnFinishChange(), this;
216
+ }
217
+ save() {
218
+ return this.getValue();
219
+ }
220
+ /**
221
+ * Destroys this controller and removes it from the parent GUI.
222
+ */
223
+ destroy() {
224
+ this.listen(!1), this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.controllers.splice(this.parent.controllers.indexOf(this), 1), this.parent.$children.removeChild(this.domElement);
225
+ }
226
+ }
227
+ class L extends u {
228
+ constructor(t, i, e) {
229
+ super(t, i, e, "lil-boolean", "label"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "checkbox"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$widget.appendChild(this.$input), this.$input.addEventListener("change", () => {
230
+ this.setValue(this.$input.checked), this._callOnFinishChange();
231
+ }), this.$disable = this.$input, this.updateDisplay();
232
+ }
233
+ updateDisplay() {
234
+ return this.$input.checked = this.getValue(), this;
235
+ }
236
+ }
237
+ function E(s) {
238
+ let t, i;
239
+ return (t = s.match(/(#|0x)?([a-f0-9]{6})/i)) ? i = t[2] : (t = s.match(/rgb\(\s*(\d*)\s*,\s*(\d*)\s*,\s*(\d*)\s*\)/)) ? i = parseInt(t[1]).toString(16).padStart(2, 0) + parseInt(t[2]).toString(16).padStart(2, 0) + parseInt(t[3]).toString(16).padStart(2, 0) : (t = s.match(/^#?([a-f0-9])([a-f0-9])([a-f0-9])$/i)) && (i = t[1] + t[1] + t[2] + t[2] + t[3] + t[3]), i ? "#" + i : !1;
240
+ }
241
+ const F = {
242
+ isPrimitive: !0,
243
+ match: (s) => typeof s == "string",
244
+ fromHexString: E,
245
+ toHexString: E
246
+ }, b = {
247
+ isPrimitive: !0,
248
+ match: (s) => typeof s == "number",
249
+ fromHexString: (s) => parseInt(s.substring(1), 16),
250
+ toHexString: (s) => "#" + s.toString(16).padStart(6, 0)
251
+ }, S = {
252
+ isPrimitive: !1,
253
+ match: (s) => Array.isArray(s) || ArrayBuffer.isView(s),
254
+ fromHexString(s, t, i = 1) {
255
+ const e = b.fromHexString(s);
256
+ t[0] = (e >> 16 & 255) / 255 * i, t[1] = (e >> 8 & 255) / 255 * i, t[2] = (e & 255) / 255 * i;
257
+ },
258
+ toHexString([s, t, i], e = 1) {
259
+ e = 255 / e;
260
+ const n = s * e << 16 ^ t * e << 8 ^ i * e << 0;
261
+ return b.toHexString(n);
262
+ }
263
+ }, V = {
264
+ isPrimitive: !1,
265
+ match: (s) => Object(s) === s,
266
+ fromHexString(s, t, i = 1) {
267
+ const e = b.fromHexString(s);
268
+ t.r = (e >> 16 & 255) / 255 * i, t.g = (e >> 8 & 255) / 255 * i, t.b = (e & 255) / 255 * i;
269
+ },
270
+ toHexString({ r: s, g: t, b: i }, e = 1) {
271
+ e = 255 / e;
272
+ const n = s * e << 16 ^ t * e << 8 ^ i * e << 0;
273
+ return b.toHexString(n);
274
+ }
275
+ }, D = [F, b, S, V];
276
+ function M(s) {
277
+ return D.find((t) => t.match(s));
278
+ }
279
+ class O extends u {
280
+ constructor(t, i, e, n) {
281
+ super(t, i, e, "lil-color"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "color"), this.$input.setAttribute("tabindex", -1), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$text = document.createElement("input"), this.$text.setAttribute("type", "text"), this.$text.setAttribute("spellcheck", "false"), this.$text.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("lil-display"), this.$display.appendChild(this.$input), this.$widget.appendChild(this.$display), this.$widget.appendChild(this.$text), this._format = M(this.initialValue), this._rgbScale = n, this._initialValueHexString = this.save(), this._textFocused = !1, this.$input.addEventListener("input", () => {
282
+ this._setValueFromHexString(this.$input.value);
283
+ }), this.$input.addEventListener("blur", () => {
284
+ this._callOnFinishChange();
285
+ }), this.$text.addEventListener("input", () => {
286
+ const a = E(this.$text.value);
287
+ a && this._setValueFromHexString(a);
288
+ }), this.$text.addEventListener("focus", () => {
289
+ this._textFocused = !0, this.$text.select();
290
+ }), this.$text.addEventListener("blur", () => {
291
+ this._textFocused = !1, this.updateDisplay(), this._callOnFinishChange();
292
+ }), this.$disable = this.$text, this.updateDisplay();
293
+ }
294
+ reset() {
295
+ return this._setValueFromHexString(this._initialValueHexString), this;
296
+ }
297
+ _setValueFromHexString(t) {
298
+ if (this._format.isPrimitive) {
299
+ const i = this._format.fromHexString(t);
300
+ this.setValue(i);
301
+ } else
302
+ this._format.fromHexString(t, this.getValue(), this._rgbScale), this._callOnChange(), this.updateDisplay();
303
+ }
304
+ save() {
305
+ return this._format.toHexString(this.getValue(), this._rgbScale);
306
+ }
307
+ load(t) {
308
+ return this._setValueFromHexString(t), this._callOnFinishChange(), this;
309
+ }
310
+ updateDisplay() {
311
+ return this.$input.value = this._format.toHexString(this.getValue(), this._rgbScale), this._textFocused || (this.$text.value = this.$input.value.substring(1)), this.$display.style.backgroundColor = this.$input.value, this;
312
+ }
313
+ }
314
+ class $ extends u {
315
+ constructor(t, i, e) {
316
+ super(t, i, e, "lil-function"), this.$button = document.createElement("button"), this.$button.appendChild(this.$name), this.$widget.appendChild(this.$button), this.$button.addEventListener("click", (n) => {
317
+ n.preventDefault(), this.getValue().call(this.object), this._callOnChange();
318
+ }), this.$button.addEventListener("touchstart", () => {
319
+ }, { passive: !0 }), this.$disable = this.$button;
320
+ }
321
+ }
322
+ class H extends u {
323
+ constructor(t, i, e, n, a, o) {
324
+ super(t, i, e, "lil-number"), this._initInput(), this.min(n), this.max(a);
325
+ const c = o !== void 0;
326
+ this.step(c ? o : this._getImplicitStep(), c), this.updateDisplay();
327
+ }
328
+ decimals(t) {
329
+ return this._decimals = t, this.updateDisplay(), this;
330
+ }
331
+ min(t) {
332
+ return this._min = t, this._onUpdateMinMax(), this;
333
+ }
334
+ max(t) {
335
+ return this._max = t, this._onUpdateMinMax(), this;
336
+ }
337
+ step(t, i = !0) {
338
+ return this._step = t, this._stepExplicit = i, this;
339
+ }
340
+ updateDisplay() {
341
+ const t = this.getValue();
342
+ if (this._hasSlider) {
343
+ let i = (t - this._min) / (this._max - this._min);
344
+ i = Math.max(0, Math.min(i, 1)), this.$fill.style.width = i * 100 + "%";
345
+ }
346
+ return this._inputFocused || (this.$input.value = this._decimals === void 0 ? t : t.toFixed(this._decimals)), this;
347
+ }
348
+ _initInput() {
349
+ this.$input = document.createElement("input"), this.$input.setAttribute("type", "text"), this.$input.setAttribute("aria-labelledby", this.$name.id), window.matchMedia("(pointer: coarse)").matches && (this.$input.setAttribute("type", "number"), this.$input.setAttribute("step", "any")), this.$widget.appendChild(this.$input), this.$disable = this.$input;
350
+ const i = () => {
351
+ let l = parseFloat(this.$input.value);
352
+ isNaN(l) || (this._stepExplicit && (l = this._snap(l)), this.setValue(this._clamp(l)));
353
+ }, e = (l) => {
354
+ const h = parseFloat(this.$input.value);
355
+ isNaN(h) || (this._snapClampSetValue(h + l), this.$input.value = this.getValue());
356
+ }, n = (l) => {
357
+ l.key === "Enter" && this.$input.blur(), l.code === "ArrowUp" && (l.preventDefault(), e(this._step * this._arrowKeyMultiplier(l))), l.code === "ArrowDown" && (l.preventDefault(), e(this._step * this._arrowKeyMultiplier(l) * -1));
358
+ }, a = (l) => {
359
+ this._inputFocused && (l.preventDefault(), e(this._step * this._normalizeMouseWheel(l)));
360
+ };
361
+ let o = !1, c, g, m, p, d;
362
+ const f = 5, x = (l) => {
363
+ c = l.clientX, g = m = l.clientY, o = !0, p = this.getValue(), d = 0, window.addEventListener("mousemove", w), window.addEventListener("mouseup", v);
364
+ }, w = (l) => {
365
+ if (o) {
366
+ const h = l.clientX - c, _ = l.clientY - g;
367
+ Math.abs(_) > f ? (l.preventDefault(), this.$input.blur(), o = !1, this._setDraggingStyle(!0, "vertical")) : Math.abs(h) > f && v();
368
+ }
369
+ if (!o) {
370
+ const h = l.clientY - m;
371
+ d -= h * this._step * this._arrowKeyMultiplier(l), p + d > this._max ? d = this._max - p : p + d < this._min && (d = this._min - p), this._snapClampSetValue(p + d);
372
+ }
373
+ m = l.clientY;
374
+ }, v = () => {
375
+ this._setDraggingStyle(!1, "vertical"), this._callOnFinishChange(), window.removeEventListener("mousemove", w), window.removeEventListener("mouseup", v);
376
+ }, y = () => {
377
+ this._inputFocused = !0;
378
+ }, r = () => {
379
+ this._inputFocused = !1, this.updateDisplay(), this._callOnFinishChange();
380
+ };
381
+ this.$input.addEventListener("input", i), this.$input.addEventListener("keydown", n), this.$input.addEventListener("wheel", a, { passive: !1 }), this.$input.addEventListener("mousedown", x), this.$input.addEventListener("focus", y), this.$input.addEventListener("blur", r);
382
+ }
383
+ _initSlider() {
384
+ this._hasSlider = !0, this.$slider = document.createElement("div"), this.$slider.classList.add("lil-slider"), this.$fill = document.createElement("div"), this.$fill.classList.add("lil-fill"), this.$slider.appendChild(this.$fill), this.$widget.insertBefore(this.$slider, this.$input), this.domElement.classList.add("lil-has-slider");
385
+ const t = (r, l, h, _, k) => (r - l) / (h - l) * (k - _) + _, i = (r) => {
386
+ const l = this.$slider.getBoundingClientRect();
387
+ let h = t(r, l.left, l.right, this._min, this._max);
388
+ this._snapClampSetValue(h);
389
+ }, e = (r) => {
390
+ this._setDraggingStyle(!0), i(r.clientX), window.addEventListener("mousemove", n), window.addEventListener("mouseup", a);
391
+ }, n = (r) => {
392
+ i(r.clientX);
393
+ }, a = () => {
394
+ this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("mousemove", n), window.removeEventListener("mouseup", a);
395
+ };
396
+ let o = !1, c, g;
397
+ const m = (r) => {
398
+ r.preventDefault(), this._setDraggingStyle(!0), i(r.touches[0].clientX), o = !1;
399
+ }, p = (r) => {
400
+ r.touches.length > 1 || (this._hasScrollBar ? (c = r.touches[0].clientX, g = r.touches[0].clientY, o = !0) : m(r), window.addEventListener("touchmove", d, { passive: !1 }), window.addEventListener("touchend", f));
401
+ }, d = (r) => {
402
+ if (o) {
403
+ const l = r.touches[0].clientX - c, h = r.touches[0].clientY - g;
404
+ Math.abs(l) > Math.abs(h) ? m(r) : (window.removeEventListener("touchmove", d), window.removeEventListener("touchend", f));
405
+ } else
406
+ r.preventDefault(), i(r.touches[0].clientX);
407
+ }, f = () => {
408
+ this._callOnFinishChange(), this._setDraggingStyle(!1), window.removeEventListener("touchmove", d), window.removeEventListener("touchend", f);
409
+ }, x = this._callOnFinishChange.bind(this), w = 400;
410
+ let v;
411
+ const y = (r) => {
412
+ if (Math.abs(r.deltaX) < Math.abs(r.deltaY) && this._hasScrollBar) return;
413
+ r.preventDefault();
414
+ const h = this._normalizeMouseWheel(r) * this._step;
415
+ this._snapClampSetValue(this.getValue() + h), this.$input.value = this.getValue(), clearTimeout(v), v = setTimeout(x, w);
416
+ };
417
+ this.$slider.addEventListener("mousedown", e), this.$slider.addEventListener("touchstart", p, { passive: !1 }), this.$slider.addEventListener("wheel", y, { passive: !1 });
418
+ }
419
+ _setDraggingStyle(t, i = "horizontal") {
420
+ this.$slider && this.$slider.classList.toggle("lil-active", t), document.body.classList.toggle("lil-dragging", t), document.body.classList.toggle(`lil-${i}`, t);
421
+ }
422
+ _getImplicitStep() {
423
+ return this._hasMin && this._hasMax ? (this._max - this._min) / 1e3 : 0.1;
424
+ }
425
+ _onUpdateMinMax() {
426
+ !this._hasSlider && this._hasMin && this._hasMax && (this._stepExplicit || this.step(this._getImplicitStep(), !1), this._initSlider(), this.updateDisplay());
427
+ }
428
+ _normalizeMouseWheel(t) {
429
+ let { deltaX: i, deltaY: e } = t;
430
+ return Math.floor(t.deltaY) !== t.deltaY && t.wheelDelta && (i = 0, e = -t.wheelDelta / 120, e *= this._stepExplicit ? 1 : 10), i + -e;
431
+ }
432
+ _arrowKeyMultiplier(t) {
433
+ let i = this._stepExplicit ? 1 : 10;
434
+ return t.shiftKey ? i *= 10 : t.altKey && (i /= 10), i;
435
+ }
436
+ _snap(t) {
437
+ let i = 0;
438
+ return this._hasMin ? i = this._min : this._hasMax && (i = this._max), t -= i, t = Math.round(t / this._step) * this._step, t += i, t = parseFloat(t.toPrecision(15)), t;
439
+ }
440
+ _clamp(t) {
441
+ return t < this._min && (t = this._min), t > this._max && (t = this._max), t;
442
+ }
443
+ _snapClampSetValue(t) {
444
+ this.setValue(this._clamp(this._snap(t)));
445
+ }
446
+ get _hasScrollBar() {
447
+ const t = this.parent.root.$children;
448
+ return t.scrollHeight > t.clientHeight;
449
+ }
450
+ get _hasMin() {
451
+ return this._min !== void 0;
452
+ }
453
+ get _hasMax() {
454
+ return this._max !== void 0;
455
+ }
456
+ }
457
+ class I extends u {
458
+ constructor(t, i, e, n) {
459
+ super(t, i, e, "lil-option"), this.$select = document.createElement("select"), this.$select.setAttribute("aria-labelledby", this.$name.id), this.$display = document.createElement("div"), this.$display.classList.add("lil-display"), this.$select.addEventListener("change", () => {
460
+ this.setValue(this._values[this.$select.selectedIndex]), this._callOnFinishChange();
461
+ }), this.$select.addEventListener("focus", () => {
462
+ this.$display.classList.add("lil-focus");
463
+ }), this.$select.addEventListener("blur", () => {
464
+ this.$display.classList.remove("lil-focus");
465
+ }), this.$widget.appendChild(this.$select), this.$widget.appendChild(this.$display), this.$disable = this.$select, this.options(n);
466
+ }
467
+ options(t) {
468
+ return this._values = Array.isArray(t) ? t : Object.values(t), this._names = Array.isArray(t) ? t : Object.keys(t), this.$select.replaceChildren(), this._names.forEach((i) => {
469
+ const e = document.createElement("option");
470
+ e.textContent = i, this.$select.appendChild(e);
471
+ }), this.updateDisplay(), this;
472
+ }
473
+ updateDisplay() {
474
+ const t = this.getValue(), i = this._values.indexOf(t);
475
+ return this.$select.selectedIndex = i, this.$display.textContent = i === -1 ? t : this._names[i], this;
476
+ }
477
+ }
478
+ class z extends u {
479
+ constructor(t, i, e) {
480
+ super(t, i, e, "lil-string"), this.$input = document.createElement("input"), this.$input.setAttribute("type", "text"), this.$input.setAttribute("spellcheck", "false"), this.$input.setAttribute("aria-labelledby", this.$name.id), this.$input.addEventListener("input", () => {
481
+ this.setValue(this.$input.value);
482
+ }), this.$input.addEventListener("keydown", (n) => {
483
+ n.code === "Enter" && this.$input.blur();
484
+ }), this.$input.addEventListener("blur", () => {
485
+ this._callOnFinishChange();
486
+ }), this.$widget.appendChild(this.$input), this.$disable = this.$input, this.updateDisplay();
487
+ }
488
+ updateDisplay() {
489
+ return this.$input.value = this.getValue(), this;
490
+ }
491
+ }
492
+ var B = `.lil-gui {
493
+ font-family: var(--font-family);
494
+ font-size: var(--font-size);
495
+ line-height: 1;
496
+ font-weight: normal;
497
+ font-style: normal;
498
+ text-align: left;
499
+ color: var(--text-color);
500
+ user-select: none;
501
+ -webkit-user-select: none;
502
+ touch-action: manipulation;
503
+ --background-color: #1f1f1f;
504
+ --text-color: #ebebeb;
505
+ --title-background-color: #111111;
506
+ --title-text-color: #ebebeb;
507
+ --widget-color: #424242;
508
+ --hover-color: #4f4f4f;
509
+ --focus-color: #595959;
510
+ --number-color: #2cc9ff;
511
+ --string-color: #a2db3c;
512
+ --font-size: 11px;
513
+ --input-font-size: 11px;
514
+ --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
515
+ --font-family-mono: Menlo, Monaco, Consolas, "Droid Sans Mono", monospace;
516
+ --padding: 4px;
517
+ --spacing: 4px;
518
+ --widget-height: 20px;
519
+ --title-height: calc(var(--widget-height) + var(--spacing) * 1.25);
520
+ --name-width: 45%;
521
+ --slider-knob-width: 2px;
522
+ --slider-input-width: 27%;
523
+ --color-input-width: 27%;
524
+ --slider-input-min-width: 45px;
525
+ --color-input-min-width: 45px;
526
+ --folder-indent: 7px;
527
+ --widget-padding: 0 0 0 3px;
528
+ --widget-border-radius: 2px;
529
+ --checkbox-size: calc(0.75 * var(--widget-height));
530
+ --scrollbar-width: 5px;
531
+ }
532
+ .lil-gui, .lil-gui * {
533
+ box-sizing: border-box;
534
+ margin: 0;
535
+ padding: 0;
536
+ }
537
+ .lil-gui.lil-root {
538
+ width: var(--width, 245px);
539
+ display: flex;
540
+ flex-direction: column;
541
+ background: var(--background-color);
542
+ }
543
+ .lil-gui.lil-root > .lil-title {
544
+ background: var(--title-background-color);
545
+ color: var(--title-text-color);
546
+ }
547
+ .lil-gui.lil-root > .lil-children {
548
+ overflow-x: hidden;
549
+ overflow-y: auto;
550
+ }
551
+ .lil-gui.lil-root > .lil-children::-webkit-scrollbar {
552
+ width: var(--scrollbar-width);
553
+ height: var(--scrollbar-width);
554
+ background: var(--background-color);
555
+ }
556
+ .lil-gui.lil-root > .lil-children::-webkit-scrollbar-thumb {
557
+ border-radius: var(--scrollbar-width);
558
+ background: var(--focus-color);
559
+ }
560
+ @media (pointer: coarse) {
561
+ .lil-gui.lil-allow-touch-styles, .lil-gui.lil-allow-touch-styles .lil-gui {
562
+ --widget-height: 28px;
563
+ --padding: 6px;
564
+ --spacing: 6px;
565
+ --font-size: 13px;
566
+ --input-font-size: 16px;
567
+ --folder-indent: 10px;
568
+ --scrollbar-width: 7px;
569
+ --slider-input-min-width: 50px;
570
+ --color-input-min-width: 65px;
571
+ }
572
+ }
573
+ .lil-gui.lil-force-touch-styles, .lil-gui.lil-force-touch-styles .lil-gui {
574
+ --widget-height: 28px;
575
+ --padding: 6px;
576
+ --spacing: 6px;
577
+ --font-size: 13px;
578
+ --input-font-size: 16px;
579
+ --folder-indent: 10px;
580
+ --scrollbar-width: 7px;
581
+ --slider-input-min-width: 50px;
582
+ --color-input-min-width: 65px;
583
+ }
584
+ .lil-gui.lil-auto-place, .lil-gui.autoPlace {
585
+ max-height: 100%;
586
+ position: fixed;
587
+ top: 0;
588
+ right: 15px;
589
+ z-index: 1001;
590
+ }
591
+
592
+ .lil-controller {
593
+ display: flex;
594
+ align-items: center;
595
+ padding: 0 var(--padding);
596
+ margin: var(--spacing) 0;
597
+ }
598
+ .lil-controller.lil-disabled {
599
+ opacity: 0.5;
600
+ }
601
+ .lil-controller.lil-disabled, .lil-controller.lil-disabled * {
602
+ pointer-events: none !important;
603
+ }
604
+ .lil-controller > .lil-name {
605
+ min-width: var(--name-width);
606
+ flex-shrink: 0;
607
+ white-space: pre;
608
+ padding-right: var(--spacing);
609
+ line-height: var(--widget-height);
610
+ }
611
+ .lil-controller .lil-widget {
612
+ position: relative;
613
+ display: flex;
614
+ align-items: center;
615
+ width: 100%;
616
+ min-height: var(--widget-height);
617
+ }
618
+ .lil-controller.lil-string input {
619
+ color: var(--string-color);
620
+ }
621
+ .lil-controller.lil-boolean {
622
+ cursor: pointer;
623
+ }
624
+ .lil-controller.lil-color .lil-display {
625
+ width: 100%;
626
+ height: var(--widget-height);
627
+ border-radius: var(--widget-border-radius);
628
+ position: relative;
629
+ }
630
+ @media (hover: hover) {
631
+ .lil-controller.lil-color .lil-display:hover:before {
632
+ content: " ";
633
+ display: block;
634
+ position: absolute;
635
+ border-radius: var(--widget-border-radius);
636
+ border: 1px solid #fff9;
637
+ top: 0;
638
+ right: 0;
639
+ bottom: 0;
640
+ left: 0;
641
+ }
642
+ }
643
+ .lil-controller.lil-color input[type=color] {
644
+ opacity: 0;
645
+ width: 100%;
646
+ height: 100%;
647
+ cursor: pointer;
648
+ }
649
+ .lil-controller.lil-color input[type=text] {
650
+ margin-left: var(--spacing);
651
+ font-family: var(--font-family-mono);
652
+ min-width: var(--color-input-min-width);
653
+ width: var(--color-input-width);
654
+ flex-shrink: 0;
655
+ }
656
+ .lil-controller.lil-option select {
657
+ opacity: 0;
658
+ position: absolute;
659
+ width: 100%;
660
+ max-width: 100%;
661
+ }
662
+ .lil-controller.lil-option .lil-display {
663
+ position: relative;
664
+ pointer-events: none;
665
+ border-radius: var(--widget-border-radius);
666
+ height: var(--widget-height);
667
+ line-height: var(--widget-height);
668
+ max-width: 100%;
669
+ overflow: hidden;
670
+ word-break: break-all;
671
+ padding-left: 0.55em;
672
+ padding-right: 1.75em;
673
+ background: var(--widget-color);
674
+ }
675
+ @media (hover: hover) {
676
+ .lil-controller.lil-option .lil-display.lil-focus {
677
+ background: var(--focus-color);
678
+ }
679
+ }
680
+ .lil-controller.lil-option .lil-display.lil-active {
681
+ background: var(--focus-color);
682
+ }
683
+ .lil-controller.lil-option .lil-display:after {
684
+ font-family: "lil-gui";
685
+ content: "↕";
686
+ position: absolute;
687
+ top: 0;
688
+ right: 0;
689
+ bottom: 0;
690
+ padding-right: 0.375em;
691
+ }
692
+ .lil-controller.lil-option .lil-widget,
693
+ .lil-controller.lil-option select {
694
+ cursor: pointer;
695
+ }
696
+ @media (hover: hover) {
697
+ .lil-controller.lil-option .lil-widget:hover .lil-display {
698
+ background: var(--hover-color);
699
+ }
700
+ }
701
+ .lil-controller.lil-number input {
702
+ color: var(--number-color);
703
+ }
704
+ .lil-controller.lil-number.lil-has-slider input {
705
+ margin-left: var(--spacing);
706
+ width: var(--slider-input-width);
707
+ min-width: var(--slider-input-min-width);
708
+ flex-shrink: 0;
709
+ }
710
+ .lil-controller.lil-number .lil-slider {
711
+ width: 100%;
712
+ height: var(--widget-height);
713
+ background: var(--widget-color);
714
+ border-radius: var(--widget-border-radius);
715
+ padding-right: var(--slider-knob-width);
716
+ overflow: hidden;
717
+ cursor: ew-resize;
718
+ touch-action: pan-y;
719
+ }
720
+ @media (hover: hover) {
721
+ .lil-controller.lil-number .lil-slider:hover {
722
+ background: var(--hover-color);
723
+ }
724
+ }
725
+ .lil-controller.lil-number .lil-slider.lil-active {
726
+ background: var(--focus-color);
727
+ }
728
+ .lil-controller.lil-number .lil-slider.lil-active .lil-fill {
729
+ opacity: 0.95;
730
+ }
731
+ .lil-controller.lil-number .lil-fill {
732
+ height: 100%;
733
+ border-right: var(--slider-knob-width) solid var(--number-color);
734
+ box-sizing: content-box;
735
+ }
736
+
737
+ .lil-dragging .lil-gui {
738
+ --hover-color: var(--widget-color);
739
+ }
740
+ .lil-dragging * {
741
+ cursor: ew-resize !important;
742
+ }
743
+ .lil-dragging.lil-vertical * {
744
+ cursor: ns-resize !important;
745
+ }
746
+
747
+ .lil-gui .lil-title {
748
+ height: var(--title-height);
749
+ font-weight: 600;
750
+ padding: 0 var(--padding);
751
+ width: 100%;
752
+ text-align: left;
753
+ background: none;
754
+ text-decoration-skip: objects;
755
+ }
756
+ .lil-gui .lil-title:before {
757
+ font-family: "lil-gui";
758
+ content: "▾";
759
+ padding-right: 2px;
760
+ display: inline-block;
761
+ }
762
+ .lil-gui .lil-title:active {
763
+ background: var(--title-background-color);
764
+ opacity: 0.75;
765
+ }
766
+ @media (hover: hover) {
767
+ body:not(.lil-dragging) .lil-gui .lil-title:hover {
768
+ background: var(--title-background-color);
769
+ opacity: 0.85;
770
+ }
771
+ .lil-gui .lil-title:focus {
772
+ text-decoration: underline var(--focus-color);
773
+ }
774
+ }
775
+ .lil-gui.lil-root > .lil-title:focus {
776
+ text-decoration: none !important;
777
+ }
778
+ .lil-gui.lil-closed > .lil-title:before {
779
+ content: "▸";
780
+ }
781
+ .lil-gui.lil-closed > .lil-children {
782
+ transform: translateY(-7px);
783
+ opacity: 0;
784
+ }
785
+ .lil-gui.lil-closed:not(.lil-transition) > .lil-children {
786
+ display: none;
787
+ }
788
+ .lil-gui.lil-transition > .lil-children {
789
+ transition-duration: 300ms;
790
+ transition-property: height, opacity, transform;
791
+ transition-timing-function: cubic-bezier(0.2, 0.6, 0.35, 1);
792
+ overflow: hidden;
793
+ pointer-events: none;
794
+ }
795
+ .lil-gui .lil-children:empty:before {
796
+ content: "Empty";
797
+ padding: 0 var(--padding);
798
+ margin: var(--spacing) 0;
799
+ display: block;
800
+ height: var(--widget-height);
801
+ font-style: italic;
802
+ line-height: var(--widget-height);
803
+ opacity: 0.5;
804
+ }
805
+ .lil-gui.lil-root > .lil-children > .lil-gui > .lil-title {
806
+ border: 0 solid var(--widget-color);
807
+ border-width: 1px 0;
808
+ transition: border-color 300ms;
809
+ }
810
+ .lil-gui.lil-root > .lil-children > .lil-gui.lil-closed > .lil-title {
811
+ border-bottom-color: transparent;
812
+ }
813
+ .lil-gui + .lil-controller {
814
+ border-top: 1px solid var(--widget-color);
815
+ margin-top: 0;
816
+ padding-top: var(--spacing);
817
+ }
818
+ .lil-gui .lil-gui .lil-gui > .lil-title {
819
+ border: none;
820
+ }
821
+ .lil-gui .lil-gui .lil-gui > .lil-children {
822
+ border: none;
823
+ margin-left: var(--folder-indent);
824
+ border-left: 2px solid var(--widget-color);
825
+ }
826
+ .lil-gui .lil-gui .lil-controller {
827
+ border: none;
828
+ }
829
+
830
+ .lil-gui label, .lil-gui input, .lil-gui button {
831
+ -webkit-tap-highlight-color: transparent;
832
+ }
833
+ .lil-gui input {
834
+ border: 0;
835
+ outline: none;
836
+ font-family: var(--font-family);
837
+ font-size: var(--input-font-size);
838
+ border-radius: var(--widget-border-radius);
839
+ height: var(--widget-height);
840
+ background: var(--widget-color);
841
+ color: var(--text-color);
842
+ width: 100%;
843
+ }
844
+ @media (hover: hover) {
845
+ .lil-gui input:hover {
846
+ background: var(--hover-color);
847
+ }
848
+ .lil-gui input:active {
849
+ background: var(--focus-color);
850
+ }
851
+ }
852
+ .lil-gui input:disabled {
853
+ opacity: 1;
854
+ }
855
+ .lil-gui input[type=text],
856
+ .lil-gui input[type=number] {
857
+ padding: var(--widget-padding);
858
+ -moz-appearance: textfield;
859
+ }
860
+ .lil-gui input[type=text]:focus,
861
+ .lil-gui input[type=number]:focus {
862
+ background: var(--focus-color);
863
+ }
864
+ .lil-gui input[type=checkbox] {
865
+ appearance: none;
866
+ width: var(--checkbox-size);
867
+ height: var(--checkbox-size);
868
+ border-radius: var(--widget-border-radius);
869
+ text-align: center;
870
+ cursor: pointer;
871
+ }
872
+ .lil-gui input[type=checkbox]:checked:before {
873
+ font-family: "lil-gui";
874
+ content: "✓";
875
+ font-size: var(--checkbox-size);
876
+ line-height: var(--checkbox-size);
877
+ }
878
+ @media (hover: hover) {
879
+ .lil-gui input[type=checkbox]:focus {
880
+ box-shadow: inset 0 0 0 1px var(--focus-color);
881
+ }
882
+ }
883
+ .lil-gui button {
884
+ outline: none;
885
+ cursor: pointer;
886
+ font-family: var(--font-family);
887
+ font-size: var(--font-size);
888
+ color: var(--text-color);
889
+ width: 100%;
890
+ border: none;
891
+ }
892
+ .lil-gui .lil-controller button {
893
+ height: var(--widget-height);
894
+ text-transform: none;
895
+ background: var(--widget-color);
896
+ border-radius: var(--widget-border-radius);
897
+ }
898
+ @media (hover: hover) {
899
+ .lil-gui .lil-controller button:hover {
900
+ background: var(--hover-color);
901
+ }
902
+ .lil-gui .lil-controller button:focus {
903
+ box-shadow: inset 0 0 0 1px var(--focus-color);
904
+ }
905
+ }
906
+ .lil-gui .lil-controller button:active {
907
+ background: var(--focus-color);
908
+ }
909
+
910
+ @font-face {
911
+ font-family: "lil-gui";
912
+ src: url("data:application/font-woff2;charset=utf-8;base64,d09GMgABAAAAAALkAAsAAAAABtQAAAKVAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHFQGYACDMgqBBIEbATYCJAMUCwwABCAFhAoHgQQbHAbIDiUFEYVARAAAYQTVWNmz9MxhEgodq49wYRUFKE8GWNiUBxI2LBRaVnc51U83Gmhs0Q7JXWMiz5eteLwrKwuxHO8VFxUX9UpZBs6pa5ABRwHA+t3UxUnH20EvVknRerzQgX6xC/GH6ZUvTcAjAv122dF28OTqCXrPuyaDER30YBA1xnkVutDDo4oCi71Ca7rrV9xS8dZHbPHefsuwIyCpmT7j+MnjAH5X3984UZoFFuJ0yiZ4XEJFxjagEBeqs+e1iyK8Xf/nOuwF+vVK0ur765+vf7txotUi0m3N0m/84RGSrBCNrh8Ee5GjODjF4gnWP+dJrH/Lk9k4oT6d+gr6g/wssA2j64JJGP6cmx554vUZnpZfn6ZfX2bMwPPrlANsB86/DiHjhl0OP+c87+gaJo/gY084s3HoYL/ZkWHTRfBXvvoHnnkHvngKun4KBE/ede7tvq3/vQOxDXB1/fdNz6XbPdcr0Vhpojj9dG+owuSKFsslCi1tgEjirjXdwMiov2EioadxmqTHUCIwo8NgQaeIasAi0fTYSPTbSmwbMOFduyh9wvBrESGY0MtgRjtgQR8Q1bRPohn2UoCRZf9wyYANMXFeJTysqAe0I4mrherOekFdKMrYvJjLvOIUM9SuwYB5DVZUwwVjJJOaUnZCmcEkIZZrKqNvRGRMvmFZsmhP4VMKCSXBhSqUBxgMS7h0cZvEd71AWkEhGWaeMFcNnpqyJkyXgYL7PQ1MoSq0wDAkRtJIijkZSmqYTiSImfLiSWXIZwhRh3Rug2X0kk1Dgj+Iu43u5p98ghopcpSo0Uyc8SnjlYX59WUeaMoDqmVD2TOWD9a4pCRAzf2ECgwGcrHjPOWY9bNxq/OL3I/QjwEAAAA=") format("woff2");
913
+ }`;
914
+ function Y(s) {
915
+ const t = document.createElement("style");
916
+ t.innerHTML = s;
917
+ const i = document.querySelector("head link[rel=stylesheet], head style");
918
+ i ? document.head.insertBefore(t, i) : document.head.appendChild(t);
919
+ }
920
+ let C = !1;
921
+ class A {
922
+ /**
923
+ * Creates a panel that holds controllers.
924
+ * @example
925
+ * new GUI();
926
+ * new GUI( { container: document.getElementById( 'custom' ) } );
927
+ *
928
+ * @param {object} [options]
929
+ * @param {boolean} [options.autoPlace=true]
930
+ * Adds the GUI to `document.body` and fixes it to the top right of the page.
931
+ *
932
+ * @param {Node} [options.container]
933
+ * Adds the GUI to this DOM element. Overrides `autoPlace`.
934
+ *
935
+ * @param {number} [options.width=245]
936
+ * Width of the GUI in pixels, usually set when name labels become too long. Note that you can make
937
+ * name labels wider in CSS with `.lil‑gui { ‑‑name‑width: 55% }`.
938
+ *
939
+ * @param {string} [options.title=Controls]
940
+ * Name to display in the title bar.
941
+ *
942
+ * @param {boolean} [options.closeFolders=false]
943
+ * Pass `true` to close all folders in this GUI by default.
944
+ *
945
+ * @param {boolean} [options.injectStyles=true]
946
+ * Injects the default stylesheet into the page if this is the first GUI.
947
+ * Pass `false` to use your own stylesheet.
948
+ *
949
+ * @param {number} [options.touchStyles=true]
950
+ * Makes controllers larger on touch devices. Pass `false` to disable touch styles.
951
+ *
952
+ * @param {GUI} [options.parent]
953
+ * Adds this GUI as a child in another GUI. Usually this is done for you by `addFolder()`.
954
+ */
955
+ constructor({
956
+ parent: t,
957
+ autoPlace: i = t === void 0,
958
+ container: e,
959
+ width: n,
960
+ title: a = "Controls",
961
+ closeFolders: o = !1,
962
+ injectStyles: c = !0,
963
+ touchStyles: g = !0
964
+ } = {}) {
965
+ if (this.parent = t, this.root = t ? t.root : this, this.children = [], this.controllers = [], this.folders = [], this._closed = !1, this._hidden = !1, this.domElement = document.createElement("div"), this.domElement.classList.add("lil-gui"), this.$title = document.createElement("button"), this.$title.classList.add("lil-title"), this.$title.setAttribute("aria-expanded", !0), this.$title.addEventListener("click", () => this.openAnimated(this._closed)), this.$title.addEventListener("touchstart", () => {
966
+ }, { passive: !0 }), this.$children = document.createElement("div"), this.$children.classList.add("lil-children"), this.domElement.appendChild(this.$title), this.domElement.appendChild(this.$children), this.title(a), this.parent) {
967
+ this.parent.children.push(this), this.parent.folders.push(this), this.parent.$children.appendChild(this.domElement);
968
+ return;
969
+ }
970
+ this.domElement.classList.add("lil-root"), g && this.domElement.classList.add("lil-allow-touch-styles"), !C && c && (Y(B), C = !0), e ? e.appendChild(this.domElement) : i && (this.domElement.classList.add("lil-auto-place", "autoPlace"), document.body.appendChild(this.domElement)), n && this.domElement.style.setProperty("--width", n + "px"), this._closeFolders = o;
971
+ }
972
+ /**
973
+ * Adds a controller to the GUI, inferring controller type using the `typeof` operator.
974
+ * @example
975
+ * gui.add( object, 'property' );
976
+ * gui.add( object, 'number', 0, 100, 1 );
977
+ * gui.add( object, 'options', [ 1, 2, 3 ] );
978
+ *
979
+ * @param {object} object The object the controller will modify.
980
+ * @param {string} property Name of the property to control.
981
+ * @param {number|object|Array} [$1] Minimum value for number controllers, or the set of
982
+ * selectable values for a dropdown.
983
+ * @param {number} [max] Maximum value for number controllers.
984
+ * @param {number} [step] Step value for number controllers.
985
+ * @returns {Controller}
986
+ */
987
+ add(t, i, e, n, a) {
988
+ if (Object(e) === e)
989
+ return new I(this, t, i, e);
990
+ const o = t[i];
991
+ switch (typeof o) {
992
+ case "number":
993
+ return new H(this, t, i, e, n, a);
994
+ case "boolean":
995
+ return new L(this, t, i);
996
+ case "string":
997
+ return new z(this, t, i);
998
+ case "function":
999
+ return new $(this, t, i);
1000
+ }
1001
+ console.error(`gui.add failed
1002
+ property:`, i, `
1003
+ object:`, t, `
1004
+ value:`, o);
1005
+ }
1006
+ /**
1007
+ * Adds a color controller to the GUI.
1008
+ * @example
1009
+ * params = {
1010
+ * cssColor: '#ff00ff',
1011
+ * rgbColor: { r: 0, g: 0.2, b: 0.4 },
1012
+ * customRange: [ 0, 127, 255 ],
1013
+ * };
1014
+ *
1015
+ * gui.addColor( params, 'cssColor' );
1016
+ * gui.addColor( params, 'rgbColor' );
1017
+ * gui.addColor( params, 'customRange', 255 );
1018
+ *
1019
+ * @param {object} object The object the controller will modify.
1020
+ * @param {string} property Name of the property to control.
1021
+ * @param {number} rgbScale Maximum value for a color channel when using an RGB color. You may
1022
+ * need to set this to 255 if your colors are too bright.
1023
+ * @returns {Controller}
1024
+ */
1025
+ addColor(t, i, e = 1) {
1026
+ return new O(this, t, i, e);
1027
+ }
1028
+ /**
1029
+ * Adds a folder to the GUI, which is just another GUI. This method returns
1030
+ * the nested GUI so you can add controllers to it.
1031
+ * @example
1032
+ * const folder = gui.addFolder( 'Position' );
1033
+ * folder.add( position, 'x' );
1034
+ * folder.add( position, 'y' );
1035
+ * folder.add( position, 'z' );
1036
+ *
1037
+ * @param {string} title Name to display in the folder's title bar.
1038
+ * @returns {GUI}
1039
+ */
1040
+ addFolder(t) {
1041
+ const i = new A({ parent: this, title: t });
1042
+ return this.root._closeFolders && i.close(), i;
1043
+ }
1044
+ /**
1045
+ * Recalls values that were saved with `gui.save()`.
1046
+ * @param {object} obj
1047
+ * @param {boolean} recursive Pass false to exclude folders descending from this GUI.
1048
+ * @returns {this}
1049
+ */
1050
+ load(t, i = !0) {
1051
+ return t.controllers && this.controllers.forEach((e) => {
1052
+ e instanceof $ || e._name in t.controllers && e.load(t.controllers[e._name]);
1053
+ }), i && t.folders && this.folders.forEach((e) => {
1054
+ e._title in t.folders && e.load(t.folders[e._title]);
1055
+ }), this;
1056
+ }
1057
+ /**
1058
+ * Returns an object mapping controller names to values. The object can be passed to `gui.load()` to
1059
+ * recall these values.
1060
+ * @example
1061
+ * {
1062
+ * controllers: {
1063
+ * prop1: 1,
1064
+ * prop2: 'value',
1065
+ * ...
1066
+ * },
1067
+ * folders: {
1068
+ * folderName1: { controllers, folders },
1069
+ * folderName2: { controllers, folders }
1070
+ * ...
1071
+ * }
1072
+ * }
1073
+ *
1074
+ * @param {boolean} recursive Pass false to exclude folders descending from this GUI.
1075
+ * @returns {object}
1076
+ */
1077
+ save(t = !0) {
1078
+ const i = {
1079
+ controllers: {},
1080
+ folders: {}
1081
+ };
1082
+ return this.controllers.forEach((e) => {
1083
+ if (!(e instanceof $)) {
1084
+ if (e._name in i.controllers)
1085
+ throw new Error(`Cannot save GUI with duplicate property "${e._name}"`);
1086
+ i.controllers[e._name] = e.save();
1087
+ }
1088
+ }), t && this.folders.forEach((e) => {
1089
+ if (e._title in i.folders)
1090
+ throw new Error(`Cannot save GUI with duplicate folder "${e._title}"`);
1091
+ i.folders[e._title] = e.save();
1092
+ }), i;
1093
+ }
1094
+ /**
1095
+ * Opens a GUI or folder. GUI and folders are open by default.
1096
+ * @param {boolean} open Pass false to close.
1097
+ * @returns {this}
1098
+ * @example
1099
+ * gui.open(); // open
1100
+ * gui.open( false ); // close
1101
+ * gui.open( gui._closed ); // toggle
1102
+ */
1103
+ open(t = !0) {
1104
+ return this._setClosed(!t), this.$title.setAttribute("aria-expanded", !this._closed), this.domElement.classList.toggle("lil-closed", this._closed), this;
1105
+ }
1106
+ /**
1107
+ * Closes the GUI.
1108
+ * @returns {this}
1109
+ */
1110
+ close() {
1111
+ return this.open(!1);
1112
+ }
1113
+ _setClosed(t) {
1114
+ this._closed !== t && (this._closed = t, this._callOnOpenClose(this));
1115
+ }
1116
+ /**
1117
+ * Shows the GUI after it's been hidden.
1118
+ * @param {boolean} show
1119
+ * @returns {this}
1120
+ * @example
1121
+ * gui.show();
1122
+ * gui.show( false ); // hide
1123
+ * gui.show( gui._hidden ); // toggle
1124
+ */
1125
+ show(t = !0) {
1126
+ return this._hidden = !t, this.domElement.style.display = this._hidden ? "none" : "", this;
1127
+ }
1128
+ /**
1129
+ * Hides the GUI.
1130
+ * @returns {this}
1131
+ */
1132
+ hide() {
1133
+ return this.show(!1);
1134
+ }
1135
+ openAnimated(t = !0) {
1136
+ return this._setClosed(!t), this.$title.setAttribute("aria-expanded", !this._closed), requestAnimationFrame(() => {
1137
+ const i = this.$children.clientHeight;
1138
+ this.$children.style.height = i + "px", this.domElement.classList.add("lil-transition");
1139
+ const e = (a) => {
1140
+ a.target === this.$children && (this.$children.style.height = "", this.domElement.classList.remove("lil-transition"), this.$children.removeEventListener("transitionend", e));
1141
+ };
1142
+ this.$children.addEventListener("transitionend", e);
1143
+ const n = t ? this.$children.scrollHeight : 0;
1144
+ this.domElement.classList.toggle("lil-closed", !t), requestAnimationFrame(() => {
1145
+ this.$children.style.height = n + "px";
1146
+ });
1147
+ }), this;
1148
+ }
1149
+ /**
1150
+ * Change the title of this GUI.
1151
+ * @param {string} title
1152
+ * @returns {this}
1153
+ */
1154
+ title(t) {
1155
+ return this._title = t, this.$title.textContent = t, this;
1156
+ }
1157
+ /**
1158
+ * Resets all controllers to their initial values.
1159
+ * @param {boolean} recursive Pass false to exclude folders descending from this GUI.
1160
+ * @returns {this}
1161
+ */
1162
+ reset(t = !0) {
1163
+ return (t ? this.controllersRecursive() : this.controllers).forEach((e) => e.reset()), this;
1164
+ }
1165
+ /**
1166
+ * Pass a function to be called whenever a controller in this GUI changes.
1167
+ * @param {function({object:object, property:string, value:any, controller:Controller})} callback
1168
+ * @returns {this}
1169
+ * @example
1170
+ * gui.onChange( event => {
1171
+ * event.object // object that was modified
1172
+ * event.property // string, name of property
1173
+ * event.value // new value of controller
1174
+ * event.controller // controller that was modified
1175
+ * } );
1176
+ */
1177
+ onChange(t) {
1178
+ return this._onChange = t, this;
1179
+ }
1180
+ _callOnChange(t) {
1181
+ this.parent && this.parent._callOnChange(t), this._onChange !== void 0 && this._onChange.call(this, {
1182
+ object: t.object,
1183
+ property: t.property,
1184
+ value: t.getValue(),
1185
+ controller: t
1186
+ });
1187
+ }
1188
+ /**
1189
+ * Pass a function to be called whenever a controller in this GUI has finished changing.
1190
+ * @param {function({object:object, property:string, value:any, controller:Controller})} callback
1191
+ * @returns {this}
1192
+ * @example
1193
+ * gui.onFinishChange( event => {
1194
+ * event.object // object that was modified
1195
+ * event.property // string, name of property
1196
+ * event.value // new value of controller
1197
+ * event.controller // controller that was modified
1198
+ * } );
1199
+ */
1200
+ onFinishChange(t) {
1201
+ return this._onFinishChange = t, this;
1202
+ }
1203
+ _callOnFinishChange(t) {
1204
+ this.parent && this.parent._callOnFinishChange(t), this._onFinishChange !== void 0 && this._onFinishChange.call(this, {
1205
+ object: t.object,
1206
+ property: t.property,
1207
+ value: t.getValue(),
1208
+ controller: t
1209
+ });
1210
+ }
1211
+ /**
1212
+ * Pass a function to be called when this GUI or its descendants are opened or closed.
1213
+ * @param {function(GUI)} callback
1214
+ * @returns {this}
1215
+ * @example
1216
+ * gui.onOpenClose( changedGUI => {
1217
+ * console.log( changedGUI._closed );
1218
+ * } );
1219
+ */
1220
+ onOpenClose(t) {
1221
+ return this._onOpenClose = t, this;
1222
+ }
1223
+ _callOnOpenClose(t) {
1224
+ this.parent && this.parent._callOnOpenClose(t), this._onOpenClose !== void 0 && this._onOpenClose.call(this, t);
1225
+ }
1226
+ /**
1227
+ * Destroys all DOM elements and event listeners associated with this GUI.
1228
+ */
1229
+ destroy() {
1230
+ this.parent && (this.parent.children.splice(this.parent.children.indexOf(this), 1), this.parent.folders.splice(this.parent.folders.indexOf(this), 1)), this.domElement.parentElement && this.domElement.parentElement.removeChild(this.domElement), Array.from(this.children).forEach((t) => t.destroy());
1231
+ }
1232
+ /**
1233
+ * Returns an array of controllers contained by this GUI and its descendents.
1234
+ * @returns {Controller[]}
1235
+ */
1236
+ controllersRecursive() {
1237
+ let t = Array.from(this.controllers);
1238
+ return this.folders.forEach((i) => {
1239
+ t = t.concat(i.controllersRecursive());
1240
+ }), t;
1241
+ }
1242
+ /**
1243
+ * Returns an array of folders contained by this GUI and its descendents.
1244
+ * @returns {GUI[]}
1245
+ */
1246
+ foldersRecursive() {
1247
+ let t = Array.from(this.folders);
1248
+ return this.folders.forEach((i) => {
1249
+ t = t.concat(i.foldersRecursive());
1250
+ }), t;
1251
+ }
1252
+ }
1253
+ export {
1254
+ L as BooleanController,
1255
+ O as ColorController,
1256
+ u as Controller,
1257
+ $ as FunctionController,
1258
+ A as GUI,
1259
+ H as NumberController,
1260
+ I as OptionController,
1261
+ z as StringController,
1262
+ A as default
1263
+ };