laymur 0.1.73 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +16 -0
- package/dist/Passes/UIPass.d.ts +2 -2
- package/dist/{Builders → builders}/UIConstraint2DBuilder.d.ts +14 -14
- package/dist/{Builders → builders}/UIConstraintContainerBuilder.d.ts +5 -5
- package/dist/{Builders → builders}/UIConstraintStackBuilder.d.ts +7 -7
- package/dist/{Constraints → constraints}/UIAspectConstraint.d.ts +5 -5
- package/dist/{Constraints → constraints}/UIConstraint.d.ts +3 -3
- package/dist/{Constraints → constraints}/UIConstraintRule.d.ts +1 -1
- package/dist/{Constraints → constraints}/UICoverConstraint.d.ts +6 -6
- package/dist/{Constraints → constraints}/UIFitConstraint.d.ts +6 -6
- package/dist/{Constraints → constraints}/UIHeightConstraint.d.ts +2 -2
- package/dist/{Constraints → constraints}/UIHorizontalDistanceConstraint.d.ts +7 -7
- package/dist/{Constraints → constraints}/UIHorizontalProportionConstraint.d.ts +6 -6
- package/dist/{Constraints → constraints}/UIVerticalDistanceConstraint.d.ts +7 -7
- package/dist/{Constraints → constraints}/UIVerticalProportionConstraint.d.ts +6 -6
- package/dist/{Constraints → constraints}/UIWidthConstraint.d.ts +2 -2
- package/dist/{Elements → elements}/UIAnchor.d.ts +5 -6
- package/dist/{Elements → elements}/UIDummy.d.ts +1 -1
- package/dist/{Elements → elements}/UIElement.d.ts +9 -10
- package/dist/{Elements → elements}/UIImage.d.ts +2 -2
- package/dist/{Elements → elements}/UIProgress.d.ts +1 -1
- package/dist/{Elements → elements}/UIScene.d.ts +1 -1
- package/dist/{Elements → elements}/UIText.d.ts +4 -4
- package/dist/index.d.ts +28 -29
- package/dist/index.js +782 -862
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/{Layers → layers}/UILayer.d.ts +20 -21
- package/dist/{Materials → materials}/UIMaterial.d.ts +1 -1
- package/dist/{Miscellaneous → miscellaneous}/UIMicro.d.ts +1 -1
- package/dist/{Miscellaneous → miscellaneous}/asserts.d.ts +3 -3
- package/package.json +3 -3
- package/dist/Miscellaneous/symbols.d.ts +0 -1
- /package/dist/{Constraints → constraints}/UIConstraintPower.d.ts +0 -0
- /package/dist/{Layers → layers}/UIFullScreenLayer.d.ts +0 -0
- /package/dist/{Materials → materials}/UIProgressMaterial.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/UIBlending.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/UIMode.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/UIOrientation.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/UITextInterfaces.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/math.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/microTransformationTools.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/textTools.d.ts +0 -0
- /package/dist/{Miscellaneous → miscellaneous}/threeInstances.d.ts +0 -0
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as h,Vector3 as r,ShaderMaterial as n,Color as e,AddEquation as o,SrcAlphaFactor as a,OneMinusSrcAlphaFactor as c,NormalBlending as u,CustomBlending as d,OneMinusDstColorFactor as f,OneFactor as l,MultiplyBlending as w,SubtractiveBlending as v,AdditiveBlending as g,PlaneGeometry as p,Scene as m,Mesh as y,OrthographicCamera as b,WebGLRenderTarget as x,UnsignedByteType as C,LinearFilter as S,RGBAFormat as E,NoBlending as k,Object3D as M,UniformsUtils as T,PerspectiveCamera as O,CanvasTexture as I}from"three";function _(){return new F}var F=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 h=new A(t,i());return this.index[t.id()]=this.array.length,this.array.push(h),h}return this.array[s]},t.prototype.insert=function(t,i){var s=new A(t,i),h=this.index[t.id()];return void 0===h?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[h]=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],h=this.array.pop();return s!==h&&(this.array[i]=h,this.index[h.first.id()]=i),s}},t.prototype.copy=function(){for(var i=new t,s=0;this.array.length>s;s++){var h=this.array[s].copy();i.array[s]=h,i.index[h.first.id()]=s}return i},t}(),A=function(){function t(t,i){this.first=t,this.second=i}return t.prototype.copy=function(){return new t(this.first,this.second)},t}(),B=function(){function t(t){void 0===t&&(t=""),this.C=0,this.S=null,this.T=$++,this.O=t}return t.prototype.id=function(){return this.T},t.prototype.name=function(){return this.O},t.prototype.setName=function(t){this.O=t},t.prototype.context=function(){return this.S},t.prototype.setContext=function(t){this.S=t},t.prototype.value=function(){return this.C},t.prototype.setValue=function(t){this.C=t},t.prototype.plus=function(t){return new P(this,t)},t.prototype.minus=function(t){return new P(this,"number"==typeof t?-t:[-1,t])},t.prototype.multiply=function(t){return new P([t,this])},t.prototype.divide=function(t){return new P([1/t,this])},t.prototype.toJSON=function(){return{name:this.O,value:this.C}},t.prototype.toString=function(){return this.S+"["+this.O+":"+this.C+"]"},t}(),$=0,P=function(){function t(){var t=U(arguments);this.I=t.terms,this._=t.constant}return t.prototype.terms=function(){return this.I},t.prototype.constant=function(){return this._},t.prototype.value=function(){for(var t=this._,i=0,s=this.I.size();s>i;i++){var h=this.I.itemAt(i);t+=h.first.value()*h.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.I.size()},t.prototype.toString=function(){var t=this.I.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this._||(t+=" + "),t+this._},t}();function U(t){for(var i=0,s=()=>0,h=_(),r=0,n=t.length;n>r;++r){var e=t[r];if("number"==typeof e)i+=e;else if(e instanceof B)h.setDefault(e,s).second+=1;else if(e instanceof P){i+=e.constant();for(var o=0,a=(f=e.terms()).size();a>o;o++){var c=f.itemAt(o);h.setDefault(c.first,s).second+=c.second}}else{if(!(e instanceof Array))throw Error("invalid Expression argument: "+e);if(2!==e.length)throw Error("array must have length 2");var u=e[0],d=e[1];if("number"!=typeof u)throw Error("array item 0 must be a number");if(d instanceof B)h.setDefault(d,s).second+=u;else{if(!(d instanceof P))throw Error("array item 1 must be a variable or expression");var f;for(i+=d.constant()*u,o=0,a=(f=d.terms()).size();a>o;o++)c=f.itemAt(o),h.setDefault(c.first,s).second+=c.second*u}}}return{terms:h,constant:i}}var z,D=(()=>{function t(){}return t.create=(t,i,s,h)=>{void 0===h&&(h=1);var r=0;return r+=1e6*Math.max(0,Math.min(1e3,t*h)),(r+=1e3*Math.max(0,Math.min(1e3,i*h)))+Math.max(0,Math.min(1e3,s*h))},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"})(z||(z={}));var V,R=function(){function t(t,i,s,h){void 0===h&&(h=D.required),this.T=H++,this.F=i,this.A=D.clip(h),this.B=void 0===s&&t instanceof P?t:t.minus(s)}return t.prototype.id=function(){return this.T},t.prototype.expression=function(){return this.B},t.prototype.op=function(){return this.F},t.prototype.strength=function(){return this.A},t.prototype.toString=function(){return this.B+" "+["<=",">=","="][this.F]+" 0 ("+this.A+")"},t}(),H=0,L=function(){function t(){this.$=_(),this.P=_(),this.U=_(),this.D=_(),this.V=[],this.R=new Y,this.H=null,this.L=0}return t.prototype.createConstraint=function(t,i,s,h){void 0===h&&(h=D.required);var r=new R(t,i,s,h);return this.addConstraint(r),r},t.prototype.addConstraint=function(t){if(void 0!==this.$.find(t))throw Error("duplicate constraint");var i=this.j(t),s=i.row,h=i.tag,r=this.N(s,h);if(r.type()===V.Invalid&&s.allDummies()){if(!j(s.constant()))throw Error("unsatisfiable constraint");r=h.marker}if(r.type()===V.Invalid){if(!this.X(s))throw Error("unsatisfiable constraint")}else s.solveFor(r),this.Y(r,s),this.P.insert(r,s);this.$.insert(t,h),this.W(this.R)},t.prototype.removeConstraint=function(t){var i=this.$.erase(t);if(void 0===i)throw Error("unknown constraint");this.q(t,i.second);var s=i.second.marker,h=this.P.erase(s);if(void 0===h){var r=this.G(s);if(r.type()===V.Invalid)throw Error("failed to find leaving row");(h=this.P.erase(r)).second.solveForEx(r,s),this.Y(s,h.second)}this.W(this.R)},t.prototype.hasConstraint=function(t){return this.$.contains(t)},t.prototype.addEditVariable=function(t,i){if(void 0!==this.D.find(t))throw Error("duplicate edit variable");if((i=D.clip(i))===D.required)throw Error("bad required strength");var s=new P(t),h=new R(s,z.Eq,void 0,i);this.addConstraint(h);var r=this.$.find(h).second;this.D.insert(t,{tag:r,constraint:h,constant:0})},t.prototype.removeEditVariable=function(t){var i=this.D.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)},t.prototype.hasEditVariable=function(t){return this.D.contains(t)},t.prototype.suggestValue=function(t,i){var s=this.D.find(t);if(void 0===s)throw Error("unknown edit variable");var h=this.P,r=s.second,n=i-r.constant;r.constant=i;var e=r.tag.marker,o=h.find(e);if(void 0!==o)return 0>o.second.add(-n)&&this.V.push(e),void this.J();var a=r.tag.other;if(void 0!==(o=h.find(a)))return 0>o.second.add(n)&&this.V.push(a),void this.J();for(var c=0,u=h.size();u>c;++c){var d=h.itemAt(c),f=d.second,l=f.coefficientFor(e);0!==l&&0>f.add(n*l)&&d.first.type()!==V.External&&this.V.push(d.first)}this.J()},t.prototype.updateVariables=function(){for(var t=this.U,i=this.P,s=0,h=t.size();h>s;++s){var r=t.itemAt(s),n=i.find(r.second);r.first.setValue(void 0!==n?n.second.constant():0)}},t.prototype.K=function(t){var i=this;return this.U.setDefault(t,()=>i.Z(V.External)).second},t.prototype.j=function(t){for(var i=t.expression(),s=new Y(i.constant()),h=i.terms(),r=0,n=h.size();n>r;++r){var e=h.itemAt(r);if(!j(e.second)){var o=this.K(e.first),a=this.P.find(o);void 0!==a?s.insertRow(a.second,e.second):s.insertSymbol(o,e.second)}}var c=this.R,u=t.strength(),d={marker:X,other:X};switch(t.op()){case z.Le:case z.Ge:var f=t.op()===z.Le?1:-1,l=this.Z(V.Slack);if(d.marker=l,s.insertSymbol(l,f),D.required>u){var w=this.Z(V.Error);d.other=w,s.insertSymbol(w,-f),c.insertSymbol(w,u)}break;case z.Eq:if(D.required>u){var v=this.Z(V.Error),g=this.Z(V.Error);d.marker=v,d.other=g,s.insertSymbol(v,-1),s.insertSymbol(g,1),c.insertSymbol(v,u),c.insertSymbol(g,u)}else{var p=this.Z(V.Dummy);d.marker=p,s.insertSymbol(p)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:d}},t.prototype.N=(t,i)=>{for(var s=t.cells(),h=0,r=s.size();r>h;++h){var n=s.itemAt(h);if(n.first.type()===V.External)return n.first}var e=i.marker.type();return e!==V.Slack&&e!==V.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type())!==V.Slack&&e!==V.Error||t.coefficientFor(i.other)>=0?X:i.other:i.marker},t.prototype.X=function(t){var i=this.Z(V.Slack);this.P.insert(i,t.copy()),this.H=t.copy(),this.W(this.H);var s=j(this.H.constant());this.H=null;var h=this.P.erase(i);if(void 0!==h){var r=h.second;if(r.isConstant())return s;var n=this.tt(r);if(n.type()===V.Invalid)return!1;r.solveForEx(i,n),this.Y(n,r),this.P.insert(n,r)}for(var e=this.P,o=0,a=e.size();a>o;++o)e.itemAt(o).second.removeSymbol(i);return this.R.removeSymbol(i),s},t.prototype.Y=function(t,i){for(var s=this.P,h=0,r=s.size();r>h;++h){var n=s.itemAt(h);n.second.substitute(t,i),0>n.second.constant()&&n.first.type()!==V.External&&this.V.push(n.first)}this.R.substitute(t,i),this.H&&this.H.substitute(t,i)},t.prototype.W=function(t){for(;;){var i=this.it(t);if(i.type()===V.Invalid)return;var s=this.st(i);if(s.type()===V.Invalid)throw Error("the objective is unbounded");var h=this.P.erase(s).second;h.solveForEx(s,i),this.Y(i,h),this.P.insert(i,h)}},t.prototype.J=function(){for(var t=this.P,i=this.V;0!==i.length;){var s=i.pop(),h=t.find(s);if(void 0!==h&&0>h.second.constant()){var r=this.ht(h.second);if(r.type()===V.Invalid)throw Error("dual optimize failed");var n=h.second;t.erase(s),n.solveForEx(s,r),this.Y(r,n),t.insert(r,n)}}},t.prototype.it=t=>{for(var i=t.cells(),s=0,h=i.size();h>s;++s){var r=i.itemAt(s),n=r.first;if(0>r.second&&n.type()!==V.Dummy)return n}return X},t.prototype.ht=function(t){for(var i=Number.MAX_VALUE,s=X,h=t.cells(),r=0,n=h.size();n>r;++r){var e=h.itemAt(r),o=e.first,a=e.second;if(a>0&&o.type()!==V.Dummy){var c=this.R.coefficientFor(o)/a;i>c&&(i=c,s=o)}}return s},t.prototype.st=function(t){for(var i=Number.MAX_VALUE,s=X,h=this.P,r=0,n=h.size();n>r;++r){var e=h.itemAt(r),o=e.first;if(o.type()!==V.External){var a=e.second,c=a.coefficientFor(t);if(0>c){var u=-a.constant()/c;i>u&&(i=u,s=o)}}}return s},t.prototype.G=function(t){for(var i=Number.MAX_VALUE,s=i,h=i,r=X,n=r,e=r,o=r,a=this.P,c=0,u=a.size();u>c;++c){var d=a.itemAt(c),f=d.second,l=f.coefficientFor(t);if(0!==l){var w=d.first;if(w.type()===V.External)o=w;else if(0>l)s>(v=-f.constant()/l)&&(s=v,n=w);else{var v;h>(v=f.constant()/l)&&(h=v,e=w)}}}return n!==r?n:e!==r?e:o},t.prototype.q=function(t,i){i.marker.type()===V.Error&&this.rt(i.marker,t.strength()),i.other.type()===V.Error&&this.rt(i.other,t.strength())},t.prototype.rt=function(t,i){var s=this.P.find(t);void 0!==s?this.R.insertRow(s.second,-i):this.R.insertSymbol(t,-i)},t.prototype.tt=t=>{for(var i=t.cells(),s=0,h=i.size();h>s;++s){var r=i.itemAt(s),n=r.first.type();if(n===V.Slack||n===V.Error)return r.first}return X},t.prototype.Z=function(t){return new N(t,this.L++)},t}();function j(t){return 0>t?1e-8>-t:1e-8>t}(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"})(V||(V={}));var N=function(){function t(t,i){this.T=i,this.nt=t}return t.prototype.id=function(){return this.T},t.prototype.type=function(){return this.nt},t}(),X=new N(V.Invalid,-1),Y=function(){function t(t){void 0===t&&(t=0),this.et=_(),this._=t}return t.prototype.cells=function(){return this.et},t.prototype.constant=function(){return this._},t.prototype.isConstant=function(){return this.et.empty()},t.prototype.allDummies=function(){for(var t=this.et,i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==V.Dummy)return!1;return!0},t.prototype.copy=function(){var i=new t(this._);return i.et=this.et.copy(),i},t.prototype.add=function(t){return this._+=t},t.prototype.insertSymbol=function(t,i){void 0===i&&(i=1),j(this.et.setDefault(t,()=>0).second+=i)&&this.et.erase(t)},t.prototype.insertRow=function(t,i){void 0===i&&(i=1),this._+=t._*i;for(var s=t.et,h=0,r=s.size();r>h;++h){var n=s.itemAt(h);this.insertSymbol(n.first,n.second*i)}},t.prototype.removeSymbol=function(t){this.et.erase(t)},t.prototype.reverseSign=function(){this._=-this._;for(var t=this.et,i=0,s=t.size();s>i;++i){var h=t.itemAt(i);h.second=-h.second}},t.prototype.solveFor=function(t){var i=this.et,s=-1/i.erase(t).second;this._*=s;for(var h=0,r=i.size();r>h;++h)i.itemAt(h).second*=s},t.prototype.solveForEx=function(t,i){this.insertSymbol(t,-1),this.solveFor(i)},t.prototype.coefficientFor=function(t){var i=this.et.find(t);return void 0!==i?i.second:0},t.prototype.substitute=function(t,i){var s=this.et.erase(t);void 0!==s&&this.insertRow(i,s.second)},t}();const W=Symbol("xSymbol"),q=Symbol("ySymbol"),G=Symbol("widthSymbol"),Q=Symbol("heightSymbol"),J=Symbol("addUIElementSymbol"),K=Symbol("removeUIElementSymbol"),Z=Symbol("addConstraintSymbol"),tt=Symbol("removeUIConstraintSymbol"),it=Symbol("addConstraintSymbol"),st=Symbol("removeConstraintSymbol"),ht=Symbol("addVariableSymbol"),rt=Symbol("removeVariableSymbol"),nt=Symbol("suggestVariableSymbol"),et=Symbol("disableConstraintSymbol"),ot=Symbol("enableConstraintSymbol"),at=Symbol("needsRecalculation"),ct=Symbol("renderSymbol"),ut=Symbol("clickSymbol"),dt=Symbol("sortSymbol");var ft;function lt(t){return null!==t&&Object.values(ft).some(i=>i===t)}function wt(t){return t??ft.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(ft||(ft={}));class vt{constructor(t,i){this.layer=t,this.name="",this.layer[Z](this,i)}destroy(){this.layer[tt](this)}}const gt=1e3;var pt,mt,yt,bt,xt;function Ct(t){return null!==t&&Object.values(pt).some(i=>i===t)}function St(t){return t??pt.P0}function Et(t){switch(t){case pt.P0:return D.create(gt,gt,gt);case pt.P1:return D.create(100,0,0);case pt.P2:return D.create(10,0,0);case pt.P3:return D.create(0,100,0);case pt.P4:return D.create(0,10,0);case pt.P5:return D.create(0,0,100);case pt.P6:return D.create(0,0,10);case pt.P7:return D.create(0,0,1);default:return D.create(gt,gt,gt)}}function kt(t){return null!==t&&Object.values(mt).some(i=>i===t)}function Mt(t){return t??mt.EQUAL}function Tt(t){switch(t){case mt.EQUAL:return z.Eq;case mt.LESS:return z.Le;case mt.GREATER:return z.Ge;default:return z.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"})(pt||(pt={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(mt||(mt={}));class Ot extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.ct={height:i?.height??t.height,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.ct.orientation!==ft.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.ct.orientation!==ft.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}[ot](t){this.ct.orientation!==ft.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.ut=new R(new P(this.ot[Q]),Tt(this.ct.rule),this.ct.height,Et(this.ct.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class It{constructor(t,i,s=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,s):this.t.set(i,new Map([[t,s]])))}insert(t,i,s=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,s)}const h=this.t.get(i);void 0===h?this.t.set(i,new Map([[t,s]])):h.has(t)||h.set(t,s)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class _t{constructor(){this.o=new Map}on(t,i,s,h=0){return this.h(t,!1,h,i,s),this}once(t,i,s,h=0){return this.h(t,!0,h,i,s),this}off(t,i,s){const h=this.o.get(t);if(void 0===h)return this;h.u&&(h.u=!1,h.v=h.v.slice());const r=h.v;if(0===r.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;r.length>t;t++){const i=r[t];h.l.remove(i.dt,i.p)}return this}{const n=r.length;if(r[0].dt===i&&r[0].p===s)return 1===n?this.o.delete(t):r.shift(),this;const e=n-1;if(r[e].dt===i&&r[e].p===s)return r.pop(),this;if(10>n||r[0].M===r[e].M)for(let t=1;e>t;t++){const h=r[t];if(h.dt===i&&h.p===s)return r.splice(t,1),this}else{const t=h.l.getPriority(i,s);if(void 0===t)return this;let n=0,e=r.length-1;for(;e>=n;){const i=n+e>>>1;t>r[i].M?n=i+1:e=i-1}const o=n;for(e=r.length-1;e>=n;){const i=n+e>>>1;r[i].M>t?e=i-1:n=i+1}const a=e;for(let t=o;a>=t;t++)if(r[t].dt===i&&r[t].p===s)return r.splice(t,1),this}}return this}emit(t,...i){const s=this.o.get(t);if(void 0===s)return!1;if(0===s.v.length)return!1;s.u?s.v=s.v.slice():s.u=!0;const h=s.v;let r=!1;for(let t=0;h.length>t;t++){const s=h[t];s.dt.apply(s.p,i),s.k&&(r=!0,s.m=!0)}const n=this.o.get(t);if(void 0===n)return!0;n.v===h&&(n.u=!1);const e=n.v;if(r){let i=0;for(let t=0;e.length>t;t++){const s=e[t];s.m?n.l.remove(s.dt,s.p):e[i++]=s}0===i?this.o.delete(t):e.length=i}return!0}h(t,i,s,h,r){let n=this.o.get(t);if(void 0===n)return void this.o.set(t,{v:[{dt:h,p:r,M:s,k:i,m:!1}],u:!1,l:new It(h,r,s)});if(n.l.has(h,r))throw Error("Event listener already exists");n.l.insert(h,r,s);const e={dt:h,p:r,M:s,k:i,m:!1};n.u&&(n.u=!1,n.v=n.v.slice());{const t=n.v,i=e.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(e);if(t[0].M>=i)return void t.unshift(e);{let s=0,h=t.length;for(;h>s;){const r=s+h>>>1;i>t[r].M?s=r+1:h=r}t.splice(s,0,e)}}}}class Ft extends _t{constructor(i,s,h,r){super(),this.layer=i,this.object=r,this[yt]=new B("x"),this[bt]=new B("y"),this[xt]=!1,this.name=t.generateUUID(),this.object&&(this.object.matrixAutoUpdate=!1),this.layer[J](this,r),this.layer[ht](this,this[W],Et(pt.P7)),this.layer[ht](this,this[q],Et(pt.P7)),this[W].setValue(s),this[q].setValue(h),this.layer[nt](this,this[W],s),this.layer[nt](this,this[q],h)}get x(){return this[W].value()}get y(){return this[q].value()}get zIndex(){return this.object?.position.z??0}get needsRecalculation(){return this[at]}set x(t){this.layer[nt](this,this[W],t)}set y(t){this.layer[nt](this,this[q],t)}set zIndex(t){this.object&&this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[dt](),this.object.updateMatrix())}destroy(){this.layer[rt](this,this[q]),this.layer[rt](this,this[W]),this.layer[K](this)}[(yt=W,bt=q,xt=at,ct)](t,i){this.render(t,i)}applyTransformations(){this[at]&&(this.object&&this.object.updateMatrix(),this[at]=!1)}}const At=new i,Bt=new s,$t=new h,Pt=new h,Ut=new h,zt=new h,Dt=new h,Vt=new r,Rt=.5;class Ht{constructor(){this.x=0,this.y=0,this.anchorX=Rt,this.anchorY=Rt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=!1}}class Lt{constructor(t,i){this.ft=t,this.lt=i}get x(){return this.ft.x}get y(){return this.ft.y}get anchorX(){return this.ft.anchorX}get anchorY(){return this.ft.anchorY}get scaleX(){return this.ft.scaleX}get scaleY(){return this.ft.scaleY}get angle(){return t.radToDeg(this.ft.rotation)}get rotation(){return this.ft.rotation}set x(t){t!==this.ft.x&&(this.ft.x=t,this.ft.needsRecalculation=!0)}set y(t){t!==this.ft.y&&(this.ft.y=t,this.ft.needsRecalculation=!0)}set anchorX(t){t!==this.ft.anchorX&&(this.ft.anchorX=t,this.ft.needsRecalculation=!0)}set anchorY(t){t!==this.ft.anchorY&&(this.ft.anchorY=t,this.ft.needsRecalculation=!0)}set scaleX(t){t!==this.ft.scaleX&&(this.ft.scaleX=t,this.ft.needsRecalculation=!0)}set scaleY(t){t!==this.ft.scaleY&&(this.ft.scaleY=t,this.ft.needsRecalculation=!0)}set angle(i){const s=t.degToRad(i);s!==this.ft.rotation&&(this.ft.rotation=s,this.ft.needsRecalculation=!0)}set rotation(t){t!==this.ft.rotation&&(this.ft.rotation=t,this.ft.needsRecalculation=!0)}setAnchorByGlobalPosition(t,i){const s=(t-this.lt.x)/this.lt.width,h=(i-this.lt.y)/this.lt.height;s===this.ft.anchorX&&h===this.ft.anchorY||(this.ft.anchorX=s,this.ft.anchorY=h,this.ft.needsRecalculation=!0)}reset(){0===this.ft.x&&0===this.ft.y&&this.ft.anchorX===Rt&&this.ft.anchorY===Rt&&1===this.ft.scaleX&&1===this.ft.scaleY&&0===this.ft.rotation||(this.ft.x=0,this.ft.y=0,this.ft.anchorX=Rt,this.ft.anchorY=Rt,this.ft.scaleX=1,this.ft.scaleY=1,this.ft.rotation=0,this.ft.needsRecalculation=!0)}}var jt,Nt;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(jt||(jt={})),(t=>{t[t.NORMAL=0]="NORMAL",t[t.ADDITIVE=1]="ADDITIVE",t[t.SUBTRACTIVE=2]="SUBTRACTIVE",t[t.MULTIPLY=3]="MULTIPLY",t[t.SCREEN=4]="SCREEN"})(Nt||(Nt={}));class Xt extends n{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new e(1,1,1)}},vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D map;\n uniform float opacity;\n uniform vec3 color;\n varying vec2 vUv;\n\n void main() {\n vec4 textureColor = texture2D(map, vUv);\n gl_FragColor = vec4(textureColor.rgb * color, textureColor.a * opacity);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}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=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setBlending(t){switch(this.premultipliedAlpha=!1,this.blendEquation=o,this.blendSrc=a,this.blendDst=c,t){case Nt.ADDITIVE:this.blending=g;break;case Nt.SUBTRACTIVE:this.blending=v;break;case Nt.MULTIPLY:this.blending=w,this.premultipliedAlpha=!0;break;case Nt.SCREEN:this.blending=d,this.blendEquation=o,this.blendSrc=f,this.blendDst=l;break;default:this.blending=u}this.needsUpdate=!0}}const Yt=new p(1,1).translate(.5,.5,0),Wt=new m,qt=new y(Yt);Wt.add(qt);class Gt{constructor(t=0,i=0){this.wt=t,this.vt=i,this.gt=new b(-1,1,1,-1,0,1),this.yt()}get paddingHorizontal(){return this.wt}get paddingVertical(){return this.vt}set paddingHorizontal(t){this.wt!==t&&(this.wt=t,this.yt())}set paddingVertical(t){this.vt!==t&&(this.vt=t,this.yt())}render(t,i){qt.material=i,t.render(Wt,this.gt)}yt(){this.gt.left=-this.wt,this.gt.right=1+this.wt,this.gt.bottom=-this.vt,this.gt.top=1+this.vt,this.gt.updateProjectionMatrix()}}class Qt{constructor(){this.passes=[],this.bt=new Xt,this.xt=new Gt,this.Ct=!1,this.St=!1,this.Et=0;const t={format:E,minFilter:S,magFilter:S,type:C,depthBuffer:!1,stencilBuffer:!1};this.kt=new x(1,1,t),this.Mt=new x(1,1,t),this.kt.texture.generateMipmaps=!1,this.Mt.texture.generateMipmaps=!1}get needsUpdate(){return this.Ct&&this.Tt()||this.Ot()}get paddingHasChanged(){return this.St}get padding(){return this.Et}requestUpdate(){this.Ct=!0}compose(t,i,s,h,r=!0){const n=this.Tt();if(!(this.Ct&&n||this.Ot()))return n||(this.St=0!==this.Et,this.Et=0),this.Ct=!1,n?this.bt:h;const e=this.It();this.St=this.Et!==e,this.Et=e;const o=i+2*e,a=s+2*e;this.kt.setSize(o,a),this.Mt.setSize(o,a),this._t(i,s,e),t.setClearColor(0,0),t.setRenderTarget(this.Mt),t.clear(!0,!1,!1);const c=h.blending;r&&(h.blending=k),this.xt.render(t,h),h.blending=c;const u={width:i,height:s,padding:e};for(let i=0;this.passes.length>i;i++){const s=this.passes[i];(s.needsUpdate||s.isValuable)&&(this.Ft(),t.setRenderTarget(this.Mt),t.clear(!0,!1,!1),this.passes[i].render(t,this.kt.texture,u))}return this.Ct=!1,this.bt.setTexture(this.Mt.texture),this.bt}destroy(){this.kt.dispose(),this.Mt.dispose()}Tt(){return this.passes.some(t=>t.isValuable)}Ot(){return this.passes.some(t=>t.needsUpdate)}It(){return this.passes.reduce((t,i)=>Math.max(t,i.padding),0)}_t(t,i,s){this.xt.paddingHorizontal=s/t,this.xt.paddingVertical=s/i}Ft(){const t=this.kt;this.kt=this.Mt,this.Mt=t}}class Jt{constructor(t){this.ft=t}get passes(){return this.ft.passes}}var Kt,Zt,ti,ii,si,hi,ri,ni,ei,oi;(t=>{t.CLICK="click"})(hi||(hi={}));class ai extends _t{constructor(i,s,h,r,n,e){super(),this.layer=i,this.object=s,this[Kt]=new B("x"),this[Zt]=new B("y"),this[ti]=new B("width"),this[ii]=new B("height"),this[si]=!1,this.name=t.generateUUID(),this.microInternal=new Ht,this.composerInternal=new Qt,this.modeInternal=jt.VISIBLE,this.micro=new Lt(this.microInternal,this),this.composer=new Jt(this.composerInternal),this.object.matrixAutoUpdate=!1,this.layer[J](this,this.object),this.layer[ht](this,this[W],Et(pt.P7)),this.layer[ht](this,this[q],Et(pt.P7)),this.layer[ht](this,this[G],Et(pt.P5)),this.layer[ht](this,this[Q],Et(pt.P5)),this[W].setValue(h),this[q].setValue(r),this[G].setValue(n),this[Q].setValue(e),this.layer[nt](this,this[W],h),this.layer[nt](this,this[q],r),this.layer[nt](this,this[G],n),this.layer[nt](this,this[Q],e)}get x(){return this[W].value()}get y(){return this[q].value()}get width(){return this[G].value()}get height(){return this[Q].value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this[at]}set x(t){this.layer[nt](this,this[W],t)}set y(t){this.layer[nt](this,this[q],t)}set width(t){this.layer[nt](this,this[G],t)}set height(t){this.layer[nt](this,this[Q],t)}set zIndex(t){this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer[dt](),this.object.updateMatrix())}set mode(t){this.modeInternal=t,this.object.visible=t!==jt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer[rt](this,this[Q]),this.layer[rt](this,this[G]),this.layer[rt](this,this[q]),this.layer[rt](this,this[W]),this.layer[K](this)}[(Kt=W,Zt=q,ti=G,ii=Q,si=at,ct)](t,i){this.render(t,i)}[ut](t,i){return this.click(t,i)}applyTransformations(){(this[at]||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,h,r,n,e)=>{const o=this.x-e,a=this.y-e,c=this.width+2*e,u=this.height+2*e,d=o+c*i.anchorX,f=a+u*i.anchorY,l=$t.set(1,0,-d,0,1,-f,0,0,1),w=Pt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),v=Ut.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),g=zt.set(1,0,i.x+d,0,1,i.y+f,0,0,1),p=Dt.multiplyMatrices(g,v).multiply(w).multiply(l),m=Vt.set(o,a,1).applyMatrix3(p);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=c*i.scaleX,t.scale.y=u*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this.object.updateMatrix(),this[at]=!1,this.microInternal.needsRecalculation=!1)}click(t,i){return this.mode===jt.INTERACTIVE&&(this.applyTransformations(),s=this.x,h=this.y,r=this.width,n=this.height,At.set(t,i),Bt.min.set(s,h),Bt.max.set(r,n).add(Bt.min),!!Bt.containsPoint(At)&&(this.emit(hi.CLICK,this),!0));var s,h,r,n}}const ci=new e(0);var ui,di,fi;(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.CLICK="click"})(ui||(ui={}));class li extends _t{constructor(){super(...arguments),this.mode=jt.VISIBLE,this[ri]=new B,this[ni]=new B,this[ei]=new B,this[oi]=new B,this.scene=new m,this.camera=new b,this.solver=new L,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=ft.PORTRAIT,this.needsRecalculation=!1}get orientation(){return this.orientationPrivate}get width(){return this[G].value()}get height(){return this[Q].value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}[(ri=W,ni=q,ei=G,oi=Q,J)](t,i,s){if(this.elements.has(t))throw Error("Element already added");if(this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i){const t=s??this.scene.children.length;i.position.z=t,i.renderOrder=t,this.scene.add(i),this[dt]()}}[K](t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),i.object&&this.scene.remove(i.object)}[Z](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})}[tt](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)}[it](t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before adding constraint you need to add it's owner");if(s.constraints.has(i))throw Error("Constraint already exists");s.constraints.add(i);try{this.solver?.addConstraint(i)}catch{this.At()}this.needsRecalculation=!0}[st](t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before removing constraint you need to add it's owner");if(!s.constraints.has(i))throw Error("Constraint not found");s.constraints.delete(i);try{this.solver?.removeConstraint(i)}catch{this.At()}this.needsRecalculation=!0}[ht](t,i,s){const h=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before adding variable you need to add it's owner");if(h.variables.has(i))throw Error("Variable already exists");h.variables.set(i,{strength:s,suggestedValue:i.value()});try{this.solver?.addEditVariable(i,s)}catch{this.At()}this.needsRecalculation=!0}[rt](t,i){const s=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===s)throw Error("Before removing variable you need to add it's owner");if(!s.variables.has(i))throw Error("Variable does not exist");s.variables.delete(i);try{this.solver?.removeEditVariable(i)}catch{this.At()}this.needsRecalculation=!0}[nt](t,i,s){const h=t instanceof ai||t instanceof Ft?this.elements.get(t):this.constraints.get(t);if(void 0===h)throw Error("Before suggesting variable you need to add it's owner");const r=h.variables.get(i);if(!r)throw Error("Variable does not exist");if(r.suggestedValue!==s){r.suggestedValue=s;try{this.solver?.suggestValue(i,s)}catch{this.At()}this.needsRecalculation=!0}}[dt](){this.scene.children.sort((t,i)=>t.position.z-i.position.z);for(let t=0;this.scene.children.length>t;t++){const i=this.scene.children[t];i.position.z=t,i.renderOrder=t}this.camera.position.set(0,0,this.scene.children.length+1),this.camera.near=1,this.camera.far=this.scene.children.length+1+1,this.camera.updateProjectionMatrix(),this.camera.updateMatrix()}render(t,i){if(this.mode===jt.HIDDEN)return;const s=t.getRenderTarget(),h=t.getClearColor(ci),r=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=!1,this.solver?.updateVariables();for(const t of this.elements.keys())t[at]=!0}for(const s of this.elements.keys())s[ct](t,i);t.setRenderTarget(s),t.setClearColor(h),t.setClearAlpha(r),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==jt.INTERACTIVE)return;this.emit(ui.CLICK,this,t,i);const s=[...this.elements.keys()].filter(t=>t instanceof ai).filter(t=>t.mode===jt.INTERACTIVE).sort((t,i)=>t.zIndex-i.zIndex);for(const h of s)if(h[ut](t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=!0}applyCameraSize(t,i){this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){this.constraintX&&(this.solver?.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(this.solver?.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(this.solver?.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(this.solver?.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new R(new P(this[W]),z.Eq,0,D.required),this.constraintY=new R(new P(this[q]),z.Eq,0,D.required),this.constraintW=new R(new P(this[G]),z.Eq,t,D.required),this.constraintH=new R(new P(this[Q]),z.Eq,i,D.required),this.solver?.addConstraint(this.constraintX),this.solver?.addConstraint(this.constraintY),this.solver?.addConstraint(this.constraintW),this.solver?.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?ft.LANDSCAPE:ft.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t[ot](this.orientationPrivate);for(const t of this.constraints.keys())t[et](this.orientationPrivate);this.solver=new L;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(ui.ORIENTATION_CHANGED,this,this.orientation)}}At(){try{this.solver=void 0,this.solver=new L;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)}catch(t){throw t}}}function wi(t,i){if((t instanceof li?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 vi(t,i,s){if(0>=t||0>=i)throw Error(s??`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class gi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai||t instanceof Ft?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={anchorOne:s?.anchorOne??.5,anchorTwo:s?.anchorTwo??.5,distance:s?.distance??0,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Bt instanceof ai||this.Bt instanceof li?new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.anchorOne)):new P(this.Bt[W]),i=this.$t instanceof ai?new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.anchorTwo)):new P(this.$t[W]);this.ut=new R(i.minus(t),Tt(this.Pt.rule),this.Pt.distance,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class pi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={proportion:s?.proportion??1,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.Bt[G]).multiply(this.Pt.proportion),i=new P(this.$t[G]);this.ut=new R(t.minus(i),Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class mi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai||t instanceof Ft?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={anchorOne:s?.anchorOne??.5,anchorTwo:s?.anchorTwo??.5,distance:s?.distance??0,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Bt instanceof ai||this.Bt instanceof li?new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.anchorOne)):new P(this.Bt[q]),i=this.$t instanceof ai?new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.anchorTwo)):new P(this.$t[q]);this.ut=new R(i.minus(t),Tt(this.Pt.rule),this.Pt.distance,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class yi extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={proportion:s?.proportion??1,power:St(s?.power),rule:Mt(s?.rule),orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.Bt[Q]).multiply(this.Pt.proportion),i=new P(this.$t[Q]);this.ut=new R(t.minus(i),Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class bi extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.ct={width:i?.width??t.width,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.ct.orientation!==ft.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.ct.orientation!==ft.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}[ot](t){this.ct.orientation!==ft.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.ut=new R(new P(this.ot[G]),Tt(this.ct.rule),this.ct.width,Et(this.ct.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class xi{static size(t,i={}){return{x:new bi(t,{width:i.size?.x,power:i.power?.x,rule:i.rule?.x,orientation:i.orientation?.x}),y:new Ot(t,{height:i.size?.y,power:i.power?.y,rule:i.rule?.y,orientation:i.orientation?.y})}}static distance(t,i,s={}){return{x:new gi(t,i,{anchorOne:s.anchorOne?.x,anchorTwo:s.anchorTwo?.x,distance:s.distance?.x,power:s.power?.x,rule:s.rule?.x,orientation:s.orientation?.x}),y:new mi(t,i,{anchorOne:s.anchorOne?.y,anchorTwo:s.anchorTwo?.y,distance:s.distance?.y,power:s.power?.y,rule:s.rule?.y,orientation:s.orientation?.y})}}static proportion(t,i,s={}){return{x:new pi(t,i,{proportion:s.proportion?.x,power:s.power?.x,rule:s.rule?.x,orientation:s.orientation?.x}),y:new yi(t,i,{proportion:s.proportion?.y,power:s.power?.y,rule:s.rule?.y,orientation:s.orientation?.y})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(di||(di={}));class Ci{static build(t,i,s,h={}){const r=h.direction??di.FROM_LEFT_TOP,n=[],e=[];n.push(new gi(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:h.power,orientation:h.orientation}),new gi(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:h.power,orientation:h.orientation}));const o=r===di.FROM_LEFT_TOP?1:0,a=r===di.FROM_LEFT_TOP?0:1;return e.push(new mi(t,i,{anchorOne:o,anchorTwo:o,distance:0,power:h.power,orientation:h.orientation}),new mi(t,s,{anchorOne:a,anchorTwo:a,distance:0,power:h.power,orientation:h.orientation})),{horizontalDistances:n,verticalDistances:e}}}class Si{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:gi,proportionConstraint:pi,centerDistanceConstraint:mi})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:mi,proportionConstraint:yi,centerDistanceConstraint:gi})}static buildStack(t,i,s){const h=[],r=[],n=[];for(let e=0;t.length-1>e;e++){const o=t[e],a=t[e+1];h.push(new s.distanceConstraint(o,a,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),!1!==i.keepProportions&&r.push(new s.proportionConstraint(o,a,{power:i.power,orientation:i.orientation})),!1!==i.keepAlignment&&n.push(new s.centerDistanceConstraint(o,a,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:h,proportionConstraints:r,alignmentConstraints:n}}}class Ei extends vt{constructor(t,i){super(t.layer,new Set([t])),this.ot=t,this.Pt={aspect:i?.aspect??this.ot.width/this.ot.height,power:St(i?.power),rule:Mt(i?.rule),orientation:wt(i?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){const t=new P(this.ot[G]).plus(new P(this.ot[Q]).multiply(-this.Pt.aspect));this.ut=new R(t,Tt(this.Pt.rule),0,Et(this.Pt.power)),this.layer[it](this,this.ut)}destroyConstraints(){this.ut&&(this.layer[st](this,this.ut),this.ut=void 0)}}class ki extends vt{constructor(t,i,s){wi(t,i),super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,this.Pt={isStrict:s?.isStrict??!0,horizontalAnchor:s?.horizontalAnchor??.5,verticalAnchor:s?.verticalAnchor??.5,orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){this.Ut=new R(new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.horizontalAnchor)),z.Eq,new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.horizontalAnchor))),this.zt=new R(new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.verticalAnchor)),z.Eq,new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.verticalAnchor))),this.Dt=new R(new P(this.Bt[G]),z.Le,new P(this.$t[G])),this.Vt=new R(new P(this.Bt[Q]),z.Le,new P(this.$t[Q])),this.layer[it](this,this.Ut),this.layer[it](this,this.zt),this.layer[it](this,this.Dt),this.layer[it](this,this.Vt),this.Pt.isStrict||(this.Rt=new R(new P(this.Bt[Q]),z.Eq,new P(this.$t[Q]),D.strong),this.layer[it](this,this.Rt))}destroyConstraints(){this.Ut&&(this.layer[st](this,this.Ut),this.Ut=void 0),this.zt&&(this.layer[st](this,this.zt),this.zt=void 0),this.Dt&&(this.layer[st](this,this.Dt),this.Dt=void 0),this.Vt&&(this.layer[st](this,this.Vt),this.Vt=void 0),this.Rt&&(this.layer[st](this,this.Rt),this.Rt=void 0)}}class Mi extends vt{constructor(t,i,s){super(i.layer,new Set(t instanceof ai?[t,i]:[i])),this.Bt=t,this.$t=i,wi(t,i),this.Pt={isStrict:s?.isStrict??!0,horizontalAnchor:s?.horizontalAnchor??.5,verticalAnchor:s?.verticalAnchor??.5,orientation:wt(s?.orientation)},this.Pt.orientation!==ft.ALWAYS&&this.Pt.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}[et](t){this.Pt.orientation!==ft.ALWAYS&&t!==this.Pt.orientation&&this.destroyConstraints()}[ot](t){this.Pt.orientation!==ft.ALWAYS&&t===this.Pt.orientation&&this.buildConstraints()}buildConstraints(){this.Ut=new R(new P(this.Bt[W]).plus(new P(this.Bt[G]).multiply(this.Pt.horizontalAnchor)),z.Eq,new P(this.$t[W]).plus(new P(this.$t[G]).multiply(this.Pt.horizontalAnchor))),this.zt=new R(new P(this.Bt[q]).plus(new P(this.Bt[Q]).multiply(this.Pt.verticalAnchor)),z.Eq,new P(this.$t[q]).plus(new P(this.$t[Q]).multiply(this.Pt.verticalAnchor))),this.Dt=new R(new P(this.Bt[G]),z.Ge,new P(this.$t[G])),this.Vt=new R(new P(this.Bt[Q]),z.Ge,new P(this.$t[Q])),this.layer[it](this,this.Ut),this.layer[it](this,this.zt),this.layer[it](this,this.Dt),this.layer[it](this,this.Vt),!1!==this.Pt.isStrict&&(this.Rt=new R(new P(this.Bt[Q]),z.Eq,new P(this.$t[Q]),D.strong),this.layer[it](this,this.Rt))}destroyConstraints(){this.Ut&&(this.layer[st](this,this.Ut),this.Ut=void 0),this.zt&&(this.layer[st](this,this.zt),this.zt=void 0),this.Dt&&(this.layer[st](this,this.Dt),this.Dt=void 0),this.Vt&&(this.layer[st](this,this.Vt),this.Vt=void 0),this.Rt&&(this.layer[st](this,this.Rt),this.Rt=void 0)}}class Ti extends ai{constructor(t,i=100,s=100){super(t,new M,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Oi extends ai{constructor(t,i){const s=i.image?.width,h=i.image?.height;vi(s,h,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${s}) or height (${h}). Image dimensions must be non-zero positive numbers.`);const r=new Xt(i);super(t,new y(Yt,r),0,0,s,h),this.Ht=Nt.NORMAL,this.Lt=r,this.jt=i,this.applyTransformations()}get texture(){return this.jt}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get blending(){return this.Ht}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set blending(t){this.Ht=t,this.Lt.setBlending(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.jt.image.width,this.jt.image.height,this.Lt),this.applyTransformations()}}class Ii extends n{constructor(t,i){super({uniforms:T.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new e(1,1,1)},foregroundColor:{value:new e(1,1,1)},color:{value:new e(1,1,1)},backgroundOpacity:{value:1},foregroundOpacity:{value:1},opacity:{value:1},angle:{value:0},direction:{value:1}}]),vertexShader:"\n varying vec2 vUv;\n void main() {\n vUv = uv;\n gl_Position = projectionMatrix * modelViewMatrix * vec4(position, 1.0);\n }\n ",fragmentShader:"\n uniform sampler2D background;\n uniform sampler2D foreground;\n uniform float progress;\n uniform vec3 backgroundColor;\n uniform vec3 foregroundColor;\n uniform vec3 color;\n uniform float backgroundOpacity;\n uniform float foregroundOpacity;\n uniform float opacity;\n uniform float angle;\n uniform float direction;\n varying vec2 vUv;\n\n void main() {\n vec4 backgroundTexture = texture2D(background, vUv);\n vec4 foregroundTexture = texture2D(foreground, vUv);\n\n // Apply common color and opacity\n vec3 finalBackgroundColor = backgroundTexture.rgb * backgroundColor * color;\n vec3 finalForegroundColor = foregroundTexture.rgb * foregroundColor * color;\n float finalBackgroundOpacity = backgroundTexture.a * backgroundOpacity * opacity;\n float finalForegroundOpacity = foregroundTexture.a * foregroundOpacity * opacity;\n\n vec4 backgroundColor = vec4(finalBackgroundColor, finalBackgroundOpacity);\n vec4 foregroundColor = vec4(finalForegroundColor, finalForegroundOpacity);\n\n // Calculate progress threshold with angle and direction\n float adjustedX = mix(vUv.x, 1.0 - vUv.x, step(0.0, -direction));\n float tanAngle = tan(angle);\n float threshold = adjustedX - (vUv.y - 0.5) * tanAngle * sign(direction);\n float progressMask = smoothstep(threshold - 0.01, threshold + 0.01, progress);\n\n gl_FragColor = mix(backgroundColor, foregroundColor, progressMask);\n #include <colorspace_fragment>\n }\n ",transparent:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}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=!0}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=!0}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=!0}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=!0}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=!0}}class _i extends ai{constructor(i,s,h={}){const r=s.image?.width,n=s.image?.height;vi(r,n,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${r}) or height (${n}). Image dimensions must be non-zero positive numbers.`);const e=h.textureBackground?.image?.width,o=h.textureBackground?.image?.height;h.textureBackground&&vi(e,o,`Invalid image dimensions - texture "${h.textureBackground.name||"unnamed"}" has invalid width (${e}) or height (${o}). Image dimensions must be non-zero positive numbers.`);const a=new Ii(s,h.textureBackground),c=new y(Yt,a);h.progress&&a.setProgress(h.progress),h.isForegroundDirection&&a.setIsForwardDirection(h.isForegroundDirection),h.angle&&a.setAngle(t.degToRad(h.angle)),h.color&&a.setColor(h.color),h.opacity&&a.setOpacity(h.opacity),h.backgroundColor&&a.setBackgroundColor(h.backgroundColor),h.foregroundColor&&a.setForegroundColor(h.foregroundColor),h.backgroundOpacity&&a.setBackgroundOpacity(h.backgroundOpacity),h.foregroundOpacity&&a.setForegroundOpacity(h.foregroundOpacity);const u=e??r,d=n??o;super(i,c,0,0,u,d),this.Lt=a,this.Nt=u,this.Xt=d,this.applyTransformations()}get progress(){return this.Lt.getProgress()}get backgroundTexture(){return this.Lt.getBackgroundTexture()}get foregroundTexture(){return this.Lt.getForegroundTexture()}get backgroundColor(){return this.Lt.getBackgroundColor()}get foregroundColor(){return this.Lt.getForegroundColor()}get color(){return this.Lt.getColor()}get backgroundOpacity(){return this.Lt.getBackgroundOpacity()}get foregroundOpacity(){return this.Lt.getForegroundOpacity()}get opacity(){return this.Lt.getOpacity()}get angle(){return t.radToDeg(this.Lt.getAngle())}get isForwardDirection(){return this.Lt.getIsForwardDirection()}set progress(t){this.Lt.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.Lt.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.Lt.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.Lt.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.Lt.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set angle(i){this.Lt.setAngle(t.degToRad(i)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.Lt.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.Nt,this.Xt,this.Lt),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(fi||(fi={}));const Fi=fi.PROPERTY_CHANGED;class Ai extends ai{constructor(t,i={}){const s=i.resolutionFactor??.5;if(.1>s||s>8)throw Error(`Invalid resolution factor: ${s}. Must be between 0.1 and 8.`);const h=i.width??512,r=i.height??512;vi(h,r,`Invalid width or height: ${h}x${r}. Must be positive.`);const n=new x(h*s,r*s,{format:E,minFilter:S,magFilter:S,type:C,depthBuffer:i.useDepth??!0,stencilBuffer:!1}),e=new Xt(n.texture);super(t,new y(Yt,e),0,0,h,r),this.Yt=!1,this.Wt=i.scene??new m,this.qt=i.camera??new O(75,h/r,.1,100),this.Gt=s,this.Qt=i.updateBehavior??Fi,i.renderedByDefault&&(this.Yt=!0),this.Jt=i.clearColor??0,this.Kt=i.clearAlpha??0,this.Zt=n,this.Lt=e,this.applyTransformations()}get needsRender(){return this.Yt}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get scene(){return this.Wt}get camera(){return this.qt}get clearColor(){return this.Jt}get clearAlpha(){return this.Kt}get resolutionFactor(){return this.Gt}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.Wt!==t&&(this.Wt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.qt!==t&&(this.qt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.Jt!==t&&(this.Jt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.Kt!==t&&(this.Kt=t,this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.Gt!==t&&(this.Gt=t,this.Zt.setSize(this.width*this.Gt,this.height*this.Gt),this.Qt===fi.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.Lt.dispose(),this.Zt.dispose(),super.destroy()}requestRender(){this.Yt=!0,this.composerInternal.requestUpdate()}render(t){(this.Yt||this.Qt===fi.ALWAYS)&&(this.Yt=!1,this.Zt.setSize(this.width*this.Gt,this.height*this.Gt),t.setClearColor(this.Jt,this.clearAlpha),t.setRenderTarget(this.Zt),t.clear(!0,!0,!1),t.render(this.Wt,this.qt)),this.object.material=this.composerInternal.compose(t,this.width*this.Gt,this.height*this.Gt,this.Lt),this.applyTransformations()}}function Bi(t,i){const s=Math.max(t?.fontSize??i?.fontSize??16,1),h=t?.lineHeight??i?.lineHeight??1.2*s,r=Math.max(t?.shadowBlur??i?.shadowBlur??0,0),n=Math.max(t?.strokeWidth??i?.strokeWidth??0,0);return{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:s,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:t?.fontWeight??i?.fontWeight??"normal",lineHeight:h,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:t?.shadowOffsetX??i?.shadowOffsetX??0,shadowOffsetY:t?.shadowOffsetY??i?.shadowOffsetY??0,shadowBlur:r,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"transparent",strokeWidth:n}}function $i(t){return t.match(/\S+|\s|\n/g)||[]}function Pi(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 h=t.measureText(i),r=h.width,n=Math.ceil(h.actualBoundingBoxAscent+h.actualBoundingBoxDescent);return{width:Math.ceil(r),height:n,baseline:h.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function Ui(t,i,s,h,r){r.font=`${h.fontStyle} ${h.fontWeight} ${h.fontSize}px ${h.fontFamily}`,h.enableShadow&&(r.shadowOffsetX=h.shadowOffsetX,r.shadowOffsetY=h.shadowOffsetY,r.shadowBlur=h.shadowBlur,r.shadowColor=h.shadowColor),h.enableStroke&&(r.strokeStyle=h.strokeColor,r.lineWidth=h.strokeWidth,r.strokeText(s,t,i)),r.fillStyle=h.color,r.fillText(s,t,i)}class zi extends ai{constructor(t,i,s={}){const h=document.createElement("canvas"),r=h.getContext("2d");if(!r)throw Error("Failed to create canvas context");const n=[],e=Array.isArray(i)?i:[i];for(const t of e){const i="string"==typeof t,h=i?t:t.text,e=Bi(i?void 0:t.style,s.defaultStyle);for(const t of $i(h)){const i=Pi(r,t,e);n.push({text:t,style:e,metrics:i})}}const o=((t,i)=>{const s=[];let h=[],r=0,n=0,e=0,o=0;for(const a of i)"\n"!==a.text?r+a.metrics.width>t&&0!==h.length?(s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),h=[a],r=a.metrics.width,n=a.metrics.height,e=a.metrics.baseline,o=a.metrics.lineHeight):(h.push(a),r+=a.metrics.width,n=Math.max(n,a.metrics.height),e=Math.max(e,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(h.length>0&&s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),h=[],r=0,n=0,e=0,o=0);return h.length>0&&s.push({chunks:h,width:r,height:n,baseline:e,lineHeight:o}),s})(s.maxWidth??1024,n),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;t.length>i;i++){const h=t[i];s+=0===i?h.height:h.lineHeight,i===t.length-1&&(s+=h.baseline)}return{width:i,height:s}})(o),c=(t=>"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(t?.left??0,0),right:Math.max(t?.right??0,0),top:Math.max(t?.top??0,0),bottom:Math.max(t?.bottom??0,0)})(s.padding);h.width=a.width+c.left+c.right,h.height=a.height+c.top+c.bottom;const u=new I(h),d=new Xt(u);super(t,new y(Yt,d),0,0,a.width,a.height),this.ti=0,this.Lt=d,this.ii=u,this.si=h,this.hi=r,this.ri=a,this.ni=c,((t,i,s,h)=>{let r=this.ni.top;for(let t=0;s.length>t;t++){const n=s[t];let e=i;r+=0===t?n.height:n.lineHeight;for(const t of n.chunks)Ui(e,r,t.text,t.style,h),e+=t.metrics.width}})(0,this.ni.left,o,this.hi),this.ii.needsUpdate=!0,this.applyTransformations()}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),this.ii.dispose(),this.si.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.ti!==t&&(this.ti=t,this.height=this.width/((this.ri.width+this.ni.left+this.ni.right)/(this.ri.height+this.ni.top+this.ni.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.ii.image.width,this.ii.image.height,this.Lt),this.applyTransformations()}}class Di extends li{constructor(){super(),this.ei=1920,this.oi=()=>{const t=this.ai();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.ci=t=>{if(this.mode!==jt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,h=i?i.bottom-t.clientY:window.innerHeight-t.clientY,r=this.ai();this.clickInternal(s*r,h*r)},window.addEventListener("resize",this.oi),window.addEventListener("pointerdown",this.ci),this.oi()}get tergetScreenHeight(){return this.ei}set tergetScreenHeight(t){this.ei=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.oi),window.removeEventListener("pointerdown",this.ci),super.destroy()}render(t,i){t.clear(!1,!0,!0),super.render(t,i)}ai(){return(this.tergetScreenHeight??window.innerHeight)/window.innerHeight}}function Vi(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}class Ri{}export{Ft as UIAnchor,Ei as UIAspectConstraint,Nt as UIBlending,vt as UIConstraint,xi as UIConstraint2DBuilder,Ci as UIConstraintContainerBuilder,di as UIConstraintContainerDirection,pt as UIConstraintPower,mt as UIConstraintRule,Si as UIConstraintStackBuilder,ki as UICoverConstraint,Ti as UIDummy,ai as UIElement,hi as UIElementEvent,Mi as UIFitConstraint,Di as UIFullScreenLayer,Gt as UIFullScreenQuad,Ot as UIHeightConstraint,gi as UIHorizontalDistanceConstraint,pi as UIHorizontalProportionConstraint,Oi as UIImage,li as UILayer,ui as UILayerEvent,jt as UIMode,ft as UIOrientation,Ri as UIPass,_i as UIProgress,Ai as UIScene,fi as UISceneUpdateMode,zi as UIText,mi as UIVerticalDistanceConstraint,yi as UIVerticalProportionConstraint,bi as UIWidthConstraint,it as addConstraintSymbol,Z as addUIConstraintSymbol,J as addUIElementSymbol,ht as addVariableSymbol,ut as clickSymbol,Et as convertPowerToStrength,Tt as convertRuleToOperator,et as disableConstraintSymbol,ot as enableConstraintSymbol,Q as heightSymbol,Ct as isUIConstraintPower,kt as isUIConstraintRule,lt as isUIOrientation,Vi as isUITextSpan,at as needsRecalculation,st as removeConstraintSymbol,tt as removeUIConstraintSymbol,K as removeUIElementSymbol,rt as removeVariableSymbol,ct as renderSymbol,wt as resolveOrientation,St as resolvePower,Mt as resolveRule,dt as sortSymbol,nt as suggestVariableSymbol,G as widthSymbol,W as xSymbol,q as ySymbol};
|
|
1
|
+
import{MathUtils as t,Vector2 as i,Box2 as s,Matrix3 as e,Vector3 as h,ShaderMaterial as r,Color as n,AddEquation as o,SrcAlphaFactor as a,OneMinusSrcAlphaFactor as c,NormalBlending as l,CustomBlending as u,OneMinusDstColorFactor as d,OneFactor as f,MultiplyBlending as w,SubtractiveBlending as g,AdditiveBlending as p,PlaneGeometry as v,Scene as m,Mesh as b,OrthographicCamera as y,WebGLRenderTarget as C,UnsignedByteType as x,LinearFilter as E,RGBAFormat as _,NoBlending as I,Object3D as k,UniformsUtils as M,PerspectiveCamera as S,CanvasTexture as O}from"three";function T(){return new F}class F{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const s=this.index[t.id()];if(void 0===s){const s=new A(t,i());return this.index[t.id()]=this.array.length,this.array.push(s),s}return this.array[s]}insert(t,i){const s=new A(t,i),e=this.index[t.id()];return void 0===e?(this.index[t.id()]=this.array.length,this.array.push(s)):this.array[e]=s,s}erase(t){const i=this.index[t.id()];if(void 0===i)return;this.index[t.id()]=void 0;const s=this.array[i],e=this.array.pop();return s!==e&&(this.array[i]=e,this.index[e.first.id()]=i),s}copy(){const t=new F;for(let i=0;this.array.length>i;i++){const s=this.array[i].copy();t.array[i]=s,t.index[s.first.id()]=i}return t}}class A{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new A(this.first,this.second)}}class V{constructor(t=""){this.C=t}id(){return this._}name(){return this.C}setName(t){this.C=t}context(){return this.I}setContext(t){this.I=t}value(){return this.S}setValue(t){this.S=t}plus(t){return new z(this,t)}minus(t){return new z(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new z([t,this])}divide(t){return new z([1/t,this])}toJSON(){return{name:this.C,value:this.S}}toString(){return this.I+"["+this.C+":"+this.S+"]"}C;S=0;I=null;_=B++}let B=0;class z{constructor(){let t=(t=>{let i=0,s=()=>0,e=T();for(let h=0,r=t.length;r>h;++h){let r=t[h];if("number"==typeof r)i+=r;else if(r instanceof V)e.setDefault(r,s).second+=1;else if(r instanceof z){i+=r.constant();let t=r.terms();for(let i=0,h=t.size();h>i;i++){let h=t.itemAt(i);e.setDefault(h.first,s).second+=h.second}}else{if(!(r instanceof Array))throw Error("invalid Expression argument: "+r);{if(2!==r.length)throw Error("array must have length 2");let t=r[0],h=r[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(h instanceof V)e.setDefault(h,s).second+=t;else{if(!(h instanceof z))throw Error("array item 1 must be a variable or expression");{i+=h.constant()*t;let r=h.terms();for(let i=0,h=r.size();h>i;i++){let h=r.itemAt(i);e.setDefault(h.first,s).second+=h.second*t}}}}}}return{terms:e,constant:i}})(arguments);this.O=t.terms,this.T=t.constant}terms(){return this.O}constant(){return this.T}value(){let t=this.T;for(let i=0,s=this.O.size();s>i;i++){let s=this.O.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new z(this,t)}minus(t){return new z(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new z([t,this])}divide(t){return new z([1/t,this])}isConstant(){return 0==this.O.size()}toString(){let t=this.O.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.T||(t+=" + "),t+=this.T,t}O;T}class D{static create(t,i,s,e=1){let h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*e)),h+=1e3*Math.max(0,Math.min(1e3,i*e)),h+=Math.max(0,Math.min(1e3,s*e)),h}static required=D.create(1e3,1e3,1e3);static strong=D.create(1,0,0);static medium=D.create(0,1,0);static weak=D.create(0,0,1);static clip(t){return Math.max(0,Math.min(D.required,t))}}var P;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(P||(P={}));class ${constructor(t,i,s,e=D.required){this.F=i,this.A=D.clip(e),this.V=void 0===s&&t instanceof z?t:t.minus(s)}id(){return this._}expression(){return this.V}op(){return this.F}strength(){return this.A}toString(){return this.V+" "+["<=",">=","="][this.F]+" 0 ("+this.A+")"}V;F;A;_=U++}let U=0;class R{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=D.required){let h=new $(t,i,s,e);return this.addConstraint(h),h}addConstraint(t){if(void 0!==this.B.find(t))throw Error("duplicate constraint");let i=this.D(t),s=i.row,e=i.tag,h=this.P(s,e);if(h.type()===H.Invalid&&s.allDummies()){if(!L(s.constant()))throw Error("unsatisfiable constraint");h=e.marker}if(h.type()===H.Invalid){if(!this.$(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.U(h,s),this.R.insert(h,s);this.B.insert(t,e),this.L(this.H)}removeConstraint(t){let i=this.B.erase(t);if(void 0===i)throw Error("unknown constraint");this.j(t,i.second);let s=i.second.marker,e=this.R.erase(s);if(void 0===e){let t=this.N(s);if(t.type()===H.Invalid)throw Error("failed to find leaving row");e=this.R.erase(t),e.second.solveForEx(t,s),this.U(s,e.second)}this.L(this.H)}hasConstraint(t){return this.B.contains(t)}getConstraints(){return this.B.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.W.find(t))throw Error("duplicate edit variable");if((i=D.clip(i))===D.required)throw Error("bad required strength");let s=new z(t),e=new $(s,P.Eq,void 0,i);this.addConstraint(e);let h=this.B.find(e).second;this.W.insert(t,{tag:h,constraint:e,constant:0})}removeEditVariable(t){let i=this.W.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.W.contains(t)}suggestValue(t,i){let s=this.W.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.R,h=s.second,r=i-h.constant;h.constant=i;let n=h.tag.marker,o=e.find(n);if(void 0!==o)return 0>o.second.add(-r)&&this.X.push(n),void this.Y();let a=h.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(r)&&this.X.push(a),void this.Y();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t),s=i.second,h=s.coefficientFor(n);0!==h&&0>s.add(r*h)&&i.first.type()!==H.External&&this.X.push(i.first)}this.Y()}updateVariables(){let t=this.q,i=this.R;for(let s=0,e=t.size();e>s;++s){let e=t.itemAt(s),h=i.find(e.second);e.first.setValue(void 0!==h?h.second.constant():0)}}G(t){return this.q.setDefault(t,()=>this.J(H.External)).second}D(t){let i=t.expression(),s=new W(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!L(i.second)){let t=this.G(i.first),e=this.R.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let h=this.H,r=t.strength(),n={marker:N,other:N};switch(t.op()){case P.Le:case P.Ge:{let i=t.op()===P.Le?1:-1,e=this.J(H.Slack);if(n.marker=e,s.insertSymbol(e,i),D.required>r){let t=this.J(H.Error);n.other=t,s.insertSymbol(t,-i),h.insertSymbol(t,r)}break}case P.Eq:if(D.required>r){let t=this.J(H.Error),i=this.J(H.Error);n.marker=t,n.other=i,s.insertSymbol(t,-1),s.insertSymbol(i,1),h.insertSymbol(t,r),h.insertSymbol(i,r)}else{let t=this.J(H.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}P(t,i){let s=t.cells();for(let t=0,i=s.size();i>t;++t){let i=s.itemAt(t);if(i.first.type()===H.External)return i.first}let e=i.marker.type();return e!==H.Slack&&e!==H.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==H.Slack&&e!==H.Error||t.coefficientFor(i.other)>=0?N:i.other):i.marker}$(t){let i=this.J(H.Slack);this.R.insert(i,t.copy()),this.K=t.copy(),this.L(this.K);let s=L(this.K.constant());this.K=null;let e=this.R.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let h=this.Z(t);if(h.type()===H.Invalid)return!1;t.solveForEx(i,h),this.U(h,t),this.R.insert(h,t)}let h=this.R;for(let t=0,s=h.size();s>t;++t)h.itemAt(t).second.removeSymbol(i);return this.H.removeSymbol(i),s}U(t,i){let s=this.R;for(let e=0,h=s.size();h>e;++e){let h=s.itemAt(e);h.second.substitute(t,i),0>h.second.constant()&&h.first.type()!==H.External&&this.X.push(h.first)}this.H.substitute(t,i),this.K&&this.K.substitute(t,i)}L(t){let i=0;for(;this.maxIterations>i;){let s=this.tt(t);if(s.type()===H.Invalid)return;let e=this.it(s);if(e.type()===H.Invalid)throw Error("the objective is unbounded");let h=this.R.erase(e).second;h.solveForEx(e,s),this.U(s,h),this.R.insert(s,h),i++}throw Error("solver iterations exceeded")}Y(){let t=this.R,i=this.X;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.st(e.second);if(i.type()===H.Invalid)throw Error("dual optimize failed");let h=e.second;t.erase(s),h.solveForEx(s,i),this.U(i,h),t.insert(i,h)}}}tt(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first;if(0>s.second&&e.type()!==H.Dummy)return e}return N}st(t){let i=Number.MAX_VALUE,s=N,e=t.cells();for(let t=0,h=e.size();h>t;++t){let h=e.itemAt(t),r=h.first,n=h.second;if(n>0&&r.type()!==H.Dummy){let t=this.H.coefficientFor(r)/n;i>t&&(i=t,s=r)}}return s}it(t){let i=Number.MAX_VALUE,s=N,e=this.R;for(let h=0,r=e.size();r>h;++h){let r=e.itemAt(h),n=r.first;if(n.type()!==H.External){let e=r.second,h=e.coefficientFor(t);if(0>h){let t=-e.constant()/h;i>t&&(i=t,s=n)}}}return s}N(t){let i=Number.MAX_VALUE,s=i,e=i,h=N,r=h,n=h,o=h,a=this.R;for(let i=0,h=a.size();h>i;++i){let h=a.itemAt(i),c=h.second,l=c.coefficientFor(t);if(0===l)continue;let u=h.first;if(u.type()===H.External)o=u;else if(0>l){let t=-c.constant()/l;s>t&&(s=t,r=u)}else{let t=c.constant()/l;e>t&&(e=t,n=u)}}return r!==h?r:n!==h?n:o}j(t,i){i.marker.type()===H.Error&&this.et(i.marker,t.strength()),i.other.type()===H.Error&&this.et(i.other,t.strength())}et(t,i){let s=this.R.find(t);void 0!==s?this.H.insertRow(s.second,-i):this.H.insertSymbol(t,-i)}Z(t){let i=t.cells();for(let t=0,s=i.size();s>t;++t){let s=i.itemAt(t),e=s.first.type();if(e===H.Slack||e===H.Error)return s.first}return N}J(t){return new j(t,this.ht++)}B=(()=>T())();R=(()=>T())();q=(()=>T())();W=(()=>T())();X=[];H=new W;K=null;ht=0}function L(t){return 0>t?1e-8>-t:1e-8>t}var H;(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"})(H||(H={}));class j{constructor(t,i){this._=i,this.rt=t}id(){return this._}type(){return this.rt}_;rt}let N=new j(H.Invalid,-1);class W{constructor(t=0){this.T=t}cells(){return this.nt}constant(){return this.T}isConstant(){return this.nt.empty()}allDummies(){let t=this.nt;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==H.Dummy)return!1;return!0}copy(){let t=new W(this.T);return t.nt=this.nt.copy(),t}add(t){return this.T+=t}insertSymbol(t,i=1){L(this.nt.setDefault(t,()=>0).second+=i)&&this.nt.erase(t)}insertRow(t,i=1){this.T+=t.T*i;let s=t.nt;for(let t=0,e=s.size();e>t;++t){let e=s.itemAt(t);this.insertSymbol(e.first,e.second*i)}}removeSymbol(t){this.nt.erase(t)}reverseSign(){this.T=-this.T;let t=this.nt;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.nt,s=-1/i.erase(t).second;this.T*=s;for(let t=0,e=i.size();e>t;++t)i.itemAt(t).second*=s}solveForEx(t,i){this.insertSymbol(t,-1),this.solveFor(i)}coefficientFor(t){let i=this.nt.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.nt.erase(t);void 0!==s&&this.insertRow(i,s.second)}nt=T();T}var X;function Y(t){return null!==t&&Object.values(X).some(i=>i===t)}function q(t){return t??X.ALWAYS}(t=>{t[t.LANDSCAPE=0]="LANDSCAPE",t[t.PORTRAIT=1]="PORTRAIT",t[t.ALWAYS=2]="ALWAYS"})(X||(X={}));class G{constructor(t,i){this.layer=t,this.name="",this.layer.addUIConstraintInternal(this,i)}destroy(){this.layer.removeUIConstraintInternal(this)}}const J=1e3;var Q,K;function Z(t){return null!==t&&Object.values(Q).some(i=>i===t)}function tt(t){return t??Q.P0}function it(t){switch(t){case Q.P0:return D.create(J,J,J);case Q.P1:return D.create(100,0,0);case Q.P2:return D.create(10,0,0);case Q.P3:return D.create(0,100,0);case Q.P4:return D.create(0,10,0);case Q.P5:return D.create(0,0,100);case Q.P6:return D.create(0,0,10);case Q.P7:return D.create(0,0,1);default:return D.create(J,J,J)}}function st(t){return null!==t&&Object.values(K).some(i=>i===t)}function et(t){return t??K.EQUAL}function ht(t){switch(t){case K.EQUAL:return P.Eq;case K.LESS:return P.Le;case K.GREATER:return P.Ge;default:return P.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"})(Q||(Q={})),(t=>{t[t.EQUAL=2]="EQUAL",t[t.LESS=0]="LESS",t[t.GREATER=1]="GREATER"})(K||(K={}));class rt extends G{constructor(t,i={}){super(t.layer,new Set([t])),this.ot=t,this.ct={height:i.height??t.height,power:tt(i.power),rule:et(i.rule),orientation:q(i.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.lt=new $(new z(this.ot.heightInternal),ht(this.ct.rule),this.ct.height,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class nt{constructor(t,i,s=0){this.t=new WeakMap,this.i=new Map,void 0!==t&&(void 0===i?this.i.set(t,s):this.t.set(i,new Map([[t,s]])))}insert(t,i,s=0){if(void 0===i){if(this.i.has(t))return;return void this.i.set(t,s)}const e=this.t.get(i);void 0===e?this.t.set(i,new Map([[t,s]])):e.has(t)||e.set(t,s)}remove(t,i){if(void 0===i)return void this.i.delete(t);const s=this.t.get(i);void 0!==s&&(s.delete(t),0===s.size&&this.t.delete(i))}has(t,i){if(void 0===i)return this.i.has(t);const s=this.t.get(i);return void 0!==s&&s.has(t)}getPriority(t,i){if(void 0===i)return this.i.get(t);const s=this.t.get(i);return void 0!==s?s.get(t):void 0}}class ot{constructor(){this.o=new Map}on(t,i,s,e=0){return this.h(t,!1,e,i,s),this}once(t,i,s,e=0){return this.h(t,!0,e,i,s),this}off(t,i,s){const e=this.o.get(t);if(void 0===e)return this;e.u&&(e.u=!1,e.v=e.v.slice());const h=e.v;if(0===h.length)return this.o.delete(t),this;if(void 0===i){this.o.delete(t);for(let t=0;h.length>t;t++){const i=h[t];e.l.remove(i.ut,i.p)}return this}{const r=h.length;if(h[0].ut===i&&h[0].p===s)return 1===r?this.o.delete(t):h.shift(),this;const n=r-1;if(h[n].ut===i&&h[n].p===s)return h.pop(),this;if(10>r||h[0].M===h[n].M)for(let t=1;n>t;t++){const e=h[t];if(e.ut===i&&e.p===s)return h.splice(t,1),this}else{const t=e.l.getPriority(i,s);if(void 0===t)return this;let r=0,n=h.length-1;for(;n>=r;){const i=r+n>>>1;t>h[i].M?r=i+1:n=i-1}const o=r;for(n=h.length-1;n>=r;){const i=r+n>>>1;h[i].M>t?n=i-1:r=i+1}const a=n;for(let t=o;a>=t;t++)if(h[t].ut===i&&h[t].p===s)return h.splice(t,1),this}}return this}emit(t,...i){const s=this.o.get(t);if(void 0===s)return!1;if(0===s.v.length)return!1;s.u?s.v=s.v.slice():s.u=!0;const e=s.v;let h=!1;for(let t=0;e.length>t;t++){const s=e[t];s.ut.apply(s.p,i),s.k&&(h=!0,s.m=!0)}const r=this.o.get(t);if(void 0===r)return!0;r.v===e&&(r.u=!1);const n=r.v;if(h){let i=0;for(let t=0;n.length>t;t++){const s=n[t];s.m?r.l.remove(s.ut,s.p):n[i++]=s}0===i?this.o.delete(t):n.length=i}return!0}h(t,i,s,e,h){let r=this.o.get(t);if(void 0===r)return void this.o.set(t,{v:[{ut:e,p:h,M:s,k:i,m:!1}],u:!1,l:new nt(e,h,s)});if(r.l.has(e,h))throw Error("Event listener already exists");r.l.insert(e,h,s);const n={ut:e,p:h,M:s,k:i,m:!1};r.u&&(r.u=!1,r.v=r.v.slice());{const t=r.v,i=n.M;if(0===t.length||i>=t[t.length-1].M)return void t.push(n);if(t[0].M>=i)return void t.unshift(n);{let s=0,e=t.length;for(;e>s;){const h=s+e>>>1;i>t[h].M?s=h+1:e=h}t.splice(s,0,n)}}}}class at extends ot{constructor(i,s,e,h){super(),this.layer=i,this.object=h,this.xInternal=new V("x"),this.yInternal=new V("y"),this.needsRecalculationInternal=!1,this.name=t.generateUUID(),this.object&&(this.object.matrixAutoUpdate=!1),this.layer.addUIElementInternal(this,h),this.layer.addVariableInternal(this,this.xInternal,it(Q.P7)),this.layer.addVariableInternal(this,this.yInternal,it(Q.P7)),this.xInternal.setValue(s),this.yInternal.setValue(e),this.layer.suggestVariableInternal(this,this.xInternal,s),this.layer.suggestVariableInternal(this,this.yInternal,e)}get x(){return this.xInternal.value()}get y(){return this.yInternal.value()}get zIndex(){return this.object?.position.z??0}get needsRecalculation(){return this.needsRecalculationInternal}set x(t){this.layer.suggestVariableInternal(this,this.xInternal,t)}set y(t){this.layer.suggestVariableInternal(this,this.yInternal,t)}set zIndex(t){this.object&&this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer.sortInternal(),this.object.updateMatrix())}destroy(){this.layer.removeVariableInternal(this,this.yInternal),this.layer.removeVariableInternal(this,this.xInternal),this.layer.removeUIElementInternal(this)}renderInternal(t,i){this.render(t,i)}applyTransformations(){this.needsRecalculationInternal&&(this.object&&this.object.updateMatrix(),this.needsRecalculationInternal=!1)}}const ct=new i,lt=new s,ut=new e,dt=new e,ft=new e,wt=new e,gt=new e,pt=new h,vt=.5;class mt{constructor(){this.x=0,this.y=0,this.anchorX=vt,this.anchorY=vt,this.scaleX=1,this.scaleY=1,this.rotation=0,this.needsRecalculation=!1}}class bt{constructor(t,i){this.dt=t,this.ft=i}get x(){return this.dt.x}get y(){return this.dt.y}get anchorX(){return this.dt.anchorX}get anchorY(){return this.dt.anchorY}get scaleX(){return this.dt.scaleX}get scaleY(){return this.dt.scaleY}get angle(){return t.radToDeg(this.dt.rotation)}get rotation(){return this.dt.rotation}set x(t){t!==this.dt.x&&(this.dt.x=t,this.dt.needsRecalculation=!0)}set y(t){t!==this.dt.y&&(this.dt.y=t,this.dt.needsRecalculation=!0)}set anchorX(t){t!==this.dt.anchorX&&(this.dt.anchorX=t,this.dt.needsRecalculation=!0)}set anchorY(t){t!==this.dt.anchorY&&(this.dt.anchorY=t,this.dt.needsRecalculation=!0)}set scaleX(t){t!==this.dt.scaleX&&(this.dt.scaleX=t,this.dt.needsRecalculation=!0)}set scaleY(t){t!==this.dt.scaleY&&(this.dt.scaleY=t,this.dt.needsRecalculation=!0)}set angle(i){const s=t.degToRad(i);s!==this.dt.rotation&&(this.dt.rotation=s,this.dt.needsRecalculation=!0)}set rotation(t){t!==this.dt.rotation&&(this.dt.rotation=t,this.dt.needsRecalculation=!0)}setAnchorByGlobalPosition(t,i){const s=(t-this.ft.x)/this.ft.width,e=(i-this.ft.y)/this.ft.height;s===this.dt.anchorX&&e===this.dt.anchorY||(this.dt.anchorX=s,this.dt.anchorY=e,this.dt.needsRecalculation=!0)}reset(){0===this.dt.x&&0===this.dt.y&&this.dt.anchorX===vt&&this.dt.anchorY===vt&&1===this.dt.scaleX&&1===this.dt.scaleY&&0===this.dt.rotation||(this.dt.x=0,this.dt.y=0,this.dt.anchorX=vt,this.dt.anchorY=vt,this.dt.scaleX=1,this.dt.scaleY=1,this.dt.rotation=0,this.dt.needsRecalculation=!0)}}var yt,Ct;(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE"})(yt||(yt={})),(t=>{t[t.NORMAL=0]="NORMAL",t[t.ADDITIVE=1]="ADDITIVE",t[t.SUBTRACTIVE=2]="SUBTRACTIVE",t[t.MULTIPLY=3]="MULTIPLY",t[t.SCREEN=4]="SCREEN"})(Ct||(Ct={}));class xt extends r{constructor(t){super({uniforms:{map:{value:t},opacity:{value:1},color:{value:new n(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:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}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=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setBlending(t){switch(this.premultipliedAlpha=!1,this.blendEquation=o,this.blendSrc=a,this.blendDst=c,t){case Ct.ADDITIVE:this.blending=p;break;case Ct.SUBTRACTIVE:this.blending=g;break;case Ct.MULTIPLY:this.blending=w,this.premultipliedAlpha=!0;break;case Ct.SCREEN:this.blending=u,this.blendEquation=o,this.blendSrc=d,this.blendDst=f;break;default:this.blending=l}this.needsUpdate=!0}}const Et=new v(1,1).translate(.5,.5,0),_t=new m,It=new b(Et);_t.add(It);class kt{constructor(t=0,i=0){this.wt=t,this.gt=i,this.vt=new y(-1,1,1,-1,0,1),this.bt()}get paddingHorizontal(){return this.wt}get paddingVertical(){return this.gt}set paddingHorizontal(t){this.wt!==t&&(this.wt=t,this.bt())}set paddingVertical(t){this.gt!==t&&(this.gt=t,this.bt())}render(t,i){It.material=i,t.render(_t,this.vt)}bt(){this.vt.left=-this.wt,this.vt.right=1+this.wt,this.vt.bottom=-this.gt,this.vt.top=1+this.gt,this.vt.updateProjectionMatrix()}}class Mt{constructor(){this.passes=[],this.yt=new xt,this.Ct=new kt,this.xt=!1,this.Et=!1,this._t=0;const t={format:_,minFilter:E,magFilter:E,type:x,depthBuffer:!1,stencilBuffer:!1};this.It=new C(1,1,t),this.kt=new C(1,1,t),this.It.texture.generateMipmaps=!1,this.kt.texture.generateMipmaps=!1}get needsUpdate(){return this.xt&&this.Mt()||this.St()}get paddingHasChanged(){return this.Et}get padding(){return this._t}requestUpdate(){this.xt=!0}compose(t,i,s,e,h=!0){const r=this.Mt();if(!(this.xt&&r||this.St()))return r||(this.Et=0!==this._t,this._t=0),this.xt=!1,r?this.yt:e;const n=this.Ot();this.Et=this._t!==n,this._t=n;const o=i+2*n,a=s+2*n;this.It.setSize(o,a),this.kt.setSize(o,a),this.Tt(i,s,n),t.setClearColor(0,0),t.setRenderTarget(this.kt),t.clear(!0,!1,!1);const c=e.blending;h&&(e.blending=I),this.Ct.render(t,e),e.blending=c;const l={width:i,height:s,padding:n};for(const i of this.passes)(i.needsUpdate||i.isValuable)&&(this.Ft(),t.setRenderTarget(this.kt),t.clear(!0,!1,!1),i.render(t,this.It.texture,l));return this.xt=!1,this.yt.setTexture(this.kt.texture),this.yt}destroy(){this.It.dispose(),this.kt.dispose()}Mt(){return this.passes.some(t=>t.isValuable)}St(){return this.passes.some(t=>t.needsUpdate)}Ot(){return this.passes.reduce((t,i)=>Math.max(t,i.padding),0)}Tt(t,i,s){this.Ct.paddingHorizontal=s/t,this.Ct.paddingVertical=s/i}Ft(){const t=this.It;this.It=this.kt,this.kt=t}}class St{constructor(t){this.dt=t}get passes(){return this.dt.passes}}var Ot;(t=>{t.CLICK="click"})(Ot||(Ot={}));class Tt extends ot{constructor(i,s,e,h,r,n){super(),this.layer=i,this.object=s,this.xInternal=new V("x"),this.yInternal=new V("y"),this.widthInternal=new V("width"),this.heightInternal=new V("height"),this.needsRecalculationInternal=!1,this.name=t.generateUUID(),this.microInternal=new mt,this.composerInternal=new Mt,this.modeInternal=yt.VISIBLE,this.micro=new bt(this.microInternal,this),this.composer=new St(this.composerInternal),this.object.matrixAutoUpdate=!1,this.layer.addUIElementInternal(this,this.object),this.layer.addVariableInternal(this,this.xInternal,it(Q.P7)),this.layer.addVariableInternal(this,this.yInternal,it(Q.P7)),this.layer.addVariableInternal(this,this.widthInternal,it(Q.P5)),this.layer.addVariableInternal(this,this.heightInternal,it(Q.P5)),this.xInternal.setValue(e),this.yInternal.setValue(h),this.widthInternal.setValue(r),this.heightInternal.setValue(n),this.layer.suggestVariableInternal(this,this.xInternal,e),this.layer.suggestVariableInternal(this,this.yInternal,h),this.layer.suggestVariableInternal(this,this.widthInternal,r),this.layer.suggestVariableInternal(this,this.heightInternal,n)}get x(){return this.xInternal.value()}get y(){return this.yInternal.value()}get width(){return this.widthInternal.value()}get height(){return this.heightInternal.value()}get zIndex(){return this.object.position.z}get mode(){return this.modeInternal}get needsRecalculation(){return this.needsRecalculationInternal}set x(t){this.layer.suggestVariableInternal(this,this.xInternal,t)}set y(t){this.layer.suggestVariableInternal(this,this.yInternal,t)}set width(t){this.layer.suggestVariableInternal(this,this.widthInternal,t)}set height(t){this.layer.suggestVariableInternal(this,this.heightInternal,t)}set zIndex(t){this.object.renderOrder!==t&&(this.object.position.z=t,this.object.renderOrder=t,this.layer.sortInternal(),this.object.updateMatrix())}set mode(t){this.modeInternal=t,this.object.visible=t!==yt.HIDDEN}destroy(){this.composerInternal.destroy(),this.layer.removeVariableInternal(this,this.heightInternal),this.layer.removeVariableInternal(this,this.widthInternal),this.layer.removeVariableInternal(this,this.yInternal),this.layer.removeVariableInternal(this,this.xInternal),this.layer.removeUIElementInternal(this)}renderInternal(t,i){this.render(t,i)}clickInternal(t,i){return this.click(t,i)}applyTransformations(){(this.needsRecalculationInternal||this.microInternal.needsRecalculation||this.composerInternal.paddingHasChanged)&&(((t,i,s,e,h,r,n)=>{const o=this.x-n,a=this.y-n,c=this.width+2*n,l=this.height+2*n,u=o+c*i.anchorX,d=a+l*i.anchorY,f=ut.set(1,0,-u,0,1,-d,0,0,1),w=dt.set(i.scaleX,0,0,0,i.scaleY,0,0,0,1),g=ft.set(Math.cos(i.rotation),-Math.sin(i.rotation),0,Math.sin(i.rotation),Math.cos(i.rotation),0,0,0,1),p=wt.set(1,0,i.x+u,0,1,i.y+d,0,0,1),v=gt.multiplyMatrices(p,g).multiply(w).multiply(f),m=pt.set(o,a,1).applyMatrix3(v);t.position.x=m.x,t.position.y=m.y,t.rotation.z=i.rotation,t.scale.x=c*i.scaleX,t.scale.y=l*i.scaleY})(this.object,this.microInternal,0,0,0,0,this.composerInternal.padding),this.object.updateMatrix(),this.needsRecalculationInternal=!1,this.microInternal.needsRecalculation=!1)}click(t,i){return this.mode===yt.INTERACTIVE&&(this.applyTransformations(),s=this.x,e=this.y,h=this.width,r=this.height,ct.set(t,i),lt.min.set(s,e),lt.max.set(h,r).add(lt.min),!!lt.containsPoint(ct)&&(this.emit(Ot.CLICK,this),!0));var s,e,h,r}}const Ft=new n(0);var At,Vt,Bt;(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.CLICK="click"})(At||(At={}));class zt extends ot{constructor(){super(...arguments),this.mode=yt.VISIBLE,this.xInternal=new V,this.yInternal=new V,this.widthInternal=new V,this.heightInternal=new V,this.scene=new m,this.camera=new y,this.solver=new R,this.elements=new Map,this.constraints=new Map,this.orientationPrivate=X.PORTRAIT,this.needsRecalculation=!1}get orientation(){return this.orientationPrivate}get width(){return this.widthInternal.value()}get height(){return this.heightInternal.value()}destroy(){this.solver=void 0;for(const t of this.constraints.keys())t.destroy();for(const t of this.elements.keys())t.destroy()}addUIElementInternal(t,i,s){if(this.elements.has(t))throw Error("Element already added");if(this.elements.set(t,{object:i,variables:new Map,constraints:new Set}),i){const t=s??this.scene.children.length;i.position.z=t,i.renderOrder=t,this.scene.add(i),this.sortInternal()}}removeUIElementInternal(t){const i=this.elements.get(t);if(void 0===i)throw Error("Element not found");if(i.variables.size>0)throw Error("Variables should be removed before removing element");if(i.constraints.size>0)throw Error("Constraints should be removed before removing element");this.elements.delete(t),i.object&&this.scene.remove(i.object)}addUIConstraintInternal(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})}removeUIConstraintInternal(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)}addConstraintInternal(t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before adding constraint you need to add it's owner");if(s.constraints.has(i))throw Error("Constraint already exists");s.constraints.add(i);try{this.solver?.addConstraint(i)}catch{this.At()}this.needsRecalculation=!0}removeConstraintInternal(t,i){const s=this.constraints.get(t);if(void 0===s)throw Error("Before removing constraint you need to add it's owner");if(!s.constraints.has(i))throw Error("Constraint not found");s.constraints.delete(i);try{this.solver?.removeConstraint(i)}catch{this.At()}this.needsRecalculation=!0}addVariableInternal(t,i,s){const e=t instanceof Tt||t instanceof at?this.elements.get(t):this.constraints.get(t);if(void 0===e)throw Error("Before adding variable you need to add it's owner");if(e.variables.has(i))throw Error("Variable already exists");e.variables.set(i,{strength:s,suggestedValue:i.value()});try{this.solver?.addEditVariable(i,s)}catch{this.At()}this.needsRecalculation=!0}removeVariableInternal(t,i){const s=t instanceof Tt||t instanceof at?this.elements.get(t):this.constraints.get(t);if(void 0===s)throw Error("Before removing variable you need to add it's owner");if(!s.variables.has(i))throw Error("Variable does not exist");s.variables.delete(i);try{this.solver?.removeEditVariable(i)}catch{this.At()}this.needsRecalculation=!0}suggestVariableInternal(t,i,s){const e=t instanceof Tt||t instanceof at?this.elements.get(t):this.constraints.get(t);if(void 0===e)throw Error("Before suggesting variable you need to add it's owner");const h=e.variables.get(i);if(!h)throw Error("Variable does not exist");if(h.suggestedValue!==s){h.suggestedValue=s;try{this.solver?.suggestValue(i,s)}catch{this.At()}this.needsRecalculation=!0}}sortInternal(){this.scene.children.sort((t,i)=>t.position.z-i.position.z);for(let t=0;this.scene.children.length>t;t++){const i=this.scene.children[t];i.position.z=t,i.renderOrder=t}this.camera.position.set(0,0,this.scene.children.length+1),this.camera.near=1,this.camera.far=this.scene.children.length+1+1,this.camera.updateProjectionMatrix(),this.camera.updateMatrix()}render(t,i){if(this.mode===yt.HIDDEN)return;const s=t.getRenderTarget(),e=t.getClearColor(Ft),h=t.getClearAlpha();if(this.needsRecalculation){this.needsRecalculation=!1,this.solver?.updateVariables();for(const t of this.elements.keys())t.needsRecalculationInternal=!0}for(const s of this.elements.keys())s.renderInternal(t,i);t.setRenderTarget(s),t.setClearColor(e),t.setClearAlpha(h),t.render(this.scene,this.camera)}clickInternal(t,i){if(this.mode!==yt.INTERACTIVE)return;this.emit(At.CLICK,this,t,i);const s=[...this.elements.keys()].filter(t=>t instanceof Tt).filter(t=>t.mode===yt.INTERACTIVE).sort((t,i)=>t.zIndex-i.zIndex);for(const e of s)if(e.clickInternal(t,i))break}resizeInternal(t,i){this.applyCameraSize(t,i),this.rebuildLayerConstraints(t,i),this.updateOrientation(t,i),this.needsRecalculation=!0}applyCameraSize(t,i){this.camera.bottom=0,this.camera.left=0,this.camera.right=t,this.camera.top=i,this.camera.updateProjectionMatrix()}rebuildLayerConstraints(t,i){this.constraintX&&(this.solver?.removeConstraint(this.constraintX),this.constraintX=void 0),this.constraintY&&(this.solver?.removeConstraint(this.constraintY),this.constraintY=void 0),this.constraintW&&(this.solver?.removeConstraint(this.constraintW),this.constraintW=void 0),this.constraintH&&(this.solver?.removeConstraint(this.constraintH),this.constraintH=void 0),this.constraintX=new $(new z(this.xInternal),P.Eq,0,D.required),this.constraintY=new $(new z(this.yInternal),P.Eq,0,D.required),this.constraintW=new $(new z(this.widthInternal),P.Eq,t,D.required),this.constraintH=new $(new z(this.heightInternal),P.Eq,i,D.required),this.solver?.addConstraint(this.constraintX),this.solver?.addConstraint(this.constraintY),this.solver?.addConstraint(this.constraintW),this.solver?.addConstraint(this.constraintH)}updateOrientation(t,i){const s=this.orientationPrivate;if(this.orientationPrivate=t>i?X.LANDSCAPE:X.PORTRAIT,s!==this.orientationPrivate){this.solver=void 0;for(const t of this.constraints.keys())t.enableConstraintInternal(this.orientationPrivate);for(const t of this.constraints.keys())t.disableConstraintInternal(this.orientationPrivate);this.solver=new R;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(At.ORIENTATION_CHANGED,this,this.orientation)}}At(){try{this.solver=void 0,this.solver=new R;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)}catch(t){throw t}}}function Dt(t,i){if((t instanceof zt?t:t.layer)!==i.layer)throw Error(`Elements must be on the same layer - element "${i.constructor.name}" cannot interact with elements from a different layer`)}function Pt(t,i,s){if(0>=t||0>=i)throw Error(s??`Invalid dimensions: width (${t}) and height (${i}) must both be positive numbers greater than 0`)}class $t extends G{constructor(t,i,s={}){Dt(t,i),super(i.layer,new Set(t instanceof Tt||t instanceof at?[t,i]:[i])),this.Vt=t,this.Bt=i,this.ct={anchorOne:s.anchorOne??.5,anchorTwo:s.anchorTwo??.5,distance:s.distance??0,power:tt(s.power),rule:et(s.rule),orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Vt instanceof Tt||this.Vt instanceof zt?new z(this.Vt.xInternal).plus(new z(this.Vt.widthInternal).multiply(this.ct.anchorOne)):new z(this.Vt.xInternal),i=this.Bt instanceof Tt?new z(this.Bt.xInternal).plus(new z(this.Bt.widthInternal).multiply(this.ct.anchorTwo)):new z(this.Bt.xInternal);this.lt=new $(i.minus(t),ht(this.ct.rule),this.ct.distance,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class Ut extends G{constructor(t,i,s={}){Dt(t,i),super(i.layer,new Set(t instanceof Tt?[t,i]:[i])),this.Vt=t,this.Bt=i,this.ct={proportion:s.proportion??1,power:tt(s.power),rule:et(s.rule),orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){const t=new z(this.Vt.widthInternal).multiply(this.ct.proportion),i=new z(this.Bt.widthInternal);this.lt=new $(t.minus(i),ht(this.ct.rule),0,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class Rt extends G{constructor(t,i,s={}){Dt(t,i),super(i.layer,new Set(t instanceof Tt||t instanceof at?[t,i]:[i])),this.Vt=t,this.Bt=i,this.ct={anchorOne:s.anchorOne??.5,anchorTwo:s.anchorTwo??.5,distance:s.distance??0,power:tt(s.power),rule:et(s.rule),orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){const t=this.Vt instanceof Tt||this.Vt instanceof zt?new z(this.Vt.yInternal).plus(new z(this.Vt.heightInternal).multiply(this.ct.anchorOne)):new z(this.Vt.yInternal),i=this.Bt instanceof Tt?new z(this.Bt.yInternal).plus(new z(this.Bt.heightInternal).multiply(this.ct.anchorTwo)):new z(this.Bt.yInternal);this.lt=new $(i.minus(t),ht(this.ct.rule),this.ct.distance,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class Lt extends G{constructor(t,i,s={}){Dt(t,i),super(i.layer,new Set(t instanceof Tt?[t,i]:[i])),this.Vt=t,this.Bt=i,this.ct={proportion:s.proportion??1,power:tt(s.power),rule:et(s.rule),orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){const t=new z(this.Vt.heightInternal).multiply(this.ct.proportion),i=new z(this.Bt.heightInternal);this.lt=new $(t.minus(i),ht(this.ct.rule),0,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class Ht extends G{constructor(t,i={}){super(t.layer,new Set([t])),this.ot=t,this.ct={width:i.width??t.width,power:tt(i.power),rule:et(i.rule),orientation:q(i.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.lt=new $(new z(this.ot.widthInternal),ht(this.ct.rule),this.ct.width,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class jt{static size(t,i={}){return{x:new Ht(t,{width:i.size?.h,power:i.power?.h,rule:i.rule?.h,orientation:i.orientation?.h}),y:new rt(t,{height:i.size?.v,power:i.power?.v,rule:i.rule?.v,orientation:i.orientation?.v})}}static distance(t,i,s={}){return{x:new $t(t,i,{anchorOne:s.anchorOne?.h,anchorTwo:s.anchorTwo?.h,distance:s.distance?.h,power:s.power?.h,rule:s.rule?.h,orientation:s.orientation?.h}),y:new Rt(t,i,{anchorOne:s.anchorOne?.v,anchorTwo:s.anchorTwo?.v,distance:s.distance?.v,power:s.power?.v,rule:s.rule?.v,orientation:s.orientation?.v})}}static proportion(t,i,s={}){return{x:new Ut(t,i,{proportion:s.proportion?.h,power:s.power?.h,rule:s.rule?.h,orientation:s.orientation?.h}),y:new Lt(t,i,{proportion:s.proportion?.v,power:s.power?.v,rule:s.rule?.v,orientation:s.orientation?.v})}}}(t=>{t[t.FROM_LEFT_TOP=0]="FROM_LEFT_TOP",t[t.FROM_LEFT_BOTTOM=1]="FROM_LEFT_BOTTOM"})(Vt||(Vt={}));class Nt{static build(t,i,s,e={}){const h=e.direction??Vt.FROM_LEFT_TOP,r=[],n=[];r.push(new $t(t,i,{anchorOne:0,anchorTwo:0,distance:0,power:e.power,orientation:e.orientation}),new $t(t,s,{anchorOne:1,anchorTwo:1,distance:0,power:e.power,orientation:e.orientation}));const o=h===Vt.FROM_LEFT_TOP?1:0,a=h===Vt.FROM_LEFT_TOP?0:1;return n.push(new Rt(t,i,{anchorOne:o,anchorTwo:o,distance:0,power:e.power,orientation:e.orientation}),new Rt(t,s,{anchorOne:a,anchorTwo:a,distance:0,power:e.power,orientation:e.orientation})),{horizontalDistances:r,verticalDistances:n}}}class Wt{static buildHorizontal(t,i){return this.buildStack(t,i,{distanceConstraint:$t,proportionConstraint:Ut,centerDistanceConstraint:Rt})}static buildVertical(t,i){return this.buildStack(t,i,{distanceConstraint:Rt,proportionConstraint:Lt,centerDistanceConstraint:$t})}static buildStack(t,i,s){const e=[],h=[],r=[];for(let n=0;t.length-1>n;n++){const o=t[n],a=t[n+1];e.push(new s.distanceConstraint(o,a,{anchorOne:1,anchorTwo:0,distance:i.distance,power:i.power,orientation:i.orientation})),!1!==i.keepProportions&&h.push(new s.proportionConstraint(o,a,{power:i.power,orientation:i.orientation})),!1!==i.keepAlignment&&r.push(new s.centerDistanceConstraint(o,a,{power:i.power,anchorOne:0,anchorTwo:0,orientation:i.orientation}))}return{distanceConstraints:e,proportionConstraints:h,alignmentConstraints:r}}}class Xt extends G{constructor(t,i={}){super(t.layer,new Set([t])),this.ot=t,this.ct={aspect:i.aspect??this.ot.width/this.ot.height,power:tt(i.power),rule:et(i.rule),orientation:q(i.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){const t=new z(this.ot.widthInternal).plus(new z(this.ot.heightInternal).multiply(-this.ct.aspect));this.lt=new $(t,ht(this.ct.rule),0,it(this.ct.power)),this.layer.addConstraintInternal(this,this.lt)}destroyConstraints(){this.lt&&(this.layer.removeConstraintInternal(this,this.lt),this.lt=void 0)}}class Yt extends G{constructor(t,i,s={}){Dt(t,i),super(i.layer,new Set(t instanceof Tt?[t,i]:[i])),this.Vt=t,this.Bt=i,this.ct={isStrict:s.isStrict??!0,horizontalAnchor:s.horizontalAnchor??.5,verticalAnchor:s.verticalAnchor??.5,orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.zt=new $(new z(this.Vt.xInternal).plus(new z(this.Vt.widthInternal).multiply(this.ct.horizontalAnchor)),P.Eq,new z(this.Bt.xInternal).plus(new z(this.Bt.widthInternal).multiply(this.ct.horizontalAnchor))),this.Dt=new $(new z(this.Vt.yInternal).plus(new z(this.Vt.heightInternal).multiply(this.ct.verticalAnchor)),P.Eq,new z(this.Bt.yInternal).plus(new z(this.Bt.heightInternal).multiply(this.ct.verticalAnchor))),this.Pt=new $(new z(this.Vt.widthInternal),P.Eq,new z(this.Bt.widthInternal)),this.$t=new $(new z(this.Vt.heightInternal),P.Eq,new z(this.Bt.heightInternal)),this.layer.addConstraintInternal(this,this.zt),this.layer.addConstraintInternal(this,this.Dt),this.layer.addConstraintInternal(this,this.Pt),this.layer.addConstraintInternal(this,this.$t),this.ct.isStrict||(this.Ut=new $(new z(this.Vt.heightInternal),P.Eq,new z(this.Bt.heightInternal)),this.layer.addConstraintInternal(this,this.Ut))}destroyConstraints(){this.zt&&(this.layer.removeConstraintInternal(this,this.zt),this.zt=void 0),this.Dt&&(this.layer.removeConstraintInternal(this,this.Dt),this.Dt=void 0),this.Pt&&(this.layer.removeConstraintInternal(this,this.Pt),this.Pt=void 0),this.$t&&(this.layer.removeConstraintInternal(this,this.$t),this.$t=void 0),this.Ut&&(this.layer.removeConstraintInternal(this,this.Ut),this.Ut=void 0)}}class qt extends G{constructor(t,i,s={}){super(i.layer,new Set(t instanceof Tt?[t,i]:[i])),this.Vt=t,this.Bt=i,Dt(t,i),this.ct={isStrict:s.isStrict??!0,horizontalAnchor:s.horizontalAnchor??.5,verticalAnchor:s.verticalAnchor??.5,orientation:q(s.orientation)},this.ct.orientation!==X.ALWAYS&&this.ct.orientation!==this.layer.orientation||this.buildConstraints()}destroy(){this.destroyConstraints(),super.destroy()}disableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t!==this.ct.orientation&&this.destroyConstraints()}enableConstraintInternal(t){this.ct.orientation!==X.ALWAYS&&t===this.ct.orientation&&this.buildConstraints()}buildConstraints(){this.zt=new $(new z(this.Vt.xInternal).plus(new z(this.Vt.widthInternal).multiply(this.ct.horizontalAnchor)),P.Eq,new z(this.Bt.xInternal).plus(new z(this.Bt.widthInternal).multiply(this.ct.horizontalAnchor))),this.Dt=new $(new z(this.Vt.yInternal).plus(new z(this.Vt.heightInternal).multiply(this.ct.verticalAnchor)),P.Eq,new z(this.Bt.yInternal).plus(new z(this.Bt.heightInternal).multiply(this.ct.verticalAnchor))),this.Pt=new $(new z(this.Vt.widthInternal),P.Ge,new z(this.Bt.widthInternal)),this.$t=new $(new z(this.Vt.heightInternal),P.Ge,new z(this.Bt.heightInternal)),this.layer.addConstraintInternal(this,this.zt),this.layer.addConstraintInternal(this,this.Dt),this.layer.addConstraintInternal(this,this.Pt),this.layer.addConstraintInternal(this,this.$t),this.ct.isStrict&&(this.Ut=new $(new z(this.Vt.heightInternal),P.Eq,new z(this.Bt.heightInternal),D.strong),this.layer.addConstraintInternal(this,this.Ut))}destroyConstraints(){this.zt&&(this.layer.removeConstraintInternal(this,this.zt),this.zt=void 0),this.Dt&&(this.layer.removeConstraintInternal(this,this.Dt),this.Dt=void 0),this.Pt&&(this.layer.removeConstraintInternal(this,this.Pt),this.Pt=void 0),this.$t&&(this.layer.removeConstraintInternal(this,this.$t),this.$t=void 0),this.Ut&&(this.layer.removeConstraintInternal(this,this.Ut),this.Ut=void 0)}}class Gt extends Tt{constructor(t,i=100,s=100){super(t,new k,0,0,i,s),this.applyTransformations()}render(){this.applyTransformations()}}class Jt extends Tt{constructor(t,i){const s=i.image?.width,e=i.image?.height;Pt(s,e,`Invalid image dimensions - texture "${i.name||"unnamed"}" has invalid width (${s}) or height (${e}). Image dimensions must be non-zero positive numbers.`);const h=new xt(i);super(t,new b(Et,h),0,0,s,e),this.Rt=Ct.NORMAL,this.Lt=h,this.Ht=i,this.applyTransformations()}get texture(){return this.Ht}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get blending(){return this.Rt}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set blending(t){this.Rt=t,this.Lt.setBlending(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.Ht.image.width,this.Ht.image.height,this.Lt),this.applyTransformations()}}class Qt extends r{constructor(t,i){super({uniforms:M.merge([{background:{value:i},foreground:{value:t},progress:{value:1},backgroundColor:{value:new n(1,1,1)},foregroundColor:{value:new n(1,1,1)},color:{value:new n(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:!0,lights:!1,fog:!1,depthWrite:!1,depthTest:!1})}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=!0}setBackgroundTexture(t){this.uniforms.background.value=t,this.uniformsNeedUpdate=!0}setForegroundTexture(t){this.uniforms.foreground.value=t,this.uniformsNeedUpdate=!0}setBackgroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setForegroundColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setColor(t){this.uniforms.color.value.setHex(t),this.uniformsNeedUpdate=!0}setBackgroundOpacity(t){this.uniforms.backgroundOpacity.value=t,this.uniformsNeedUpdate=!0}setForegroundOpacity(t){this.uniforms.foregroundOpacity.value=t,this.uniformsNeedUpdate=!0}setOpacity(t){this.uniforms.opacity.value=t,this.uniformsNeedUpdate=!0}setAngle(t){this.uniforms.angle.value=t,this.uniformsNeedUpdate=!0}setIsForwardDirection(t){this.uniforms.direction.value=t?1:-1,this.uniformsNeedUpdate=!0}}class Kt extends Tt{constructor(i,s,e={}){const h=s.image?.width,r=s.image?.height;Pt(h,r,`Invalid image dimensions - texture "${s.name||"unnamed"}" has invalid width (${h}) or height (${r}). Image dimensions must be non-zero positive numbers.`);const n=e.textureBackground?.image?.width,o=e.textureBackground?.image?.height;e.textureBackground&&Pt(n,o,`Invalid image dimensions - texture "${e.textureBackground.name||"unnamed"}" has invalid width (${n}) or height (${o}). Image dimensions must be non-zero positive numbers.`);const a=new Qt(s,e.textureBackground),c=new b(Et,a);e.progress&&a.setProgress(e.progress),e.isForegroundDirection&&a.setIsForwardDirection(e.isForegroundDirection),e.angle&&a.setAngle(t.degToRad(e.angle)),e.color&&a.setColor(e.color),e.opacity&&a.setOpacity(e.opacity),e.backgroundColor&&a.setBackgroundColor(e.backgroundColor),e.foregroundColor&&a.setForegroundColor(e.foregroundColor),e.backgroundOpacity&&a.setBackgroundOpacity(e.backgroundOpacity),e.foregroundOpacity&&a.setForegroundOpacity(e.foregroundOpacity);const l=n??h,u=r??o;super(i,c,0,0,l,u),this.Lt=a,this.jt=l,this.Nt=u,this.applyTransformations()}get progress(){return this.Lt.getProgress()}get backgroundTexture(){return this.Lt.getBackgroundTexture()}get foregroundTexture(){return this.Lt.getForegroundTexture()}get backgroundColor(){return this.Lt.getBackgroundColor()}get foregroundColor(){return this.Lt.getForegroundColor()}get color(){return this.Lt.getColor()}get backgroundOpacity(){return this.Lt.getBackgroundOpacity()}get foregroundOpacity(){return this.Lt.getForegroundOpacity()}get opacity(){return this.Lt.getOpacity()}get angle(){return t.radToDeg(this.Lt.getAngle())}get isForwardDirection(){return this.Lt.getIsForwardDirection()}set progress(t){this.Lt.setProgress(t),this.composerInternal.requestUpdate()}set backgroundColor(t){this.Lt.setBackgroundColor(t),this.composerInternal.requestUpdate()}set foregroundColor(t){this.Lt.setForegroundColor(t),this.composerInternal.requestUpdate()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set backgroundOpacity(t){this.Lt.setBackgroundOpacity(t),this.composerInternal.requestUpdate()}set foregroundOpacity(t){this.Lt.setForegroundOpacity(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set angle(i){this.Lt.setAngle(t.degToRad(i)),this.composerInternal.requestUpdate()}set isForwardDirection(t){this.Lt.setIsForwardDirection(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),super.destroy()}render(t){this.object.material=this.composerInternal.compose(t,this.jt,this.Nt,this.Lt),this.applyTransformations()}}(t=>{t.ALWAYS="always",t.PROPERTY_CHANGED="property_changed",t.MANUAL="manual"})(Bt||(Bt={}));const Zt=Bt.PROPERTY_CHANGED;class ti extends Tt{constructor(t,i={}){const s=i.resolutionFactor??.5;if(.1>s||s>8)throw Error(`Invalid resolution factor: ${s}. Must be between 0.1 and 8.`);const e=i.width??512,h=i.height??512;Pt(e,h,`Invalid width or height: ${e}x${h}. Must be positive.`);const r=new C(e*s,h*s,{format:_,minFilter:E,magFilter:E,type:x,depthBuffer:i.useDepth??!0,stencilBuffer:!1}),n=new xt(r.texture);super(t,new b(Et,n),0,0,e,h),this.Wt=!1,this.Xt=i.scene??new m,this.Yt=i.camera??new S(75,e/h,.1,100),this.qt=s,this.Gt=i.updateBehavior??Zt,i.renderedByDefault&&(this.Wt=!0),this.Jt=i.clearColor??0,this.Qt=i.clearAlpha??0,this.Kt=r,this.Lt=n,this.applyTransformations()}get needsRender(){return this.Wt}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}get scene(){return this.Xt}get camera(){return this.Yt}get clearColor(){return this.Jt}get clearAlpha(){return this.Qt}get resolutionFactor(){return this.qt}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}set scene(t){this.Xt!==t&&(this.Xt=t,this.Gt===Bt.PROPERTY_CHANGED&&this.requestRender())}set camera(t){this.Yt!==t&&(this.Yt=t,this.Gt===Bt.PROPERTY_CHANGED&&this.requestRender())}set clearColor(t){this.Jt!==t&&(this.Jt=t,this.Gt===Bt.PROPERTY_CHANGED&&this.requestRender())}set clearAlpha(t){this.Qt!==t&&(this.Qt=t,this.Gt===Bt.PROPERTY_CHANGED&&this.requestRender())}set resolutionFactor(t){this.qt!==t&&(this.qt=t,this.Kt.setSize(this.width*this.qt,this.height*this.qt),this.Gt===Bt.PROPERTY_CHANGED&&this.requestRender())}destroy(){this.Lt.dispose(),this.Kt.dispose(),super.destroy()}requestRender(){this.Wt=!0,this.composerInternal.requestUpdate()}render(t){(this.Wt||this.Gt===Bt.ALWAYS)&&(this.Wt=!1,this.Kt.setSize(this.width*this.qt,this.height*this.qt),t.setClearColor(this.Jt,this.clearAlpha),t.setRenderTarget(this.Kt),t.clear(!0,!0,!1),t.render(this.Xt,this.Yt)),this.object.material=this.composerInternal.compose(t,this.width*this.qt,this.height*this.qt,this.Lt),this.applyTransformations()}}function ii(t,i){const s=Math.max(t?.fontSize??i?.fontSize??16,1),e=t?.lineHeight??i?.lineHeight??1.2*s,h=Math.max(t?.shadowBlur??i?.shadowBlur??0,0),r=Math.max(t?.strokeWidth??i?.strokeWidth??0,0);return{color:t?.color??i?.color??"#000000",fontFamily:t?.fontFamily??i?.fontFamily??"Arial",fontSize:s,fontStyle:t?.fontStyle??i?.fontStyle??"normal",fontWeight:t?.fontWeight??i?.fontWeight??"normal",lineHeight:e,enableShadow:t?.enableShadow??i?.enableShadow??!1,shadowOffsetX:t?.shadowOffsetX??i?.shadowOffsetX??0,shadowOffsetY:t?.shadowOffsetY??i?.shadowOffsetY??0,shadowBlur:h,shadowColor:t?.shadowColor??i?.shadowColor??"transparent",enableStroke:t?.enableStroke??i?.enableStroke??!1,strokeColor:t?.strokeColor??i?.strokeColor??"transparent",strokeWidth:r}}function si(t){return t.match(/\S+|\s|\n/g)??[]}function ei(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 e=t.measureText(i),h=e.width,r=Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent);return{width:Math.ceil(h),height:r,baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function hi(t,i,s,e,h){h.font=`${e.fontStyle} ${e.fontWeight} ${e.fontSize}px ${e.fontFamily}`,e.enableShadow&&(h.shadowOffsetX=e.shadowOffsetX,h.shadowOffsetY=e.shadowOffsetY,h.shadowBlur=e.shadowBlur,h.shadowColor=e.shadowColor),e.enableStroke&&(h.strokeStyle=e.strokeColor,h.lineWidth=e.strokeWidth,h.strokeText(s,t,i)),h.fillStyle=e.color,h.fillText(s,t,i)}class ri extends Tt{constructor(t,i,s={}){const e=document.createElement("canvas"),h=e.getContext("2d");if(!h)throw Error("Failed to create canvas context");const r=[],n=Array.isArray(i)?i:[i];for(const t of n){const i="string"==typeof t,e=i?t:t.text,n=ii(i?void 0:t.style,s.defaultStyle);for(const t of si(e)){const i=ei(h,t,n);r.push({text:t,style:n,metrics:i})}}const o=((t,i)=>{const s=[];let e=[],h=0,r=0,n=0,o=0;for(const a of i)"\n"!==a.text?h+a.metrics.width>t&&0!==e.length?(s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[a],h=a.metrics.width,r=a.metrics.height,n=a.metrics.baseline,o=a.metrics.lineHeight):(e.push(a),h+=a.metrics.width,r=Math.max(r,a.metrics.height),n=Math.max(n,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[],h=0,r=0,n=0,o=0);return e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),s})(s.maxWidth??1024,r),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;t.length>i;i++){const e=t[i];s+=0===i?e.height:e.lineHeight,i===t.length-1&&(s+=e.baseline)}return{width:i,height:s}})(o),c=(t=>"number"==typeof t?{left:t,right:t,top:t,bottom:t}:{left:Math.max(t?.left??0,0),right:Math.max(t?.right??0,0),top:Math.max(t?.top??0,0),bottom:Math.max(t?.bottom??0,0)})(s.padding);e.width=a.width+c.left+c.right,e.height=a.height+c.top+c.bottom;const l=new O(e),u=new xt(l);super(t,new b(Et,u),0,0,a.width,a.height),this.Zt=0,this.Lt=u,this.ti=l,this.ii=e,this.si=h,this.ei=a,this.hi=c,((t,i,s,e)=>{let h=this.hi.top;for(let t=0;s.length>t;t++){const r=s[t];let n=i;h+=0===t?r.height:r.lineHeight;for(const t of r.chunks)hi(n,h,t.text,t.style,e),n+=t.metrics.width}})(0,this.hi.left,o,this.si),this.ti.needsUpdate=!0,this.applyTransformations()}get color(){return this.Lt.getColor()}get opacity(){return this.Lt.getOpacity()}set color(t){this.Lt.setColor(t),this.composerInternal.requestUpdate()}set opacity(t){this.Lt.setOpacity(t),this.composerInternal.requestUpdate()}destroy(){this.Lt.dispose(),this.ti.dispose(),this.ii.remove(),super.destroy()}applyTransformations(){super.applyTransformations();const t=this.width/this.height;this.Zt!==t&&(this.Zt=t,this.height=this.width/((this.ei.width+this.hi.left+this.hi.right)/(this.ei.height+this.hi.top+this.hi.bottom)))}render(t){this.object.material=this.composerInternal.compose(t,this.ti.image.width,this.ti.image.height,this.Lt),this.applyTransformations()}}class ni extends zt{constructor(){super(),this.ri=1920,this.ni=()=>{const t=this.oi();this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.ai=t=>{if(this.mode!==yt.INTERACTIVE)return;const i=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,s=i?t.clientX-i.left:t.clientX,e=i?i.bottom-t.clientY:window.innerHeight-t.clientY,h=this.oi();this.clickInternal(s*h,e*h)},window.addEventListener("resize",this.ni),window.addEventListener("pointerdown",this.ai),this.ni()}get tergetScreenHeight(){return this.ri}set tergetScreenHeight(t){this.ri=t,this.resizeInternal(window.innerWidth,window.innerHeight)}destroy(){window.removeEventListener("resize",this.ni),window.removeEventListener("pointerdown",this.ai),super.destroy()}render(t,i){t.clear(!1,!0,!0),super.render(t,i)}oi(){return(this.tergetScreenHeight??window.innerHeight)/window.innerHeight}}function oi(t){return null!==t&&"object"==typeof t&&"text"in t&&"string"==typeof t.text}class ai{}export{at as UIAnchor,Xt as UIAspectConstraint,Ct as UIBlending,G as UIConstraint,jt as UIConstraint2DBuilder,Nt as UIConstraintContainerBuilder,Vt as UIConstraintContainerDirection,Q as UIConstraintPower,K as UIConstraintRule,Wt as UIConstraintStackBuilder,Yt as UICoverConstraint,Gt as UIDummy,Tt as UIElement,Ot as UIElementEvent,qt as UIFitConstraint,ni as UIFullScreenLayer,kt as UIFullScreenQuad,rt as UIHeightConstraint,$t as UIHorizontalDistanceConstraint,Ut as UIHorizontalProportionConstraint,Jt as UIImage,zt as UILayer,At as UILayerEvent,yt as UIMode,X as UIOrientation,ai as UIPass,Kt as UIProgress,ti as UIScene,Bt as UISceneUpdateMode,ri as UIText,Rt as UIVerticalDistanceConstraint,Lt as UIVerticalProportionConstraint,Ht as UIWidthConstraint,it as convertPowerToStrength,ht as convertRuleToOperator,Z as isUIConstraintPower,st as isUIConstraintRule,Y as isUIOrientation,oi as isUITextSpan,q as resolveOrientation,tt as resolvePower,et as resolveRule};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|