laymur 0.1.43 → 0.1.44
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.
- package/dist/Elements/UIElement.d.ts +1 -1
- package/dist/Elements/UIScene.d.ts +6 -6
- package/dist/Layers/UILayer.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- /package/dist/Miscellaneous/{UIBehavior.d.ts → UIMode.d.ts} +0 -0
|
@@ -4,8 +4,8 @@ import type { WebGLRenderer } from "three";
|
|
|
4
4
|
import { type Object3D } from "three";
|
|
5
5
|
import type { UILayer } from "../Layers/UILayer";
|
|
6
6
|
import { clickSymbol, heightSymbol, needsRecalculation, renderSymbol, widthSymbol, xSymbol, ySymbol } from "../Miscellaneous/symbols";
|
|
7
|
-
import { UIMode } from "../Miscellaneous/UIBehavior";
|
|
8
7
|
import { UIMicro, UIMicroInternal } from "../Miscellaneous/UIMicro";
|
|
8
|
+
import { UIMode } from "../Miscellaneous/UIMode";
|
|
9
9
|
import { UIComposer, UIComposerInternal } from "../Passes/UIComposer";
|
|
10
10
|
export declare enum UIElementEvent {
|
|
11
11
|
CLICK = "click"
|
|
@@ -2,10 +2,10 @@ import type { Camera, WebGLRenderer } from "three";
|
|
|
2
2
|
import { Scene } from "three";
|
|
3
3
|
import type { UILayer } from "../Layers/UILayer";
|
|
4
4
|
import { UIElement } from "./UIElement";
|
|
5
|
-
export declare enum
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
MANUAL = "
|
|
5
|
+
export declare enum UISceneUpdateMode {
|
|
6
|
+
ALWAYS = "always",
|
|
7
|
+
PROPERTY_CHANGED = "property_changed",
|
|
8
|
+
MANUAL = "manual"
|
|
9
9
|
}
|
|
10
10
|
export interface UISceneOptions {
|
|
11
11
|
scene: Scene;
|
|
@@ -17,7 +17,7 @@ export interface UISceneOptions {
|
|
|
17
17
|
useDepth: boolean;
|
|
18
18
|
clearColor: number;
|
|
19
19
|
clearAlpha: number;
|
|
20
|
-
updateBehavior:
|
|
20
|
+
updateBehavior: UISceneUpdateMode;
|
|
21
21
|
}
|
|
22
22
|
export declare class UIScene extends UIElement {
|
|
23
23
|
private readonly material;
|
|
@@ -25,7 +25,7 @@ export declare class UIScene extends UIElement {
|
|
|
25
25
|
private clearColorInternal;
|
|
26
26
|
private clearAlphaInternal;
|
|
27
27
|
private needsRenderInternal;
|
|
28
|
-
private readonly
|
|
28
|
+
private readonly updateModeInternal;
|
|
29
29
|
private resolutionFactorInternal;
|
|
30
30
|
private sceneInternal;
|
|
31
31
|
private cameraInternal;
|
package/dist/Layers/UILayer.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { OrthographicCamera, Scene } from "three";
|
|
|
5
5
|
import type { UIConstraint } from "../Constraints/UIConstraint";
|
|
6
6
|
import { UIElement } from "../Elements/UIElement";
|
|
7
7
|
import { addConstraintSymbol, addUIConstraintSymbol, addUIElementSymbol, addVariableSymbol, heightSymbol, removeConstraintSymbol, removeUIConstraintSymbol, removeUIElementSymbol, removeVariableSymbol, suggestVariableSymbol, widthSymbol, xSymbol, ySymbol } from "../Miscellaneous/symbols";
|
|
8
|
-
import { UIMode } from "../Miscellaneous/
|
|
8
|
+
import { UIMode } from "../Miscellaneous/UIMode";
|
|
9
9
|
import { UIOrientation } from "../Miscellaneous/UIOrientation";
|
|
10
10
|
interface VariableDescription {
|
|
11
11
|
strength: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export * from "./Elements/UIText";
|
|
|
23
23
|
export * from "./Layers/UIFullScreenLayer";
|
|
24
24
|
export * from "./Layers/UILayer";
|
|
25
25
|
export * from "./Layers/UIManualLayer";
|
|
26
|
-
export * from "./Miscellaneous/
|
|
26
|
+
export * from "./Miscellaneous/UIMode";
|
|
27
27
|
export { UIOrientation } from "./Miscellaneous/UIOrientation";
|
|
28
28
|
export * from "./Passes/UIFullScreenQuad";
|
|
29
29
|
export * from "./Passes/UIPass";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{Vector2 as t,Box2 as i,Matrix3 as s,Vector3 as n,MathUtils as o,ShaderMaterial as r,Color as e,PlaneGeometry as h,Scene as l,Mesh as u,OrthographicCamera as a,WebGLRenderTarget as d,UnsignedByteType as c,LinearFilter as v,RGBAFormat as f,NoBlending as w,Object3D as p,UniformsUtils as g,CanvasTexture as m,Texture as y,PerspectiveCamera as b}from"three";function x(){return new C}var C=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new S(t,i());return this.index[t.id()]=this.array.length,this.array.push(n),n}return this.array[s]},t.prototype.insert=function(t,i){var s=new S(t,i),n=this.index[t.id()];return void 0===n?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[n]=s,s},t.prototype.erase=function(t){var i=this.index[t.id()];if(void 0!==i){this.index[t.id()]=void 0;var s=this.array[i],n=this.array.pop();return s!==n&&(this.array[i]=n,this.index[n.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;s<this.array.length;s++){var n=this.array[s].copy();i.array[s]=n,i.index[n.first.id()]=s}return i},t}(),S=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),E=function(){function t(t){void 0===t&&(t=""),this.t=0,this.i=null,this.o=k++,this.h=t}return t.prototype.id=function(){return this.o},t.prototype.name=function(){return this.h},t.prototype.setName=function(t){this.h=t},t.prototype.context=function(){return this.i},t.prototype.setContext=function(t){this.i=t},t.prototype.value=function(){return this.t},t.prototype.setValue=function(t){this.t=t},t.prototype.plus=function(t){return new O(this,t)},t.prototype.minus=function(t){return new O(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new O([t,this])},t.prototype.divide=function(t){return new O([1/t,this])},t.prototype.toJSON=function(){return{name:this.h,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.h+":"+this.t+"]"},t}(),k=0,O=function(){function t(){var t=T(arguments);this.l=t.terms,this.u=t.constant}return t.prototype.terms=function(){return this.l},t.prototype.constant=function(){return this.u},t.prototype.value=function(){for(var t=this.u,i=0,s=this.l.size();i<s;i++){var n=this.l.itemAt(i);t+=n.first.value()*n.second}return t},t.prototype.plus=function(i){return new t(this,i)},t.prototype.minus=function(i){return new t(this,"number"==typeof i?-i:[-1,i])},t.prototype.multiply=function(i){return new t([i,this])},t.prototype.divide=function(i){return new t([1/i,this])},t.prototype.isConstant=function(){return 0==this.l.size()},t.prototype.toString=function(){var t=this.l.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.u||(t+=" + "),t+this.u},t}();function T(t){for(var i=0,s=()=>0,n=x(),o=0,r=t.length;o<r;++o){var e=t[o];if("number"==typeof e)i+=e;else if(e instanceof E)n.setDefault(e,s).second+=1;else if(e instanceof O){i+=e.constant();for(var h=0,l=(c=e.terms()).size();h<l;h++){var u=c.itemAt(h);n.setDefault(u.first,s).second+=u.second}}else{if(!(e instanceof Array))throw Error("invalid Expression argument: "+e);if(2!==e.length)throw Error("array must have length 2");var a=e[0],d=e[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof E)n.setDefault(d,s).second+=a;else{if(!(d instanceof O))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,h=0,l=(c=d.terms()).size();h<l;h++)u=c.itemAt(h),n.setDefault(u.first,s).second+=u.second*a}}}return{terms:n,constant:i}}var M,P=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var o=0;return o+=1e6*Math.max(0,Math.min(1e3,t*n)),(o+=1e3*Math.max(0,Math.min(1e3,i*n)))+Math.max(0,Math.min(1e3,s*n))},t.clip=i=>Math.max(0,Math.min(t.required,i)),t.required=t.create(1e3,1e3,1e3),t.strong=t.create(1,0,0),t.medium=t.create(0,1,0),t.weak=t.create(0,0,1),t})();(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(M||(M={}));var I,$=function(){function t(t,i,s,n){void 0===n&&(n=P.required),this.o=A++,this.v=i,this.p=P.clip(n),this.m=void 0===s&&t instanceof O?t:t.minus(s)}return t.prototype.id=function(){return this.o},t.prototype.expression=function(){return this.m},t.prototype.op=function(){return this.v},t.prototype.strength=function(){return this.p},t.prototype.toString=function(){return this.m+" "+["<=",">=","="][this.v]+" 0 ("+this.p+")"},t}(),A=0,D=function(){function t(){this.C=x(),this.S=x(),this.k=x(),this.O=x(),this.T=[],this.M=new j,this.P=null,this.I=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=P.required);var o=new $(t,i,s,n);return this.addConstraint(o),o},t.prototype.addConstraint=function(t){if(void 0!==this.C.find(t))throw Error("duplicate constraint");var i=this.$(t),s=i.row,n=i.tag,o=this.A(s,n);if(o.type()===I.Invalid&&s.allDummies()){if(!z(s.constant()))throw Error("unsatisfiable constraint");o=n.marker}if(o.type()===I.Invalid){if(!this.D(s))throw Error("unsatisfiable constraint")}else s.solveFor(o),this.F(o,s),this.S.insert(o,s);this.C.insert(t,n),this.U(this.M)},t.prototype.removeConstraint=function(t){var i=this.C.erase(t);if(void 0===i)throw Error("unknown constraint");this.j(t,i.second);var s=i.second.marker,n=this.S.erase(s);if(void 0===n){var o=this.B(s);if(o.type()===I.Invalid)throw Error("failed to find leaving row");(n=this.S.erase(o)).second.solveForEx(o,s),this.F(s,n.second)}this.U(this.M)},t.prototype.hasConstraint=function(t){return this.C.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.O.find(t))throw Error("duplicate edit variable");if((i=P.clip(i))===P.required)throw Error("bad required strength");var s=new O(t),n=new $(s,M.Eq,void 0,i);this.addConstraint(n);var o=this.C.find(n).second;this.O.insert(t,{tag:o,constraint:n,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.O.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.O.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.O.find(t);if(void 0===s)throw Error("unknown edit variable");var n=this.S,o=s.second,r=i-o.constant;o.constant=i;var e=o.tag.marker,h=n.find(e);if(void 0!==h)return h.second.add(-r)<0&&this.T.push(e),void this.H();var l=o.tag.other;if(void 0!==(h=n.find(l)))return h.second.add(r)<0&&this.T.push(l),void this.H();for(var u=0,a=n.size();u<a;++u){var d=n.itemAt(u),c=d.second,v=c.coefficientFor(e);0!==v&&c.add(r*v)<0&&d.first.type()!==I.External&&this.T.push(d.first)}this.H()},t.prototype.updateVariables=function(){for(var t=this.k,i=this.S,s=0,n=t.size();s<n;++s){var o=t.itemAt(s),r=i.find(o.second);o.first.setValue(void 0!==r?r.second.constant():0)}},t.prototype.V=function(t){var i=this;return this.k.setDefault(t,(()=>i.R(I.External))).second},t.prototype.$=function(t){for(var i=t.expression(),s=new j(i.constant()),n=i.terms(),o=0,r=n.size();o<r;++o){var e=n.itemAt(o);if(!z(e.second)){var h=this.V(e.first),l=this.S.find(h);void 0!==l?s.insertRow(l.second,e.second):s.insertSymbol(h,e.second)}}var u=this.M,a=t.strength(),d={marker:U,other:U};switch(t.op()){case M.Le:case M.Ge:var c=t.op()===M.Le?1:-1,v=this.R(I.Slack);if(d.marker=v,s.insertSymbol(v,c),a<P.required){var f=this.R(I.Error);d.other=f,s.insertSymbol(f,-c),u.insertSymbol(f,a)}break;case M.Eq:if(a<P.required){var w=this.R(I.Error),p=this.R(I.Error);d.marker=w,d.other=p,s.insertSymbol(w,-1),s.insertSymbol(p,1),u.insertSymbol(w,a),u.insertSymbol(p,a)}else{var g=this.R(I.Dummy);d.marker=g,s.insertSymbol(g)}}return s.constant()<0&&s.reverseSign(),{row:s,tag:d}},t.prototype.A=(t,i)=>{for(var s=t.cells(),n=0,o=s.size();n<o;++n){var r=s.itemAt(n);if(r.first.type()===I.External)return r.first}var e=i.marker.type();return(e===I.Slack||e===I.Error)&&t.coefficientFor(i.marker)<0?i.marker:((e=i.other.type())===I.Slack||e===I.Error)&&t.coefficientFor(i.other)<0?i.other:U},t.prototype.D=function(t){var i=this.R(I.Slack);this.S.insert(i,t.copy()),this.P=t.copy(),this.U(this.P);var s=z(this.P.constant());this.P=null;var n=this.S.erase(i);if(void 0!==n){var o=n.second;if(o.isConstant())return s;var r=this.L(o);if(r.type()===I.Invalid)return 0;o.solveForEx(i,r),this.F(r,o),this.S.insert(r,o)}for(var e=this.S,h=0,l=e.size();h<l;++h)e.itemAt(h).second.removeSymbol(i);return this.M.removeSymbol(i),s},t.prototype.F=function(t,i){for(var s=this.S,n=0,o=s.size();n<o;++n){var r=s.itemAt(n);r.second.substitute(t,i),r.second.constant()<0&&r.first.type()!==I.External&&this.T.push(r.first)}this.M.substitute(t,i),this.P&&this.P.substitute(t,i)},t.prototype.U=function(t){for(;;){var i=this.K(t);if(i.type()===I.Invalid)return;var s=this._(i);if(s.type()===I.Invalid)throw Error("the objective is unbounded");var n=this.S.erase(s).second;n.solveForEx(s,i),this.F(i,n),this.S.insert(i,n)}},t.prototype.H=function(){for(var t=this.S,i=this.T;0!==i.length;){var s=i.pop(),n=t.find(s);if(void 0!==n&&n.second.constant()<0){var o=this.N(n.second);if(o.type()===I.Invalid)throw Error("dual optimize failed");var r=n.second;t.erase(s),r.solveForEx(s,o),this.F(o,r),t.insert(o,r)}}},t.prototype.K=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var o=i.itemAt(s),r=o.first;if(o.second<0&&r.type()!==I.Dummy)return r}return U},t.prototype.N=function(t){for(var i=Number.MAX_VALUE,s=U,n=t.cells(),o=0,r=n.size();o<r;++o){var e=n.itemAt(o),h=e.first,l=e.second;if(l>0&&h.type()!==I.Dummy){var u=this.M.coefficientFor(h)/l;u<i&&(i=u,s=h)}}return s},t.prototype._=function(t){for(var i=Number.MAX_VALUE,s=U,n=this.S,o=0,r=n.size();o<r;++o){var e=n.itemAt(o),h=e.first;if(h.type()!==I.External){var l=e.second,u=l.coefficientFor(t);if(u<0){var a=-l.constant()/u;a<i&&(i=a,s=h)}}}return s},t.prototype.B=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,o=U,r=o,e=o,h=o,l=this.S,u=0,a=l.size();u<a;++u){var d=l.itemAt(u),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===I.External)h=f;else if(v<0)(w=-c.constant()/v)<s&&(s=w,r=f);else{var w;(w=c.constant()/v)<n&&(n=w,e=f)}}}return r!==o?r:e!==o?e:h},t.prototype.j=function(t,i){i.marker.type()===I.Error&&this.X(i.marker,t.strength()),i.other.type()===I.Error&&this.X(i.other,t.strength())},t.prototype.X=function(t,i){var s=this.S.find(t);void 0!==s?this.M.insertRow(s.second,-i):this.M.insertSymbol(t,-i)},t.prototype.L=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var o=i.itemAt(s),r=o.first.type();if(r===I.Slack||r===I.Error)return o.first}return U},t.prototype.R=function(t){return new F(t,this.I++)},t}();function z(t){return t<0?-t<1e-8:t<1e-8}(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(I||(I={}));var F=function(){function t(t,i){this.o=i,this.Y=t}return t.prototype.id=function(){return this.o},t.prototype.type=function(){return this.Y},t}(),U=new F(I.Invalid,-1),j=function(){function t(t){void 0===t&&(t=0),this.q=x(),this.u=t}return t.prototype.cells=function(){return this.q},t.prototype.constant=function(){return this.u},t.prototype.isConstant=function(){return this.q.empty()},t.prototype.allDummies=function(){for(var t=this.q,i=0,s=t.size();i<s;++i)if(t.itemAt(i).first.type()!==I.Dummy)return 0;return 1},t.prototype.copy=function(){var i=new t(this.u);return i.q=this.q.copy(),i},t.prototype.add=function(t){return this.u+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),z(this.q.setDefault(t,(()=>0)).second+=i)&&this.q.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.u+=t.u*i;for(var s=t.q,n=0,o=s.size();n<o;++n){var r=s.itemAt(n);this.insertSymbol(r.first,r.second*i)}},t.prototype.removeSymbol=function(t){this.q.erase(t)},t.prototype.reverseSign=function(){this.u=-this.u;for(var t=this.q,i=0,s=t.size();i<s;++i){var n=t.itemAt(i);n.second=-n.second}},t.prototype.solveFor=function(t){var i=this.q,s=-1/i.erase(t).second;this.u*=s;for(var n=0,o=i.size();n<o;++n)i.itemAt(n).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.q.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.q.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const B=Symbol("xSymbol"),H=Symbol("ySymbol"),V=Symbol("widthSymbol"),R=Symbol("heightSymbol"),L=Symbol("addUIElementSymbol"),K=Symbol("removeUIElementSymbol"),_=Symbol("addConstraintSymbol"),N=Symbol("removeUIConstraintSymbol"),X=Symbol("addConstraintSymbol"),Y=Symbol("removeConstraintSymbol"),q=Symbol("addVariableSymbol"),W=Symbol("removeVariableSymbol"),G=Symbol("suggestVariableSymbol"),Q=Symbol("disableConstraintSymbol"),J=Symbol("enableConstraintSymbol"),Z=Symbol("needsRecalculation"),tt=Symbol("renderSymbol"),it=Symbol("clickSymbol");var st;function nt(t){return null!==t&&Object.values(st).some((i=>i===t))}function ot(t){return null!=t?t:st.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(st||(st={}));class rt{constructor(t,i){this.layer=t,this.name="",this.layer[_](this,i)}destroy(){this.layer[N](this)}}const et=1e3;var ht,lt;function ut(t){return null!==t&&Object.values(ht).some((i=>i===t))}function at(t){return null!=t?t:ht.P0}function dt(t){switch(t){case ht.P0:return P.create(et,et,et);case ht.P1:return P.create(100,0,0);case ht.P2:return P.create(10,0,0);case ht.P3:return P.create(0,100,0);case ht.P4:return P.create(0,10,0);case ht.P5:return P.create(0,0,100);case ht.P6:return P.create(0,0,10);case ht.P7:return P.create(0,0,1);default:return P.create(et,et,et)}}function ct(t){return null!==t&&Object.values(lt).some((i=>i===t))}function vt(t){return null!=t?t:lt.EQUAL}function ft(t){switch(t){case lt.EQUAL:return M.Eq;case lt.LESS:return M.Le;case lt.GREATER:return M.Ge;default:return M.Eq}}(t=>{t[t.P0=0]="P0",t[t.P1=1]="P1",t[t.P2=2]="P2",t[t.P3=3]="P3",t[t.P4=4]="P4",t[t.P5=5]="P5",t[t.P6=6]="P6",t[t.P7=7]="P7"})(ht||(ht={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(lt||(lt={}));class wt extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={height:null!==(s=null==i?void 0:i.height)&&void 0!==s?s:t.height,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new $(new O(this.element[R]),ft(this.options.rule),this.options.height,dt(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class pt{constructor(){this.listeners=new Map}on(t,i,s,n=100){return this.addListener(t,i,s,n,0),this}once(t,i,s,n=100){return this.addListener(t,i,s,n,1),this}off(t,i,s){const n=this.listeners.get(t);if(!n)return this;if(!i)return this.listeners.delete(t),this;const o=n.filter((t=>t.callback!==i||void 0!==s&&t.context!==s));return o.length?this.listeners.set(t,o):this.listeners.delete(t),this}emit(t,...i){const s=this.listeners.get(t);if(!(null==s?void 0:s.length))return 0;for(const n of[...s])n.callback.apply(n.context,i),n.once&&this.off(t,n.callback,n.context);return 1}addListener(t,i,s,n,o){let r=this.listeners.get(t);if(r||(r=[],this.listeners.set(t,r)),r.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const e={callback:i,context:s,priority:n,once:o};let h=0;for(;h<r.length&&r[h].priority<=n;)h++;r.splice(h,0,e)}}const gt=new t,mt=new i,yt=new s,bt=new s,xt=new s,Ct=new s,St=new s,Et=new n;var kt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(kt||(kt={}));const Ot=.5;class Tt{constructor(){this.x=0,this.y=0,this.anchorX=Ot,this.anchorY=Ot,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Mt{constructor(t,i){this.raw=t,this.owner=i}get x(){return this.raw.x}get y(){return this.raw.y}get anchorX(){return this.raw.anchorX}get anchorY(){return this.raw.anchorY}get scaleX(){return this.raw.scaleX}get scaleY(){return this.raw.scaleY}get angle(){return o.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=1)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=1)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=1)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=1)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=1)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=1)}set angle(t){const i=o.degToRad(t);i!==this.raw.rotation&&(this.raw.rotation=i,this.raw.needsRecalculation=1)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=1)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=1)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===Ot&&this.raw.anchorY===Ot&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Ot,this.raw.anchorY=Ot,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}class Pt extends r{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new e(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:1,lights:0,fog:0})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}setTexture(t){this.uniforms.map.value=t,this.uniformsNeedUpdate=1}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=1}}const It=new h(1,1).translate(.5,.5,0),$t=new l,At=new u(It);$t.add(At);class Dt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new a(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){At.material=i,t.render($t,this.camera)}updateCameraTransform(){this.camera.left=-this.paddingHorizontalInternal,this.camera.right=1+this.paddingHorizontalInternal,this.camera.bottom=-this.paddingVerticalInternal,this.camera.top=1+this.paddingVerticalInternal,this.camera.updateProjectionMatrix()}}class zt{constructor(){this.passes=[],this.defaultMaterial=new Pt,this.screen=new Dt,this.needsUpdateInternal=0,this.paddingHasChangedInternal=0,this.paddingInternal=0;const t={format:f,minFilter:v,magFilter:v,type:c,depthBuffer:0,stencilBuffer:0};this.fromRenderTarget=new d(1,1,t),this.toRenderTarget=new d(1,1,t),this.fromRenderTarget.texture.generateMipmaps=0,this.toRenderTarget.texture.generateMipmaps=0}get needsUpdate(){return this.needsUpdateInternal&&this.hasValuablePasses()||this.hasPassesNeedingUpdate()}get paddingHasChanged(){return this.paddingHasChangedInternal}get padding(){return this.paddingInternal}requestUpdate(){this.needsUpdateInternal=1}compose(t,i,s,n,o=1){const r=this.hasValuablePasses();if(!(this.needsUpdateInternal&&r||this.hasPassesNeedingUpdate()))return r||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,r?this.defaultMaterial:n;const e=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==e,this.paddingInternal=e;const h=i+2*e,l=s+2*e;this.fromRenderTarget.setSize(h,l),this.toRenderTarget.setSize(h,l),this.setScreenPadding(i,s,e),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0);const u=n.blending;o&&(n.blending=w),this.screen.render(t,n),n.blending=u;const a={width:i,height:s,padding:e};for(let i=0;i<this.passes.length;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.reverseRenderTargets(),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0),this.passes[i].render(t,this.fromRenderTarget.texture,a))}return this.needsUpdateInternal=0,this.defaultMaterial.setTexture(this.toRenderTarget.texture),this.defaultMaterial}destroy(){this.fromRenderTarget.dispose(),this.toRenderTarget.dispose()}hasValuablePasses(){return this.passes.some((t=>t.isValuable))}hasPassesNeedingUpdate(){return this.passes.some((t=>t.needsUpdate))}calculatePadding(){return this.passes.reduce(((t,i)=>Math.max(t,i.padding)),0)}setScreenPadding(t,i,s){this.screen.paddingHorizontal=s/t,this.screen.paddingVertical=s/i}reverseRenderTargets(){const t=this.fromRenderTarget;this.fromRenderTarget=this.toRenderTarget,this.toRenderTarget=t}}class Ft{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var Ut,jt,Bt,Ht,Vt,Rt,Lt,Kt,_t,Nt;(t=>{t.CLICK="click"})(Rt||(Rt={}));class Xt extends pt{constructor(t,i,s,n,r,e){super(),this.layer=t,this.object=i,this[Ut]=new E("x"),this[jt]=new E("y"),this[Bt]=new E("width"),this[Ht]=new E("height"),this[Vt]=0,this.name=o.generateUUID(),this.microInternal=new Tt,this.composerInternal=new zt,this.modeInternal=kt.VISIBLE,this.micro=new Mt(this.microInternal,this),this.composer=new Ft(this.composerInternal),this.layer[L](this,this.object),this.layer[q](this,this[B],dt(ht.P7)),this.layer[q](this,this[H],dt(ht.P7)),this.layer[q](this,this[V],dt(ht.P5)),this.layer[q](this,this[R],dt(ht.P5)),this[B].setValue(s),this[H].setValue(n),this[V].setValue(r),this[R].setValue(e),this.layer[G](this,this[B],s),this.layer[G](this,this[H],n),this.layer[G](this,this[V],r),this.layer[G](this,this[R],e)}get x(){return this[B].value()}get y(){return this[H].value()}get width(){return this[V].value()}get height(){return this[R].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[Z]}set x(t){this.layer[G](this,this[B],t)}set y(t){this.layer[G](this,this[H],t)}set width(t){this.layer[G](this,this[V],t)}set height(t){this.layer[G](this,this[R],t)}set zIndex(t){this.object.position.z=t}set mode(t){this.modeInternal=t,this.object.visible=t!==kt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[W](this,this[R]),this.layer[W](this,this[V]),this.layer[W](this,this[H]),this.layer[W](this,this[B]),this.layer[K](this)}[(Ut=B,jt=H,Bt=V,Ht=R,Vt=Z,tt)](t,i){this.render(t,i)}[it](t,i){return this.click(t,i)}applyTransformations(){(this[Z]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,o,r,e)=>{const h=this.x-e,l=this.y-e,u=this.width+2*e,a=this.height+2*e,d=h+u*i.anchorX,c=l+a*i.anchorY,v=yt.set(1,0,-d,0,1,-c,0,0,1),f=bt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=xt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),p=Ct.set(1,0,i.x+d,0,1,i.y+c,0,0,1),g=St.multiplyMatrices(p,w).multiply(f).multiply(v),m=Et.set(h,l,1).applyMatrix3(g);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=u*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this[Z]=0,this.microInternal.needsRecalculation=0)}click(t,i){return this.mode!==kt.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,o=this.width,r=this.height,gt.set(t,i),mt.min.set(s,n),mt.max.set(o,r).add(mt.min),mt.containsPoint(gt)?(this.emit(Rt.CLICK,this),1):0);var s,n,o,r}}const Yt=new e(0);var qt,Wt,Gt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(qt||(qt={}));class Qt extends pt{constructor(){super(...arguments),this.mode=kt.VISIBLE,this[Lt]=new E,this[Kt]=new E,this[_t]=new E,this[Nt]=new E,this.scene=new l,this.camera=new a,this.solver=new D,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=st.PORTRAIT,this.needsRecalculation=0}get orientation(){return this.orientationPrivate}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Lt=B,Kt=H,_t=V,Nt=R,L)](t,i){if(this.elements.has(t))throw Error("Element already added");this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i.position.z=500,this.scene.add(i)}[K](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),this.scene.remove(i.object)}[_](t,i){if(this.constraints.has(t))throw Error("Constraint already added");for(const s of i){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(i.constraints.has(t))throw Error("Something went wrong");i.constraints.add(t)}this.constraints.set(t,{elements:i,variables:new Map,constraints:new Set})}[N](t){const i=this.constraints.get(t);if(void 0===i)throw Error("Constraint not found");if(i.variables.size>0)throw Error("Variables should be removed before removing constraint");if(i.constraints.size>0)throw Error("Constraints should be removed before removing constraint");for(const s of i.elements){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(!i.constraints.has(t))throw Error("Something went wrong");i.constraints.delete(t)}this.constraints.delete(t)}[X](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before adding constraint you need to add it's owner");if(n.constraints.has(i))throw Error("Constraint already exists");n.constraints.add(i),null===(s=this.solver)||void 0===s||s.addConstraint(i),this.needsRecalculation=1}[Y](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before removing constraint you need to add it's owner");if(!n.constraints.has(i))throw Error("Constraint not found");n.constraints.delete(i),null===(s=this.solver)||void 0===s||s.removeConstraint(i),this.needsRecalculation=1}[q](t,i,s){var n;const o=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===o)throw Error("Before adding variable you need to add it's owner");if(o.variables.has(i))throw Error("Variable already exists");o.variables.set(i,{strength:s,suggestedValue:i.value()}),null===(n=this.solver)||void 0===n||n.addEditVariable(i,s),this.needsRecalculation=1}[W](t,i){var s;const n=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i),null===(s=this.solver)||void 0===s||s.removeEditVariable(i),this.needsRecalculation=1}[G](t,i,s){var n;const o=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===o)throw Error("Before suggesting variable you need to add it's owner");const r=o.variables.get(i);if(!r)throw Error("Variable does not exist");r.suggestedValue!==s&&(r.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===kt.HIDDEN)return;const n=t.getRenderTarget(),o=t.getClearColor(Yt),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=0,null===(s=this.solver)||void 0===s||s.updateVariables();for(const t of this.elements.keys())t[Z]=1}for(const s of this.elements.keys())s[tt](t,i);t.setRenderTarget(n),t.setClearColor(o),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==kt.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t.mode===kt.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[it](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=1}applyCameraSize(t,i){this.camera.near=-1e3,this.camera.far=0,this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){var s,n,o,r,e,h,l,u;this.constraintX&&(null===(s=this.solver)||void 0===s||s.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(null===(n=this.solver)||void 0===n||n.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(null===(o=this.solver)||void 0===o||o.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new $(new O(this[B]),M.Eq,0,P.required),this.constraintY=new $(new O(this[H]),M.Eq,0,P.required),this.constraintW=new $(new O(this[V]),M.Eq,t,P.required),this.constraintH=new $(new O(this[R]),M.Eq,i,P.required),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintX),null===(h=this.solver)||void 0===h||h.addConstraint(this.constraintY),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintW),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?st.LANDSCAPE:st.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[J](this.orientationPrivate);for(const t of this.constraints.keys())t[Q](this.orientationPrivate);this.solver=new D;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i);this.emit(qt.ORIENTATION_CHANGED,this,this.orientation)}}}function Jt(t,i){if((t instanceof Qt?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function Zt(t,i,s){if(t<=0||i<=0)throw Error(null!=s?s:`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class ti extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(o=null==s?void 0:s.anchorTwo)&&void 0!==o?o:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[B]).plus(new O(this.elementOne[V]).multiply(this.parameters.anchorOne)),i=new O(this.elementTwo[B]).plus(new O(this.elementTwo[V]).multiply(this.parameters.anchorTwo));this.constraint=new $(i.minus(t),ft(this.parameters.rule),this.parameters.distance,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ii extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[V]).multiply(this.parameters.proportion),i=new O(this.elementTwo[V]);this.constraint=new $(t.minus(i),ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class si extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(o=null==s?void 0:s.anchorTwo)&&void 0!==o?o:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.anchorOne)),i=new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.anchorTwo));this.constraint=new $(i.minus(t),ft(this.parameters.rule),this.parameters.distance,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ni extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[R]).multiply(this.parameters.proportion),i=new O(this.elementTwo[R]);this.constraint=new $(t.minus(i),ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class oi extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={width:null!==(s=null==i?void 0:i.width)&&void 0!==s?s:t.width,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new $(new O(this.element[V]),ft(this.options.rule),this.options.width,dt(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ri{static size(t,i){var s,n,o,r,e,h,l,u;return{x:new oi(t,{width:null===(s=i.size)||void 0===s?void 0:s.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(o=i.rule)||void 0===o?void 0:o.x,orientation:null===(r=i.orientation)||void 0===r?void 0:r.x}),y:new wt(t,{height:null===(e=i.size)||void 0===e?void 0:e.y,power:null===(h=i.power)||void 0===h?void 0:h.y,rule:null===(l=i.rule)||void 0===l?void 0:l.y,orientation:null===(u=i.orientation)||void 0===u?void 0:u.y})}}static distance(t,i,s){var n,o,r,e,h,l,u,a,d,c,v,f;return{x:new ti(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(o=s.anchorTwo)||void 0===o?void 0:o.x,distance:null===(r=s.distance)||void 0===r?void 0:r.x,power:null===(e=s.power)||void 0===e?void 0:e.x,rule:null===(h=s.rule)||void 0===h?void 0:h.x,orientation:null===(l=s.orientation)||void 0===l?void 0:l.x}),y:new si(t,i,{anchorOne:null===(u=s.anchorOne)||void 0===u?void 0:u.y,anchorTwo:null===(a=s.anchorTwo)||void 0===a?void 0:a.y,distance:null===(d=s.distance)||void 0===d?void 0:d.y,power:null===(c=s.power)||void 0===c?void 0:c.y,rule:null===(v=s.rule)||void 0===v?void 0:v.y,orientation:null===(f=s.orientation)||void 0===f?void 0:f.y})}}static proportion(t,i,s){var n,o,r,e,h,l,u,a;return{x:new ii(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(r=s.rule)||void 0===r?void 0:r.x,orientation:null===(e=s.orientation)||void 0===e?void 0:e.x}),y:new ni(t,i,{proportion:null===(h=s.proportion)||void 0===h?void 0:h.y,power:null===(l=s.power)||void 0===l?void 0:l.y,rule:null===(u=s.rule)||void 0===u?void 0:u.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}class ei extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.element[V]).plus(new O(this.element[R]).multiply(-this.parameters.aspect));this.constraint=new $(t,ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class hi extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(o=null==s?void 0:s.horizontalAnchor)&&void 0!==o?o:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new $(new O(this.elementOne[B]).plus(new O(this.elementOne[V]).multiply(this.parameters.horizontalAnchor)),M.Eq,new O(this.elementTwo[B]).plus(new O(this.elementTwo[V]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new $(new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new $(new O(this.elementOne[V]),M.Le,new O(this.elementTwo[V])),this.constraintH=new $(new O(this.elementOne[R]),M.Le,new O(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),this.parameters.isStrict||(this.constraintStrict=new $(new O(this.elementOne[R]),M.Eq,new O(this.elementTwo[R]),P.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[Y](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[Y](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[Y](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[Y](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[Y](this,this.constraintStrict),this.constraintStrict=void 0)}}function li(t){return null!==t&&"object"==typeof t&&("x"in t&&"number"==typeof t.x||"y"in t&&"number"==typeof t.y)}function ui(t){return null!==t&&"object"==typeof t&&("x"in t&&ut(t.x)||"y"in t&&ut(t.y))}function ai(t){return null!==t&&"object"==typeof t&&("x"in t&&ct(t.x)||"y"in t&&ct(t.y))}function di(t){return null!==t&&"object"==typeof t&&"elementOne"in t&&"elementTwo"in t&&(t.elementOne instanceof Xt||t.elementOne instanceof Qt)&&t.elementTwo instanceof Xt}function ci(t){return di(t)&&"distance"in t&&li(t.distance)&&(!("anchorOne"in t)||"anchorOne"in t&&li(t.anchorOne))&&(!("anchorTwo"in t)||"anchorTwo"in t&&li(t.anchorTwo))&&(!("power"in t)||ui(t.power))&&(!("rule"in t)||ai(t.rule))&&(!("orientation"in t)||nt(t.orientation))}function vi(t){return di(t)&&"proportion"in t&&li(t.proportion)&&(!("power"in t)||ui(t.power))&&(!("rule"in t)||ai(t.rule))&&(!("orientation"in t)||nt(t.orientation))}function fi(t){return di(t)&&"isStrict"in t&&"boolean"==typeof t.isStrict&&(!("anchor"in t)||"anchor"in t&&li(t.anchor))}function wi(t){return null!==t&&"object"==typeof t&&"element"in t&&t.element instanceof Xt&&(!("power"in t)||ut(t.power))&&(!("rule"in t)||ct(t.rule))}function pi(t){return wi(t)&&"height"in t&&"number"==typeof t.height}function gi(t){return wi(t)&&"keepAspect"in t&&"boolean"==typeof t.keepAspect}function mi(t){return wi(t)&&"keepSize"in t&&"boolean"==typeof t.keepSize}class yi{static fromDescription(t){const i=t instanceof Map?t.entries():Object.entries(t),s=new Map;for(const[t,o]of i){if(s.has(t))throw Error(`Duplicate constraint key "${t}" - each constraint must have a unique identifier`);if(wi(n=o)&&"width"in n&&"number"==typeof n.width)yi.buildWidthConstraint(t,o,s);else if(pi(o))yi.buildHeightConstraint(t,o,s);else if(gi(o))yi.buildKeepAspectConstraint(t,o,s);else if(mi(o))yi.buildKeepSizeConstraint(t,o,s);else if(ci(o))yi.buildDistanceConstraint(t,o,s);else if(vi(o))yi.buildProportionalConstraint(t,o,s);else{if(!fi(o))throw Error(`Invalid constraint type for "${t}". Expected one of: Width, Height, KeepAspect, KeepSize, Distance, Proportional, or Cover constraint`);yi.buildCoverConstraint(t,o,s)}}var n;return Object.fromEntries(s)}static buildWidthConstraint(t,i,s){s.set(t,new oi(i.element,{width:i.width,power:i.power,rule:i.rule,orientation:i.orientation}))}static buildHeightConstraint(t,i,s){s.set(t,new wt(i.element,{height:i.height,power:i.power,rule:i.rule,orientation:i.orientation}))}static buildKeepAspectConstraint(t,i,s){s.set(t,new ei(i.element,{power:i.power,rule:i.rule,orientation:i.orientation}))}static buildKeepSizeConstraint(t,i,s){const n=t.replace(/(KeepSize|Keep)$/,"")+"KeepWidth",o=t.replace(/(KeepSize|Keep)$/,"")+"KeepHeight";s.set(n,new oi(i.element,{power:i.power,rule:i.rule,orientation:i.orientation})),s.set(o,new wt(i.element,{power:i.power,rule:i.rule,orientation:i.orientation}))}static buildDistanceConstraint(t,i,s){var n,o,r,e,h,l,u,a;if("number"==typeof i.distance.x){const h=t.replace(/(HorizontalDistance|Distance)$/,"")+"HorizontalDistance";s.set(h,new ti(i.elementOne,i.elementTwo,{distance:i.distance.x,anchorOne:null===(n=i.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(o=i.anchorTwo)||void 0===o?void 0:o.x,power:null===(r=i.power)||void 0===r?void 0:r.x,rule:null===(e=i.rule)||void 0===e?void 0:e.x,orientation:i.orientation}))}if("number"==typeof i.distance.y){const n=t.replace(/(VerticalDistance|Distance)$/,"")+"VerticalDistance";s.set(n,new si(i.elementOne,i.elementTwo,{distance:i.distance.y,anchorOne:null===(h=i.anchorOne)||void 0===h?void 0:h.y,anchorTwo:null===(l=i.anchorTwo)||void 0===l?void 0:l.y,power:null===(u=i.power)||void 0===u?void 0:u.y,rule:null===(a=i.rule)||void 0===a?void 0:a.y,orientation:i.orientation}))}}static buildProportionalConstraint(t,i,s){var n,o,r,e;if("number"==typeof i.proportion.x){const r=t.replace(/(HorizontalProportional|HorizontalProportion|Proportional|Proportion)$/,"")+"HorizontalProportion";s.set(r,new ii(i.elementOne,i.elementTwo,{proportion:i.proportion.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(o=i.rule)||void 0===o?void 0:o.x,orientation:i.orientation}))}if("number"==typeof i.proportion.y){const n=t.replace(/(VerticalProportional|VerticalProportion|Proportional|Proportion)$/,"")+"VerticalProportion";s.set(n,new ni(i.elementOne,i.elementTwo,{proportion:i.proportion.y,power:null===(r=i.power)||void 0===r?void 0:r.y,rule:null===(e=i.rule)||void 0===e?void 0:e.y,orientation:i.orientation}))}}static buildCoverConstraint(t,i,s){var n,o;s.set(t,new hi(i.elementOne,i.elementTwo,{isStrict:i.isStrict,horizontalAnchor:null===(n=i.anchor)||void 0===n?void 0:n.x,verticalAnchor:null===(o=i.anchor)||void 0===o?void 0:o.y}))}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Wt||(Wt={}));class bi{static build(t,i,s,n={}){var o;const r=null!==(o=n.direction)&&void 0!==o?o:Wt.FROM_LEFT_TOP,e=[],h=[];e.push(new ti(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new ti(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const l=r===Wt.FROM_LEFT_TOP?1:0,u=r===Wt.FROM_LEFT_TOP?0:1;return h.push(new si(t,i,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation}),new si(t,s,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:e,verticalDistances:h}}}class xi{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:ti,proportionConstraint:ii,centerDistanceConstraint:si})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:si,proportionConstraint:ni,centerDistanceConstraint:ti})}static buildStack(t,i,s){const n=[],o=[],r=[];for(let e=0;e<t.length-1;e++){const h=t[e],l=t[e+1];n.push(new s.distanceConstraint(h,l,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),0!=i.keepProportions&&o.push(new s.proportionConstraint(h,l,{power:i.power,orientation:i.orientation})),0!=i.keepAlignment&&r.push(new s.centerDistanceConstraint(h,l,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:o,alignmentConstraints:r}}}class Ci extends Xt{constructor(t,i=100,s=100){super(t,new p,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Si extends Xt{constructor(t,i){var s,n;const o=null===(s=i.image)||void 0===s?void 0:s.width,r=null===(n=i.image)||void 0===n?void 0:n.height;Zt(o,r,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${o}) or height (${r}). Image dimensions must be non-zero positive numbers.`);const e=new Pt(i);super(t,new u(It,e),0,0,o,r),this.material=e,this.textureInternal=i,this.applyTransformations()}get texture(){return this.textureInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.textureInternal.image.width,this.textureInternal.image.height,this.material),this.applyTransformations()}}class Ei extends r{constructor(t,i){super({uniforms:g.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new e(1,1,1)},foregroundColor:{value:new e(1,1,1)},color:{value:new e(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:1,lights:0,fog:0})}getProgress(){return this.uniforms.progress.value}getBackgroundTexture(){return this.uniforms.background.value}getForegroundTexture(){return this.uniforms.foreground.value}getBackgroundColor(){return this.uniforms.color.value.getHex()}getForegroundColor(){return this.uniforms.color.value.getHex()}getColor(){return this.uniforms.color.value.getHex()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.value}getOpacity(){return this.uniforms.opacity.value}getAngle(){return this.uniforms.angle.value}getIsForwardDirection(){return 1===this.uniforms.direction.value}setProgress(t){this.uniforms.progress.value=t,this.uniformsNeedUpdate=1}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=1}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=1}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=1}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=1}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=1}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=1}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=1}}class ki extends Xt{constructor(t,i,s={}){var n,r,e,h,l,a;const d=null===(n=i.image)||void 0===n?void 0:n.width,c=null===(r=i.image)||void 0===r?void 0:r.height;Zt(d,c,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(h=null===(e=s.textureBackground)||void 0===e?void 0:e.image)||void 0===h?void 0:h.width,f=null===(a=null===(l=s.textureBackground)||void 0===l?void 0:l.image)||void 0===a?void 0:a.height;s.textureBackground&&Zt(v,f,`Invalid image dimensions - texture "${s.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new Ei(i,s.textureBackground),p=new u(It,w);s.progress&&w.setProgress(s.progress),s.isForegroundDirection&&w.setIsForwardDirection(s.isForegroundDirection),s.angle&&w.setAngle(o.degToRad(s.angle)),s.color&&w.setColor(s.color),s.opacity&&w.setOpacity(s.opacity),s.backgroundColor&&w.setBackgroundColor(s.backgroundColor),s.foregroundColor&&w.setForegroundColor(s.foregroundColor),s.backgroundOpacity&&w.setBackgroundOpacity(s.backgroundOpacity),s.foregroundOpacity&&w.setForegroundOpacity(s.foregroundOpacity);const g=null!=v?v:d,m=null!=c?c:f;super(t,p,0,0,g,m),this.material=w,this.imageWidth=g,this.imageHeight=m,this.applyTransformations()}get progress(){return this.material.getProgress()}get backgroundTexture(){return this.material.getBackgroundTexture()}get foregroundTexture(){return this.material.getForegroundTexture()}get backgroundColor(){return this.material.getBackgroundColor()}get foregroundColor(){return this.material.getForegroundColor()}get color(){return this.material.getColor()}get backgroundOpacity(){return this.material.getBackgroundOpacity()}get foregroundOpacity(){return this.material.getForegroundOpacity()}get opacity(){return this.material.getOpacity()}get angle(){return o.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(t){this.material.setAngle(o.degToRad(t)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}function Oi(t,i){var s,n,o,r,e,h,l,u,a,d,c,v,f,w,p,g,m,y,b,x,C,S,E,k,O,T,M,P;const I=Math.max(null!==(n=null!==(s=null==t?void 0:t.fontSize)&&void 0!==s?s:null==i?void 0:i.fontSize)&&void 0!==n?n:16,1),$=null!==(r=null!==(o=null==t?void 0:t.lineHeight)&&void 0!==o?o:null==i?void 0:i.lineHeight)&&void 0!==r?r:1.2*I,A=Math.max(null!==(h=null!==(e=null==t?void 0:t.shadowBlur)&&void 0!==e?e:null==i?void 0:i.shadowBlur)&&void 0!==h?h:0,0),D=Math.max(null!==(u=null!==(l=null==t?void 0:t.strokeWidth)&&void 0!==l?l:null==i?void 0:i.strokeWidth)&&void 0!==u?u:0,0);return{color:null!==(d=null!==(a=null==t?void 0:t.color)&&void 0!==a?a:null==i?void 0:i.color)&&void 0!==d?d:"#000000",fontFamily:null!==(v=null!==(c=null==t?void 0:t.fontFamily)&&void 0!==c?c:null==i?void 0:i.fontFamily)&&void 0!==v?v:"Arial",fontSize:I,fontStyle:null!==(w=null!==(f=null==t?void 0:t.fontStyle)&&void 0!==f?f:null==i?void 0:i.fontStyle)&&void 0!==w?w:"normal",fontWeight:null!==(g=null!==(p=null==t?void 0:t.fontWeight)&&void 0!==p?p:null==i?void 0:i.fontWeight)&&void 0!==g?g:"normal",lineHeight:$,enableShadow:null!==(y=null!==(m=null==t?void 0:t.enableShadow)&&void 0!==m?m:null==i?void 0:i.enableShadow)&&void 0!==y?y:0,shadowOffsetX:null!==(x=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==x?x:0,shadowOffsetY:null!==(S=null!==(C=null==t?void 0:t.shadowOffsetY)&&void 0!==C?C:null==i?void 0:i.shadowOffsetY)&&void 0!==S?S:0,shadowBlur:A,shadowColor:null!==(k=null!==(E=null==t?void 0:t.shadowColor)&&void 0!==E?E:null==i?void 0:i.shadowColor)&&void 0!==k?k:"transparent",enableStroke:null!==(T=null!==(O=null==t?void 0:t.enableStroke)&&void 0!==O?O:null==i?void 0:i.enableStroke)&&void 0!==T?T:0,strokeColor:null!==(P=null!==(M=null==t?void 0:t.strokeColor)&&void 0!==M?M:null==i?void 0:i.strokeColor)&&void 0!==P?P:"transparent",strokeWidth:D}}function Ti(t){return t.match(/\S+|\s|\n/g)||[]}function Mi(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),o=n.width,r=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(o),height:r,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Pi(t,i,s,n,o){o.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(o.shadowOffsetX=n.shadowOffsetX,o.shadowOffsetY=n.shadowOffsetY,o.shadowBlur=n.shadowBlur,o.shadowColor=n.shadowColor),n.enableStroke&&(o.strokeStyle=n.strokeColor,o.lineWidth=n.strokeWidth,o.strokeText(s,t,i)),o.fillStyle=n.color,o.fillText(s,t,i)}class Ii extends Xt{constructor(t,i,s={}){var n;const o=document.createElement("canvas"),r=o.getContext("2d");if(!r)throw Error("Failed to create canvas context");const e=[],h=Array.isArray(i)?i:[i];for(const t of h){const i="string"==typeof t,n=i?t:t.text,o=Oi(i?void 0:t.style,s.defaultStyle);for(const t of Ti(n)){const i=Mi(r,t,o);e.push({text:t,style:o,metrics:i})}}const l=((t,i)=>{const s=[];let n=[],o=0,r=0,e=0,h=0;for(const l of i)"\n"!==l.text?o+l.metrics.width<=t||0===n.length?(n.push(l),o+=l.metrics.width,r=Math.max(r,l.metrics.height),e=Math.max(e,l.metrics.baseline),h=Math.max(h,l.metrics.lineHeight)):(s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),n=[l],o=l.metrics.width,r=l.metrics.height,e=l.metrics.baseline,h=l.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),n=[],o=0,r=0,e=0,h=0);return n.length>0&&s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,e),a=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map((t=>t.width)));let s=0;for(let i=0;i<t.length;i++){const n=t[i];s+=0===i?n.height:n.lineHeight,i===t.length-1&&(s+=n.baseline)}return{width:i,height:s}})(l),d=(t=>{var i,s,n,o;return"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(null!==(i=null==t?void 0:t.left)&&void 0!==i?i:0,0),right:Math.max(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:0,0),top:Math.max(null!==(n=null==t?void 0:t.top)&&void 0!==n?n:0,0),bottom:Math.max(null!==(o=null==t?void 0:t.bottom)&&void 0!==o?o:0,0)}})(s.padding);o.width=a.width+d.left+d.right,o.height=a.height+d.top+d.bottom;const c=new m(o),v=new Pt(c);super(t,new u(It,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=o,this.context=r,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let o=this.padding.top;for(let t=0;t<s.length;t++){const r=s[t];let e=i;o+=0===t?r.height:r.lineHeight;for(const t of r.chunks)Pi(e,o,t.text,t.style,n),e+=t.metrics.width}})(0,this.padding.left,l,this.context),this.texture.needsUpdate=1,this.applyTransformations()}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),this.texture.dispose(),this.canvas.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.suggestedAspect!==t&&(this.suggestedAspect=t,this.height=this.width/((this.textBlockSize.width+this.padding.left+this.padding.right)/(this.textBlockSize.height+this.padding.top+this.padding.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.texture.image.width,this.texture.image.height,this.material),this.applyTransformations()}}function $i(t){return null!==t&&"object"==typeof t&&"background"in t&&t.background instanceof y&&"foreground"in t&&t.foreground instanceof y}function Ai(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}function Di(t){return null!==t&&"object"==typeof t&&"spans"in t&&Array.isArray(t.spans)&&t.spans.every((t=>"string"==typeof t||(t=>null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text)(t)))}function zi(t){return!(null===t||"object"!=typeof t||"width"in t&&"number"!=typeof t.width||"height"in t&&"number"!=typeof t.height)}class Fi{static fromDescription(t,i){const s=i instanceof Map?i.entries():Object.entries(i),n=new Map;for(const[i,r]of s){if(n.has(i))throw Error(`Duplicate element key "${i}" - each UI element must have a unique identifier`);let s;if(r instanceof y)s=new Si(t,r);else if(null!==(o=r)&&"object"==typeof o&&"texture"in o&&o.texture instanceof y)s=new Si(t,r.texture);else if("string"==typeof r)s=new Ii(t,[r]);else if($i(r))s=new ki(t,r.foreground,{textureBackground:r.background});else if(Ai(r))s=new Ii(t,[r.text],{defaultStyle:r.style});else if(Di(r))s=new Ii(t,r.spans,{defaultStyle:r.defaultStyle});else{if(!zi(r))throw Error(`Invalid UI element type for "${i}". Expected one of: Texture, UIImage, String, UITextDescription, or UITextEnhancedDescription`);s=new Ci(t,r.width,r.height)}n.set(i,s)}var o;return Object.fromEntries(n)}}class Ui extends rt{constructor(t,i,s){var n,o,r;super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,Jt(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(o=null==s?void 0:s.horizontalAnchor)&&void 0!==o?o:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new $(new O(this.elementOne[B]).plus(new O(this.elementOne[V]).multiply(this.parameters.horizontalAnchor)),M.Eq,new O(this.elementTwo[B]).plus(new O(this.elementTwo[V]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new $(new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new $(new O(this.elementOne[V]),M.Ge,new O(this.elementTwo[V])),this.constraintH=new $(new O(this.elementOne[R]),M.Ge,new O(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),0!=this.parameters.isStrict&&(this.constraintStrict=new $(new O(this.elementOne[R]),M.Eq,new O(this.elementTwo[R]),P.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[Y](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[Y](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[Y](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[Y](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[Y](this,this.constraintStrict),this.constraintStrict=void 0)}}(t=>{t.AUTO="AUTO",t.PROPERTY="PROPERTY",t.MANUAL="MANUAL"})(Gt||(Gt={}));const ji=Gt.PROPERTY;class Bi extends Xt{constructor(t,i={}){var s,n,o,r,e,h,a,w,p,g;const m=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(m<.1||m>8)throw Error(`Invalid resolution factor: ${m}. Must be between 0.1 and 8.`);const y=null!==(n=i.width)&&void 0!==n?n:512,x=null!==(o=i.height)&&void 0!==o?o:512;Zt(y,x,`Invalid width or height: ${y}x${x}. Must be positive.`);const C=new d(y*m,x*m,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(r=i.useDepth)&&void 0!==r?r:1,stencilBuffer:0}),S=new Pt(C.texture);super(t,new u(It,S),0,0,y,x),this.needsRenderInternal=0,this.sceneInternal=null!==(e=i.scene)&&void 0!==e?e:new l,this.cameraInternal=null!==(h=i.camera)&&void 0!==h?h:new b(75,y/x,.1,100),this.resolutionFactorInternal=m,this.updateBehaviorInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:ji,null!==(w=i.renderedByDefault)&&void 0!==w&&w&&(this.needsRenderInternal=1),this.clearColorInternal=null!==(p=i.clearColor)&&void 0!==p?p:0,this.clearAlphaInternal=null!==(g=i.clearAlpha)&&void 0!==g?g:0,this.renderTarget=C,this.material=S,this.applyTransformations()}get needsRender(){return this.needsRenderInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}get scene(){return this.sceneInternal}get camera(){return this.cameraInternal}get clearColor(){return this.clearColorInternal}get clearAlpha(){return this.clearAlphaInternal}get resolutionFactor(){return this.resolutionFactorInternal}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.sceneInternal!==t&&(this.sceneInternal=t,this.updateBehaviorInternal===Gt.PROPERTY&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateBehaviorInternal===Gt.PROPERTY&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateBehaviorInternal===Gt.PROPERTY&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateBehaviorInternal===Gt.PROPERTY&&this.requestRender())}set resolutionFactor(t){this.resolutionFactorInternal!==t&&(this.resolutionFactorInternal=t,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),this.updateBehaviorInternal===Gt.PROPERTY&&this.requestRender())}destroy(){this.material.dispose(),this.renderTarget.dispose(),super.destroy()}requestRender(){this.needsRenderInternal=1,this.composerInternal.requestUpdate()}render(t){(this.needsRenderInternal||this.updateBehaviorInternal===Gt.AUTO)&&(this.needsRenderInternal=0,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),t.setClearColor(this.clearColorInternal,this.clearAlpha),t.setRenderTarget(this.renderTarget),t.clear(1,1,0),t.render(this.sceneInternal,this.cameraInternal)),this.object.material=this.composerInternal.compose(t,this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal,this.material),this.applyTransformations()}}class Hi extends Qt{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.behavior!==kt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,n=i?i.bottom-t.clientY:window.innerHeight-t.clientY,o=this.calculateScale();this.clickInternal(s*o,n*o)},window.addEventListener("resize",this.onResize),window.addEventListener("pointerdown",this.onClick),this.onResize()}get tergetScreenHeight(){return this.targetScreenHeight}set tergetScreenHeight(t){this.targetScreenHeight=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.onResize),window.removeEventListener("pointerdown",this.onClick),super.destroy()}calculateScale(){var t;return(null!==(t=this.tergetScreenHeight)&&void 0!==t?t:window.innerHeight)/window.innerHeight}}class Vi extends Qt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Ri{}export{ei as UIAspectConstraint,ri as UIConstraint2DBuilder,yi as UIConstraintBuilder,bi as UIConstraintContainerBuilder,Wt as UIConstraintContainerDirection,ht as UIConstraintPower,lt as UIConstraintRule,xi as UIConstraintStackBuilder,hi as UICoverConstraint,Ci as UIDummy,Fi as UIElementBuilder,Rt as UIElementEvent,Ui as UIFitConstraint,Hi as UIFullScreenLayer,Dt as UIFullScreenQuad,wt as UIHeightConstraint,ti as UIHorizontalDistanceConstraint,ii as UIHorizontalProportionConstraint,Si as UIImage,Qt as UILayer,qt as UILayerEvent,Vi as UIManualLayer,kt as UIMode,st as UIOrientation,Ri as UIPass,ki as UIProgress,Bi as UIScene,Gt as UISceneUpdateBehavior,Ii as UIText,si as UIVerticalDistanceConstraint,ni as UIVerticalProportionConstraint,oi as UIWidthConstraint};
|
|
1
|
+
import{Vector2 as t,Box2 as i,Matrix3 as s,Vector3 as n,MathUtils as o,ShaderMaterial as r,Color as e,PlaneGeometry as h,Scene as l,Mesh as u,OrthographicCamera as a,WebGLRenderTarget as d,UnsignedByteType as c,LinearFilter as v,RGBAFormat as f,NoBlending as w,Object3D as p,UniformsUtils as g,CanvasTexture as m,Texture as y,PerspectiveCamera as b}from"three";function x(){return new C}var C=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new S(t,i());return this.index[t.id()]=this.array.length,this.array.push(n),n}return this.array[s]},t.prototype.insert=function(t,i){var s=new S(t,i),n=this.index[t.id()];return void 0===n?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[n]=s,s},t.prototype.erase=function(t){var i=this.index[t.id()];if(void 0!==i){this.index[t.id()]=void 0;var s=this.array[i],n=this.array.pop();return s!==n&&(this.array[i]=n,this.index[n.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;s<this.array.length;s++){var n=this.array[s].copy();i.array[s]=n,i.index[n.first.id()]=s}return i},t}(),S=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),E=function(){function t(t){void 0===t&&(t=""),this.t=0,this.i=null,this.o=k++,this.h=t}return t.prototype.id=function(){return this.o},t.prototype.name=function(){return this.h},t.prototype.setName=function(t){this.h=t},t.prototype.context=function(){return this.i},t.prototype.setContext=function(t){this.i=t},t.prototype.value=function(){return this.t},t.prototype.setValue=function(t){this.t=t},t.prototype.plus=function(t){return new O(this,t)},t.prototype.minus=function(t){return new O(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new O([t,this])},t.prototype.divide=function(t){return new O([1/t,this])},t.prototype.toJSON=function(){return{name:this.h,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.h+":"+this.t+"]"},t}(),k=0,O=function(){function t(){var t=M(arguments);this.l=t.terms,this.u=t.constant}return t.prototype.terms=function(){return this.l},t.prototype.constant=function(){return this.u},t.prototype.value=function(){for(var t=this.u,i=0,s=this.l.size();i<s;i++){var n=this.l.itemAt(i);t+=n.first.value()*n.second}return t},t.prototype.plus=function(i){return new t(this,i)},t.prototype.minus=function(i){return new t(this,"number"==typeof i?-i:[-1,i])},t.prototype.multiply=function(i){return new t([i,this])},t.prototype.divide=function(i){return new t([1/i,this])},t.prototype.isConstant=function(){return 0==this.l.size()},t.prototype.toString=function(){var t=this.l.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.u||(t+=" + "),t+this.u},t}();function M(t){for(var i=0,s=()=>0,n=x(),o=0,r=t.length;o<r;++o){var e=t[o];if("number"==typeof e)i+=e;else if(e instanceof E)n.setDefault(e,s).second+=1;else if(e instanceof O){i+=e.constant();for(var h=0,l=(c=e.terms()).size();h<l;h++){var u=c.itemAt(h);n.setDefault(u.first,s).second+=u.second}}else{if(!(e instanceof Array))throw Error("invalid Expression argument: "+e);if(2!==e.length)throw Error("array must have length 2");var a=e[0],d=e[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof E)n.setDefault(d,s).second+=a;else{if(!(d instanceof O))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,h=0,l=(c=d.terms()).size();h<l;h++)u=c.itemAt(h),n.setDefault(u.first,s).second+=u.second*a}}}return{terms:n,constant:i}}var T,I=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var o=0;return o+=1e6*Math.max(0,Math.min(1e3,t*n)),(o+=1e3*Math.max(0,Math.min(1e3,i*n)))+Math.max(0,Math.min(1e3,s*n))},t.clip=i=>Math.max(0,Math.min(t.required,i)),t.required=t.create(1e3,1e3,1e3),t.strong=t.create(1,0,0),t.medium=t.create(0,1,0),t.weak=t.create(0,0,1),t})();(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(T||(T={}));var $,D=function(){function t(t,i,s,n){void 0===n&&(n=I.required),this.o=P++,this.v=i,this.p=I.clip(n),this.m=void 0===s&&t instanceof O?t:t.minus(s)}return t.prototype.id=function(){return this.o},t.prototype.expression=function(){return this.m},t.prototype.op=function(){return this.v},t.prototype.strength=function(){return this.p},t.prototype.toString=function(){return this.m+" "+["<=",">=","="][this.v]+" 0 ("+this.p+")"},t}(),P=0,z=function(){function t(){this.C=x(),this.S=x(),this.k=x(),this.O=x(),this.M=[],this.T=new B,this.I=null,this.$=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=I.required);var o=new D(t,i,s,n);return this.addConstraint(o),o},t.prototype.addConstraint=function(t){if(void 0!==this.C.find(t))throw Error("duplicate constraint");var i=this.D(t),s=i.row,n=i.tag,o=this.P(s,n);if(o.type()===$.Invalid&&s.allDummies()){if(!A(s.constant()))throw Error("unsatisfiable constraint");o=n.marker}if(o.type()===$.Invalid){if(!this.A(s))throw Error("unsatisfiable constraint")}else s.solveFor(o),this.F(o,s),this.S.insert(o,s);this.C.insert(t,n),this.j(this.T)},t.prototype.removeConstraint=function(t){var i=this.C.erase(t);if(void 0===i)throw Error("unknown constraint");this.B(t,i.second);var s=i.second.marker,n=this.S.erase(s);if(void 0===n){var o=this.U(s);if(o.type()===$.Invalid)throw Error("failed to find leaving row");(n=this.S.erase(o)).second.solveForEx(o,s),this.F(s,n.second)}this.j(this.T)},t.prototype.hasConstraint=function(t){return this.C.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.O.find(t))throw Error("duplicate edit variable");if((i=I.clip(i))===I.required)throw Error("bad required strength");var s=new O(t),n=new D(s,T.Eq,void 0,i);this.addConstraint(n);var o=this.C.find(n).second;this.O.insert(t,{tag:o,constraint:n,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.O.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.O.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.O.find(t);if(void 0===s)throw Error("unknown edit variable");var n=this.S,o=s.second,r=i-o.constant;o.constant=i;var e=o.tag.marker,h=n.find(e);if(void 0!==h)return h.second.add(-r)<0&&this.M.push(e),void this.H();var l=o.tag.other;if(void 0!==(h=n.find(l)))return h.second.add(r)<0&&this.M.push(l),void this.H();for(var u=0,a=n.size();u<a;++u){var d=n.itemAt(u),c=d.second,v=c.coefficientFor(e);0!==v&&c.add(r*v)<0&&d.first.type()!==$.External&&this.M.push(d.first)}this.H()},t.prototype.updateVariables=function(){for(var t=this.k,i=this.S,s=0,n=t.size();s<n;++s){var o=t.itemAt(s),r=i.find(o.second);o.first.setValue(void 0!==r?r.second.constant():0)}},t.prototype.V=function(t){var i=this;return this.k.setDefault(t,(()=>i.R($.External))).second},t.prototype.D=function(t){for(var i=t.expression(),s=new B(i.constant()),n=i.terms(),o=0,r=n.size();o<r;++o){var e=n.itemAt(o);if(!A(e.second)){var h=this.V(e.first),l=this.S.find(h);void 0!==l?s.insertRow(l.second,e.second):s.insertSymbol(h,e.second)}}var u=this.T,a=t.strength(),d={marker:j,other:j};switch(t.op()){case T.Le:case T.Ge:var c=t.op()===T.Le?1:-1,v=this.R($.Slack);if(d.marker=v,s.insertSymbol(v,c),a<I.required){var f=this.R($.Error);d.other=f,s.insertSymbol(f,-c),u.insertSymbol(f,a)}break;case T.Eq:if(a<I.required){var w=this.R($.Error),p=this.R($.Error);d.marker=w,d.other=p,s.insertSymbol(w,-1),s.insertSymbol(p,1),u.insertSymbol(w,a),u.insertSymbol(p,a)}else{var g=this.R($.Dummy);d.marker=g,s.insertSymbol(g)}}return s.constant()<0&&s.reverseSign(),{row:s,tag:d}},t.prototype.P=(t,i)=>{for(var s=t.cells(),n=0,o=s.size();n<o;++n){var r=s.itemAt(n);if(r.first.type()===$.External)return r.first}var e=i.marker.type();return(e===$.Slack||e===$.Error)&&t.coefficientFor(i.marker)<0?i.marker:((e=i.other.type())===$.Slack||e===$.Error)&&t.coefficientFor(i.other)<0?i.other:j},t.prototype.A=function(t){var i=this.R($.Slack);this.S.insert(i,t.copy()),this.I=t.copy(),this.j(this.I);var s=A(this.I.constant());this.I=null;var n=this.S.erase(i);if(void 0!==n){var o=n.second;if(o.isConstant())return s;var r=this.L(o);if(r.type()===$.Invalid)return 0;o.solveForEx(i,r),this.F(r,o),this.S.insert(r,o)}for(var e=this.S,h=0,l=e.size();h<l;++h)e.itemAt(h).second.removeSymbol(i);return this.T.removeSymbol(i),s},t.prototype.F=function(t,i){for(var s=this.S,n=0,o=s.size();n<o;++n){var r=s.itemAt(n);r.second.substitute(t,i),r.second.constant()<0&&r.first.type()!==$.External&&this.M.push(r.first)}this.T.substitute(t,i),this.I&&this.I.substitute(t,i)},t.prototype.j=function(t){for(;;){var i=this._(t);if(i.type()===$.Invalid)return;var s=this.K(i);if(s.type()===$.Invalid)throw Error("the objective is unbounded");var n=this.S.erase(s).second;n.solveForEx(s,i),this.F(i,n),this.S.insert(i,n)}},t.prototype.H=function(){for(var t=this.S,i=this.M;0!==i.length;){var s=i.pop(),n=t.find(s);if(void 0!==n&&n.second.constant()<0){var o=this.N(n.second);if(o.type()===$.Invalid)throw Error("dual optimize failed");var r=n.second;t.erase(s),r.solveForEx(s,o),this.F(o,r),t.insert(o,r)}}},t.prototype._=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var o=i.itemAt(s),r=o.first;if(o.second<0&&r.type()!==$.Dummy)return r}return j},t.prototype.N=function(t){for(var i=Number.MAX_VALUE,s=j,n=t.cells(),o=0,r=n.size();o<r;++o){var e=n.itemAt(o),h=e.first,l=e.second;if(l>0&&h.type()!==$.Dummy){var u=this.T.coefficientFor(h)/l;u<i&&(i=u,s=h)}}return s},t.prototype.K=function(t){for(var i=Number.MAX_VALUE,s=j,n=this.S,o=0,r=n.size();o<r;++o){var e=n.itemAt(o),h=e.first;if(h.type()!==$.External){var l=e.second,u=l.coefficientFor(t);if(u<0){var a=-l.constant()/u;a<i&&(i=a,s=h)}}}return s},t.prototype.U=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,o=j,r=o,e=o,h=o,l=this.S,u=0,a=l.size();u<a;++u){var d=l.itemAt(u),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===$.External)h=f;else if(v<0)(w=-c.constant()/v)<s&&(s=w,r=f);else{var w;(w=c.constant()/v)<n&&(n=w,e=f)}}}return r!==o?r:e!==o?e:h},t.prototype.B=function(t,i){i.marker.type()===$.Error&&this.X(i.marker,t.strength()),i.other.type()===$.Error&&this.X(i.other,t.strength())},t.prototype.X=function(t,i){var s=this.S.find(t);void 0!==s?this.T.insertRow(s.second,-i):this.T.insertSymbol(t,-i)},t.prototype.L=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var o=i.itemAt(s),r=o.first.type();if(r===$.Slack||r===$.Error)return o.first}return j},t.prototype.R=function(t){return new F(t,this.$++)},t}();function A(t){return t<0?-t<1e-8:t<1e-8}(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})($||($={}));var F=function(){function t(t,i){this.o=i,this.q=t}return t.prototype.id=function(){return this.o},t.prototype.type=function(){return this.q},t}(),j=new F($.Invalid,-1),B=function(){function t(t){void 0===t&&(t=0),this.W=x(),this.u=t}return t.prototype.cells=function(){return this.W},t.prototype.constant=function(){return this.u},t.prototype.isConstant=function(){return this.W.empty()},t.prototype.allDummies=function(){for(var t=this.W,i=0,s=t.size();i<s;++i)if(t.itemAt(i).first.type()!==$.Dummy)return 0;return 1},t.prototype.copy=function(){var i=new t(this.u);return i.W=this.W.copy(),i},t.prototype.add=function(t){return this.u+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),A(this.W.setDefault(t,(()=>0)).second+=i)&&this.W.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.u+=t.u*i;for(var s=t.W,n=0,o=s.size();n<o;++n){var r=s.itemAt(n);this.insertSymbol(r.first,r.second*i)}},t.prototype.removeSymbol=function(t){this.W.erase(t)},t.prototype.reverseSign=function(){this.u=-this.u;for(var t=this.W,i=0,s=t.size();i<s;++i){var n=t.itemAt(i);n.second=-n.second}},t.prototype.solveFor=function(t){var i=this.W,s=-1/i.erase(t).second;this.u*=s;for(var n=0,o=i.size();n<o;++n)i.itemAt(n).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.W.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.W.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const U=Symbol("xSymbol"),H=Symbol("ySymbol"),V=Symbol("widthSymbol"),R=Symbol("heightSymbol"),L=Symbol("addUIElementSymbol"),_=Symbol("removeUIElementSymbol"),K=Symbol("addConstraintSymbol"),N=Symbol("removeUIConstraintSymbol"),X=Symbol("addConstraintSymbol"),q=Symbol("removeConstraintSymbol"),W=Symbol("addVariableSymbol"),Y=Symbol("removeVariableSymbol"),G=Symbol("suggestVariableSymbol"),Q=Symbol("disableConstraintSymbol"),J=Symbol("enableConstraintSymbol"),Z=Symbol("needsRecalculation"),tt=Symbol("renderSymbol"),it=Symbol("clickSymbol");var st;function nt(t){return null!==t&&Object.values(st).some((i=>i===t))}function ot(t){return null!=t?t:st.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(st||(st={}));class rt{constructor(t,i){this.layer=t,this.name="",this.layer[K](this,i)}destroy(){this.layer[N](this)}}const et=1e3;var ht,lt;function ut(t){return null!==t&&Object.values(ht).some((i=>i===t))}function at(t){return null!=t?t:ht.P0}function dt(t){switch(t){case ht.P0:return I.create(et,et,et);case ht.P1:return I.create(100,0,0);case ht.P2:return I.create(10,0,0);case ht.P3:return I.create(0,100,0);case ht.P4:return I.create(0,10,0);case ht.P5:return I.create(0,0,100);case ht.P6:return I.create(0,0,10);case ht.P7:return I.create(0,0,1);default:return I.create(et,et,et)}}function ct(t){return null!==t&&Object.values(lt).some((i=>i===t))}function vt(t){return null!=t?t:lt.EQUAL}function ft(t){switch(t){case lt.EQUAL:return T.Eq;case lt.LESS:return T.Le;case lt.GREATER:return T.Ge;default:return T.Eq}}(t=>{t[t.P0=0]="P0",t[t.P1=1]="P1",t[t.P2=2]="P2",t[t.P3=3]="P3",t[t.P4=4]="P4",t[t.P5=5]="P5",t[t.P6=6]="P6",t[t.P7=7]="P7"})(ht||(ht={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(lt||(lt={}));class wt extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={height:null!==(s=null==i?void 0:i.height)&&void 0!==s?s:t.height,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new D(new O(this.element[R]),ft(this.options.rule),this.options.height,dt(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class pt{constructor(){this.listeners=new Map}on(t,i,s,n=100){return this.addListener(t,i,s,n,0),this}once(t,i,s,n=100){return this.addListener(t,i,s,n,1),this}off(t,i,s){const n=this.listeners.get(t);if(!n)return this;if(!i)return this.listeners.delete(t),this;const o=n.filter((t=>t.callback!==i||void 0!==s&&t.context!==s));return o.length?this.listeners.set(t,o):this.listeners.delete(t),this}emit(t,...i){const s=this.listeners.get(t);if(!(null==s?void 0:s.length))return 0;for(const n of[...s])n.callback.apply(n.context,i),n.once&&this.off(t,n.callback,n.context);return 1}addListener(t,i,s,n,o){let r=this.listeners.get(t);if(r||(r=[],this.listeners.set(t,r)),r.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const e={callback:i,context:s,priority:n,once:o};let h=0;for(;h<r.length&&r[h].priority<=n;)h++;r.splice(h,0,e)}}const gt=new t,mt=new i,yt=new s,bt=new s,xt=new s,Ct=new s,St=new s,Et=new n,kt=.5;class Ot{constructor(){this.x=0,this.y=0,this.anchorX=kt,this.anchorY=kt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Mt{constructor(t,i){this.raw=t,this.owner=i}get x(){return this.raw.x}get y(){return this.raw.y}get anchorX(){return this.raw.anchorX}get anchorY(){return this.raw.anchorY}get scaleX(){return this.raw.scaleX}get scaleY(){return this.raw.scaleY}get angle(){return o.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=1)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=1)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=1)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=1)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=1)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=1)}set angle(t){const i=o.degToRad(t);i!==this.raw.rotation&&(this.raw.rotation=i,this.raw.needsRecalculation=1)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=1)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=1)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===kt&&this.raw.anchorY===kt&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=kt,this.raw.anchorY=kt,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}var Tt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(Tt||(Tt={}));class It extends r{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new e(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:1,lights:0,fog:0})}getTexture(){return this.uniforms.map.value}getColor(){return this.uniforms.color.value.getHex()}getOpacity(){return this.uniforms.opacity.value}setTexture(t){this.uniforms.map.value=t,this.uniformsNeedUpdate=1}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=1}}const $t=new h(1,1).translate(.5,.5,0),Dt=new l,Pt=new u($t);Dt.add(Pt);class zt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new a(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){Pt.material=i,t.render(Dt,this.camera)}updateCameraTransform(){this.camera.left=-this.paddingHorizontalInternal,this.camera.right=1+this.paddingHorizontalInternal,this.camera.bottom=-this.paddingVerticalInternal,this.camera.top=1+this.paddingVerticalInternal,this.camera.updateProjectionMatrix()}}class At{constructor(){this.passes=[],this.defaultMaterial=new It,this.screen=new zt,this.needsUpdateInternal=0,this.paddingHasChangedInternal=0,this.paddingInternal=0;const t={format:f,minFilter:v,magFilter:v,type:c,depthBuffer:0,stencilBuffer:0};this.fromRenderTarget=new d(1,1,t),this.toRenderTarget=new d(1,1,t),this.fromRenderTarget.texture.generateMipmaps=0,this.toRenderTarget.texture.generateMipmaps=0}get needsUpdate(){return this.needsUpdateInternal&&this.hasValuablePasses()||this.hasPassesNeedingUpdate()}get paddingHasChanged(){return this.paddingHasChangedInternal}get padding(){return this.paddingInternal}requestUpdate(){this.needsUpdateInternal=1}compose(t,i,s,n,o=1){const r=this.hasValuablePasses();if(!(this.needsUpdateInternal&&r||this.hasPassesNeedingUpdate()))return r||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,r?this.defaultMaterial:n;const e=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==e,this.paddingInternal=e;const h=i+2*e,l=s+2*e;this.fromRenderTarget.setSize(h,l),this.toRenderTarget.setSize(h,l),this.setScreenPadding(i,s,e),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0);const u=n.blending;o&&(n.blending=w),this.screen.render(t,n),n.blending=u;const a={width:i,height:s,padding:e};for(let i=0;i<this.passes.length;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.reverseRenderTargets(),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0),this.passes[i].render(t,this.fromRenderTarget.texture,a))}return this.needsUpdateInternal=0,this.defaultMaterial.setTexture(this.toRenderTarget.texture),this.defaultMaterial}destroy(){this.fromRenderTarget.dispose(),this.toRenderTarget.dispose()}hasValuablePasses(){return this.passes.some((t=>t.isValuable))}hasPassesNeedingUpdate(){return this.passes.some((t=>t.needsUpdate))}calculatePadding(){return this.passes.reduce(((t,i)=>Math.max(t,i.padding)),0)}setScreenPadding(t,i,s){this.screen.paddingHorizontal=s/t,this.screen.paddingVertical=s/i}reverseRenderTargets(){const t=this.fromRenderTarget;this.fromRenderTarget=this.toRenderTarget,this.toRenderTarget=t}}class Ft{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var jt,Bt,Ut,Ht,Vt,Rt,Lt,_t,Kt,Nt;(t=>{t.CLICK="click"})(Rt||(Rt={}));class Xt extends pt{constructor(t,i,s,n,r,e){super(),this.layer=t,this.object=i,this[jt]=new E("x"),this[Bt]=new E("y"),this[Ut]=new E("width"),this[Ht]=new E("height"),this[Vt]=0,this.name=o.generateUUID(),this.microInternal=new Ot,this.composerInternal=new At,this.modeInternal=Tt.VISIBLE,this.micro=new Mt(this.microInternal,this),this.composer=new Ft(this.composerInternal),this.layer[L](this,this.object),this.layer[W](this,this[U],dt(ht.P7)),this.layer[W](this,this[H],dt(ht.P7)),this.layer[W](this,this[V],dt(ht.P5)),this.layer[W](this,this[R],dt(ht.P5)),this[U].setValue(s),this[H].setValue(n),this[V].setValue(r),this[R].setValue(e),this.layer[G](this,this[U],s),this.layer[G](this,this[H],n),this.layer[G](this,this[V],r),this.layer[G](this,this[R],e)}get x(){return this[U].value()}get y(){return this[H].value()}get width(){return this[V].value()}get height(){return this[R].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[Z]}set x(t){this.layer[G](this,this[U],t)}set y(t){this.layer[G](this,this[H],t)}set width(t){this.layer[G](this,this[V],t)}set height(t){this.layer[G](this,this[R],t)}set zIndex(t){this.object.position.z=t}set mode(t){this.modeInternal=t,this.object.visible=t!==Tt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[Y](this,this[R]),this.layer[Y](this,this[V]),this.layer[Y](this,this[H]),this.layer[Y](this,this[U]),this.layer[_](this)}[(jt=U,Bt=H,Ut=V,Ht=R,Vt=Z,tt)](t,i){this.render(t,i)}[it](t,i){return this.click(t,i)}applyTransformations(){(this[Z]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,o,r,e)=>{const h=this.x-e,l=this.y-e,u=this.width+2*e,a=this.height+2*e,d=h+u*i.anchorX,c=l+a*i.anchorY,v=yt.set(1,0,-d,0,1,-c,0,0,1),f=bt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=xt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),p=Ct.set(1,0,i.x+d,0,1,i.y+c,0,0,1),g=St.multiplyMatrices(p,w).multiply(f).multiply(v),m=Et.set(h,l,1).applyMatrix3(g);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=u*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this[Z]=0,this.microInternal.needsRecalculation=0)}click(t,i){return this.mode!==Tt.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,o=this.width,r=this.height,gt.set(t,i),mt.min.set(s,n),mt.max.set(o,r).add(mt.min),mt.containsPoint(gt)?(this.emit(Rt.CLICK,this),1):0);var s,n,o,r}}const qt=new e(0);var Wt,Yt,Gt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(Wt||(Wt={}));class Qt extends pt{constructor(){super(...arguments),this.mode=Tt.VISIBLE,this[Lt]=new E,this[_t]=new E,this[Kt]=new E,this[Nt]=new E,this.scene=new l,this.camera=new a,this.solver=new z,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=st.PORTRAIT,this.needsRecalculation=0}get orientation(){return this.orientationPrivate}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Lt=U,_t=H,Kt=V,Nt=R,L)](t,i){if(this.elements.has(t))throw Error("Element already added");this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i.position.z=500,this.scene.add(i)}[_](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),this.scene.remove(i.object)}[K](t,i){if(this.constraints.has(t))throw Error("Constraint already added");for(const s of i){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(i.constraints.has(t))throw Error("Something went wrong");i.constraints.add(t)}this.constraints.set(t,{elements:i,variables:new Map,constraints:new Set})}[N](t){const i=this.constraints.get(t);if(void 0===i)throw Error("Constraint not found");if(i.variables.size>0)throw Error("Variables should be removed before removing constraint");if(i.constraints.size>0)throw Error("Constraints should be removed before removing constraint");for(const s of i.elements){const i=this.elements.get(s);if(void 0===i)throw Error("Element not found");if(!i.constraints.has(t))throw Error("Something went wrong");i.constraints.delete(t)}this.constraints.delete(t)}[X](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before adding constraint you need to add it's owner");if(n.constraints.has(i))throw Error("Constraint already exists");n.constraints.add(i),null===(s=this.solver)||void 0===s||s.addConstraint(i),this.needsRecalculation=1}[q](t,i){var s;const n=this.constraints.get(t);if(void 0===n)throw Error("Before removing constraint you need to add it's owner");if(!n.constraints.has(i))throw Error("Constraint not found");n.constraints.delete(i),null===(s=this.solver)||void 0===s||s.removeConstraint(i),this.needsRecalculation=1}[W](t,i,s){var n;const o=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===o)throw Error("Before adding variable you need to add it's owner");if(o.variables.has(i))throw Error("Variable already exists");o.variables.set(i,{strength:s,suggestedValue:i.value()}),null===(n=this.solver)||void 0===n||n.addEditVariable(i,s),this.needsRecalculation=1}[Y](t,i){var s;const n=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i),null===(s=this.solver)||void 0===s||s.removeEditVariable(i),this.needsRecalculation=1}[G](t,i,s){var n;const o=t instanceof Xt?this.elements.get(t):this.constraints.get(t);if(void 0===o)throw Error("Before suggesting variable you need to add it's owner");const r=o.variables.get(i);if(!r)throw Error("Variable does not exist");r.suggestedValue!==s&&(r.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===Tt.HIDDEN)return;const n=t.getRenderTarget(),o=t.getClearColor(qt),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=0,null===(s=this.solver)||void 0===s||s.updateVariables();for(const t of this.elements.keys())t[Z]=1}for(const s of this.elements.keys())s[tt](t,i);t.setRenderTarget(n),t.setClearColor(o),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==Tt.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t.mode===Tt.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[it](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=1}applyCameraSize(t,i){this.camera.near=-1e3,this.camera.far=0,this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){var s,n,o,r,e,h,l,u;this.constraintX&&(null===(s=this.solver)||void 0===s||s.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(null===(n=this.solver)||void 0===n||n.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(null===(o=this.solver)||void 0===o||o.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new D(new O(this[U]),T.Eq,0,I.required),this.constraintY=new D(new O(this[H]),T.Eq,0,I.required),this.constraintW=new D(new O(this[V]),T.Eq,t,I.required),this.constraintH=new D(new O(this[R]),T.Eq,i,I.required),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintX),null===(h=this.solver)||void 0===h||h.addConstraint(this.constraintY),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintW),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?st.LANDSCAPE:st.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[J](this.orientationPrivate);for(const t of this.constraints.keys())t[Q](this.orientationPrivate);this.solver=new z;const t=[...this.elements.values(),...this.constraints.values()];for(const i of t)for(const[t,s]of i.variables.entries())this.solver.addEditVariable(t,s.strength),this.solver.suggestValue(t,s.suggestedValue);this.constraintX&&this.solver.addConstraint(this.constraintX),this.constraintY&&this.solver.addConstraint(this.constraintY),this.constraintW&&this.solver.addConstraint(this.constraintW),this.constraintH&&this.solver.addConstraint(this.constraintH);for(const t of this.constraints.values())for(const i of t.constraints.values())this.solver.addConstraint(i);this.emit(Wt.ORIENTATION_CHANGED,this,this.orientation)}}}function Jt(t,i){if((t instanceof Qt?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function Zt(t,i,s){if(t<=0||i<=0)throw Error(null!=s?s:`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class ti extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(o=null==s?void 0:s.anchorTwo)&&void 0!==o?o:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[U]).plus(new O(this.elementOne[V]).multiply(this.parameters.anchorOne)),i=new O(this.elementTwo[U]).plus(new O(this.elementTwo[V]).multiply(this.parameters.anchorTwo));this.constraint=new D(i.minus(t),ft(this.parameters.rule),this.parameters.distance,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class ii extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[V]).multiply(this.parameters.proportion),i=new O(this.elementTwo[V]);this.constraint=new D(t.minus(i),ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class si extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(o=null==s?void 0:s.anchorTwo)&&void 0!==o?o:.5,distance:null!==(r=null==s?void 0:s.distance)&&void 0!==r?r:0,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.anchorOne)),i=new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.anchorTwo));this.constraint=new D(i.minus(t),ft(this.parameters.rule),this.parameters.distance,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class ni extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:at(null==s?void 0:s.power),rule:vt(null==s?void 0:s.rule),orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.elementOne[R]).multiply(this.parameters.proportion),i=new O(this.elementTwo[R]);this.constraint=new D(t.minus(i),ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class oi extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.options={width:null!==(s=null==i?void 0:i.width)&&void 0!==s?s:t.width,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.options.orientation!==st.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==st.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==st.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new D(new O(this.element[V]),ft(this.options.rule),this.options.width,dt(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class ri{static size(t,i){var s,n,o,r,e,h,l,u;return{x:new oi(t,{width:null===(s=i.size)||void 0===s?void 0:s.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(o=i.rule)||void 0===o?void 0:o.x,orientation:null===(r=i.orientation)||void 0===r?void 0:r.x}),y:new wt(t,{height:null===(e=i.size)||void 0===e?void 0:e.y,power:null===(h=i.power)||void 0===h?void 0:h.y,rule:null===(l=i.rule)||void 0===l?void 0:l.y,orientation:null===(u=i.orientation)||void 0===u?void 0:u.y})}}static distance(t,i,s){var n,o,r,e,h,l,u,a,d,c,v,f;return{x:new ti(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(o=s.anchorTwo)||void 0===o?void 0:o.x,distance:null===(r=s.distance)||void 0===r?void 0:r.x,power:null===(e=s.power)||void 0===e?void 0:e.x,rule:null===(h=s.rule)||void 0===h?void 0:h.x,orientation:null===(l=s.orientation)||void 0===l?void 0:l.x}),y:new si(t,i,{anchorOne:null===(u=s.anchorOne)||void 0===u?void 0:u.y,anchorTwo:null===(a=s.anchorTwo)||void 0===a?void 0:a.y,distance:null===(d=s.distance)||void 0===d?void 0:d.y,power:null===(c=s.power)||void 0===c?void 0:c.y,rule:null===(v=s.rule)||void 0===v?void 0:v.y,orientation:null===(f=s.orientation)||void 0===f?void 0:f.y})}}static proportion(t,i,s){var n,o,r,e,h,l,u,a;return{x:new ii(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(r=s.rule)||void 0===r?void 0:r.x,orientation:null===(e=s.orientation)||void 0===e?void 0:e.x}),y:new ni(t,i,{proportion:null===(h=s.proportion)||void 0===h?void 0:h.y,power:null===(l=s.power)||void 0===l?void 0:l.y,rule:null===(u=s.rule)||void 0===u?void 0:u.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}class ei extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:at(null==i?void 0:i.power),rule:vt(null==i?void 0:i.rule),orientation:ot(null==i?void 0:i.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new O(this.element[V]).plus(new O(this.element[R]).multiply(-this.parameters.aspect));this.constraint=new D(t,ft(this.parameters.rule),0,dt(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[q](this,this.constraint),this.constraint=void 0)}}class hi extends rt{constructor(t,i,s){var n,o,r;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(o=null==s?void 0:s.horizontalAnchor)&&void 0!==o?o:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new D(new O(this.elementOne[U]).plus(new O(this.elementOne[V]).multiply(this.parameters.horizontalAnchor)),T.Eq,new O(this.elementTwo[U]).plus(new O(this.elementTwo[V]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new D(new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),T.Eq,new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new D(new O(this.elementOne[V]),T.Le,new O(this.elementTwo[V])),this.constraintH=new D(new O(this.elementOne[R]),T.Le,new O(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),this.parameters.isStrict||(this.constraintStrict=new D(new O(this.elementOne[R]),T.Eq,new O(this.elementTwo[R]),I.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[q](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[q](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[q](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[q](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[q](this,this.constraintStrict),this.constraintStrict=void 0)}}function li(t){return null!==t&&"object"==typeof t&&("x"in t&&"number"==typeof t.x||"y"in t&&"number"==typeof t.y)}function ui(t){return null!==t&&"object"==typeof t&&("x"in t&&ut(t.x)||"y"in t&&ut(t.y))}function ai(t){return null!==t&&"object"==typeof t&&("x"in t&&ct(t.x)||"y"in t&&ct(t.y))}function di(t){return null!==t&&"object"==typeof t&&"elementOne"in t&&"elementTwo"in t&&(t.elementOne instanceof Xt||t.elementOne instanceof Qt)&&t.elementTwo instanceof Xt}function ci(t){return di(t)&&"distance"in t&&li(t.distance)&&(!("anchorOne"in t)||"anchorOne"in t&&li(t.anchorOne))&&(!("anchorTwo"in t)||"anchorTwo"in t&&li(t.anchorTwo))&&(!("power"in t)||ui(t.power))&&(!("rule"in t)||ai(t.rule))&&(!("orientation"in t)||nt(t.orientation))}function vi(t){return di(t)&&"proportion"in t&&li(t.proportion)&&(!("power"in t)||ui(t.power))&&(!("rule"in t)||ai(t.rule))&&(!("orientation"in t)||nt(t.orientation))}function fi(t){return di(t)&&"isStrict"in t&&"boolean"==typeof t.isStrict&&(!("anchor"in t)||"anchor"in t&&li(t.anchor))}function wi(t){return null!==t&&"object"==typeof t&&"element"in t&&t.element instanceof Xt&&(!("power"in t)||ut(t.power))&&(!("rule"in t)||ct(t.rule))}function pi(t){return wi(t)&&"height"in t&&"number"==typeof t.height}function gi(t){return wi(t)&&"keepAspect"in t&&"boolean"==typeof t.keepAspect}function mi(t){return wi(t)&&"keepSize"in t&&"boolean"==typeof t.keepSize}class yi{static fromDescription(t){const i=t instanceof Map?t.entries():Object.entries(t),s=new Map;for(const[t,o]of i){if(s.has(t))throw Error(`Duplicate constraint key "${t}" - each constraint must have a unique identifier`);if(wi(n=o)&&"width"in n&&"number"==typeof n.width)yi.buildWidthConstraint(t,o,s);else if(pi(o))yi.buildHeightConstraint(t,o,s);else if(gi(o))yi.buildKeepAspectConstraint(t,o,s);else if(mi(o))yi.buildKeepSizeConstraint(t,o,s);else if(ci(o))yi.buildDistanceConstraint(t,o,s);else if(vi(o))yi.buildProportionalConstraint(t,o,s);else{if(!fi(o))throw Error(`Invalid constraint type for "${t}". Expected one of: Width, Height, KeepAspect, KeepSize, Distance, Proportional, or Cover constraint`);yi.buildCoverConstraint(t,o,s)}}var n;return Object.fromEntries(s)}static buildWidthConstraint(t,i,s){s.set(t,new oi(i.element,{width:i.width,power:i.power,rule:i.rule,orientation:i.orientation}))}static buildHeightConstraint(t,i,s){s.set(t,new wt(i.element,{height:i.height,power:i.power,rule:i.rule,orientation:i.orientation}))}static buildKeepAspectConstraint(t,i,s){s.set(t,new ei(i.element,{power:i.power,rule:i.rule,orientation:i.orientation}))}static buildKeepSizeConstraint(t,i,s){const n=t.replace(/(KeepSize|Keep)$/,"")+"KeepWidth",o=t.replace(/(KeepSize|Keep)$/,"")+"KeepHeight";s.set(n,new oi(i.element,{power:i.power,rule:i.rule,orientation:i.orientation})),s.set(o,new wt(i.element,{power:i.power,rule:i.rule,orientation:i.orientation}))}static buildDistanceConstraint(t,i,s){var n,o,r,e,h,l,u,a;if("number"==typeof i.distance.x){const h=t.replace(/(HorizontalDistance|Distance)$/,"")+"HorizontalDistance";s.set(h,new ti(i.elementOne,i.elementTwo,{distance:i.distance.x,anchorOne:null===(n=i.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(o=i.anchorTwo)||void 0===o?void 0:o.x,power:null===(r=i.power)||void 0===r?void 0:r.x,rule:null===(e=i.rule)||void 0===e?void 0:e.x,orientation:i.orientation}))}if("number"==typeof i.distance.y){const n=t.replace(/(VerticalDistance|Distance)$/,"")+"VerticalDistance";s.set(n,new si(i.elementOne,i.elementTwo,{distance:i.distance.y,anchorOne:null===(h=i.anchorOne)||void 0===h?void 0:h.y,anchorTwo:null===(l=i.anchorTwo)||void 0===l?void 0:l.y,power:null===(u=i.power)||void 0===u?void 0:u.y,rule:null===(a=i.rule)||void 0===a?void 0:a.y,orientation:i.orientation}))}}static buildProportionalConstraint(t,i,s){var n,o,r,e;if("number"==typeof i.proportion.x){const r=t.replace(/(HorizontalProportional|HorizontalProportion|Proportional|Proportion)$/,"")+"HorizontalProportion";s.set(r,new ii(i.elementOne,i.elementTwo,{proportion:i.proportion.x,power:null===(n=i.power)||void 0===n?void 0:n.x,rule:null===(o=i.rule)||void 0===o?void 0:o.x,orientation:i.orientation}))}if("number"==typeof i.proportion.y){const n=t.replace(/(VerticalProportional|VerticalProportion|Proportional|Proportion)$/,"")+"VerticalProportion";s.set(n,new ni(i.elementOne,i.elementTwo,{proportion:i.proportion.y,power:null===(r=i.power)||void 0===r?void 0:r.y,rule:null===(e=i.rule)||void 0===e?void 0:e.y,orientation:i.orientation}))}}static buildCoverConstraint(t,i,s){var n,o;s.set(t,new hi(i.elementOne,i.elementTwo,{isStrict:i.isStrict,horizontalAnchor:null===(n=i.anchor)||void 0===n?void 0:n.x,verticalAnchor:null===(o=i.anchor)||void 0===o?void 0:o.y}))}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Yt||(Yt={}));class bi{static build(t,i,s,n={}){var o;const r=null!==(o=n.direction)&&void 0!==o?o:Yt.FROM_LEFT_TOP,e=[],h=[];e.push(new ti(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new ti(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const l=r===Yt.FROM_LEFT_TOP?1:0,u=r===Yt.FROM_LEFT_TOP?0:1;return h.push(new si(t,i,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation}),new si(t,s,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:e,verticalDistances:h}}}class xi{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:ti,proportionConstraint:ii,centerDistanceConstraint:si})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:si,proportionConstraint:ni,centerDistanceConstraint:ti})}static buildStack(t,i,s){const n=[],o=[],r=[];for(let e=0;e<t.length-1;e++){const h=t[e],l=t[e+1];n.push(new s.distanceConstraint(h,l,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),0!=i.keepProportions&&o.push(new s.proportionConstraint(h,l,{power:i.power,orientation:i.orientation})),0!=i.keepAlignment&&r.push(new s.centerDistanceConstraint(h,l,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:o,alignmentConstraints:r}}}class Ci extends Xt{constructor(t,i=100,s=100){super(t,new p,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Si extends Xt{constructor(t,i){var s,n;const o=null===(s=i.image)||void 0===s?void 0:s.width,r=null===(n=i.image)||void 0===n?void 0:n.height;Zt(o,r,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${o}) or height (${r}). Image dimensions must be non-zero positive numbers.`);const e=new It(i);super(t,new u($t,e),0,0,o,r),this.material=e,this.textureInternal=i,this.applyTransformations()}get texture(){return this.textureInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.textureInternal.image.width,this.textureInternal.image.height,this.material),this.applyTransformations()}}class Ei extends r{constructor(t,i){super({uniforms:g.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new e(1,1,1)},foregroundColor:{value:new e(1,1,1)},color:{value:new e(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:1,lights:0,fog:0})}getProgress(){return this.uniforms.progress.value}getBackgroundTexture(){return this.uniforms.background.value}getForegroundTexture(){return this.uniforms.foreground.value}getBackgroundColor(){return this.uniforms.color.value.getHex()}getForegroundColor(){return this.uniforms.color.value.getHex()}getColor(){return this.uniforms.color.value.getHex()}getBackgroundOpacity(){return this.uniforms.backgroundOpacity.value}getForegroundOpacity(){return this.uniforms.foregroundOpacity.value}getOpacity(){return this.uniforms.opacity.value}getAngle(){return this.uniforms.angle.value}getIsForwardDirection(){return 1===this.uniforms.direction.value}setProgress(t){this.uniforms.progress.value=t,this.uniformsNeedUpdate=1}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=1}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=1}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=1}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=1}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=1}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=1}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=1}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=1}}class ki extends Xt{constructor(t,i,s={}){var n,r,e,h,l,a;const d=null===(n=i.image)||void 0===n?void 0:n.width,c=null===(r=i.image)||void 0===r?void 0:r.height;Zt(d,c,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(h=null===(e=s.textureBackground)||void 0===e?void 0:e.image)||void 0===h?void 0:h.width,f=null===(a=null===(l=s.textureBackground)||void 0===l?void 0:l.image)||void 0===a?void 0:a.height;s.textureBackground&&Zt(v,f,`Invalid image dimensions - texture "${s.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new Ei(i,s.textureBackground),p=new u($t,w);s.progress&&w.setProgress(s.progress),s.isForegroundDirection&&w.setIsForwardDirection(s.isForegroundDirection),s.angle&&w.setAngle(o.degToRad(s.angle)),s.color&&w.setColor(s.color),s.opacity&&w.setOpacity(s.opacity),s.backgroundColor&&w.setBackgroundColor(s.backgroundColor),s.foregroundColor&&w.setForegroundColor(s.foregroundColor),s.backgroundOpacity&&w.setBackgroundOpacity(s.backgroundOpacity),s.foregroundOpacity&&w.setForegroundOpacity(s.foregroundOpacity);const g=null!=v?v:d,m=null!=c?c:f;super(t,p,0,0,g,m),this.material=w,this.imageWidth=g,this.imageHeight=m,this.applyTransformations()}get progress(){return this.material.getProgress()}get backgroundTexture(){return this.material.getBackgroundTexture()}get foregroundTexture(){return this.material.getForegroundTexture()}get backgroundColor(){return this.material.getBackgroundColor()}get foregroundColor(){return this.material.getForegroundColor()}get color(){return this.material.getColor()}get backgroundOpacity(){return this.material.getBackgroundOpacity()}get foregroundOpacity(){return this.material.getForegroundOpacity()}get opacity(){return this.material.getOpacity()}get angle(){return o.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(t){this.material.setAngle(o.degToRad(t)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}function Oi(t,i){var s,n,o,r,e,h,l,u,a,d,c,v,f,w,p,g,m,y,b,x,C,S,E,k,O,M,T,I;const $=Math.max(null!==(n=null!==(s=null==t?void 0:t.fontSize)&&void 0!==s?s:null==i?void 0:i.fontSize)&&void 0!==n?n:16,1),D=null!==(r=null!==(o=null==t?void 0:t.lineHeight)&&void 0!==o?o:null==i?void 0:i.lineHeight)&&void 0!==r?r:1.2*$,P=Math.max(null!==(h=null!==(e=null==t?void 0:t.shadowBlur)&&void 0!==e?e:null==i?void 0:i.shadowBlur)&&void 0!==h?h:0,0),z=Math.max(null!==(u=null!==(l=null==t?void 0:t.strokeWidth)&&void 0!==l?l:null==i?void 0:i.strokeWidth)&&void 0!==u?u:0,0);return{color:null!==(d=null!==(a=null==t?void 0:t.color)&&void 0!==a?a:null==i?void 0:i.color)&&void 0!==d?d:"#000000",fontFamily:null!==(v=null!==(c=null==t?void 0:t.fontFamily)&&void 0!==c?c:null==i?void 0:i.fontFamily)&&void 0!==v?v:"Arial",fontSize:$,fontStyle:null!==(w=null!==(f=null==t?void 0:t.fontStyle)&&void 0!==f?f:null==i?void 0:i.fontStyle)&&void 0!==w?w:"normal",fontWeight:null!==(g=null!==(p=null==t?void 0:t.fontWeight)&&void 0!==p?p:null==i?void 0:i.fontWeight)&&void 0!==g?g:"normal",lineHeight:D,enableShadow:null!==(y=null!==(m=null==t?void 0:t.enableShadow)&&void 0!==m?m:null==i?void 0:i.enableShadow)&&void 0!==y?y:0,shadowOffsetX:null!==(x=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==x?x:0,shadowOffsetY:null!==(S=null!==(C=null==t?void 0:t.shadowOffsetY)&&void 0!==C?C:null==i?void 0:i.shadowOffsetY)&&void 0!==S?S:0,shadowBlur:P,shadowColor:null!==(k=null!==(E=null==t?void 0:t.shadowColor)&&void 0!==E?E:null==i?void 0:i.shadowColor)&&void 0!==k?k:"transparent",enableStroke:null!==(M=null!==(O=null==t?void 0:t.enableStroke)&&void 0!==O?O:null==i?void 0:i.enableStroke)&&void 0!==M?M:0,strokeColor:null!==(I=null!==(T=null==t?void 0:t.strokeColor)&&void 0!==T?T:null==i?void 0:i.strokeColor)&&void 0!==I?I:"transparent",strokeWidth:z}}function Mi(t){return t.match(/\S+|\s|\n/g)||[]}function Ti(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),o=n.width,r=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(o),height:r,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ii(t,i,s,n,o){o.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(o.shadowOffsetX=n.shadowOffsetX,o.shadowOffsetY=n.shadowOffsetY,o.shadowBlur=n.shadowBlur,o.shadowColor=n.shadowColor),n.enableStroke&&(o.strokeStyle=n.strokeColor,o.lineWidth=n.strokeWidth,o.strokeText(s,t,i)),o.fillStyle=n.color,o.fillText(s,t,i)}class $i extends Xt{constructor(t,i,s={}){var n;const o=document.createElement("canvas"),r=o.getContext("2d");if(!r)throw Error("Failed to create canvas context");const e=[],h=Array.isArray(i)?i:[i];for(const t of h){const i="string"==typeof t,n=i?t:t.text,o=Oi(i?void 0:t.style,s.defaultStyle);for(const t of Mi(n)){const i=Ti(r,t,o);e.push({text:t,style:o,metrics:i})}}const l=((t,i)=>{const s=[];let n=[],o=0,r=0,e=0,h=0;for(const l of i)"\n"!==l.text?o+l.metrics.width<=t||0===n.length?(n.push(l),o+=l.metrics.width,r=Math.max(r,l.metrics.height),e=Math.max(e,l.metrics.baseline),h=Math.max(h,l.metrics.lineHeight)):(s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),n=[l],o=l.metrics.width,r=l.metrics.height,e=l.metrics.baseline,h=l.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),n=[],o=0,r=0,e=0,h=0);return n.length>0&&s.push({chunks:n,width:o,height:r,baseline:e,lineHeight:h}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,e),a=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map((t=>t.width)));let s=0;for(let i=0;i<t.length;i++){const n=t[i];s+=0===i?n.height:n.lineHeight,i===t.length-1&&(s+=n.baseline)}return{width:i,height:s}})(l),d=(t=>{var i,s,n,o;return"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(null!==(i=null==t?void 0:t.left)&&void 0!==i?i:0,0),right:Math.max(null!==(s=null==t?void 0:t.right)&&void 0!==s?s:0,0),top:Math.max(null!==(n=null==t?void 0:t.top)&&void 0!==n?n:0,0),bottom:Math.max(null!==(o=null==t?void 0:t.bottom)&&void 0!==o?o:0,0)}})(s.padding);o.width=a.width+d.left+d.right,o.height=a.height+d.top+d.bottom;const c=new m(o),v=new It(c);super(t,new u($t,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=o,this.context=r,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let o=this.padding.top;for(let t=0;t<s.length;t++){const r=s[t];let e=i;o+=0===t?r.height:r.lineHeight;for(const t of r.chunks)Ii(e,o,t.text,t.style,n),e+=t.metrics.width}})(0,this.padding.left,l,this.context),this.texture.needsUpdate=1,this.applyTransformations()}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),this.texture.dispose(),this.canvas.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.suggestedAspect!==t&&(this.suggestedAspect=t,this.height=this.width/((this.textBlockSize.width+this.padding.left+this.padding.right)/(this.textBlockSize.height+this.padding.top+this.padding.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.texture.image.width,this.texture.image.height,this.material),this.applyTransformations()}}function Di(t){return null!==t&&"object"==typeof t&&"background"in t&&t.background instanceof y&&"foreground"in t&&t.foreground instanceof y}function Pi(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}function zi(t){return null!==t&&"object"==typeof t&&"spans"in t&&Array.isArray(t.spans)&&t.spans.every((t=>"string"==typeof t||(t=>null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text)(t)))}function Ai(t){return!(null===t||"object"!=typeof t||"width"in t&&"number"!=typeof t.width||"height"in t&&"number"!=typeof t.height)}class Fi{static fromDescription(t,i){const s=i instanceof Map?i.entries():Object.entries(i),n=new Map;for(const[i,r]of s){if(n.has(i))throw Error(`Duplicate element key "${i}" - each UI element must have a unique identifier`);let s;if(r instanceof y)s=new Si(t,r);else if(null!==(o=r)&&"object"==typeof o&&"texture"in o&&o.texture instanceof y)s=new Si(t,r.texture);else if("string"==typeof r)s=new $i(t,[r]);else if(Di(r))s=new ki(t,r.foreground,{textureBackground:r.background});else if(Pi(r))s=new $i(t,[r.text],{defaultStyle:r.style});else if(zi(r))s=new $i(t,r.spans,{defaultStyle:r.defaultStyle});else{if(!Ai(r))throw Error(`Invalid UI element type for "${i}". Expected one of: Texture, UIImage, String, UITextDescription, or UITextEnhancedDescription`);s=new Ci(t,r.width,r.height)}n.set(i,s)}var o;return Object.fromEntries(n)}}class ji extends rt{constructor(t,i,s){var n,o,r;super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,Jt(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(o=null==s?void 0:s.horizontalAnchor)&&void 0!==o?o:.5,verticalAnchor:null!==(r=null==s?void 0:s.verticalAnchor)&&void 0!==r?r:.5,orientation:ot(null==s?void 0:s.orientation)},this.parameters.orientation!==st.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==st.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==st.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new D(new O(this.elementOne[U]).plus(new O(this.elementOne[V]).multiply(this.parameters.horizontalAnchor)),T.Eq,new O(this.elementTwo[U]).plus(new O(this.elementTwo[V]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new D(new O(this.elementOne[H]).plus(new O(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),T.Eq,new O(this.elementTwo[H]).plus(new O(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new D(new O(this.elementOne[V]),T.Ge,new O(this.elementTwo[V])),this.constraintH=new D(new O(this.elementOne[R]),T.Ge,new O(this.elementTwo[R])),this.layer[X](this,this.constraintX),this.layer[X](this,this.constraintY),this.layer[X](this,this.constraintW),this.layer[X](this,this.constraintH),0!=this.parameters.isStrict&&(this.constraintStrict=new D(new O(this.elementOne[R]),T.Eq,new O(this.elementTwo[R]),I.strong),this.layer[X](this,this.constraintStrict))}destroyConstraints(){this.constraintX&&(this.layer[q](this,this.constraintX),this.constraintX=void 0),this.constraintY&&(this.layer[q](this,this.constraintY),this.constraintY=void 0),this.constraintW&&(this.layer[q](this,this.constraintW),this.constraintW=void 0),this.constraintH&&(this.layer[q](this,this.constraintH),this.constraintH=void 0),this.constraintStrict&&(this.layer[q](this,this.constraintStrict),this.constraintStrict=void 0)}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Gt||(Gt={}));const Bi=Gt.PROPERTY_CHANGED;class Ui extends Xt{constructor(t,i={}){var s,n,o,r,e,h,a,w,p,g;const m=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(m<.1||m>8)throw Error(`Invalid resolution factor: ${m}. Must be between 0.1 and 8.`);const y=null!==(n=i.width)&&void 0!==n?n:512,x=null!==(o=i.height)&&void 0!==o?o:512;Zt(y,x,`Invalid width or height: ${y}x${x}. Must be positive.`);const C=new d(y*m,x*m,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(r=i.useDepth)&&void 0!==r?r:1,stencilBuffer:0}),S=new It(C.texture);super(t,new u($t,S),0,0,y,x),this.needsRenderInternal=0,this.sceneInternal=null!==(e=i.scene)&&void 0!==e?e:new l,this.cameraInternal=null!==(h=i.camera)&&void 0!==h?h:new b(75,y/x,.1,100),this.resolutionFactorInternal=m,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:Bi,null!==(w=i.renderedByDefault)&&void 0!==w&&w&&(this.needsRenderInternal=1),this.clearColorInternal=null!==(p=i.clearColor)&&void 0!==p?p:0,this.clearAlphaInternal=null!==(g=i.clearAlpha)&&void 0!==g?g:0,this.renderTarget=C,this.material=S,this.applyTransformations()}get needsRender(){return this.needsRenderInternal}get color(){return this.material.getColor()}get opacity(){return this.material.getOpacity()}get scene(){return this.sceneInternal}get camera(){return this.cameraInternal}get clearColor(){return this.clearColorInternal}get clearAlpha(){return this.clearAlphaInternal}get resolutionFactor(){return this.resolutionFactorInternal}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.sceneInternal!==t&&(this.sceneInternal=t,this.updateModeInternal===Gt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===Gt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===Gt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===Gt.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.resolutionFactorInternal!==t&&(this.resolutionFactorInternal=t,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),this.updateModeInternal===Gt.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.material.dispose(),this.renderTarget.dispose(),super.destroy()}requestRender(){this.needsRenderInternal=1,this.composerInternal.requestUpdate()}render(t){(this.needsRenderInternal||this.updateModeInternal===Gt.ALWAYS)&&(this.needsRenderInternal=0,this.renderTarget.setSize(this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal),t.setClearColor(this.clearColorInternal,this.clearAlpha),t.setRenderTarget(this.renderTarget),t.clear(1,1,0),t.render(this.sceneInternal,this.cameraInternal)),this.object.material=this.composerInternal.compose(t,this.width*this.resolutionFactorInternal,this.height*this.resolutionFactorInternal,this.material),this.applyTransformations()}}class Hi extends Qt{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.mode!==Tt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,n=i?i.bottom-t.clientY:window.innerHeight-t.clientY,o=this.calculateScale();this.clickInternal(s*o,n*o)},window.addEventListener("resize",this.onResize),window.addEventListener("pointerdown",this.onClick),this.onResize()}get tergetScreenHeight(){return this.targetScreenHeight}set tergetScreenHeight(t){this.targetScreenHeight=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.onResize),window.removeEventListener("pointerdown",this.onClick),super.destroy()}calculateScale(){var t;return(null!==(t=this.tergetScreenHeight)&&void 0!==t?t:window.innerHeight)/window.innerHeight}}class Vi extends Qt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Ri{}export{ei as UIAspectConstraint,ri as UIConstraint2DBuilder,yi as UIConstraintBuilder,bi as UIConstraintContainerBuilder,Yt as UIConstraintContainerDirection,ht as UIConstraintPower,lt as UIConstraintRule,xi as UIConstraintStackBuilder,hi as UICoverConstraint,Ci as UIDummy,Fi as UIElementBuilder,Rt as UIElementEvent,ji as UIFitConstraint,Hi as UIFullScreenLayer,zt as UIFullScreenQuad,wt as UIHeightConstraint,ti as UIHorizontalDistanceConstraint,ii as UIHorizontalProportionConstraint,Si as UIImage,Qt as UILayer,Wt as UILayerEvent,Vi as UIManualLayer,Tt as UIMode,st as UIOrientation,Ri as UIPass,ki as UIProgress,Ui as UIScene,Gt as UISceneUpdateMode,$i as UIText,si as UIVerticalDistanceConstraint,ni as UIVerticalProportionConstraint,oi as UIWidthConstraint};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|