laymur 0.1.49 → 0.1.50

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.
@@ -42,6 +42,8 @@ export declare abstract class UILayer extends Eventail {
42
42
  protected orientationPrivate: UIOrientation;
43
43
  protected needsRecalculation: boolean;
44
44
  get orientation(): UIOrientation;
45
+ get width(): number;
46
+ get height(): number;
45
47
  destroy(): void;
46
48
  [addUIElementSymbol](element: UIElement, object: Object3D): void;
47
49
  [removeUIElementSymbol](element: UIElement): void;
package/dist/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{Vector2 as t,Box2 as i,Matrix3 as s,Vector3 as n,MathUtils as r,ShaderMaterial as o,Color as h,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 C}var C=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new x(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 x(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}(),x=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.o=E++,this.h=t}return t.prototype.id=function(){return this.o},t.prototype.name=function(){return this.h},t.prototype.setName=function(t){this.h=t},t.prototype.context=function(){return this.i},t.prototype.setContext=function(t){this.i=t},t.prototype.value=function(){return this.t},t.prototype.setValue=function(t){this.t=t},t.prototype.plus=function(t){return new 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.h,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.h+":"+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,o=t.length;r<o;++r){var h=t[r];if("number"==typeof h)i+=h;else if(h instanceof S)n.setDefault(h,s).second+=1;else if(h instanceof k){i+=h.constant();for(var e=0,u=(c=h.terms()).size();e<u;e++){var l=c.itemAt(e);n.setDefault(l.first,s).second+=l.second}}else{if(!(h instanceof Array))throw Error("invalid Expression argument: "+h);if(2!==h.length)throw Error("array must have length 2");var a=h[0],d=h[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.o=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.o},t.prototype.expression=function(){return this.m},t.prototype.op=function(){return this.v},t.prototype.strength=function(){return this.p},t.prototype.toString=function(){return this.m+" "+["<=",">=","="][this.v]+" 0 ("+this.p+")"},t}(),A=0,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,o=i-r.constant;r.constant=i;var h=r.tag.marker,e=n.find(h);if(void 0!==e)return e.second.add(-o)<0&&this.M.push(h),void this.H();var u=r.tag.other;if(void 0!==(e=n.find(u)))return e.second.add(o)<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(h);0!==v&&c.add(o*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),o=i.find(r.second);r.first.setValue(void 0!==o?o.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,o=n.size();r<o;++r){var h=n.itemAt(r);if(!$(h.second)){var e=this.R(h.first),u=this.S.find(e);void 0!==u?s.insertRow(u.second,h.second):s.insertSymbol(e,h.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 o=s.itemAt(n);if(o.first.type()===F.External)return o.first}var h=i.marker.type();return(h===F.Slack||h===F.Error)&&t.coefficientFor(i.marker)<0?i.marker:((h=i.other.type())===F.Slack||h===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 o=this._(r);if(o.type()===F.Invalid)return 0;r.solveForEx(i,o),this.P(o,r),this.S.insert(o,r)}for(var h=this.S,e=0,u=h.size();e<u;++e)h.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 o=s.itemAt(n);o.second.substitute(t,i),o.second.constant()<0&&o.first.type()!==F.External&&this.M.push(o.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 o=n.second;t.erase(s),o.solveForEx(s,r),this.P(r,o),t.insert(r,o)}}},t.prototype.j=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),o=r.first;if(r.second<0&&o.type()!==F.Dummy)return o}return z},t.prototype.X=function(t){for(var i=Number.MAX_VALUE,s=z,n=t.cells(),r=0,o=n.size();r<o;++r){var h=n.itemAt(r),e=h.first,u=h.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,o=n.size();r<o;++r){var h=n.itemAt(r),e=h.first;if(e.type()!==F.External){var u=h.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,o=r,h=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,o=f);else{var w;(w=c.constant()/v)<n&&(n=w,h=f)}}}return o!==r?o:h!==r?h: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),o=r.first.type();if(o===F.Slack||o===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.o=i,this.q=t}return t.prototype.id=function(){return this.o},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 o=s.itemAt(n);this.insertSymbol(o.first,o.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 ot=1e3;var ht,et;function ut(t){return null!==t&&Object.values(ht).some((i=>i===t))}function lt(t){return null!=t?t:ht.P0}function at(t){switch(t){case ht.P0:return T.create(ot,ot,ot);case ht.P1:return T.create(100,0,0);case ht.P2:return T.create(10,0,0);case ht.P3:return T.create(0,100,0);case ht.P4:return T.create(0,10,0);case ht.P5:return T.create(0,0,100);case ht.P6:return T.create(0,0,10);case ht.P7:return T.create(0,0,1);default:return T.create(ot,ot,ot)}}function dt(t){return null!==t&&Object.values(et).some((i=>i===t))}function ct(t){return null!=t?t:et.EQUAL}function vt(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"})(ht||(ht={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(et||(et={}));class ft 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:lt(null==i?void 0:i.power),rule:ct(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]),vt(this.options.rule),this.options.height,at(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class wt{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 o=this.listeners.get(t);if(o||(o=[],this.listeners.set(t,o)),o.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const h={callback:i,context:s,priority:n,once:r};let e=0;for(;e<o.length&&o[e].priority<=n;)e++;o.splice(e,0,h)}}const gt=new t,pt=new i,mt=new s,yt=new s,bt=new s,Ct=new s,xt=new s,St=new n,Et=.5;class kt{constructor(){this.x=0,this.y=0,this.anchorX=Et,this.anchorY=Et,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Ot{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 r.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=1)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=1)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=1)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=1)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=1)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=1)}set angle(t){const i=r.degToRad(t);i!==this.raw.rotation&&(this.raw.rotation=i,this.raw.needsRecalculation=1)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=1)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=1)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===Et&&this.raw.anchorY===Et&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Et,this.raw.anchorY=Et,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}var Mt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(Mt||(Mt={}));class Tt extends o{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new h(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 Ft=new e(1,1).translate(.5,.5,0),It=new u,At=new l(Ft);It.add(At);class Bt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new a(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){At.material=i,t.render(It,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 $t{constructor(){this.passes=[],this.defaultMaterial=new Tt,this.screen=new Bt,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 o=this.hasValuablePasses();if(!(this.needsUpdateInternal&&o||this.hasPassesNeedingUpdate()))return o||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,o?this.defaultMaterial:n;const h=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==h,this.paddingInternal=h;const e=i+2*h,u=s+2*h;this.fromRenderTarget.setSize(e,u),this.toRenderTarget.setSize(e,u),this.setScreenPadding(i,s,h),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:h};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 Pt{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var zt,Ut,Dt,Vt,Ht,Rt,Lt,_t,jt,Nt;(t=>{t.CLICK="click"})(Rt||(Rt={}));class Xt extends wt{constructor(t,i,s,n,o,h){super(),this.layer=t,this.object=i,this[zt]=new S("x"),this[Ut]=new S("y"),this[Dt]=new S("width"),this[Vt]=new S("height"),this[Ht]=0,this.name=r.generateUUID(),this.microInternal=new kt,this.composerInternal=new $t,this.modeInternal=Mt.VISIBLE,this.micro=new Ot(this.microInternal,this),this.composer=new Pt(this.composerInternal),this.layer[L](this,this.object),this.layer[q](this,this[D],at(ht.P7)),this.layer[q](this,this[V],at(ht.P7)),this.layer[q](this,this[H],at(ht.P5)),this.layer[q](this,this[R],at(ht.P5)),this[D].setValue(s),this[V].setValue(n),this[H].setValue(o),this[R].setValue(h),this.layer[W](this,this[D],s),this.layer[W](this,this[V],n),this.layer[W](this,this[H],o),this.layer[W](this,this[R],h)}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!==Mt.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)}[(zt=D,Ut=V,Dt=H,Vt=R,Ht=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,o,h)=>{const e=this.x-h,u=this.y-h,l=this.width+2*h,a=this.height+2*h,d=e+l*i.anchorX,c=u+a*i.anchorY,v=mt.set(1,0,-d,0,1,-c,0,0,1),f=yt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=bt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Ct.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=xt.multiplyMatrices(g,w).multiply(f).multiply(v),m=St.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!==Mt.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,r=this.width,o=this.height,gt.set(t,i),pt.min.set(s,n),pt.max.set(r,o).add(pt.min),pt.containsPoint(gt)?(this.emit(Rt.CLICK,this),1):0);var s,n,r,o}}const Yt=new h(0);var qt,Gt,Wt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(qt||(qt={}));class Qt extends wt{constructor(){super(...arguments),this.mode=Mt.VISIBLE,this[Lt]=new S,this[_t]=new S,this[jt]=new S,this[Nt]=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}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(Lt=D,_t=V,jt=H,Nt=R,L)](t,i){if(this.elements.has(t))throw Error("Element already added");this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i.position.z=500,this.scene.add(i)}[_](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),this.scene.remove(i.object)}[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 Xt?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 Xt?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i),null===(s=this.solver)||void 0===s||s.removeEditVariable(i),this.needsRecalculation=1}[W](t,i,s){var n;const r=t instanceof Xt?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 o=r.variables.get(i);if(!o)throw Error("Variable does not exist");o.suggestedValue!==s&&(o.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===Mt.HIDDEN)return;const n=t.getRenderTarget(),r=t.getClearColor(Yt),o=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[K]=1}for(const s of this.elements.keys())s[Z](t,i);t.setRenderTarget(n),t.setClearColor(r),t.setClearAlpha(o),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==Mt.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t.mode===Mt.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,o,h,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===(o=this.solver)||void 0===o||o.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===(h=this.solver)||void 0===h||h.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 Jt(t,i){if((t instanceof Qt?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function Kt(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 Zt extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(o=null==s?void 0:s.distance)&&void 0!==o?o:0,power:lt(null==s?void 0:s.power),rule:ct(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[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.anchorOne)),i=new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.anchorTwo));this.constraint=new I(i.minus(t),vt(this.parameters.rule),this.parameters.distance,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ti extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:lt(null==s?void 0:s.power),rule:ct(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),vt(this.parameters.rule),0,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ii extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(o=null==s?void 0:s.distance)&&void 0!==o?o:0,power:lt(null==s?void 0:s.power),rule:ct(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[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.anchorOne)),i=new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.anchorTwo));this.constraint=new I(i.minus(t),vt(this.parameters.rule),this.parameters.distance,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class si extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:lt(null==s?void 0:s.power),rule:ct(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),vt(this.parameters.rule),0,at(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){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:lt(null==i?void 0:i.power),rule:ct(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]),vt(this.options.rule),this.options.width,at(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ri{static size(t,i){var s,n,r,o,h,e,u,l;return{x:new ni(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===(o=i.orientation)||void 0===o?void 0:o.x}),y:new ft(t,{height:null===(h=i.size)||void 0===h?void 0:h.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,o,h,e,u,l,a,d,c,v,f;return{x:new Zt(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===(o=s.distance)||void 0===o?void 0:o.x,power:null===(h=s.power)||void 0===h?void 0:h.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 ii(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,o,h,e,u,l,a;return{x:new ti(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===(o=s.rule)||void 0===o?void 0:o.x,orientation:null===(h=s.orientation)||void 0===h?void 0:h.x}),y:new si(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"})(Gt||(Gt={}));class oi{static build(t,i,s,n={}){var r;const o=null!==(r=n.direction)&&void 0!==r?r:Gt.FROM_LEFT_TOP,h=[],e=[];h.push(new Zt(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new Zt(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const u=o===Gt.FROM_LEFT_TOP?1:0,l=o===Gt.FROM_LEFT_TOP?0:1;return e.push(new ii(t,i,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation}),new ii(t,s,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:h,verticalDistances:e}}}class hi{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:Zt,proportionConstraint:ti,centerDistanceConstraint:ii})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:ii,proportionConstraint:si,centerDistanceConstraint:Zt})}static buildStack(t,i,s){const n=[],r=[],o=[];for(let h=0;h<t.length-1;h++){const e=t[h],u=t[h+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&&o.push(new s.centerDistanceConstraint(e,u,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:r,alignmentConstraints:o}}}class ei extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:lt(null==i?void 0:i.power),rule:ct(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,vt(this.parameters.rule),0,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ui extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(o=null==s?void 0:s.verticalAnchor)&&void 0!==o?o:.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 li extends rt{constructor(t,i,s){var n,r,o;super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,Jt(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(o=null==s?void 0:s.verticalAnchor)&&void 0!==o?o:.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 ai extends Xt{constructor(t,i=100,s=100){super(t,new g,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class di extends Xt{constructor(t,i){var s,n;const r=null===(s=i.image)||void 0===s?void 0:s.width,o=null===(n=i.image)||void 0===n?void 0:n.height;Kt(r,o,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${r}) or height (${o}). Image dimensions must be non-zero positive numbers.`);const h=new Tt(i);super(t,new l(Ft,h),0,0,r,o),this.material=h,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 ci extends o{constructor(t,i){super({uniforms:p.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new h(1,1,1)},foregroundColor:{value:new h(1,1,1)},color:{value:new h(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 vi extends Xt{constructor(t,i,s={}){var n,o,h,e,u,a;const d=null===(n=i.image)||void 0===n?void 0:n.width,c=null===(o=i.image)||void 0===o?void 0:o.height;Kt(d,c,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(e=null===(h=s.textureBackground)||void 0===h?void 0:h.image)||void 0===e?void 0:e.width,f=null===(a=null===(u=s.textureBackground)||void 0===u?void 0:u.image)||void 0===a?void 0:a.height;s.textureBackground&&Kt(v,f,`Invalid image dimensions - texture "${s.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new ci(i,s.textureBackground),g=new l(Ft,w);s.progress&&w.setProgress(s.progress),s.isForegroundDirection&&w.setIsForwardDirection(s.isForegroundDirection),s.angle&&w.setAngle(r.degToRad(s.angle)),s.color&&w.setColor(s.color),s.opacity&&w.setOpacity(s.opacity),s.backgroundColor&&w.setBackgroundColor(s.backgroundColor),s.foregroundColor&&w.setForegroundColor(s.foregroundColor),s.backgroundOpacity&&w.setBackgroundOpacity(s.backgroundOpacity),s.foregroundOpacity&&w.setForegroundOpacity(s.foregroundOpacity);const p=null!=v?v:d,m=null!=c?c:f;super(t,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 r.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(t){this.material.setAngle(r.degToRad(t)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Wt||(Wt={}));const fi=Wt.PROPERTY_CHANGED;class wi extends Xt{constructor(t,i={}){var s,n,r,o,h,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,C=null!==(r=i.height)&&void 0!==r?r:512;Kt(b,C,`Invalid width or height: ${b}x${C}. Must be positive.`);const x=new d(b*y,C*y,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(o=i.useDepth)&&void 0!==o?o:1,stencilBuffer:0}),S=new Tt(x.texture);super(t,new l(Ft,S),0,0,b,C),this.needsRenderInternal=0,this.sceneInternal=null!==(h=i.scene)&&void 0!==h?h:new u,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new m(75,b/C,.1,100),this.resolutionFactorInternal=y,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:fi,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=x,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===Wt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===Wt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===Wt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===Wt.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===Wt.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===Wt.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 gi(t,i){var s,n,r,o,h,e,u,l,a,d,c,v,f,w,g,p,m,y,b,C,x,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!==(o=null!==(r=null==t?void 0:t.lineHeight)&&void 0!==r?r:null==i?void 0:i.lineHeight)&&void 0!==o?o:1.2*I,B=Math.max(null!==(e=null!==(h=null==t?void 0:t.shadowBlur)&&void 0!==h?h: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!==(C=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==C?C:0,shadowOffsetY:null!==(S=null!==(x=null==t?void 0:t.shadowOffsetY)&&void 0!==x?x: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 pi(t){return t.match(/\S+|\s|\n/g)||[]}function mi(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),r=n.width,o=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(r),height:o,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function yi(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 bi extends Xt{constructor(t,i,s={}){var n;const r=document.createElement("canvas"),o=r.getContext("2d");if(!o)throw Error("Failed to create canvas context");const h=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,r=gi(i?void 0:t.style,s.defaultStyle);for(const t of pi(n)){const i=mi(o,t,r);h.push({text:t,style:r,metrics:i})}}const u=((t,i)=>{const s=[];let n=[],r=0,o=0,h=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,o=Math.max(o,u.metrics.height),h=Math.max(h,u.metrics.baseline),e=Math.max(e,u.metrics.lineHeight)):(s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),n=[u],r=u.metrics.width,o=u.metrics.height,h=u.metrics.baseline,e=u.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),n=[],r=0,o=0,h=0,e=0);return n.length>0&&s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,h),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 Tt(c);super(t,new l(Ft,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=r,this.context=o,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let r=this.padding.top;for(let t=0;t<s.length;t++){const o=s[t];let h=i;r+=0===t?o.height:o.lineHeight;for(const t of o.chunks)yi(h,r,t.text,t.style,n),h+=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 Ci extends Qt{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.mode!==Mt.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 xi extends Qt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Si{}export{ei as UIAspectConstraint,ri as UIConstraint2DBuilder,oi as UIConstraintContainerBuilder,Gt as UIConstraintContainerDirection,ht as UIConstraintPower,et as UIConstraintRule,hi as UIConstraintStackBuilder,ui as UICoverConstraint,ai as UIDummy,Xt as UIElement,Rt as UIElementEvent,li as UIFitConstraint,Ci as UIFullScreenLayer,Bt as UIFullScreenQuad,ft as UIHeightConstraint,Zt as UIHorizontalDistanceConstraint,ti as UIHorizontalProportionConstraint,di as UIImage,Qt as UILayer,qt as UILayerEvent,xi as UIManualLayer,Mt as UIMode,it as UIOrientation,Si as UIPass,vi as UIProgress,wi as UIScene,Wt as UISceneUpdateMode,bi as UIText,ii as UIVerticalDistanceConstraint,si as UIVerticalProportionConstraint,ni as UIWidthConstraint,X as addConstraintSymbol,j as addUIConstraintSymbol,L as addUIElementSymbol,q as addVariableSymbol,tt as clickSymbol,at as convertPowerToStrength,vt as convertRuleToOperator,Q as disableConstraintSymbol,J as enableConstraintSymbol,R as heightSymbol,ut as isUIConstraintPower,dt 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,lt as resolvePower,ct as resolveRule,W as suggestVariableSymbol,H as widthSymbol,D as xSymbol,V as ySymbol};
1
+ import{Vector2 as t,Box2 as i,Matrix3 as s,Vector3 as n,MathUtils as r,ShaderMaterial as o,Color as h,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 C}var C=function(){function t(){this.index={},this.array=[]}return t.prototype.size=function(){return this.array.length},t.prototype.empty=function(){return 0===this.array.length},t.prototype.itemAt=function(t){return this.array[t]},t.prototype.contains=function(t){return void 0!==this.index[t.id()]},t.prototype.find=function(t){var i=this.index[t.id()];return void 0===i?void 0:this.array[i]},t.prototype.setDefault=function(t,i){var s=this.index[t.id()];if(void 0===s){var n=new x(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 x(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}(),x=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.o=E++,this.h=t}return t.prototype.id=function(){return this.o},t.prototype.name=function(){return this.h},t.prototype.setName=function(t){this.h=t},t.prototype.context=function(){return this.i},t.prototype.setContext=function(t){this.i=t},t.prototype.value=function(){return this.t},t.prototype.setValue=function(t){this.t=t},t.prototype.plus=function(t){return new 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.h,value:this.t}},t.prototype.toString=function(){return this.i+"["+this.h+":"+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,o=t.length;r<o;++r){var h=t[r];if("number"==typeof h)i+=h;else if(h instanceof S)n.setDefault(h,s).second+=1;else if(h instanceof k){i+=h.constant();for(var e=0,u=(c=h.terms()).size();e<u;e++){var l=c.itemAt(e);n.setDefault(l.first,s).second+=l.second}}else{if(!(h instanceof Array))throw Error("invalid Expression argument: "+h);if(2!==h.length)throw Error("array must have length 2");var a=h[0],d=h[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.o=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.o},t.prototype.expression=function(){return this.m},t.prototype.op=function(){return this.v},t.prototype.strength=function(){return this.p},t.prototype.toString=function(){return this.m+" "+["<=",">=","="][this.v]+" 0 ("+this.p+")"},t}(),A=0,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,o=i-r.constant;r.constant=i;var h=r.tag.marker,e=n.find(h);if(void 0!==e)return e.second.add(-o)<0&&this.M.push(h),void this.H();var u=r.tag.other;if(void 0!==(e=n.find(u)))return e.second.add(o)<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(h);0!==v&&c.add(o*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),o=i.find(r.second);r.first.setValue(void 0!==o?o.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,o=n.size();r<o;++r){var h=n.itemAt(r);if(!$(h.second)){var e=this.R(h.first),u=this.S.find(e);void 0!==u?s.insertRow(u.second,h.second):s.insertSymbol(e,h.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 o=s.itemAt(n);if(o.first.type()===F.External)return o.first}var h=i.marker.type();return(h===F.Slack||h===F.Error)&&t.coefficientFor(i.marker)<0?i.marker:((h=i.other.type())===F.Slack||h===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 o=this._(r);if(o.type()===F.Invalid)return 0;r.solveForEx(i,o),this.P(o,r),this.S.insert(o,r)}for(var h=this.S,e=0,u=h.size();e<u;++e)h.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 o=s.itemAt(n);o.second.substitute(t,i),o.second.constant()<0&&o.first.type()!==F.External&&this.M.push(o.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 o=n.second;t.erase(s),o.solveForEx(s,r),this.P(r,o),t.insert(r,o)}}},t.prototype.j=t=>{for(var i=t.cells(),s=0,n=i.size();s<n;++s){var r=i.itemAt(s),o=r.first;if(r.second<0&&o.type()!==F.Dummy)return o}return z},t.prototype.X=function(t){for(var i=Number.MAX_VALUE,s=z,n=t.cells(),r=0,o=n.size();r<o;++r){var h=n.itemAt(r),e=h.first,u=h.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,o=n.size();r<o;++r){var h=n.itemAt(r),e=h.first;if(e.type()!==F.External){var u=h.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,o=r,h=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,o=f);else{var w;(w=c.constant()/v)<n&&(n=w,h=f)}}}return o!==r?o:h!==r?h: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),o=r.first.type();if(o===F.Slack||o===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.o=i,this.q=t}return t.prototype.id=function(){return this.o},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 o=s.itemAt(n);this.insertSymbol(o.first,o.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 ot=1e3;var ht,et;function ut(t){return null!==t&&Object.values(ht).some((i=>i===t))}function lt(t){return null!=t?t:ht.P0}function at(t){switch(t){case ht.P0:return T.create(ot,ot,ot);case ht.P1:return T.create(100,0,0);case ht.P2:return T.create(10,0,0);case ht.P3:return T.create(0,100,0);case ht.P4:return T.create(0,10,0);case ht.P5:return T.create(0,0,100);case ht.P6:return T.create(0,0,10);case ht.P7:return T.create(0,0,1);default:return T.create(ot,ot,ot)}}function dt(t){return null!==t&&Object.values(et).some((i=>i===t))}function ct(t){return null!=t?t:et.EQUAL}function vt(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"})(ht||(ht={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(et||(et={}));class ft 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:lt(null==i?void 0:i.power),rule:ct(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]),vt(this.options.rule),this.options.height,at(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class wt{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 o=this.listeners.get(t);if(o||(o=[],this.listeners.set(t,o)),o.some((t=>t.callback===i&&t.context===s)))throw Error("Event listener already exists");const h={callback:i,context:s,priority:n,once:r};let e=0;for(;e<o.length&&o[e].priority<=n;)e++;o.splice(e,0,h)}}const gt=new t,pt=new i,mt=new s,yt=new s,bt=new s,Ct=new s,xt=new s,St=new n,Et=.5;class kt{constructor(){this.x=0,this.y=0,this.anchorX=Et,this.anchorY=Et,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=0}}class Ot{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 r.radToDeg(this.raw.rotation)}get rotation(){return this.raw.rotation}set x(t){t!==this.raw.x&&(this.raw.x=t,this.raw.needsRecalculation=1)}set y(t){t!==this.raw.y&&(this.raw.y=t,this.raw.needsRecalculation=1)}set anchorX(t){t!==this.raw.anchorX&&(this.raw.anchorX=t,this.raw.needsRecalculation=1)}set anchorY(t){t!==this.raw.anchorY&&(this.raw.anchorY=t,this.raw.needsRecalculation=1)}set scaleX(t){t!==this.raw.scaleX&&(this.raw.scaleX=t,this.raw.needsRecalculation=1)}set scaleY(t){t!==this.raw.scaleY&&(this.raw.scaleY=t,this.raw.needsRecalculation=1)}set angle(t){const i=r.degToRad(t);i!==this.raw.rotation&&(this.raw.rotation=i,this.raw.needsRecalculation=1)}set rotation(t){t!==this.raw.rotation&&(this.raw.rotation=t,this.raw.needsRecalculation=1)}setAnchorByGlobalPosition(t,i){const s=(t-this.owner.x)/this.owner.width,n=(i-this.owner.y)/this.owner.height;s===this.raw.anchorX&&n===this.raw.anchorY||(this.raw.anchorX=s,this.raw.anchorY=n,this.raw.needsRecalculation=1)}reset(){0===this.raw.x&&0===this.raw.y&&this.raw.anchorX===Et&&this.raw.anchorY===Et&&1===this.raw.scaleX&&1===this.raw.scaleY&&0===this.raw.rotation||(this.raw.x=0,this.raw.y=0,this.raw.anchorX=Et,this.raw.anchorY=Et,this.raw.scaleX=1,this.raw.scaleY=1,this.raw.rotation=0,this.raw.needsRecalculation=1)}}var Mt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(Mt||(Mt={}));class Tt extends o{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new h(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 Ft=new e(1,1).translate(.5,.5,0),It=new u,At=new l(Ft);It.add(At);class Bt{constructor(t=0,i=0){this.paddingHorizontalInternal=t,this.paddingVerticalInternal=i,this.camera=new a(-1,1,1,-1,0,1),this.updateCameraTransform()}get paddingHorizontal(){return this.paddingHorizontalInternal}get paddingVertical(){return this.paddingVerticalInternal}set paddingHorizontal(t){this.paddingHorizontalInternal!==t&&(this.paddingHorizontalInternal=t,this.updateCameraTransform())}set paddingVertical(t){this.paddingVerticalInternal!==t&&(this.paddingVerticalInternal=t,this.updateCameraTransform())}render(t,i){At.material=i,t.render(It,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 $t{constructor(){this.passes=[],this.defaultMaterial=new Tt,this.screen=new Bt,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 o=this.hasValuablePasses();if(!(this.needsUpdateInternal&&o||this.hasPassesNeedingUpdate()))return o||(this.paddingHasChangedInternal=0!==this.paddingInternal,this.paddingInternal=0),this.needsUpdateInternal=0,o?this.defaultMaterial:n;const h=this.calculatePadding();this.paddingHasChangedInternal=this.paddingInternal!==h,this.paddingInternal=h;const e=i+2*h,u=s+2*h;this.fromRenderTarget.setSize(e,u),this.toRenderTarget.setSize(e,u),this.setScreenPadding(i,s,h),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:h};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 Pt{constructor(t){this.raw=t}get passes(){return this.raw.passes}}var zt,Ut,Dt,Vt,Ht,Rt,Lt,_t,jt,Nt;(t=>{t.CLICK="click"})(Rt||(Rt={}));class Xt extends wt{constructor(t,i,s,n,o,h){super(),this.layer=t,this.object=i,this[zt]=new S("x"),this[Ut]=new S("y"),this[Dt]=new S("width"),this[Vt]=new S("height"),this[Ht]=0,this.name=r.generateUUID(),this.microInternal=new kt,this.composerInternal=new $t,this.modeInternal=Mt.VISIBLE,this.micro=new Ot(this.microInternal,this),this.composer=new Pt(this.composerInternal),this.layer[L](this,this.object),this.layer[q](this,this[D],at(ht.P7)),this.layer[q](this,this[V],at(ht.P7)),this.layer[q](this,this[H],at(ht.P5)),this.layer[q](this,this[R],at(ht.P5)),this[D].setValue(s),this[V].setValue(n),this[H].setValue(o),this[R].setValue(h),this.layer[W](this,this[D],s),this.layer[W](this,this[V],n),this.layer[W](this,this[H],o),this.layer[W](this,this[R],h)}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!==Mt.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)}[(zt=D,Ut=V,Dt=H,Vt=R,Ht=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,o,h)=>{const e=this.x-h,u=this.y-h,l=this.width+2*h,a=this.height+2*h,d=e+l*i.anchorX,c=u+a*i.anchorY,v=mt.set(1,0,-d,0,1,-c,0,0,1),f=yt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),w=bt.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=Ct.set(1,0,i.x+d,0,1,i.y+c,0,0,1),p=xt.multiplyMatrices(g,w).multiply(f).multiply(v),m=St.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!==Mt.INTERACTIVE?0:(this.applyTransformations(),s=this.x,n=this.y,r=this.width,o=this.height,gt.set(t,i),pt.min.set(s,n),pt.max.set(r,o).add(pt.min),pt.containsPoint(gt)?(this.emit(Rt.CLICK,this),1):0);var s,n,r,o}}const Yt=new h(0);var qt,Gt,Wt;(t=>{t.ORIENTATION_CHANGED="orientationChanged"})(qt||(qt={}));class Qt extends wt{constructor(){super(...arguments),this.mode=Mt.VISIBLE,this[Lt]=new S,this[_t]=new S,this[jt]=new S,this[Nt]=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()}[(Lt=D,_t=V,jt=H,Nt=R,L)](t,i){if(this.elements.has(t))throw Error("Element already added");this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i.position.z=500,this.scene.add(i)}[_](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),this.scene.remove(i.object)}[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 Xt?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 Xt?this.elements.get(t):this.constraints.get(t);if(void 0===n)throw Error("Before removing variable you need to add it's owner");if(!n.variables.has(i))throw Error("Variable does not exist");n.variables.delete(i),null===(s=this.solver)||void 0===s||s.removeEditVariable(i),this.needsRecalculation=1}[W](t,i,s){var n;const r=t instanceof Xt?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 o=r.variables.get(i);if(!o)throw Error("Variable does not exist");o.suggestedValue!==s&&(o.suggestedValue=s,null===(n=this.solver)||void 0===n||n.suggestValue(i,s),this.needsRecalculation=1)}render(t,i){var s;if(this.mode===Mt.HIDDEN)return;const n=t.getRenderTarget(),r=t.getClearColor(Yt),o=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[K]=1}for(const s of this.elements.keys())s[Z](t,i);t.setRenderTarget(n),t.setClearColor(r),t.setClearAlpha(o),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==Mt.INTERACTIVE)return;const s=[...this.elements.keys()].filter((t=>t.mode===Mt.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,o,h,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===(o=this.solver)||void 0===o||o.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===(h=this.solver)||void 0===h||h.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 Jt(t,i){if((t instanceof Qt?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function Kt(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 Zt extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(o=null==s?void 0:s.distance)&&void 0!==o?o:0,power:lt(null==s?void 0:s.power),rule:ct(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[D]).plus(new k(this.elementOne[H]).multiply(this.parameters.anchorOne)),i=new k(this.elementTwo[D]).plus(new k(this.elementTwo[H]).multiply(this.parameters.anchorTwo));this.constraint=new I(i.minus(t),vt(this.parameters.rule),this.parameters.distance,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ti extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:lt(null==s?void 0:s.power),rule:ct(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),vt(this.parameters.rule),0,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ii extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={anchorOne:null!==(n=null==s?void 0:s.anchorOne)&&void 0!==n?n:.5,anchorTwo:null!==(r=null==s?void 0:s.anchorTwo)&&void 0!==r?r:.5,distance:null!==(o=null==s?void 0:s.distance)&&void 0!==o?o:0,power:lt(null==s?void 0:s.power),rule:ct(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[V]).plus(new k(this.elementOne[R]).multiply(this.parameters.anchorOne)),i=new k(this.elementTwo[V]).plus(new k(this.elementTwo[R]).multiply(this.parameters.anchorTwo));this.constraint=new I(i.minus(t),vt(this.parameters.rule),this.parameters.distance,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class si extends rt{constructor(t,i,s){var n;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={proportion:null!==(n=null==s?void 0:s.proportion)&&void 0!==n?n:1,power:lt(null==s?void 0:s.power),rule:ct(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),vt(this.parameters.rule),0,at(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){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:lt(null==i?void 0:i.power),rule:ct(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]),vt(this.options.rule),this.options.width,at(this.options.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ri{static size(t,i){var s,n,r,o,h,e,u,l;return{x:new ni(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===(o=i.orientation)||void 0===o?void 0:o.x}),y:new ft(t,{height:null===(h=i.size)||void 0===h?void 0:h.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,o,h,e,u,l,a,d,c,v,f;return{x:new Zt(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===(o=s.distance)||void 0===o?void 0:o.x,power:null===(h=s.power)||void 0===h?void 0:h.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 ii(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,o,h,e,u,l,a;return{x:new ti(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===(o=s.rule)||void 0===o?void 0:o.x,orientation:null===(h=s.orientation)||void 0===h?void 0:h.x}),y:new si(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"})(Gt||(Gt={}));class oi{static build(t,i,s,n={}){var r;const o=null!==(r=n.direction)&&void 0!==r?r:Gt.FROM_LEFT_TOP,h=[],e=[];h.push(new Zt(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:n.power,orientation:n.orientation}),new Zt(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:n.power,orientation:n.orientation}));const u=o===Gt.FROM_LEFT_TOP?1:0,l=o===Gt.FROM_LEFT_TOP?0:1;return e.push(new ii(t,i,{anchorOne:u,anchorTwo:u,distance:0,power:n.power,orientation:n.orientation}),new ii(t,s,{anchorOne:l,anchorTwo:l,distance:0,power:n.power,orientation:n.orientation})),{horizontalDistances:h,verticalDistances:e}}}class hi{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:Zt,proportionConstraint:ti,centerDistanceConstraint:ii})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:ii,proportionConstraint:si,centerDistanceConstraint:Zt})}static buildStack(t,i,s){const n=[],r=[],o=[];for(let h=0;h<t.length-1;h++){const e=t[h],u=t[h+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&&o.push(new s.centerDistanceConstraint(e,u,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:n,proportionConstraints:r,alignmentConstraints:o}}}class ei extends rt{constructor(t,i){var s;super(t.layer,new Set([t])),this.element=t,this.parameters={aspect:null!==(s=null==i?void 0:i.aspect)&&void 0!==s?s:this.element.width/this.element.height,power:lt(null==i?void 0:i.power),rule:ct(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,vt(this.parameters.rule),0,at(this.parameters.power)),this.layer[X](this,this.constraint)}destroyConstraints(){this.constraint&&(this.layer[Y](this,this.constraint),this.constraint=void 0)}}class ui extends rt{constructor(t,i,s){var n,r,o;Jt(t,i),super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(o=null==s?void 0:s.verticalAnchor)&&void 0!==o?o:.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 li extends rt{constructor(t,i,s){var n,r,o;super(i.layer,new Set(t instanceof Xt?[t,i]:[i])),this.elementOne=t,this.elementTwo=i,Jt(t,i),this.parameters={isStrict:null!==(n=null==s?void 0:s.isStrict)&&void 0!==n?n:1,horizontalAnchor:null!==(r=null==s?void 0:s.horizontalAnchor)&&void 0!==r?r:.5,verticalAnchor:null!==(o=null==s?void 0:s.verticalAnchor)&&void 0!==o?o:.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 ai extends Xt{constructor(t,i=100,s=100){super(t,new g,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class di extends Xt{constructor(t,i){var s,n;const r=null===(s=i.image)||void 0===s?void 0:s.width,o=null===(n=i.image)||void 0===n?void 0:n.height;Kt(r,o,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${r}) or height (${o}). Image dimensions must be non-zero positive numbers.`);const h=new Tt(i);super(t,new l(Ft,h),0,0,r,o),this.material=h,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 ci extends o{constructor(t,i){super({uniforms:p.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new h(1,1,1)},foregroundColor:{value:new h(1,1,1)},color:{value:new h(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 vi extends Xt{constructor(t,i,s={}){var n,o,h,e,u,a;const d=null===(n=i.image)||void 0===n?void 0:n.width,c=null===(o=i.image)||void 0===o?void 0:o.height;Kt(d,c,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${d}) or height (${c}). Image dimensions must be non-zero positive numbers.`);const v=null===(e=null===(h=s.textureBackground)||void 0===h?void 0:h.image)||void 0===e?void 0:e.width,f=null===(a=null===(u=s.textureBackground)||void 0===u?void 0:u.image)||void 0===a?void 0:a.height;s.textureBackground&&Kt(v,f,`Invalid image dimensions - texture "${s.textureBackground.name||"unnamed"}" has invalid width (${v}) or height (${f}). Image dimensions must be non-zero positive numbers.`);const w=new ci(i,s.textureBackground),g=new l(Ft,w);s.progress&&w.setProgress(s.progress),s.isForegroundDirection&&w.setIsForwardDirection(s.isForegroundDirection),s.angle&&w.setAngle(r.degToRad(s.angle)),s.color&&w.setColor(s.color),s.opacity&&w.setOpacity(s.opacity),s.backgroundColor&&w.setBackgroundColor(s.backgroundColor),s.foregroundColor&&w.setForegroundColor(s.foregroundColor),s.backgroundOpacity&&w.setBackgroundOpacity(s.backgroundOpacity),s.foregroundOpacity&&w.setForegroundOpacity(s.foregroundOpacity);const p=null!=v?v:d,m=null!=c?c:f;super(t,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 r.radToDeg(this.material.getAngle())}get isForwardDirection(){return this.material.getIsForwardDirection()}set progress(t){this.material.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.material.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.material.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.material.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.material.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.material.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.material.setOpacity(t),this.composerInternal.requestUpdate()}set angle(t){this.material.setAngle(r.degToRad(t)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.material.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.material.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.imageWidth,this.imageHeight,this.material),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Wt||(Wt={}));const fi=Wt.PROPERTY_CHANGED;class wi extends Xt{constructor(t,i={}){var s,n,r,o,h,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,C=null!==(r=i.height)&&void 0!==r?r:512;Kt(b,C,`Invalid width or height: ${b}x${C}. Must be positive.`);const x=new d(b*y,C*y,{format:f,minFilter:v,magFilter:v,type:c,depthBuffer:null!==(o=i.useDepth)&&void 0!==o?o:1,stencilBuffer:0}),S=new Tt(x.texture);super(t,new l(Ft,S),0,0,b,C),this.needsRenderInternal=0,this.sceneInternal=null!==(h=i.scene)&&void 0!==h?h:new u,this.cameraInternal=null!==(e=i.camera)&&void 0!==e?e:new m(75,b/C,.1,100),this.resolutionFactorInternal=y,this.updateModeInternal=null!==(a=i.updateBehavior)&&void 0!==a?a:fi,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=x,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===Wt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.cameraInternal!==t&&(this.cameraInternal=t,this.updateModeInternal===Wt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.clearColorInternal!==t&&(this.clearColorInternal=t,this.updateModeInternal===Wt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.clearAlphaInternal!==t&&(this.clearAlphaInternal=t,this.updateModeInternal===Wt.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===Wt.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===Wt.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 gi(t,i){var s,n,r,o,h,e,u,l,a,d,c,v,f,w,g,p,m,y,b,C,x,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!==(o=null!==(r=null==t?void 0:t.lineHeight)&&void 0!==r?r:null==i?void 0:i.lineHeight)&&void 0!==o?o:1.2*I,B=Math.max(null!==(e=null!==(h=null==t?void 0:t.shadowBlur)&&void 0!==h?h: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!==(C=null!==(b=null==t?void 0:t.shadowOffsetX)&&void 0!==b?b:null==i?void 0:i.shadowOffsetX)&&void 0!==C?C:0,shadowOffsetY:null!==(S=null!==(x=null==t?void 0:t.shadowOffsetY)&&void 0!==x?x: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 pi(t){return t.match(/\S+|\s|\n/g)||[]}function mi(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px ${s.fontFamily}`,"\n"===i)return{width:0,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const n=t.measureText(i),r=n.width,o=Math.ceil(n.actualBoundingBoxAscent+n.actualBoundingBoxDescent);return{width:Math.ceil(r),height:o,baseline:n.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function yi(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 bi extends Xt{constructor(t,i,s={}){var n;const r=document.createElement("canvas"),o=r.getContext("2d");if(!o)throw Error("Failed to create canvas context");const h=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,n=i?t:t.text,r=gi(i?void 0:t.style,s.defaultStyle);for(const t of pi(n)){const i=mi(o,t,r);h.push({text:t,style:r,metrics:i})}}const u=((t,i)=>{const s=[];let n=[],r=0,o=0,h=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,o=Math.max(o,u.metrics.height),h=Math.max(h,u.metrics.baseline),e=Math.max(e,u.metrics.lineHeight)):(s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),n=[u],r=u.metrics.width,o=u.metrics.height,h=u.metrics.baseline,e=u.metrics.lineHeight):(n.length>0&&s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),n=[],r=0,o=0,h=0,e=0);return n.length>0&&s.push({chunks:n,width:r,height:o,baseline:h,lineHeight:e}),s})(null!==(n=s.maxWidth)&&void 0!==n?n:1024,h),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 Tt(c);super(t,new l(Ft,v),0,0,a.width,a.height),this.suggestedAspect=0,this.material=v,this.texture=c,this.canvas=r,this.context=o,this.textBlockSize=a,this.padding=d,((t,i,s,n)=>{let r=this.padding.top;for(let t=0;t<s.length;t++){const o=s[t];let h=i;r+=0===t?o.height:o.lineHeight;for(const t of o.chunks)yi(h,r,t.text,t.style,n),h+=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 Ci extends Qt{constructor(){super(),this.targetScreenHeight=1920,this.onResize=()=>{const t=this.calculateScale();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.onClick=t=>{if(this.mode!==Mt.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 xi extends Qt{click(t,i){this.clickInternal(t,i)}resize(t,i){this.resizeInternal(t,i)}}class Si{}export{ei as UIAspectConstraint,ri as UIConstraint2DBuilder,oi as UIConstraintContainerBuilder,Gt as UIConstraintContainerDirection,ht as UIConstraintPower,et as UIConstraintRule,hi as UIConstraintStackBuilder,ui as UICoverConstraint,ai as UIDummy,Xt as UIElement,Rt as UIElementEvent,li as UIFitConstraint,Ci as UIFullScreenLayer,Bt as UIFullScreenQuad,ft as UIHeightConstraint,Zt as UIHorizontalDistanceConstraint,ti as UIHorizontalProportionConstraint,di as UIImage,Qt as UILayer,qt as UILayerEvent,xi as UIManualLayer,Mt as UIMode,it as UIOrientation,Si as UIPass,vi as UIProgress,wi as UIScene,Wt as UISceneUpdateMode,bi as UIText,ii as UIVerticalDistanceConstraint,si as UIVerticalProportionConstraint,ni as UIWidthConstraint,X as addConstraintSymbol,j as addUIConstraintSymbol,L as addUIElementSymbol,q as addVariableSymbol,tt as clickSymbol,at as convertPowerToStrength,vt as convertRuleToOperator,Q as disableConstraintSymbol,J as enableConstraintSymbol,R as heightSymbol,ut as isUIConstraintPower,dt 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,lt as resolvePower,ct as resolveRule,W as suggestVariableSymbol,H as widthSymbol,D as xSymbol,V as ySymbol};
2
2
  //# sourceMappingURL=index.js.map