laymur 0.1.53 → 0.1.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UIAnchor } from "../Elements/UIAnchor";
|
|
2
2
|
import { UIElement } from "../Elements/UIElement";
|
|
3
|
-
import
|
|
3
|
+
import { UILayer } from "../Layers/UILayer";
|
|
4
4
|
import { UIOrientation } from "../Miscellaneous/UIOrientation";
|
|
5
5
|
import { UIConstraint } from "./UIConstraint";
|
|
6
6
|
import type { UIConstraintPower } from "./UIConstraintPower";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { UIAnchor } from "../Elements/UIAnchor";
|
|
2
2
|
import { UIElement } from "../Elements/UIElement";
|
|
3
|
-
import
|
|
3
|
+
import { UILayer } from "../Layers/UILayer";
|
|
4
4
|
import { UIOrientation } from "../Miscellaneous/UIOrientation";
|
|
5
5
|
import { UIConstraint } from "./UIConstraint";
|
|
6
6
|
import type { UIConstraintPower } from "./UIConstraintPower";
|
package/dist/index.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ export * from "./Builders/UIConstraint2DBuilder";
|
|
|
2
2
|
export * from "./Builders/UIConstraintContainerBuilder";
|
|
3
3
|
export * from "./Builders/UIConstraintStackBuilder";
|
|
4
4
|
export * from "./Constraints/UIAspectConstraint";
|
|
5
|
+
export * from "./Constraints/UIConstraint";
|
|
5
6
|
export * from "./Constraints/UIConstraintPower";
|
|
6
7
|
export * from "./Constraints/UIConstraintRule";
|
|
7
8
|
export * from "./Constraints/UICoverConstraint";
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as n,Vector3 as r,ShaderMaterial as h,Color as o,PlaneGeometry as e,Scene as u,Mesh as l,OrthographicCamera as a,WebGLRenderTarget as d,UnsignedByteType as c,LinearFilter as v,RGBAFormat as f,NoBlending as w,Object3D as g,UniformsUtils as p,PerspectiveCamera as m,CanvasTexture as y}from"three";function b(){return new x}var x=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 C(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 C(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}(),C=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),S=function(){function t(t){void 0===t&&(t=""),this.t=0,this.i=null,this.h=E++,this.o=t}return t.prototype.id=function(){return this.h},t.prototype.name=function(){return this.o},t.prototype.setName=function(t){this.o=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 k(this,t)},t.prototype.minus=function(t){return new k(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new k([t,this])},t.prototype.divide=function(t){return new k([1/t,this])},t.prototype.toJSON=function(){return{name:this.o,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.o+":"+this.t+"]"},t}(),E=0,k=function(){function t(){var t=O(arguments);this.u=t.terms,this.l=t.constant}return t.prototype.terms=function(){return this.u},t.prototype.constant=function(){return this.l},t.prototype.value=function(){for(var t=this.l,i=0,s=this.u.size();i<s;i++){var n=this.u.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.u.size()},t.prototype.toString=function(){var t=this.u.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.l||(t+=" + "),t+this.l},t}();function O(t){for(var i=0,s=()=>0,n=b(),r=0,h=t.length;r<h;++r){var o=t[r];if("number"==typeof o)i+=o;else if(o instanceof S)n.setDefault(o,s).second+=1;else if(o instanceof k){i+=o.constant();for(var e=0,u=(c=o.terms()).size();e<u;e++){var l=c.itemAt(e);n.setDefault(l.first,s).second+=l.second}}else{if(!(o instanceof Array))throw Error("invalid Expression argument: "+o);if(2!==o.length)throw Error("array must have length 2");var a=o[0],d=o[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof S)n.setDefault(d,s).second+=a;else{if(!(d instanceof k))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,e=0,u=(c=d.terms()).size();e<u;e++)l=c.itemAt(e),n.setDefault(l.first,s).second+=l.second*a}}}return{terms:n,constant:i}}var M,T=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*n)),(r+=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 F,I=function(){function t(t,i,s,n){void 0===n&&(n=T.required),this.h=A++,this.v=i,this.p=T.clip(n),this.m=void 0===s&&t instanceof k?t:t.minus(s)}return t.prototype.id=function(){return this.h},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,B=function(){function t(){this.C=b(),this.S=b(),this.k=b(),this.O=b(),this.M=[],this.T=new U,this.F=null,this.I=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=T.required);var r=new I(t,i,s,n);return this.addConstraint(r),r},t.prototype.addConstraint=function(t){if(void 0!==this.C.find(t))throw Error("duplicate constraint");var i=this.A(t),s=i.row,n=i.tag,r=this.B(s,n);if(r.type()===F.Invalid&&s.allDummies()){if(!$(s.constant()))throw Error("unsatisfiable constraint");r=n.marker}if(r.type()===F.Invalid){if(!this.$(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this.P(r,s),this.S.insert(r,s);this.C.insert(t,n),this.U(this.T)},t.prototype.removeConstraint=function(t){var i=this.C.erase(t);if(void 0===i)throw Error("unknown constraint");this.D(t,i.second);var s=i.second.marker,n=this.S.erase(s);if(void 0===n){var r=this.V(s);if(r.type()===F.Invalid)throw Error("failed to find leaving row");(n=this.S.erase(r)).second.solveForEx(r,s),this.P(s,n.second)}this.U(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=T.clip(i))===T.required)throw Error("bad required strength");var s=new k(t),n=new I(s,M.Eq,void 0,i);this.addConstraint(n);var r=this.C.find(n).second;this.O.insert(t,{tag:r,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,r=s.second,h=i-r.constant;r.constant=i;var o=r.tag.marker,e=n.find(o);if(void 0!==e)return e.second.add(-h)<0&&this.M.push(o),void this.H();var u=r.tag.other;if(void 0!==(e=n.find(u)))return e.second.add(h)<0&&this.M.push(u),void this.H();for(var l=0,a=n.size();l<a;++l){var d=n.itemAt(l),c=d.second,v=c.coefficientFor(o);0!==v&&c.add(h*v)<0&&d.first.type()!==F.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 r=t.itemAt(s),h=i.find(r.second);r.first.setValue(void 0!==h?h.second.constant():0)}},t.prototype.R=function(t){var i=this;return this.k.setDefault(t,(()=>i.L(F.External))).second},t.prototype.A=function(t){for(var i=t.expression(),s=new U(i.constant()),n=i.terms(),r=0,h=n.size();r<h;++r){var o=n.itemAt(r);if(!$(o.second)){var e=this.R(o.first),u=this.S.find(e);void 0!==u?s.insertRow(u.second,o.second):s.insertSymbol(e,o.second)}}var l=this.T,a=t.strength(),d={marker:z,other:z};switch(t.op()){case M.Le:case M.Ge:var c=t.op()===M.Le?1:-1,v=this.L(F.Slack);if(d.marker=v,s.insertSymbol(v,c),a<T.required){var f=this.L(F.Error);d.other=f,s.insertSymbol(f,-c),l.insertSymbol(f,a)}break;case M.Eq:if(a<T.required){var w=this.L(F.Error),g=this.L(F.Error);d.marker=w,d.other=g,s.insertSymbol(w,-1),s.insertSymbol(g,1),l.insertSymbol(w,a),l.insertSymbol(g,a)}else{var p=this.L(F.Dummy);d.marker=p,s.insertSymbol(p)}}return s.constant()<0&&s.reverseSign(),{row:s,tag:d}},t.prototype.B=(t,i)=>{for(var s=t.cells(),n=0,r=s.size();n<r;++n){var h=s.itemAt(n);if(h.first.type()===F.External)return h.first}var o=i.marker.type();return(o===F.Slack||o===F.Error)&&t.coefficientFor(i.marker)<0?i.marker:((o=i.other.type())===F.Slack||o===F.Error)&&t.coefficientFor(i.other)<0?i.other:z},t.prototype.$=function(t){var i=this.L(F.Slack);this.S.insert(i,t.copy()),this.F=t.copy(),this.U(this.F);var s=$(this.F.constant());this.F=null;var n=this.S.erase(i);if(void 0!==n){var r=n.second;if(r.isConstant())return s;var h=this._(r);if(h.type()===F.Invalid)return 0;r.solveForEx(i,h),this.P(h,r),this.S.insert(h,r)}for(var o=this.S,e=0,u=o.size();e<u;++e)o.itemAt(e).second.removeSymbol(i);return this.T.removeSymbol(i),s},t.prototype.P=function(t,i){for(var s=this.S,n=0,r=s.size();n<r;++n){var h=s.itemAt(n);h.second.substitute(t,i),h.second.constant()<0&&h.first.type()!==F.External&&this.M.push(h.first)}this.T.substitute(t,i),this.F&&this.F.substitute(t,i)},t.prototype.U=function(t){for(;;){var i=this.j(t);if(i.type()===F.Invalid)return;var s=this.N(i);if(s.type()===F.Invalid)throw Error("the objective is unbounded");var n=this.S.erase(s).second;n.solveForEx(s,i),this.P(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 r=this.X(n.second);if(r.type()===F.Invalid)throw Error("dual optimize failed");var h=n.second;t.erase(s),h.solveForEx(s,r),this.P(r,h),t.insert(r,h)}}},t.prototype.j=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),h=r.first;if(r.second<0&&h.type()!==F.Dummy)return h}return z},t.prototype.X=function(t){for(var i=Number.MAX_VALUE,s=z,n=t.cells(),r=0,h=n.size();r<h;++r){var o=n.itemAt(r),e=o.first,u=o.second;if(u>0&&e.type()!==F.Dummy){var l=this.T.coefficientFor(e)/u;l<i&&(i=l,s=e)}}return s},t.prototype.N=function(t){for(var i=Number.MAX_VALUE,s=z,n=this.S,r=0,h=n.size();r<h;++r){var o=n.itemAt(r),e=o.first;if(e.type()!==F.External){var u=o.second,l=u.coefficientFor(t);if(l<0){var a=-u.constant()/l;a<i&&(i=a,s=e)}}}return s},t.prototype.V=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,r=z,h=r,o=r,e=r,u=this.S,l=0,a=u.size();l<a;++l){var d=u.itemAt(l),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===F.External)e=f;else if(v<0)(w=-c.constant()/v)<s&&(s=w,h=f);else{var w;(w=c.constant()/v)<n&&(n=w,o=f)}}}return h!==r?h:o!==r?o:e},t.prototype.D=function(t,i){i.marker.type()===F.Error&&this.Y(i.marker,t.strength()),i.other.type()===F.Error&&this.Y(i.other,t.strength())},t.prototype.Y=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._=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),h=r.first.type();if(h===F.Slack||h===F.Error)return r.first}return z},t.prototype.L=function(t){return new P(t,this.I++)},t}();function $(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"})(F||(F={}));var P=function(){function t(t,i){this.h=i,this.q=t}return t.prototype.id=function(){return this.h},t.prototype.type=function(){return this.q},t}(),z=new P(F.Invalid,-1),U=function(){function t(t){void 0===t&&(t=0),this.G=b(),this.l=t}return t.prototype.cells=function(){return this.G},t.prototype.constant=function(){return this.l},t.prototype.isConstant=function(){return this.G.empty()},t.prototype.allDummies=function(){for(var t=this.G,i=0,s=t.size();i<s;++i)if(t.itemAt(i).first.type()!==F.Dummy)return 0;return 1},t.prototype.copy=function(){var i=new t(this.l);return i.G=this.G.copy(),i},t.prototype.add=function(t){return this.l+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),$(this.G.setDefault(t,(()=>0)).second+=i)&&this.G.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.l+=t.l*i;for(var s=t.G,n=0,r=s.size();n<r;++n){var h=s.itemAt(n);this.insertSymbol(h.first,h.second*i)}},t.prototype.removeSymbol=function(t){this.G.erase(t)},t.prototype.reverseSign=function(){this.l=-this.l;for(var t=this.G,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.G,s=-1/i.erase(t).second;this.l*=s;for(var n=0,r=i.size();n<r;++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.G.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.G.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const D=Symbol("xSymbol"),V=Symbol("ySymbol"),H=Symbol("widthSymbol"),R=Symbol("heightSymbol"),L=Symbol("addUIElementSymbol"),_=Symbol("removeUIElementSymbol"),j=Symbol("addConstraintSymbol"),N=Symbol("removeUIConstraintSymbol"),X=Symbol("addConstraintSymbol"),Y=Symbol("removeConstraintSymbol"),q=Symbol("addVariableSymbol"),G=Symbol("removeVariableSymbol"),W=Symbol("suggestVariableSymbol"),Q=Symbol("disableConstraintSymbol"),J=Symbol("enableConstraintSymbol"),K=Symbol("needsRecalculation"),Z=Symbol("renderSymbol"),tt=Symbol("clickSymbol");var it;function st(t){return null!==t&&Object.values(it).some((i=>i===t))}function nt(t){return null!=t?t:it.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(it||(it={}));class rt{constructor(t,i){this.layer=t,this.name="",this.layer[j](this,i)}destroy(){this.layer[N](this)}}const ht=1e3;var ot,et,ut,lt;function at(t){return null!==t&&Object.values(ot).some((i=>i===t))}function dt(t){return null!=t?t:ot.P0}function ct(t){switch(t){case ot.P0:return T.create(ht,ht,ht);case ot.P1:return T.create(100,0,0);case ot.P2:return T.create(10,0,0);case ot.P3:return T.create(0,100,0);case ot.P4:return T.create(0,10,0);case ot.P5:return T.create(0,0,100);case ot.P6:return T.create(0,0,10);case ot.P7:return T.create(0,0,1);default:return T.create(ht,ht,ht)}}function vt(t){return null!==t&&Object.values(et).some((i=>i===t))}function ft(t){return null!=t?t:et.EQUAL}function wt(t){switch(t){case et.EQUAL:return M.Eq;case et.LESS:return M.Le;case et.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"})(ot||(ot={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(et||(et={}));class gt 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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.options.orientation!==it.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==it.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==it.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[R]),wt(this.options.rule),this.options.height,ct(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 r=n.filter((t=>t.callback!==i||void 0!==s&&t.context!==s));return r.length?this.listeners.set(t,r):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,r){let h=this.listeners.get(t);if(h||(h=[],this.listeners.set(t,h)),h.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const o={callback:i,context:s,priority:n,once:r};let e=0;for(;e<h.length&&h[e].priority<=n;)e++;h.splice(e,0,o)}}class mt extends pt{constructor(i,s,n,r){super(),this.layer=i,this.object=r,this[ut]=new S("x"),this[lt]=new S("y"),this.name=t.generateUUID(),this.layer[L](this,r),this.layer[q](this,this[D],ct(ot.P7)),this.layer[q](this,this[V],ct(ot.P7)),this[D].setValue(s),this[V].setValue(n),this.layer[W](this,this[D],s),this.layer[W](this,this[V],n)}get x(){return this[D].value()}get y(){return this[V].value()}set x(t){this.layer[W](this,this[D],t)}set y(t){this.layer[W](this,this[V],t)}destroy(){this.layer[G](this,this[V]),this.layer[G](this,this[D]),this.layer[_](this)}[(ut=D,lt=V,Z)](t,i){this.render(t,i)}}const yt=new i,bt=new s,xt=new n,Ct=new n,St=new n,Et=new n,kt=new n,Ot=new r,Mt=.5;class Tt{constructor(){this.x=0,this.y=0,this.anchorX=Mt,this.anchorY=Mt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Ft{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 t.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(i){const s=t.degToRad(i);s!==this.raw.rotation&&(this.raw.rotation=s,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===Mt&&this.raw.anchorY===Mt&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Mt,this.raw.anchorY=Mt,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}var It;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(It||(It={}));class At extends h{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new o(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 Bt=new e(1,1).translate(.5,.5,0),$t=new u,Pt=new l(Bt);$t.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($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 Ut{constructor(){this.passes=[],this.defaultMaterial=new At,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,r=1){const h=this.hasValuablePasses();if(!(this.needsUpdateInternal&&h||this.hasPassesNeedingUpdate()))return h||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,h?this.defaultMaterial:n;const o=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==o,this.paddingInternal=o;const e=i+2*o,u=s+2*o;this.fromRenderTarget.setSize(e,u),this.toRenderTarget.setSize(e,u),this.setScreenPadding(i,s,o),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0);const l=n.blending;r&&(n.blending=w),this.screen.render(t,n),n.blending=l;const a={width:i,height:s,padding:o};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 Dt{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var Vt,Ht,Rt,Lt,_t,jt,Nt,Xt,Yt,qt;(t=>{t.CLICK="click"})(jt||(jt={}));class Gt extends pt{constructor(i,s,n,r,h,o){super(),this.layer=i,this.object=s,this[Vt]=new S("x"),this[Ht]=new S("y"),this[Rt]=new S("width"),this[Lt]=new S("height"),this[_t]=0,this.name=t.generateUUID(),this.microInternal=new Tt,this.composerInternal=new Ut,this.modeInternal=It.VISIBLE,this.micro=new Ft(this.microInternal,this),this.composer=new Dt(this.composerInternal),this.layer[L](this,this.object),this.layer[q](this,this[D],ct(ot.P7)),this.layer[q](this,this[V],ct(ot.P7)),this.layer[q](this,this[H],ct(ot.P5)),this.layer[q](this,this[R],ct(ot.P5)),this[D].setValue(n),this[V].setValue(r),this[H].setValue(h),this[R].setValue(o),this.layer[W](this,this[D],n),this.layer[W](this,this[V],r),this.layer[W](this,this[H],h),this.layer[W](this,this[R],o)}get x(){return this[D].value()}get y(){return this[V].value()}get width(){return this[H].value()}get height(){return this[R].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[K]}set x(t){this.layer[W](this,this[D],t)}set y(t){this.layer[W](this,this[V],t)}set width(t){this.layer[W](this,this[H],t)}set height(t){this.layer[W](this,this[R],t)}set zIndex(t){this.object.position.z=t}set mode(t){this.modeInternal=t,this.object.visible=t!==It.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[G](this,this[R]),this.layer[G](this,this[H]),this.layer[G](this,this[V]),this.layer[G](this,this[D]),this.layer[_](this)}[(Vt=D,Ht=V,Rt=H,Lt=R,_t=K,Z)](t,i){this.render(t,i)}[tt](t,i){return this.click(t,i)}applyTransformations(){(this[K]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,r,h,o)=>{const e=this.x-o,u=this.y-o,l=this.width+2*o,a=this.height+2*o,d=e+l*i.anchorX,c=u+a*i.anchorY,v=xt.set(1,0,-d,0,1,-c,0,0,1),f=Ct.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=St.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Et.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=kt.multiplyMatrices(g,w).multiply(f).multiply(v),m=Ot.set(e,u,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=l*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this[K]=0,this.microInternal.needsRecalculation=0)}click(t,i){return this.mode!==It.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,r=this.width,h=this.height,yt.set(t,i),bt.min.set(s,n),bt.max.set(r,h).add(bt.min),bt.containsPoint(yt)?(this.emit(jt.CLICK,this),1):0);var s,n,r,h}}const Wt=new o(0);var Qt,Jt,Kt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(Qt||(Qt={}));class Zt extends pt{constructor(){super(...arguments),this.mode=It.VISIBLE,this[Nt]=new S,this[Xt]=new S,this[Yt]=new S,this[qt]=new S,this.scene=new u,this.camera=new a,this.solver=new B,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=it.PORTRAIT,this.needsRecalculation=0}get orientation(){return this.orientationPrivate}get width(){return this[H].value()}get height(){return this[R].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Nt=D,Xt=V,Yt=H,qt=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&&(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),i.object&&this.scene.remove(i.object)}[j](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 r=t instanceof Gt||t instanceof mt?this.elements.get(t):this.constraints.get(t);if(void 0===r)throw Error("Before adding variable you need to add it's owner");if(r.variables.has(i))throw Error("Variable already exists");r.variables.set(i,{strength:s,suggestedValue:i.value()}),null===(n=this.solver)||void 0===n||n.addEditVariable(i,s),this.needsRecalculation=1}[G](t,i){var s;const n=t instanceof Gt||t instanceof mt?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}[W](t,i,s){var n;const r=t instanceof Gt||t instanceof mt?this.elements.get(t):this.constraints.get(t);if(void 0===r)throw Error("Before suggesting variable you need to add it's owner");const h=r.variables.get(i);if(!h)throw Error("Variable does not exist");h.suggestedValue!==s&&(h.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===It.HIDDEN)return;const n=t.getRenderTarget(),r=t.getClearColor(Wt),h=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 instanceof Gt&&(t[K]=1)}for(const s of this.elements.keys())s[Z](t,i);t.setRenderTarget(n),t.setClearColor(r),t.setClearAlpha(h),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==It.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t instanceof Gt)).filter((t=>t instanceof Gt&&t.mode===It.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[tt](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,r,h,o,e,u,l;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===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(h=this.solver)||void 0===h||h.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new I(new k(this[D]),M.Eq,0,T.required),this.constraintY=new I(new k(this[V]),M.Eq,0,T.required),this.constraintW=new I(new k(this[H]),M.Eq,t,T.required),this.constraintH=new I(new k(this[R]),M.Eq,i,T.required),null===(o=this.solver)||void 0===o||o.addConstraint(this.constraintX),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintY),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintW),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?it.LANDSCAPE:it.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 B;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 ti(t,i){if((t instanceof Zt?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 ii(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 si extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt||t instanceof mt?[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!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(h=null==s?void 0:s.distance)&&void 0!==h?h:0,power:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Gt?new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.anchorOne)):new k(this.elementOne[D]),i=this.elementTwo instanceof Gt?new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[D]);this.constraint=new I(i.minus(t),wt(this.parameters.rule),this.parameters.distance,ct(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;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[H]).multiply(this.parameters.proportion),i=new k(this.elementTwo[H]);this.constraint=new I(t.minus(i),wt(this.parameters.rule),0,ct(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ri extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt||t instanceof mt?[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!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(h=null==s?void 0:s.distance)&&void 0!==h?h:0,power:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Gt?new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.anchorOne)):new k(this.elementOne[V]),i=this.elementTwo instanceof Gt?new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[V]);this.constraint=new I(i.minus(t),wt(this.parameters.rule),this.parameters.distance,ct(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;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[R]).multiply(this.parameters.proportion),i=new k(this.elementTwo[R]);this.constraint=new I(t.minus(i),wt(this.parameters.rule),0,ct(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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.options.orientation!==it.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==it.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==it.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[H]),wt(this.options.rule),this.options.width,ct(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ei{static size(t,i){var s,n,r,h,o,e,u,l;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===(r=i.rule)||void 0===r?void 0:r.x,orientation:null===(h=i.orientation)||void 0===h?void 0:h.x}),y:new gt(t,{height:null===(o=i.size)||void 0===o?void 0:o.y,power:null===(e=i.power)||void 0===e?void 0:e.y,rule:null===(u=i.rule)||void 0===u?void 0:u.y,orientation:null===(l=i.orientation)||void 0===l?void 0:l.y})}}static distance(t,i,s){var n,r,h,o,e,u,l,a,d,c,v,f;return{x:new si(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(r=s.anchorTwo)||void 0===r?void 0:r.x,distance:null===(h=s.distance)||void 0===h?void 0:h.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(e=s.rule)||void 0===e?void 0:e.x,orientation:null===(u=s.orientation)||void 0===u?void 0:u.x}),y:new ri(t,i,{anchorOne:null===(l=s.anchorOne)||void 0===l?void 0:l.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,r,h,o,e,u,l,a;return{x:new ni(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(r=s.power)||void 0===r?void 0:r.x,rule:null===(h=s.rule)||void 0===h?void 0:h.x,orientation:null===(o=s.orientation)||void 0===o?void 0:o.x}),y:new hi(t,i,{proportion:null===(e=s.proportion)||void 0===e?void 0:e.y,power:null===(u=s.power)||void 0===u?void 0:u.y,rule:null===(l=s.rule)||void 0===l?void 0:l.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Jt||(Jt={}));class ui{static build(t,i,s,n={}){var r;const h=null!==(r=n.direction)&&void 0!==r?r:Jt.FROM_LEFT_TOP,o=[],e=[];o.push(new si(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new si(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const u=h===Jt.FROM_LEFT_TOP?1:0,l=h===Jt.FROM_LEFT_TOP?0:1;return e.push(new ri(t,i,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation}),new ri(t,s,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:o,verticalDistances:e}}}class li{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:si,proportionConstraint:ni,centerDistanceConstraint:ri})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:ri,proportionConstraint:hi,centerDistanceConstraint:si})}static buildStack(t,i,s){const n=[],r=[],h=[];for(let o=0;o<t.length-1;o++){const e=t[o],u=t[o+1];n.push(new s.distanceConstraint(e,u,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),0!=i.keepProportions&&r.push(new s.proportionConstraint(e,u,{power:i.power,orientation:i.orientation})),0!=i.keepAlignment&&h.push(new s.centerDistanceConstraint(e,u,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:r,alignmentConstraints:h}}}class ai 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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.element[H]).plus(new k(this.element[R]).multiply(-this.parameters.aspect));this.constraint=new I(t,wt(this.parameters.rule),0,ct(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class di extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(h=null==s?void 0:s.verticalAnchor)&&void 0!==h?h:.5,orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Le,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Le,new k(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 I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.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)}}class ci extends rt{constructor(t,i,s){var n,r,h;super(i.layer,new Set(t instanceof Gt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,ti(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(h=null==s?void 0:s.verticalAnchor)&&void 0!==h?h:.5,orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Ge,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Ge,new k(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 I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.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)}}class vi extends Gt{constructor(t,i=100,s=100){super(t,new g,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class fi extends Gt{constructor(t,i){var s,n;const r=null===(s=i.image)||void 0===s?void 0:s.width,h=null===(n=i.image)||void 0===n?void 0:n.height;ii(r,h,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${r}) or height (${h}). Image dimensions must be non-zero positive numbers.`);const o=new At(i);super(t,new l(Bt,o),0,0,r,h),this.material=o,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 wi extends h{constructor(t,i){super({uniforms:p.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new o(1,1,1)},foregroundColor:{value:new o(1,1,1)},color:{value:new o(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 gi extends Gt{constructor(i,s,n={}){var r,h,o,e,u,a;const d=null===(r=s.image)||void 0===r?void 0:r.width,c=null===(h=s.image)||void 0===h?void 0:h.height;ii(d,c,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(e=null===(o=n.textureBackground)||void 0===o?void 0:o.image)||void 0===e?void 0:e.width,f=null===(a=null===(u=n.textureBackground)||void 0===u?void 0:u.image)||void 0===a?void 0:a.height;n.textureBackground&&ii(v,f,`Invalid image dimensions - texture "${n.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new wi(s,n.textureBackground),g=new l(Bt,w);n.progress&&w.setProgress(n.progress),n.isForegroundDirection&&w.setIsForwardDirection(n.isForegroundDirection),n.angle&&w.setAngle(t.degToRad(n.angle)),n.color&&w.setColor(n.color),n.opacity&&w.setOpacity(n.opacity),n.backgroundColor&&w.setBackgroundColor(n.backgroundColor),n.foregroundColor&&w.setForegroundColor(n.foregroundColor),n.backgroundOpacity&&w.setBackgroundOpacity(n.backgroundOpacity),n.foregroundOpacity&&w.setForegroundOpacity(n.foregroundOpacity);const p=null!=v?v:d,m=null!=c?c:f;super(i,g,0,0,p,m),this.material=w,this.imageWidth=p,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 t.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(i){this.material.setAngle(t.degToRad(i)),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()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Kt||(Kt={}));const pi=Kt.PROPERTY_CHANGED;class mi extends Gt{constructor(t,i={}){var s,n,r,h,o,e,a,w,g,p;const y=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(y<.1||y>8)throw Error(`Invalid resolution factor: ${y}. Must be between 0.1 and 8.`);const b=null!==(n=i.width)&&void 0!==n?n:512,x=null!==(r=i.height)&&void 0!==r?r:512;ii(b,x,`Invalid width or height: ${b}x${x}. Must be positive.`);const C=new d(b*y,x*y,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(h=i.useDepth)&&void 0!==h?h:1,stencilBuffer:0}),S=new At(C.texture);super(t,new l(Bt,S),0,0,b,x),this.needsRenderInternal=0,this.sceneInternal=null!==(o=i.scene)&&void 0!==o?o:new u,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new m(75,b/x,.1,100),this.resolutionFactorInternal=y,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:pi,null!==(w=i.renderedByDefault)&&void 0!==w&&w&&(this.needsRenderInternal=1),this.clearColorInternal=null!==(g=i.clearColor)&&void 0!==g?g:0,this.clearAlphaInternal=null!==(p=i.clearAlpha)&&void 0!==p?p: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===Kt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===Kt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===Kt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===Kt.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===Kt.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===Kt.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()}}function yi(t,i){var s,n,r,h,o,e,u,l,a,d,c,v,f,w,g,p,m,y,b,x,C,S,E,k,O,M,T,F;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),A=null!==(h=null!==(r=null==t?void 0:t.lineHeight)&&void 0!==r?r:null==i?void 0:i.lineHeight)&&void 0!==h?h:1.2*I,B=Math.max(null!==(e=null!==(o=null==t?void 0:t.shadowBlur)&&void 0!==o?o:null==i?void 0:i.shadowBlur)&&void 0!==e?e:0,0),$=Math.max(null!==(l=null!==(u=null==t?void 0:t.strokeWidth)&&void 0!==u?u:null==i?void 0:i.strokeWidth)&&void 0!==l?l: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!==(p=null!==(g=null==t?void 0:t.fontWeight)&&void 0!==g?g:null==i?void 0:i.fontWeight)&&void 0!==p?p:"normal",lineHeight:A,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:B,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!==(F=null!==(T=null==t?void 0:t.strokeColor)&&void 0!==T?T:null==i?void 0:i.strokeColor)&&void 0!==F?F:"transparent",strokeWidth:$}}function bi(t){return t.match(/\S+|\s|\n/g)||[]}function xi(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),r=n.width,h=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(r),height:h,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ci(t,i,s,n,r){r.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(r.shadowOffsetX=n.shadowOffsetX,r.shadowOffsetY=n.shadowOffsetY,r.shadowBlur=n.shadowBlur,r.shadowColor=n.shadowColor),n.enableStroke&&(r.strokeStyle=n.strokeColor,r.lineWidth=n.strokeWidth,r.strokeText(s,t,i)),r.fillStyle=n.color,r.fillText(s,t,i)}class Si extends Gt{constructor(t,i,s={}){var n;const r=document.createElement("canvas"),h=r.getContext("2d");if(!h)throw Error("Failed to create canvas context");const o=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,r=yi(i?void 0:t.style,s.defaultStyle);for(const t of bi(n)){const i=xi(h,t,r);o.push({text:t,style:r,metrics:i})}}const u=((t,i)=>{const s=[];let n=[],r=0,h=0,o=0,e=0;for(const u of i)"\n"!==u.text?r+u.metrics.width<=t||0===n.length?(n.push(u),r+=u.metrics.width,h=Math.max(h,u.metrics.height),o=Math.max(o,u.metrics.baseline),e=Math.max(e,u.metrics.lineHeight)):(s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),n=[u],r=u.metrics.width,h=u.metrics.height,o=u.metrics.baseline,e=u.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),n=[],r=0,h=0,o=0,e=0);return n.length>0&&s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,o),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}})(u),d=(t=>{var i,s,n,r;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!==(r=null==t?void 0:t.bottom)&&void 0!==r?r:0,0)}})(s.padding);r.width=a.width+d.left+d.right,r.height=a.height+d.top+d.bottom;const c=new y(r),v=new At(c);super(t,new l(Bt,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=r,this.context=h,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let r=this.padding.top;for(let t=0;t<s.length;t++){const h=s[t];let o=i;r+=0===t?h.height:h.lineHeight;for(const t of h.chunks)Ci(o,r,t.text,t.style,n),o+=t.metrics.width}})(0,this.padding.left,u,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()}}class Ei extends Zt{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!==It.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,r=this.calculateScale();this.clickInternal(s*r,n*r)},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 ki extends Zt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Oi{}export{mt as UIAnchor,ai as UIAspectConstraint,ei as UIConstraint2DBuilder,ui as UIConstraintContainerBuilder,Jt as UIConstraintContainerDirection,ot as UIConstraintPower,et as UIConstraintRule,li as UIConstraintStackBuilder,di as UICoverConstraint,vi as UIDummy,Gt as UIElement,jt as UIElementEvent,ci as UIFitConstraint,Ei as UIFullScreenLayer,zt as UIFullScreenQuad,gt as UIHeightConstraint,si as UIHorizontalDistanceConstraint,ni as UIHorizontalProportionConstraint,fi as UIImage,Zt as UILayer,Qt as UILayerEvent,ki as UIManualLayer,It as UIMode,it as UIOrientation,Oi as UIPass,gi as UIProgress,mi as UIScene,Kt as UISceneUpdateMode,Si as UIText,ri as UIVerticalDistanceConstraint,hi as UIVerticalProportionConstraint,oi as UIWidthConstraint,X as addConstraintSymbol,j as addUIConstraintSymbol,L as addUIElementSymbol,q as addVariableSymbol,tt as clickSymbol,ct as convertPowerToStrength,wt as convertRuleToOperator,Q as disableConstraintSymbol,J as enableConstraintSymbol,R as heightSymbol,at as isUIConstraintPower,vt as isUIConstraintRule,st as isUIOrientation,K as needsRecalculation,Y as removeConstraintSymbol,N as removeUIConstraintSymbol,_ as removeUIElementSymbol,G as removeVariableSymbol,Z as renderSymbol,nt as resolveOrientation,dt as resolvePower,ft as resolveRule,W as suggestVariableSymbol,H as widthSymbol,D as xSymbol,V as ySymbol};
|
|
1
|
+
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as n,Vector3 as r,ShaderMaterial as h,Color as o,PlaneGeometry as e,Scene as u,Mesh as l,OrthographicCamera as a,WebGLRenderTarget as d,UnsignedByteType as c,LinearFilter as v,RGBAFormat as f,NoBlending as w,Object3D as g,UniformsUtils as p,PerspectiveCamera as m,CanvasTexture as y}from"three";function b(){return new x}var x=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 C(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 C(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}(),C=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),S=function(){function t(t){void 0===t&&(t=""),this.t=0,this.i=null,this.h=E++,this.o=t}return t.prototype.id=function(){return this.h},t.prototype.name=function(){return this.o},t.prototype.setName=function(t){this.o=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 k(this,t)},t.prototype.minus=function(t){return new k(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new k([t,this])},t.prototype.divide=function(t){return new k([1/t,this])},t.prototype.toJSON=function(){return{name:this.o,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.o+":"+this.t+"]"},t}(),E=0,k=function(){function t(){var t=O(arguments);this.u=t.terms,this.l=t.constant}return t.prototype.terms=function(){return this.u},t.prototype.constant=function(){return this.l},t.prototype.value=function(){for(var t=this.l,i=0,s=this.u.size();i<s;i++){var n=this.u.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.u.size()},t.prototype.toString=function(){var t=this.u.array.map((t=>t.second+"*"+t.first)).join(" + ");return this.isConstant()||0===this.l||(t+=" + "),t+this.l},t}();function O(t){for(var i=0,s=()=>0,n=b(),r=0,h=t.length;r<h;++r){var o=t[r];if("number"==typeof o)i+=o;else if(o instanceof S)n.setDefault(o,s).second+=1;else if(o instanceof k){i+=o.constant();for(var e=0,u=(c=o.terms()).size();e<u;e++){var l=c.itemAt(e);n.setDefault(l.first,s).second+=l.second}}else{if(!(o instanceof Array))throw Error("invalid Expression argument: "+o);if(2!==o.length)throw Error("array must have length 2");var a=o[0],d=o[1];if("number"!=typeof a)throw Error("array item 0 must be a number");if(d instanceof S)n.setDefault(d,s).second+=a;else{if(!(d instanceof k))throw Error("array item 1 must be a variable or expression");var c;for(i+=d.constant()*a,e=0,u=(c=d.terms()).size();e<u;e++)l=c.itemAt(e),n.setDefault(l.first,s).second+=l.second*a}}}return{terms:n,constant:i}}var M,T=(()=>{function t(){}return t.create=(t,i,s,n)=>{void 0===n&&(n=1);var r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*n)),(r+=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 F,I=function(){function t(t,i,s,n){void 0===n&&(n=T.required),this.h=A++,this.v=i,this.p=T.clip(n),this.m=void 0===s&&t instanceof k?t:t.minus(s)}return t.prototype.id=function(){return this.h},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,B=function(){function t(){this.C=b(),this.S=b(),this.k=b(),this.O=b(),this.M=[],this.T=new U,this.F=null,this.I=0}return t.prototype.createConstraint=function(t,i,s,n){void 0===n&&(n=T.required);var r=new I(t,i,s,n);return this.addConstraint(r),r},t.prototype.addConstraint=function(t){if(void 0!==this.C.find(t))throw Error("duplicate constraint");var i=this.A(t),s=i.row,n=i.tag,r=this.B(s,n);if(r.type()===F.Invalid&&s.allDummies()){if(!$(s.constant()))throw Error("unsatisfiable constraint");r=n.marker}if(r.type()===F.Invalid){if(!this.$(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this.P(r,s),this.S.insert(r,s);this.C.insert(t,n),this.U(this.T)},t.prototype.removeConstraint=function(t){var i=this.C.erase(t);if(void 0===i)throw Error("unknown constraint");this.D(t,i.second);var s=i.second.marker,n=this.S.erase(s);if(void 0===n){var r=this.V(s);if(r.type()===F.Invalid)throw Error("failed to find leaving row");(n=this.S.erase(r)).second.solveForEx(r,s),this.P(s,n.second)}this.U(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=T.clip(i))===T.required)throw Error("bad required strength");var s=new k(t),n=new I(s,M.Eq,void 0,i);this.addConstraint(n);var r=this.C.find(n).second;this.O.insert(t,{tag:r,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,r=s.second,h=i-r.constant;r.constant=i;var o=r.tag.marker,e=n.find(o);if(void 0!==e)return e.second.add(-h)<0&&this.M.push(o),void this.H();var u=r.tag.other;if(void 0!==(e=n.find(u)))return e.second.add(h)<0&&this.M.push(u),void this.H();for(var l=0,a=n.size();l<a;++l){var d=n.itemAt(l),c=d.second,v=c.coefficientFor(o);0!==v&&c.add(h*v)<0&&d.first.type()!==F.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 r=t.itemAt(s),h=i.find(r.second);r.first.setValue(void 0!==h?h.second.constant():0)}},t.prototype.R=function(t){var i=this;return this.k.setDefault(t,(()=>i.L(F.External))).second},t.prototype.A=function(t){for(var i=t.expression(),s=new U(i.constant()),n=i.terms(),r=0,h=n.size();r<h;++r){var o=n.itemAt(r);if(!$(o.second)){var e=this.R(o.first),u=this.S.find(e);void 0!==u?s.insertRow(u.second,o.second):s.insertSymbol(e,o.second)}}var l=this.T,a=t.strength(),d={marker:z,other:z};switch(t.op()){case M.Le:case M.Ge:var c=t.op()===M.Le?1:-1,v=this.L(F.Slack);if(d.marker=v,s.insertSymbol(v,c),a<T.required){var f=this.L(F.Error);d.other=f,s.insertSymbol(f,-c),l.insertSymbol(f,a)}break;case M.Eq:if(a<T.required){var w=this.L(F.Error),g=this.L(F.Error);d.marker=w,d.other=g,s.insertSymbol(w,-1),s.insertSymbol(g,1),l.insertSymbol(w,a),l.insertSymbol(g,a)}else{var p=this.L(F.Dummy);d.marker=p,s.insertSymbol(p)}}return s.constant()<0&&s.reverseSign(),{row:s,tag:d}},t.prototype.B=(t,i)=>{for(var s=t.cells(),n=0,r=s.size();n<r;++n){var h=s.itemAt(n);if(h.first.type()===F.External)return h.first}var o=i.marker.type();return(o===F.Slack||o===F.Error)&&t.coefficientFor(i.marker)<0?i.marker:((o=i.other.type())===F.Slack||o===F.Error)&&t.coefficientFor(i.other)<0?i.other:z},t.prototype.$=function(t){var i=this.L(F.Slack);this.S.insert(i,t.copy()),this.F=t.copy(),this.U(this.F);var s=$(this.F.constant());this.F=null;var n=this.S.erase(i);if(void 0!==n){var r=n.second;if(r.isConstant())return s;var h=this._(r);if(h.type()===F.Invalid)return 0;r.solveForEx(i,h),this.P(h,r),this.S.insert(h,r)}for(var o=this.S,e=0,u=o.size();e<u;++e)o.itemAt(e).second.removeSymbol(i);return this.T.removeSymbol(i),s},t.prototype.P=function(t,i){for(var s=this.S,n=0,r=s.size();n<r;++n){var h=s.itemAt(n);h.second.substitute(t,i),h.second.constant()<0&&h.first.type()!==F.External&&this.M.push(h.first)}this.T.substitute(t,i),this.F&&this.F.substitute(t,i)},t.prototype.U=function(t){for(;;){var i=this.j(t);if(i.type()===F.Invalid)return;var s=this.N(i);if(s.type()===F.Invalid)throw Error("the objective is unbounded");var n=this.S.erase(s).second;n.solveForEx(s,i),this.P(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 r=this.X(n.second);if(r.type()===F.Invalid)throw Error("dual optimize failed");var h=n.second;t.erase(s),h.solveForEx(s,r),this.P(r,h),t.insert(r,h)}}},t.prototype.j=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),h=r.first;if(r.second<0&&h.type()!==F.Dummy)return h}return z},t.prototype.X=function(t){for(var i=Number.MAX_VALUE,s=z,n=t.cells(),r=0,h=n.size();r<h;++r){var o=n.itemAt(r),e=o.first,u=o.second;if(u>0&&e.type()!==F.Dummy){var l=this.T.coefficientFor(e)/u;l<i&&(i=l,s=e)}}return s},t.prototype.N=function(t){for(var i=Number.MAX_VALUE,s=z,n=this.S,r=0,h=n.size();r<h;++r){var o=n.itemAt(r),e=o.first;if(e.type()!==F.External){var u=o.second,l=u.coefficientFor(t);if(l<0){var a=-u.constant()/l;a<i&&(i=a,s=e)}}}return s},t.prototype.V=function(t){for(var i=Number.MAX_VALUE,s=i,n=i,r=z,h=r,o=r,e=r,u=this.S,l=0,a=u.size();l<a;++l){var d=u.itemAt(l),c=d.second,v=c.coefficientFor(t);if(0!==v){var f=d.first;if(f.type()===F.External)e=f;else if(v<0)(w=-c.constant()/v)<s&&(s=w,h=f);else{var w;(w=c.constant()/v)<n&&(n=w,o=f)}}}return h!==r?h:o!==r?o:e},t.prototype.D=function(t,i){i.marker.type()===F.Error&&this.Y(i.marker,t.strength()),i.other.type()===F.Error&&this.Y(i.other,t.strength())},t.prototype.Y=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._=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),h=r.first.type();if(h===F.Slack||h===F.Error)return r.first}return z},t.prototype.L=function(t){return new P(t,this.I++)},t}();function $(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"})(F||(F={}));var P=function(){function t(t,i){this.h=i,this.q=t}return t.prototype.id=function(){return this.h},t.prototype.type=function(){return this.q},t}(),z=new P(F.Invalid,-1),U=function(){function t(t){void 0===t&&(t=0),this.G=b(),this.l=t}return t.prototype.cells=function(){return this.G},t.prototype.constant=function(){return this.l},t.prototype.isConstant=function(){return this.G.empty()},t.prototype.allDummies=function(){for(var t=this.G,i=0,s=t.size();i<s;++i)if(t.itemAt(i).first.type()!==F.Dummy)return 0;return 1},t.prototype.copy=function(){var i=new t(this.l);return i.G=this.G.copy(),i},t.prototype.add=function(t){return this.l+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),$(this.G.setDefault(t,(()=>0)).second+=i)&&this.G.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this.l+=t.l*i;for(var s=t.G,n=0,r=s.size();n<r;++n){var h=s.itemAt(n);this.insertSymbol(h.first,h.second*i)}},t.prototype.removeSymbol=function(t){this.G.erase(t)},t.prototype.reverseSign=function(){this.l=-this.l;for(var t=this.G,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.G,s=-1/i.erase(t).second;this.l*=s;for(var n=0,r=i.size();n<r;++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.G.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.G.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const D=Symbol("xSymbol"),V=Symbol("ySymbol"),H=Symbol("widthSymbol"),R=Symbol("heightSymbol"),L=Symbol("addUIElementSymbol"),_=Symbol("removeUIElementSymbol"),j=Symbol("addConstraintSymbol"),N=Symbol("removeUIConstraintSymbol"),X=Symbol("addConstraintSymbol"),Y=Symbol("removeConstraintSymbol"),q=Symbol("addVariableSymbol"),G=Symbol("removeVariableSymbol"),W=Symbol("suggestVariableSymbol"),Q=Symbol("disableConstraintSymbol"),J=Symbol("enableConstraintSymbol"),K=Symbol("needsRecalculation"),Z=Symbol("renderSymbol"),tt=Symbol("clickSymbol");var it;function st(t){return null!==t&&Object.values(it).some((i=>i===t))}function nt(t){return null!=t?t:it.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(it||(it={}));class rt{constructor(t,i){this.layer=t,this.name="",this.layer[j](this,i)}destroy(){this.layer[N](this)}}const ht=1e3;var ot,et,ut,lt;function at(t){return null!==t&&Object.values(ot).some((i=>i===t))}function dt(t){return null!=t?t:ot.P0}function ct(t){switch(t){case ot.P0:return T.create(ht,ht,ht);case ot.P1:return T.create(100,0,0);case ot.P2:return T.create(10,0,0);case ot.P3:return T.create(0,100,0);case ot.P4:return T.create(0,10,0);case ot.P5:return T.create(0,0,100);case ot.P6:return T.create(0,0,10);case ot.P7:return T.create(0,0,1);default:return T.create(ht,ht,ht)}}function vt(t){return null!==t&&Object.values(et).some((i=>i===t))}function ft(t){return null!=t?t:et.EQUAL}function wt(t){switch(t){case et.EQUAL:return M.Eq;case et.LESS:return M.Le;case et.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"})(ot||(ot={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(et||(et={}));class gt 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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.options.orientation!==it.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==it.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==it.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[R]),wt(this.options.rule),this.options.height,ct(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 r=n.filter((t=>t.callback!==i||void 0!==s&&t.context!==s));return r.length?this.listeners.set(t,r):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,r){let h=this.listeners.get(t);if(h||(h=[],this.listeners.set(t,h)),h.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const o={callback:i,context:s,priority:n,once:r};let e=0;for(;e<h.length&&h[e].priority<=n;)e++;h.splice(e,0,o)}}class mt extends pt{constructor(i,s,n,r){super(),this.layer=i,this.object=r,this[ut]=new S("x"),this[lt]=new S("y"),this.name=t.generateUUID(),this.layer[L](this,r),this.layer[q](this,this[D],ct(ot.P7)),this.layer[q](this,this[V],ct(ot.P7)),this[D].setValue(s),this[V].setValue(n),this.layer[W](this,this[D],s),this.layer[W](this,this[V],n)}get x(){return this[D].value()}get y(){return this[V].value()}set x(t){this.layer[W](this,this[D],t)}set y(t){this.layer[W](this,this[V],t)}destroy(){this.layer[G](this,this[V]),this.layer[G](this,this[D]),this.layer[_](this)}[(ut=D,lt=V,Z)](t,i){this.render(t,i)}}const yt=new i,bt=new s,xt=new n,Ct=new n,St=new n,Et=new n,kt=new n,Ot=new r,Mt=.5;class Tt{constructor(){this.x=0,this.y=0,this.anchorX=Mt,this.anchorY=Mt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Ft{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 t.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(i){const s=t.degToRad(i);s!==this.raw.rotation&&(this.raw.rotation=s,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===Mt&&this.raw.anchorY===Mt&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Mt,this.raw.anchorY=Mt,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}var It;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(It||(It={}));class At extends h{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new o(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 Bt=new e(1,1).translate(.5,.5,0),$t=new u,Pt=new l(Bt);$t.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($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 Ut{constructor(){this.passes=[],this.defaultMaterial=new At,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,r=1){const h=this.hasValuablePasses();if(!(this.needsUpdateInternal&&h||this.hasPassesNeedingUpdate()))return h||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,h?this.defaultMaterial:n;const o=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==o,this.paddingInternal=o;const e=i+2*o,u=s+2*o;this.fromRenderTarget.setSize(e,u),this.toRenderTarget.setSize(e,u),this.setScreenPadding(i,s,o),t.setClearColor(0,0),t.setRenderTarget(this.toRenderTarget),t.clear(1,0,0);const l=n.blending;r&&(n.blending=w),this.screen.render(t,n),n.blending=l;const a={width:i,height:s,padding:o};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 Dt{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var Vt,Ht,Rt,Lt,_t,jt,Nt,Xt,Yt,qt;(t=>{t.CLICK="click"})(jt||(jt={}));class Gt extends pt{constructor(i,s,n,r,h,o){super(),this.layer=i,this.object=s,this[Vt]=new S("x"),this[Ht]=new S("y"),this[Rt]=new S("width"),this[Lt]=new S("height"),this[_t]=0,this.name=t.generateUUID(),this.microInternal=new Tt,this.composerInternal=new Ut,this.modeInternal=It.VISIBLE,this.micro=new Ft(this.microInternal,this),this.composer=new Dt(this.composerInternal),this.layer[L](this,this.object),this.layer[q](this,this[D],ct(ot.P7)),this.layer[q](this,this[V],ct(ot.P7)),this.layer[q](this,this[H],ct(ot.P5)),this.layer[q](this,this[R],ct(ot.P5)),this[D].setValue(n),this[V].setValue(r),this[H].setValue(h),this[R].setValue(o),this.layer[W](this,this[D],n),this.layer[W](this,this[V],r),this.layer[W](this,this[H],h),this.layer[W](this,this[R],o)}get x(){return this[D].value()}get y(){return this[V].value()}get width(){return this[H].value()}get height(){return this[R].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[K]}set x(t){this.layer[W](this,this[D],t)}set y(t){this.layer[W](this,this[V],t)}set width(t){this.layer[W](this,this[H],t)}set height(t){this.layer[W](this,this[R],t)}set zIndex(t){this.object.position.z=t}set mode(t){this.modeInternal=t,this.object.visible=t!==It.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[G](this,this[R]),this.layer[G](this,this[H]),this.layer[G](this,this[V]),this.layer[G](this,this[D]),this.layer[_](this)}[(Vt=D,Ht=V,Rt=H,Lt=R,_t=K,Z)](t,i){this.render(t,i)}[tt](t,i){return this.click(t,i)}applyTransformations(){(this[K]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,n,r,h,o)=>{const e=this.x-o,u=this.y-o,l=this.width+2*o,a=this.height+2*o,d=e+l*i.anchorX,c=u+a*i.anchorY,v=xt.set(1,0,-d,0,1,-c,0,0,1),f=Ct.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=St.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Et.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=kt.multiplyMatrices(g,w).multiply(f).multiply(v),m=Ot.set(e,u,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=l*i.scaleX,t.scale.y=a*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this[K]=0,this.microInternal.needsRecalculation=0)}click(t,i){return this.mode!==It.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,r=this.width,h=this.height,yt.set(t,i),bt.min.set(s,n),bt.max.set(r,h).add(bt.min),bt.containsPoint(yt)?(this.emit(jt.CLICK,this),1):0);var s,n,r,h}}const Wt=new o(0);var Qt,Jt,Kt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(Qt||(Qt={}));class Zt extends pt{constructor(){super(...arguments),this.mode=It.VISIBLE,this[Nt]=new S,this[Xt]=new S,this[Yt]=new S,this[qt]=new S,this.scene=new u,this.camera=new a,this.solver=new B,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=it.PORTRAIT,this.needsRecalculation=0}get orientation(){return this.orientationPrivate}get width(){return this[H].value()}get height(){return this[R].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Nt=D,Xt=V,Yt=H,qt=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&&(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),i.object&&this.scene.remove(i.object)}[j](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 r=t instanceof Gt||t instanceof mt?this.elements.get(t):this.constraints.get(t);if(void 0===r)throw Error("Before adding variable you need to add it's owner");if(r.variables.has(i))throw Error("Variable already exists");r.variables.set(i,{strength:s,suggestedValue:i.value()}),null===(n=this.solver)||void 0===n||n.addEditVariable(i,s),this.needsRecalculation=1}[G](t,i){var s;const n=t instanceof Gt||t instanceof mt?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}[W](t,i,s){var n;const r=t instanceof Gt||t instanceof mt?this.elements.get(t):this.constraints.get(t);if(void 0===r)throw Error("Before suggesting variable you need to add it's owner");const h=r.variables.get(i);if(!h)throw Error("Variable does not exist");h.suggestedValue!==s&&(h.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===It.HIDDEN)return;const n=t.getRenderTarget(),r=t.getClearColor(Wt),h=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 instanceof Gt&&(t[K]=1)}for(const s of this.elements.keys())s[Z](t,i);t.setRenderTarget(n),t.setClearColor(r),t.setClearAlpha(h),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==It.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t instanceof Gt)).filter((t=>t instanceof Gt&&t.mode===It.INTERACTIVE)).sort(((t,i)=>t.zIndex-i.zIndex));for(const n of s)if(n[tt](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,r,h,o,e,u,l;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===(r=this.solver)||void 0===r||r.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(null===(h=this.solver)||void 0===h||h.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new I(new k(this[D]),M.Eq,0,T.required),this.constraintY=new I(new k(this[V]),M.Eq,0,T.required),this.constraintW=new I(new k(this[H]),M.Eq,t,T.required),this.constraintH=new I(new k(this[R]),M.Eq,i,T.required),null===(o=this.solver)||void 0===o||o.addConstraint(this.constraintX),null===(e=this.solver)||void 0===e||e.addConstraint(this.constraintY),null===(u=this.solver)||void 0===u||u.addConstraint(this.constraintW),null===(l=this.solver)||void 0===l||l.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?it.LANDSCAPE:it.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 B;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 ti(t,i){if((t instanceof Zt?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 ii(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 si extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt||t instanceof mt?[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!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(h=null==s?void 0:s.distance)&&void 0!==h?h:0,power:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Gt||this.elementOne instanceof Zt?new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.anchorOne)):new k(this.elementOne[D]),i=this.elementTwo instanceof Gt?new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[D]);this.constraint=new I(i.minus(t),wt(this.parameters.rule),this.parameters.distance,ct(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;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[H]).multiply(this.parameters.proportion),i=new k(this.elementTwo[H]);this.constraint=new I(t.minus(i),wt(this.parameters.rule),0,ct(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ri extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt||t instanceof mt?[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!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(h=null==s?void 0:s.distance)&&void 0!==h?h:0,power:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=this.elementOne instanceof Gt||this.elementOne instanceof Zt?new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.anchorOne)):new k(this.elementOne[V]),i=this.elementTwo instanceof Gt?new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.anchorTwo)):new k(this.elementTwo[V]);this.constraint=new I(i.minus(t),wt(this.parameters.rule),this.parameters.distance,ct(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;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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:dt(null==s?void 0:s.power),rule:ft(null==s?void 0:s.rule),orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.elementOne[R]).multiply(this.parameters.proportion),i=new k(this.elementTwo[R]);this.constraint=new I(t.minus(i),wt(this.parameters.rule),0,ct(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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.options.orientation!==it.ALWAYS&&this.options.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.options.orientation!==it.ALWAYS&&t!==this.options.orientation&&this.destroyConstraints()}[J](t){this.options.orientation!==it.ALWAYS&&t===this.options.orientation&&this.buildConstraints()}buildConstraints(){this.constraint=new I(new k(this.element[H]),wt(this.options.rule),this.options.width,ct(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ei{static size(t,i){var s,n,r,h,o,e,u,l;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===(r=i.rule)||void 0===r?void 0:r.x,orientation:null===(h=i.orientation)||void 0===h?void 0:h.x}),y:new gt(t,{height:null===(o=i.size)||void 0===o?void 0:o.y,power:null===(e=i.power)||void 0===e?void 0:e.y,rule:null===(u=i.rule)||void 0===u?void 0:u.y,orientation:null===(l=i.orientation)||void 0===l?void 0:l.y})}}static distance(t,i,s){var n,r,h,o,e,u,l,a,d,c,v,f;return{x:new si(t,i,{anchorOne:null===(n=s.anchorOne)||void 0===n?void 0:n.x,anchorTwo:null===(r=s.anchorTwo)||void 0===r?void 0:r.x,distance:null===(h=s.distance)||void 0===h?void 0:h.x,power:null===(o=s.power)||void 0===o?void 0:o.x,rule:null===(e=s.rule)||void 0===e?void 0:e.x,orientation:null===(u=s.orientation)||void 0===u?void 0:u.x}),y:new ri(t,i,{anchorOne:null===(l=s.anchorOne)||void 0===l?void 0:l.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,r,h,o,e,u,l,a;return{x:new ni(t,i,{proportion:null===(n=s.proportion)||void 0===n?void 0:n.x,power:null===(r=s.power)||void 0===r?void 0:r.x,rule:null===(h=s.rule)||void 0===h?void 0:h.x,orientation:null===(o=s.orientation)||void 0===o?void 0:o.x}),y:new hi(t,i,{proportion:null===(e=s.proportion)||void 0===e?void 0:e.y,power:null===(u=s.power)||void 0===u?void 0:u.y,rule:null===(l=s.rule)||void 0===l?void 0:l.y,orientation:null===(a=s.orientation)||void 0===a?void 0:a.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Jt||(Jt={}));class ui{static build(t,i,s,n={}){var r;const h=null!==(r=n.direction)&&void 0!==r?r:Jt.FROM_LEFT_TOP,o=[],e=[];o.push(new si(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new si(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const u=h===Jt.FROM_LEFT_TOP?1:0,l=h===Jt.FROM_LEFT_TOP?0:1;return e.push(new ri(t,i,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation}),new ri(t,s,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:o,verticalDistances:e}}}class li{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:si,proportionConstraint:ni,centerDistanceConstraint:ri})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:ri,proportionConstraint:hi,centerDistanceConstraint:si})}static buildStack(t,i,s){const n=[],r=[],h=[];for(let o=0;o<t.length-1;o++){const e=t[o],u=t[o+1];n.push(new s.distanceConstraint(e,u,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),0!=i.keepProportions&&r.push(new s.proportionConstraint(e,u,{power:i.power,orientation:i.orientation})),0!=i.keepAlignment&&h.push(new s.centerDistanceConstraint(e,u,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:r,alignmentConstraints:h}}}class ai 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:dt(null==i?void 0:i.power),rule:ft(null==i?void 0:i.rule),orientation:nt(null==i?void 0:i.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){const t=new k(this.element[H]).plus(new k(this.element[R]).multiply(-this.parameters.aspect));this.constraint=new I(t,wt(this.parameters.rule),0,ct(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class di extends rt{constructor(t,i,s){var n,r,h;ti(t,i),super(i.layer,new Set(t instanceof Gt?[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!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(h=null==s?void 0:s.verticalAnchor)&&void 0!==h?h:.5,orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Le,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Le,new k(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 I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.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)}}class ci extends rt{constructor(t,i,s){var n,r,h;super(i.layer,new Set(t instanceof Gt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,ti(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(h=null==s?void 0:s.verticalAnchor)&&void 0!==h?h:.5,orientation:nt(null==s?void 0:s.orientation)},this.parameters.orientation!==it.ALWAYS&&this.parameters.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[Q](t){this.parameters.orientation!==it.ALWAYS&&t!==this.parameters.orientation&&this.destroyConstraints()}[J](t){this.parameters.orientation!==it.ALWAYS&&t===this.parameters.orientation&&this.buildConstraints()}buildConstraints(){this.constraintX=new I(new k(this.elementOne[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.horizontalAnchor)),M.Eq,new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.horizontalAnchor))),this.constraintY=new I(new k(this.elementOne[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.verticalAnchor)),M.Eq,new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.verticalAnchor))),this.constraintW=new I(new k(this.elementOne[H]),M.Ge,new k(this.elementTwo[H])),this.constraintH=new I(new k(this.elementOne[R]),M.Ge,new k(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 I(new k(this.elementOne[R]),M.Eq,new k(this.elementTwo[R]),T.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)}}class vi extends Gt{constructor(t,i=100,s=100){super(t,new g,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class fi extends Gt{constructor(t,i){var s,n;const r=null===(s=i.image)||void 0===s?void 0:s.width,h=null===(n=i.image)||void 0===n?void 0:n.height;ii(r,h,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${r}) or height (${h}). Image dimensions must be non-zero positive numbers.`);const o=new At(i);super(t,new l(Bt,o),0,0,r,h),this.material=o,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 wi extends h{constructor(t,i){super({uniforms:p.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new o(1,1,1)},foregroundColor:{value:new o(1,1,1)},color:{value:new o(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 gi extends Gt{constructor(i,s,n={}){var r,h,o,e,u,a;const d=null===(r=s.image)||void 0===r?void 0:r.width,c=null===(h=s.image)||void 0===h?void 0:h.height;ii(d,c,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(e=null===(o=n.textureBackground)||void 0===o?void 0:o.image)||void 0===e?void 0:e.width,f=null===(a=null===(u=n.textureBackground)||void 0===u?void 0:u.image)||void 0===a?void 0:a.height;n.textureBackground&&ii(v,f,`Invalid image dimensions - texture "${n.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new wi(s,n.textureBackground),g=new l(Bt,w);n.progress&&w.setProgress(n.progress),n.isForegroundDirection&&w.setIsForwardDirection(n.isForegroundDirection),n.angle&&w.setAngle(t.degToRad(n.angle)),n.color&&w.setColor(n.color),n.opacity&&w.setOpacity(n.opacity),n.backgroundColor&&w.setBackgroundColor(n.backgroundColor),n.foregroundColor&&w.setForegroundColor(n.foregroundColor),n.backgroundOpacity&&w.setBackgroundOpacity(n.backgroundOpacity),n.foregroundOpacity&&w.setForegroundOpacity(n.foregroundOpacity);const p=null!=v?v:d,m=null!=c?c:f;super(i,g,0,0,p,m),this.material=w,this.imageWidth=p,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 t.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(i){this.material.setAngle(t.degToRad(i)),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()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Kt||(Kt={}));const pi=Kt.PROPERTY_CHANGED;class mi extends Gt{constructor(t,i={}){var s,n,r,h,o,e,a,w,g,p;const y=null!==(s=i.resolutionFactor)&&void 0!==s?s:.5;if(y<.1||y>8)throw Error(`Invalid resolution factor: ${y}. Must be between 0.1 and 8.`);const b=null!==(n=i.width)&&void 0!==n?n:512,x=null!==(r=i.height)&&void 0!==r?r:512;ii(b,x,`Invalid width or height: ${b}x${x}. Must be positive.`);const C=new d(b*y,x*y,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(h=i.useDepth)&&void 0!==h?h:1,stencilBuffer:0}),S=new At(C.texture);super(t,new l(Bt,S),0,0,b,x),this.needsRenderInternal=0,this.sceneInternal=null!==(o=i.scene)&&void 0!==o?o:new u,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new m(75,b/x,.1,100),this.resolutionFactorInternal=y,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:pi,null!==(w=i.renderedByDefault)&&void 0!==w&&w&&(this.needsRenderInternal=1),this.clearColorInternal=null!==(g=i.clearColor)&&void 0!==g?g:0,this.clearAlphaInternal=null!==(p=i.clearAlpha)&&void 0!==p?p: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===Kt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===Kt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===Kt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===Kt.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===Kt.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===Kt.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()}}function yi(t,i){var s,n,r,h,o,e,u,l,a,d,c,v,f,w,g,p,m,y,b,x,C,S,E,k,O,M,T,F;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),A=null!==(h=null!==(r=null==t?void 0:t.lineHeight)&&void 0!==r?r:null==i?void 0:i.lineHeight)&&void 0!==h?h:1.2*I,B=Math.max(null!==(e=null!==(o=null==t?void 0:t.shadowBlur)&&void 0!==o?o:null==i?void 0:i.shadowBlur)&&void 0!==e?e:0,0),$=Math.max(null!==(l=null!==(u=null==t?void 0:t.strokeWidth)&&void 0!==u?u:null==i?void 0:i.strokeWidth)&&void 0!==l?l: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!==(p=null!==(g=null==t?void 0:t.fontWeight)&&void 0!==g?g:null==i?void 0:i.fontWeight)&&void 0!==p?p:"normal",lineHeight:A,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:B,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!==(F=null!==(T=null==t?void 0:t.strokeColor)&&void 0!==T?T:null==i?void 0:i.strokeColor)&&void 0!==F?F:"transparent",strokeWidth:$}}function bi(t){return t.match(/\S+|\s|\n/g)||[]}function xi(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),r=n.width,h=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(r),height:h,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ci(t,i,s,n,r){r.font=`${n.fontStyle} ${n.fontWeight} ${n.fontSize}px ${n.fontFamily}`,n.enableShadow&&(r.shadowOffsetX=n.shadowOffsetX,r.shadowOffsetY=n.shadowOffsetY,r.shadowBlur=n.shadowBlur,r.shadowColor=n.shadowColor),n.enableStroke&&(r.strokeStyle=n.strokeColor,r.lineWidth=n.strokeWidth,r.strokeText(s,t,i)),r.fillStyle=n.color,r.fillText(s,t,i)}class Si extends Gt{constructor(t,i,s={}){var n;const r=document.createElement("canvas"),h=r.getContext("2d");if(!h)throw Error("Failed to create canvas context");const o=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,r=yi(i?void 0:t.style,s.defaultStyle);for(const t of bi(n)){const i=xi(h,t,r);o.push({text:t,style:r,metrics:i})}}const u=((t,i)=>{const s=[];let n=[],r=0,h=0,o=0,e=0;for(const u of i)"\n"!==u.text?r+u.metrics.width<=t||0===n.length?(n.push(u),r+=u.metrics.width,h=Math.max(h,u.metrics.height),o=Math.max(o,u.metrics.baseline),e=Math.max(e,u.metrics.lineHeight)):(s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),n=[u],r=u.metrics.width,h=u.metrics.height,o=u.metrics.baseline,e=u.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),n=[],r=0,h=0,o=0,e=0);return n.length>0&&s.push({chunks:n,width:r,height:h,baseline:o,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,o),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}})(u),d=(t=>{var i,s,n,r;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!==(r=null==t?void 0:t.bottom)&&void 0!==r?r:0,0)}})(s.padding);r.width=a.width+d.left+d.right,r.height=a.height+d.top+d.bottom;const c=new y(r),v=new At(c);super(t,new l(Bt,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=r,this.context=h,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let r=this.padding.top;for(let t=0;t<s.length;t++){const h=s[t];let o=i;r+=0===t?h.height:h.lineHeight;for(const t of h.chunks)Ci(o,r,t.text,t.style,n),o+=t.metrics.width}})(0,this.padding.left,u,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()}}class Ei extends Zt{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!==It.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,r=this.calculateScale();this.clickInternal(s*r,n*r)},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 ki extends Zt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Oi{}export{mt as UIAnchor,ai as UIAspectConstraint,rt as UIConstraint,ei as UIConstraint2DBuilder,ui as UIConstraintContainerBuilder,Jt as UIConstraintContainerDirection,ot as UIConstraintPower,et as UIConstraintRule,li as UIConstraintStackBuilder,di as UICoverConstraint,vi as UIDummy,Gt as UIElement,jt as UIElementEvent,ci as UIFitConstraint,Ei as UIFullScreenLayer,zt as UIFullScreenQuad,gt as UIHeightConstraint,si as UIHorizontalDistanceConstraint,ni as UIHorizontalProportionConstraint,fi as UIImage,Zt as UILayer,Qt as UILayerEvent,ki as UIManualLayer,It as UIMode,it as UIOrientation,Oi as UIPass,gi as UIProgress,mi as UIScene,Kt as UISceneUpdateMode,Si as UIText,ri as UIVerticalDistanceConstraint,hi as UIVerticalProportionConstraint,oi as UIWidthConstraint,X as addConstraintSymbol,j as addUIConstraintSymbol,L as addUIElementSymbol,q as addVariableSymbol,tt as clickSymbol,ct as convertPowerToStrength,wt as convertRuleToOperator,Q as disableConstraintSymbol,J as enableConstraintSymbol,R as heightSymbol,at as isUIConstraintPower,vt as isUIConstraintRule,st as isUIOrientation,K as needsRecalculation,Y as removeConstraintSymbol,N as removeUIConstraintSymbol,_ as removeUIElementSymbol,G as removeVariableSymbol,Z as renderSymbol,nt as resolveOrientation,dt as resolvePower,ft as resolveRule,W as suggestVariableSymbol,H as widthSymbol,D as xSymbol,V as ySymbol};
|
|
2
2
|
//# sourceMappingURL=index.js.map
|