laymur 0.13.1 → 0.13.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/elements/UIText/UIText.Measuring.d.ts +3 -2
- package/dist/elements/UIText/UIText.Rendering.d.ts +3 -2
- package/dist/index.js +22 -4
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/miscellaneous/canvas.d.ts +13 -0
- package/package.json +1 -1
package/dist/index.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{MathUtils as t,Color as i,Vector4 as s,Texture as e,Vector2 as h,Vector3 as r,Matrix3 as n,Matrix4 as o,PlaneGeometry as a,InstancedBufferGeometry as c,ShaderMaterial as l,InstancedBufferAttribute as u,Mesh as f,Scene as d,OrthographicCamera as p,Quaternion as v,CanvasTexture as w,SRGBColorSpace as g,LinearFilter as y,WebGLRenderTarget as m,UnsignedByteType as _,RGBAFormat as b,PerspectiveCamera as x,Ray as S}from"three";class I{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 E{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._,i.p)}return this}{const r=h.length;if(h[0]._===i&&h[0].p===s)return 1===r?this.o.delete(t):h.shift(),this;const n=r-1;if(h[n]._===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._===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]._===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._.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._,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:[{_:e,p:h,M:s,k:i,m:!1}],u:!1,l:new I(e,h,s)});if(r.l.has(e,h))throw Error("Event listener already exists");r.l.insert(e,h,s);const n={_: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)}}}}var M,C;function T(t){return t===M.INTERACTIVE||t===M.INTERACTIVE_TRANSPARENT}function P(t){return t!==M.HIDDEN}function H(){return new A}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE",t[t.INTERACTIVE_TRANSPARENT=3]="INTERACTIVE_TRANSPARENT"})(M||(M={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(C||(C={}));class A{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 U(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 U(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 A;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 U{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new U(this.first,this.second)}}class V{constructor(t=""){this.S=t}id(){return this.I}name(){return this.S}setName(t){this.S=t}context(){return this.C}setContext(t){this.C=t}value(){return this.T}setValue(t){this.T=t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}toJSON(){return{name:this.S,value:this.T}}toString(){return this.C+"["+this.S+":"+this.T+"]"}S;T=0;C=null;I=R++}let R=0;class B{constructor(){let t=(t=>{let i=0,s=()=>0,e=H();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 B){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 B))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.P=t.terms,this.H=t.constant}terms(){return this.P}constant(){return this.H}value(){let t=this.H;for(let i=0,s=this.P.size();s>i;i++){let s=this.P.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}isConstant(){return 0==this.P.size()}toString(){let t=this.P.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.H||(t+=" + "),t+=this.H,t}P;H}class L{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=L.create(1e3,1e3,1e3);static strong=L.create(1,0,0);static medium=L.create(0,1,0);static weak=L.create(0,0,1);static clip(t){return Math.max(0,Math.min(L.required,t))}}var D;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(D||(D={}));class k{constructor(t,i,s,e=L.required){this.A=i,this.U=L.clip(e),this.V=void 0===s&&t instanceof B?t:t.minus(s)}id(){return this.I}expression(){return this.V}op(){return this.A}strength(){return this.U}toString(){return this.V+" "+["<=",">=","="][this.A]+" 0 ("+this.U+")"}V;A;U;I=W++}let W=0;class N{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=L.required){let h=new k(t,i,s,e);return this.addConstraint(h),h}addConstraint(t){if(void 0!==this.R.find(t))throw Error("duplicate constraint");let i=this.B(t),s=i.row,e=i.tag,h=this.L(s,e);if(h.type()===F.Invalid&&s.allDummies()){if(!z(s.constant()))throw Error("unsatisfiable constraint");h=e.marker}if(h.type()===F.Invalid){if(!this.D(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.W(h,s),this.N.insert(h,s);this.R.insert(t,e),this.F(this.O)}removeConstraint(t){let i=this.R.erase(t);if(void 0===i)throw Error("unknown constraint");this.j(t,i.second);let s=i.second.marker,e=this.N.erase(s);if(void 0===e){let t=this.$(s);if(t.type()===F.Invalid)throw Error("failed to find leaving row");e=this.N.erase(t),e.second.solveForEx(t,s),this.W(s,e.second)}this.F(this.O)}hasConstraint(t){return this.R.contains(t)}getConstraints(){return this.R.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.G.find(t))throw Error("duplicate edit variable");if((i=L.clip(i))===L.required)throw Error("bad required strength");let s=new B(t),e=new k(s,D.Eq,void 0,i);this.addConstraint(e);let h=this.R.find(e).second;this.G.insert(t,{tag:h,constraint:e,constant:0})}removeEditVariable(t){let i=this.G.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.G.contains(t)}suggestValue(t,i){let s=this.G.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.N,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.Y.push(n),void this.q();let a=h.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(r)&&this.Y.push(a),void this.q();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()!==F.External&&this.Y.push(i.first)}this.q()}updateVariables(){let t=this.X,i=this.N;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)}}Z(t){return this.X.setDefault(t,()=>this.J(F.External)).second}B(t){let i=t.expression(),s=new $(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!z(i.second)){let t=this.Z(i.first),e=this.N.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let h=this.O,r=t.strength(),n={marker:j,other:j};switch(t.op()){case D.Le:case D.Ge:{let i=t.op()===D.Le?1:-1,e=this.J(F.Slack);if(n.marker=e,s.insertSymbol(e,i),L.required>r){let t=this.J(F.Error);n.other=t,s.insertSymbol(t,-i),h.insertSymbol(t,r)}break}case D.Eq:if(L.required>r){let t=this.J(F.Error),i=this.J(F.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(F.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}L(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()===F.External)return i.first}let e=i.marker.type();return e!==F.Slack&&e!==F.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==F.Slack&&e!==F.Error||t.coefficientFor(i.other)>=0?j:i.other):i.marker}D(t){let i=this.J(F.Slack);this.N.insert(i,t.copy()),this.K=t.copy(),this.F(this.K);let s=z(this.K.constant());this.K=null;let e=this.N.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let h=this.tt(t);if(h.type()===F.Invalid)return!1;t.solveForEx(i,h),this.W(h,t),this.N.insert(h,t)}let h=this.N;for(let t=0,s=h.size();s>t;++t)h.itemAt(t).second.removeSymbol(i);return this.O.removeSymbol(i),s}W(t,i){let s=this.N;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()!==F.External&&this.Y.push(h.first)}this.O.substitute(t,i),this.K&&this.K.substitute(t,i)}F(t){let i=0;for(;this.maxIterations>i;){let s=this.it(t);if(s.type()===F.Invalid)return;let e=this.st(s);if(e.type()===F.Invalid)throw Error("the objective is unbounded");let h=this.N.erase(e).second;h.solveForEx(e,s),this.W(s,h),this.N.insert(s,h),i++}throw Error("solver iterations exceeded")}q(){let t=this.N,i=this.Y;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.et(e.second);if(i.type()===F.Invalid)throw Error("dual optimize failed");let h=e.second;t.erase(s),h.solveForEx(s,i),this.W(i,h),t.insert(i,h)}}}it(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()!==F.Dummy)return e}return j}et(t){let i=Number.MAX_VALUE,s=j,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()!==F.Dummy){let t=this.O.coefficientFor(r)/n;i>t&&(i=t,s=r)}}return s}st(t){let i=Number.MAX_VALUE,s=j,e=this.N;for(let h=0,r=e.size();r>h;++h){let r=e.itemAt(h),n=r.first;if(n.type()!==F.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}$(t){let i=Number.MAX_VALUE,s=i,e=i,h=j,r=h,n=h,o=h,a=this.N;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()===F.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()===F.Error&&this.ht(i.marker,t.strength()),i.other.type()===F.Error&&this.ht(i.other,t.strength())}ht(t,i){let s=this.N.find(t);void 0!==s?this.O.insertRow(s.second,-i):this.O.insertSymbol(t,-i)}tt(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===F.Slack||e===F.Error)return s.first}return j}J(t){return new O(t,this.rt++)}R=(()=>H())();N=(()=>H())();X=(()=>H())();G=(()=>H())();Y=[];O=new $;K=null;rt=0}function z(t){return 0>t?1e-8>-t:1e-8>t}var F;(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(F||(F={}));class O{constructor(t,i){this.I=i,this.nt=t}id(){return this.I}type(){return this.nt}I;nt}let j=new O(F.Invalid,-1);class ${constructor(t=0){this.H=t}cells(){return this.ot}constant(){return this.H}isConstant(){return this.ot.empty()}allDummies(){let t=this.ot;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==F.Dummy)return!1;return!0}copy(){let t=new $(this.H);return t.ot=this.ot.copy(),t}add(t){return this.H+=t}insertSymbol(t,i=1){z(this.ot.setDefault(t,()=>0).second+=i)&&this.ot.erase(t)}insertRow(t,i=1){this.H+=t.H*i;let s=t.ot;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.ot.erase(t)}reverseSign(){this.H=-this.H;let t=this.ot;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.ot,s=-1/i.erase(t).second;this.H*=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.ot.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.ot.erase(t);void 0!==s&&this.insertRow(i,s.second)}ot=H();H}const G=1e3;var Y;function q(t){switch(t){case Y.P0:return L.create(G,G,G);case Y.P1:return L.create(100,0,0);case Y.P2:return L.create(10,0,0);case Y.P3:return L.create(0,100,0);case Y.P4:return L.create(0,10,0);case Y.P5:return L.create(0,0,100);case Y.P6:return L.create(0,0,10);case Y.P7:return L.create(0,0,1);default:throw Error("convertPriority.priority: invalid priority")}}(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"})(Y||(Y={}));class X{constructor(){this.dirty=!1,this.ct=!1,this.lt=[],this.ut=0}createInputCatcher(t,i,s,e){const h=this.ut++;return this.lt.push({handler:h,catchPointerDown:t,catchPointerMove:i,catchPointerUp:s,zIndex:e,active:!0}),this.ct=!0,this.dirty=!0,h}destroyInputCatcher(t){const i=this.lt.findIndex(i=>i.handler===t);if(-1===i)throw Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");this.lt.splice(i,1)}getZIndex(t){this.ft();const i=this.lt.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getZIndex.handler: handler not found");return i.zIndex}setZIndex(t,i){const s=this.lt.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setZIndex.handler: handler not found");s.zIndex!==i&&(s.zIndex=i,this.ct=!0,this.dirty=!0)}getActive(t){const i=this.lt.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getActive.handler: handler not found");return i.active}setActive(t,i){const s=this.lt.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setActive.handler: handler not found");s.active!==i&&(s.active=i)}onPointerDown(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerDown(t,i,s))break}}onPointerMove(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerMove(t,i,s))break}}onPointerUp(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerUp(t,i,s))break}}ft(){if(this.ct){this.lt.sort((t,i)=>t.zIndex-i.zIndex);const t=this.lt.length,i=1024>t?1:1024/t;for(let s=0;t>s;s++)this.lt[s].zIndex=s*i;this.ct=!1}}}function Z(t){return.04045>t?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function J(t){return.0031308>t?12.92*t:1.055*Math.pow(t,.41666)-.055}const K={black:0,white:16777215,red:16711680,green:32768,blue:255,yellow:16776960,cyan:65535,magenta:16711935,gray:8421504,grey:8421504,silver:12632256,maroon:8388608,olive:8421376,lime:65280,aqua:65535,teal:32896,navy:128,fuchsia:16711935,purple:8388736,orange:16753920,pink:16761035,brown:10824234,gold:16766720,violet:15631086,indigo:4915330,coral:16744272,salmon:16416882,khaki:15787660,plum:14524637,orchid:14315734,tan:13808780,beige:16119260,mint:10025880,lavender:15132410,crimson:14423100,azure:15794175,ivory:16777200,snow:16775930};class Q{constructor(...t){this.dt=1,this.vt=1,this.wt=1,this.gt=1,this.yt=0,this._t=0,this.bt=1,this.xt=!1,this.St=!1,this.It=!1,t.length>0&&this.set(...t)}static get black(){return new Q("black")}static get white(){return new Q("white")}static get red(){return new Q("red")}static get green(){return new Q("green")}static get blue(){return new Q("blue")}static get yellow(){return new Q("yellow")}static get cyan(){return new Q("cyan")}static get magenta(){return new Q("magenta")}static get gray(){return new Q("gray")}static get grey(){return new Q("grey")}static get silver(){return new Q("silver")}static get maroon(){return new Q("maroon")}static get olive(){return new Q("olive")}static get lime(){return new Q("lime")}static get aqua(){return new Q("aqua")}static get teal(){return new Q("teal")}static get navy(){return new Q("navy")}static get fuchsia(){return new Q("fuchsia")}static get purple(){return new Q("purple")}static get orange(){return new Q("orange")}static get pink(){return new Q("pink")}static get brown(){return new Q("brown")}static get gold(){return new Q("gold")}static get violet(){return new Q("violet")}static get indigo(){return new Q("indigo")}static get coral(){return new Q("coral")}static get salmon(){return new Q("salmon")}static get khaki(){return new Q("khaki")}static get plum(){return new Q("plum")}static get orchid(){return new Q("orchid")}static get tan(){return new Q("tan")}static get beige(){return new Q("beige")}static get mint(){return new Q("mint")}static get lavender(){return new Q("lavender")}static get crimson(){return new Q("crimson")}static get azure(){return new Q("azure")}static get ivory(){return new Q("ivory")}static get snow(){return new Q("snow")}get r(){return this.Et(),this.dt}get g(){return this.Et(),this.vt}get b(){return this.Et(),this.wt}get a(){return this.gt}get hue(){return this.Mt(),this.yt}get saturation(){return this.Mt(),this._t}get lightness(){return this.Mt(),this.bt}get dirty(){return this.xt}set r(i){i=t.clamp(i,0,1),this.Et(),i!==this.dt&&(this.dt=i,this.It=!0,this.xt=!0)}set g(i){i=t.clamp(i,0,1),this.Et(),i!==this.vt&&(this.vt=i,this.It=!0,this.xt=!0)}set b(i){i=t.clamp(i,0,1),this.Et(),i!==this.wt&&(this.wt=i,this.It=!0,this.xt=!0)}set a(i){(i=t.clamp(i,0,1))!==this.gt&&(this.gt=i,this.xt=!0)}set hue(i){i=t.clamp(i,0,360),this.Mt(),i!==this.yt&&(this.yt=i,this.St=!0,this.xt=!0)}set saturation(i){i=t.clamp(i,0,1),this.Mt(),i!==this._t&&(this._t=i,this.St=!0,this.xt=!0)}set lightness(i){i=t.clamp(i,0,1),this.Mt(),i!==this.bt&&(this.bt=i,this.St=!0,this.xt=!0)}setDirtyFalse(){this.xt=!1}set(...t){if(0===t.length||void 0===t[0])return this.setRGBA(1,1,1,1);if(t.length>=3&&"number"==typeof t[0]){const[i,s,e,h=1]=t;return this.setRGBA(i,s,e,h)}const[s,e=1]=t;if("string"==typeof s)return s.startsWith("#")?this.setHexString(s):this.setColorName(s,e);if(s instanceof Q)return this.copy(s);if(s instanceof i)return this.setThreeColor(s,e);if("number"==typeof s)return this.setHexRGB(s,e);throw Error("UIColor.set: cannot create color from provided arguments")}setRGBA(i,s,e,h=this.gt){return i=t.clamp(i,0,1),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Et(),i===this.dt&&s===this.vt&&e===this.wt&&h===this.gt||(this.dt=i,this.vt=s,this.wt=e,this.gt=h,this.It=!0,this.xt=!0),this}getHexRGBA(){return this.Et(),Math.round(255*this.dt)<<24|Math.round(255*this.vt)<<16|Math.round(255*this.wt)<<8|Math.round(255*this.gt)}getHexRGB(){return this.Et(),Math.round(255*this.dt)<<16|Math.round(255*this.vt)<<8|Math.round(255*this.wt)}getHexStringRGB(){return"#"+this.getHexRGB().toString(16).padStart(6,"0")}getHexStringRGBA(){return"#"+this.getHexRGBA().toString(16).padStart(8,"0")}setHexRGBA(t){this.Et();const i=(t>>16&255)/255,s=(t>>8&255)/255,e=(255&t)/255,h=(t>>24&255)/255;return i===this.dt&&s===this.vt&&e===this.wt&&h===this.gt||(this.dt=i,this.vt=s,this.wt=e,this.gt=h,this.It=!0,this.xt=!0),this}setHexRGB(i,s=this.gt){s=t.clamp(s,0,1),this.Et();const e=(i>>16&255)/255,h=(i>>8&255)/255,r=(255&i)/255;return e===this.dt&&h===this.vt&&r===this.wt&&s===this.gt||(this.dt=e,this.vt=h,this.wt=r,this.gt=s,this.It=!0,this.xt=!0),this}setHexString(t){if(!t.startsWith("#"))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');const i=t.slice(1);if(6===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGB(t)}if(8===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGBA(t)}throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"')}setHSL(i,s,e,h=this.gt){return i=t.clamp(i,0,360),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Mt(),i===this.yt&&s===this._t&&e===this.bt&&h===this.gt||(this.yt=i,this._t=s,this.bt=e,this.gt=h,this.St=!0,this.xt=!0),this}setColorName(i,s=this.gt){s=t.clamp(s,0,1);const e=i.toLowerCase().trim(),h=K[e];if(void 0===h)throw Error("UIColor.setColorName.colorName: unknown color name");return this.setHexRGB(h,s)}setGLSLColor(i,s,e,h=this.gt){h=t.clamp(h,0,1),this.Et();const r=J(i),n=J(s),o=J(e);return r===this.dt&&n===this.vt&&o===this.wt&&h===this.gt||(this.dt=r,this.vt=n,this.wt=o,this.gt=h,this.It=!0,this.xt=!0),this}setThreeColor(i,s=this.gt){return s=t.clamp(s,0,1),this.Et(),i.r===this.dt&&i.g===this.vt&&i.b===this.wt&&s===this.gt||(this.dt=i.r,this.vt=i.g,this.wt=i.b,this.gt=s,this.It=!0,this.xt=!0),this}toCSSColor(){return this.Et(),`rgba(${Math.round(255*this.dt)}, ${Math.round(255*this.vt)}, ${Math.round(255*this.wt)}, ${this.gt})`}toGLSLColor(t=new s){return this.Et(),t.x=Z(this.dt),t.y=Z(this.vt),t.z=Z(this.wt),t.w=this.gt,t}toThreeColor(t=new i){return this.Et(),t.r=this.dt,t.g=this.vt,t.b=this.wt,t}copy(t){return t instanceof Q?(this.Et(),t.Et(),this.dt===t.dt&&this.vt===t.vt&&this.wt===t.wt&&this.gt===t.gt||(this.dt=t.dt,this.vt=t.vt,this.wt=t.wt,this.gt=t.gt,this.It=!0,this.xt=!0)):(this.Et(),this.dt===t.r&&this.vt===t.g&&this.wt===t.b&&1===this.gt||(this.dt=t.r,this.vt=t.g,this.wt=t.b,this.gt=1,this.It=!0,this.xt=!0)),this}clone(){return this.Et(),new Q(this.dt,this.vt,this.wt,this.gt)}Et(){if(this.St){const{yt:t,_t:i,bt:s}=this,e=(1-Math.abs(2*s-1))*i,h=t/60,r=e*(1-Math.abs(h%2-1));let[n,o,a]=1>h?[e,r,0]:2>h?[r,e,0]:3>h?[0,e,r]:4>h?[0,r,e]:5>h?[r,0,e]:[e,0,r];const c=s-e/2;this.dt=n+c,this.vt=o+c,this.wt=a+c,this.St=!1}}Mt(){if(this.It){const{dt:t,vt:i,wt:s}=this,e=Math.max(t,i,s),h=Math.min(t,i,s),r=e-h,n=(e+h)/2;let o=0;0!==r&&(o=e===t?(i-s)/r+(s>i?6:0):e===i?(s-t)/r+2:(t-i)/r+4,o*=60);const a=0===r?0:r/(1-Math.abs(2*n-1));this.yt=o,this._t=a,this.bt=n,this.It=!1}}}const tt=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),it=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),st=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),et=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),ht=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),rt=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),nt=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function ot(t){if("string"==typeof t)switch(t){case"number":return tt;case"Texture":return it;case"UIColor":case"Vector4":return ht;case"Vector2":return st;case"Vector3":return et;case"Matrix3":return rt;case"Matrix4":return nt;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return tt;if(t===e)return it;if(t===Q)return ht;if(t===h)return st;if(t===r)return et;if(t===s)return ht;if(t===n)return rt;if(t===o)return nt;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return tt;if(t instanceof e)return it;if(t instanceof Q)return ht;if(t instanceof h)return st;if(t instanceof r)return et;if(t instanceof s)return ht;if(t instanceof n)return rt;if(t instanceof o)return nt;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function at(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function ct(t,i){for(const s in i){if(!(s in t))return!1;const e=t[s].glslTypeInfo;if(e.glslTypeName!==i[s].glslTypeInfo.glslTypeName)return!1;if(!e.instantiable&&t[s]!==i[s])return!1}return!0}function lt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:ot(e)}}return i}function ut(t){return"number"==typeof t||t instanceof e?t:t.clone()}function ft(t){const i={};for(const s in t)i[s]=ut(t[s]);return i}function dt(t,i,s){return`\n // Defines\n #define PI 3.14159265359\n\n // Uniforms\n ${t.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${i.join("\n")}\n\n #include <alphahash_pars_fragment>\n\n // Source must define vec4 draw() function\n ${s}\n\n void main() {\n vec4 diffuseColor = draw();\n\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < 0.50) {\n discard;\n }\n #endif\n\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `}var pt;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(pt||(pt={}));const vt=(()=>{const t=new a(1,1);t.translate(.5,.5,0);const i=new c;return i.index=t.index,i.setAttribute("position",t.attributes.position),i.setAttribute("uv",t.attributes.uv),t.dispose(),i})(),wt=new s,gt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function yt(t,i,e){if(t instanceof Q)t.toGLSLColor(wt),i[e]=wt.x,i[e+1]=wt.y,i[e+2]=wt.z,i[e+3]=wt.w;else if(t instanceof h)i[e]=t.x,i[e+1]=t.y;else if(t instanceof r)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z;else if(t instanceof s)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z,i[e+3]=t.w;else if(t instanceof n||t instanceof o){const s=t.elements;for(let t=0;s.length>t;t++)i[e+t]=s[t]}else"number"==typeof t&&(i[e]=t)}function mt(t,i){const s=ot(t);if(!s.instantiable)throw Error("buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type");return new u(new Float32Array(i*s.bufferSize),s.bufferSize)}function _t(t,i,e){if("number"==typeof t)return i[e];if(t instanceof h)return new h(i[e],i[e+1]);if(t instanceof r)return new r(i[e],i[e+1],i[e+2]);if(t instanceof s)return new s(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof Q)return(new Q).setGLSLColor(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof n){const t=new n;return t.fromArray(i,e),t}if(t instanceof o){const t=new o;return t.fromArray(i,e),t}throw Error("reconstructValue.referenceValue: cannot reconstruct value for type")}class bt extends f{constructor(t,i,s,e=4){const h={},r={instanceVisibility:{value:1,glslTypeInfo:ot("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:ot("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?r[t]=s:h[t]=s}const n=vt.clone(),a=((t,i,s,e)=>{const h={},r=[],n=[],o=[],a=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof Q?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}for(const t in s){const{glslTypeInfo:i}=s[t];n.push(`attribute ${i.glslTypeName} a_${t};`),o.push(`varying ${i.glslTypeName} p_${t};`),a.push(`p_${t} = a_${t};`)}const c=`\n // User attributes\n ${n.join("\n")}\n\n // Uniforms\n ${r.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${o.join("\n")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${a.join("\n")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `,u=dt(r,o,t);return new l({uniforms:h,vertexShader:c,fragmentShader:u,transparent:e===pt.BLEND,alphaTest:e===pt.CLIP?.5:0,alphaHash:e===pt.HASH,depthWrite:e!==pt.BLEND,depthTest:!0})})(t,h,r,s);super(n,a),this.source=t,this.transparency=s,this.Ct=new Map,this.Tt=new Map,this.ut=0,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1,this.Pt=n,this.Pt.instanceCount=0,this.Ht=a,this.At=h,this.Ut=r,this.Vt=Math.max(4*Math.ceil(e/4),4);for(const t in this.Ut){const{value:i}=this.Ut[t],s=mt(i,this.Vt);this.Pt.setAttribute("a_"+t,s),this.Tt.set(t,s)}for(const t in this.At){const{value:i}=this.At[t];at(t,this.Ht).value=i}this.Ht.uniformsNeedUpdate=!0}get instanceCount(){return this.Pt.instanceCount}createInstance(){const t=this.ut++,i=this.Pt.instanceCount;this.Rt(i+1),this.Ct.set(t,i),this.Pt.instanceCount++;{const t=this.Tt.get("instanceVisibility"),s=this.Tt.get("instanceTransform");((t,i,s)=>{t[s]=1;const e=16*s;for(let t=0;16>t;t++)i[e+t]=gt[t]})(t.array,s.array,i),t.needsUpdate=!0,s.needsUpdate=!0}return t}destroyInstance(t){const i=this.Bt(t);this.Ct.delete(t);const s=this.Pt.instanceCount-1;s>i&&(this.Lt(s,i),this.Dt(s,i)),this.Pt.instanceCount--}setProperties(t,i){const s=this.Bt(t);for(const t in i){const{value:e,glslTypeInfo:h}=i[t];if(h.instantiable){const i=this.kt(t);yt(e,i.array,s*i.itemSize),i.needsUpdate=!0}else at(t,this.Ht).value=e,this.Ht.uniformsNeedUpdate=!0}}setTransform(t,i){const s=this.Bt(t),e=this.kt("instanceTransform"),h=e.array,r=16*s,n=i.elements;for(let t=0;16>t;t++)h[r+t]=n[t];e.needsUpdate=!0}setVisibility(t,i){const s=this.Bt(t),e=this.kt("instanceVisibility");e.array[s]=i?1:0,e.needsUpdate=!0}isPartiallyCompatible(t,i,s=pt.BLEND){return this.transparency===s&&this.source===t&&ct({...this.At,...this.Ut},i)}arePropertiesPartiallyCompatible(t){return ct({...this.At,...this.Ut},t)}extractInstanceData(t){return{source:this.source,properties:this.Wt(t),transparency:this.transparency,transform:this.Nt(t),visibility:this.zt(t)}}destroy(){this.Pt.dispose(),this.Ht.dispose(),this.Tt.clear(),this.Ct.clear()}Wt(t){const i=this.Bt(t),s={};for(const t in this.At)s[t]=this.At[t];for(const t in this.Ut){const{value:e,glslTypeInfo:h}=this.Ut[t],r=this.Tt.get(t);s[t]={value:_t(e,r.array,i*r.itemSize),glslTypeInfo:h}}return s}Nt(t){const i=this.Bt(t),s=this.Tt.get("instanceTransform").array,e=new o;return e.fromArray(s,16*i),e}zt(t){const i=this.Bt(t);return this.Tt.get("instanceVisibility").array[i]>=.5}Rt(t){if(this.Vt>=t)return;const i=4*Math.ceil(t/4);for(const[t,s]of this.Tt){const e=s.itemSize,h=new Float32Array(i*e);h.set(s.array);const r=new u(h,e);this.Pt.setAttribute("a_"+t,r),this.Tt.set(t,r)}this.Vt=i}Lt(t,i){for(const s of this.Tt.values()){const e=s.array,h=s.itemSize,r=t*h,n=i*h;for(let t=0;h>t;t++)e[n+t]=e[r+t];s.needsUpdate=!0}}Dt(t,i){for(const[s,e]of this.Ct)if(e===t){this.Ct.set(s,i);break}}Bt(t){const i=this.Ct.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveIndex.handler: invalid handler");return i}kt(t){const i=this.Tt.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveAttribute.name: unknown attribute");return i}}const xt=new a(1,1).translate(.5,.5,0);class St extends f{constructor(t,i,s,e,h){const r=((t,i,s,e)=>{const h={p_transform:{value:e}},r=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof Q?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}const n=`\n // Default uniform declarations\n uniform mat4 p_transform;\n\n // Custom uniform declarations\n ${r.join("\n")}\n\n // Default varying declarations\n varying vec3 p_position;\n varying vec2 p_uv;\n\n void main() {\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * p_transform * vec4(position, 1.0);\n }\n `,o=dt(r,[],t);return new l({uniforms:h,vertexShader:n,fragmentShader:o,transparent:s===pt.BLEND,alphaTest:s===pt.CLIP?.5:0,alphaHash:s===pt.HASH,depthWrite:s!==pt.BLEND,depthTest:!0})})(t,i,h,s);super(xt,r),this.Ft=t,this.Ht=r,this.Ot=i,this.jt=h,this.$t=s,this.visible=e,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1}get transparency(){return this.jt}setProperties(t){for(const i in t){const s=t[i],h=at(i,this.Ht),r=s.value;if(s.value instanceof Q)s.value.toGLSLColor(h.value),this.Ot[i].value.copy(s.value);else if("number"==typeof r||r instanceof e)h.value=s.value,this.Ot[i].value=s.value;else{const t=s.value;h.value.copy(t),this.Ot[i].value.copy(t)}}this.Ht.uniformsNeedUpdate=!0}setTransform(t){at("transform",this.Ht).value.copy(t),this.Ht.uniformsNeedUpdate=!0,this.$t.copy(t)}setVisibility(t){this.visible=t}setTransparency(t){this.jt!==t&&(this.Ht.transparent=t===pt.BLEND,this.Ht.alphaTest=t===pt.CLIP?.5:0,this.Ht.alphaHash=t===pt.HASH,this.Ht.depthWrite=t!==pt.BLEND,this.Ht.needsUpdate=!0,this.jt=t)}extractPlaneData(){return{source:this.Ft,properties:{...this.Ot},transform:this.$t.clone(),visibility:this.visible,transparency:this.jt}}isPartiallyCompatible(t,i,s){return this.jt===s&&this.Ft===t&&ct(this.Ot,i)}arePropertiesPartiallyCompatible(t){return ct(this.Ot,t)}destroy(){this.Ht.dispose()}}function It(t){return!("instanceHandler"in t)}function Et(t){return"instanceHandler"in t}class Mt{constructor(t){this.Gt=t,this.ut=0,this.Yt=new Map}createPlane(t,i,s,e,h){const r=this.ut++;return this.qt(r,{source:t,properties:lt(ft(i)),transform:s.clone(),visibility:e,transparency:h}),r}destroyPlane(t){const i=this.Xt(t);if(It(i))this.Gt.remove(i.plane),i.plane.destroy();else{const t=i.plane;1===t.instanceCount?(this.Gt.remove(t),t.destroy()):2===t.instanceCount?this.Zt(t,i):t.destroyInstance(i.instanceHandler)}this.Yt.delete(t)}setProperties(t,i){const s=this.Xt(t),e=lt(i);if(It(s))return void s.plane.setProperties(e);if(s.plane.arePropertiesPartiallyCompatible(e))return void s.plane.setProperties(s.instanceHandler,e);const h=s.plane.extractInstanceData(s.instanceHandler);for(const t in e)h.properties[t]={value:ut(e[t].value),glslTypeInfo:e[t].glslTypeInfo};this.destroyPlane(t),this.qt(t,h)}setTransform(t,i){const s=this.Xt(t);It(s)?s.plane.setTransform(i):s.plane.setTransform(s.instanceHandler,i)}setVisibility(t,i){const s=this.Xt(t);It(s)?s.plane.setVisibility(i):s.plane.setVisibility(s.instanceHandler,i)}setTransparency(t,i){const s=this.Xt(t);if(s.plane.transparency===i)return;if(It(s))return void s.plane.setTransparency(i);const e=s.plane.extractInstanceData(s.instanceHandler);this.destroyPlane(t),this.qt(t,{...e,transparency:i})}Jt(t,i){const{source:s,properties:e,transform:h,visibility:r,transparency:n}=i.plane.extractPlaneData();this.destroyPlane(t);const o=new bt(s,e,n),a=o.createInstance();return o.setProperties(a,e),o.setTransform(a,h),o.setVisibility(a,r),this.Gt.add(o),this.Yt.set(t,{plane:o,instanceHandler:a}),o}Zt(t,i){let s;for(const[e,h]of this.Yt)if(Et(h)&&h!==i&&h.plane===t){s=[e,h];break}if(!s)throw Error("UIGenericPlaneRegistry.demoteInstancedPlaneToSinglePlane.instancedPlane: remaining pair not found");const{source:e,properties:h,transform:r,visibility:n,transparency:o}=t.extractInstanceData(s[1].instanceHandler);this.Gt.remove(t),t.destroy();const a=new St(e,h,r,n,o);this.Gt.add(a),this.Yt.set(s[0],{plane:a})}Kt(t,i,s,e,h){const r=i.createInstance();i.setProperties(r,s),i.setTransform(r,e),i.setVisibility(r,h),this.Yt.set(t,{plane:i,instanceHandler:r})}qt(t,i){const{source:s,properties:e,transparency:h,transform:r,visibility:n}=i,o=this.Qt(s,e,h);if(o)return void this.Kt(t,o,e,r,n);const a=this.ti(s,e,h);if(a){const i=this.Jt(a[0],a[1]);return void this.Kt(t,i,e,r,n)}const c=new St(s,e,r,n,h);this.Gt.add(c),this.Yt.set(t,{plane:c})}ti(t,i,s){for(const e of this.Yt){const h=e[1];if(It(h)&&h.plane.isPartiallyCompatible(t,i,s))return[e[0],h]}}Qt(t,i,s){for(const e of this.Yt){const h=e[1];if(Et(h)&&h.plane.isPartiallyCompatible(t,i,s))return h.plane}}Xt(t){const i=this.Yt.get(t);if(!i)throw Error("UIGenericPlaneRegistry.resolvePlaneDescriptor.handler: descriptor not found");return i}}let Ct=new i,Tt=0,Pt=!1,Ht=!1,At=!1,Ut=!1;class Vt{constructor(t,i){this.Gt=new d,this.ii=new Mt(this.Gt),this.si=new p(0,t,i,0,-1024,1024)}createPlane(t,i,s,e,h){return this.ii.createPlane(t,i,s,e,h)}destroyPlane(t){this.ii.destroyPlane(t)}setTransform(t,i){this.ii.setTransform(t,i)}setProperties(t,i){this.ii.setProperties(t,i)}setVisibility(t,i){this.ii.setVisibility(t,i)}setTransparency(t,i){this.ii.setTransparency(t,i)}insertCustomObject(t){return this.Gt.add(t),this}removeCustomObject(t){return this.Gt.remove(t),this}resize(t,i){return this.si.right=t,this.si.top=i,this.si.updateProjectionMatrix(),this}render(t){return Ct=t.getClearColor(Ct),Tt=t.getClearAlpha(),Pt=t.autoClear,Ht=t.autoClearColor,At=t.autoClearDepth,Ut=t.autoClearStencil,t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1),t.clear(!1,!0,!0),t.render(this.Gt,this.si),t.setClearColor(Ct),t.setClearAlpha(Tt),t.autoClear=Pt,t.autoClearColor=Ht,t.autoClearDepth=At,t.autoClearStencil=Ut,this}}class Rt{constructor(t=0,i){if(this.constant=t,this.ei=i?new Map(i):new Map,i)for(let t=0;i.length>t;t++)jt()}static plus(t,i){const s=new Rt(t.constant+i.constant,Array.from(t.ei.entries()));for(const[t,e]of i.ei)s.plus(t,e);return s}static minus(t,i){const s=new Rt(t.constant-i.constant,Array.from(t.ei.entries()));for(const[t,e]of i.ei)s.minus(t,e);return s}plus(t,i){return this.ei.set(t,(this.ei.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this.ei)this.ei.set(i,s*t);return this}divide(t){if(0===t)throw Error("UIExpression.divide.value: cannot divide by zero");return this.multiply(1/t)}hasTerm(t){return this.ei.has(t)}copy(t){this.constant=t.constant,this.ei.clear();for(const[i,s]of t.ei)this.ei.set(i,s);return this}clone(){return new Rt(this.constant,Array.from(this.ei.entries()))}prepareTerms(){return Array.from(this.ei.entries())}}var Bt,Lt;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(Bt||(Bt={}));class Dt{constructor(){this.dirty=!1,this.hi=new N,this.ri=!1,this.ni=new Map,this.oi=0,this.ai=new Map,this.ci=0}createVariable(t,i){const s=this.oi++,e=new V;if(i===Y.P0){const h={variable:e,priority:i,value:t};this.ni.set(s,h),h.constraint=this.li(new Rt(0,[[s,1]]),new Rt(t),Bt.EQUAL,i);try{this.hi?.addConstraint(h.constraint)}catch{this.hi=void 0}}else{this.ni.set(s,{variable:e,priority:i,value:t});try{this.hi?.addEditVariable(e,q(i)),this.hi?.suggestValue(e,t)}catch{this.hi=void 0}}return this.ri=!0,this.dirty=!0,s}removeVariable(t){const i=this.ni.get(t);if(void 0===i)throw Error("UISolverWrapper.removeVariable.index: variable does not exist");for(const i of this.ai.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error("UISolverWrapper.removeVariable.index: variable is used in constraint");try{i.constraint?this.hi?.removeConstraint(i.constraint):this.hi?.removeEditVariable(i.variable)}catch{this.hi=void 0}this.ni.delete(t),this.ri=!0,this.dirty=!0}suggestVariableValue(t,i){const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.suggestVariableValue.index: variable does not exist");s.value!==i&&(s.value=i,s.constraint?s.constraint=this.ui(s.constraint,(new Rt).plus(t,1),new Rt(s.value),Bt.EQUAL,s.priority):this.hi?.suggestValue(s.variable,i),this.ri=!0,this.dirty=!0)}setVariablePriority(t,i){const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.setVariablePriority.index: variable does not exist");if(i!==s.priority){if(s.priority=i,s.priority===Y.P0){const i=(new Rt).plus(t,1),e=new Rt(s.value);s.constraint=this.li(i,e,Bt.EQUAL,s.priority);try{this.hi?.addConstraint(s.constraint)}catch{this.hi=void 0}}else{if(s.constraint)try{this.hi?.removeConstraint(s.constraint)}catch{this.hi=void 0}s.constraint=void 0,this.fi(t,s)}this.ri=!0,this.dirty=!0}}readVariableValue(t){const i=this.ni.get(t);if(void 0===i)throw Error("UISolverWrapper.readVariableValue.index: variable does not exist");return void 0===this.hi&&this.di(),this.ri&&(this.hi?.updateVariables(),this.ri=!1),i.variable.value()}createConstraint(t,i,s,e,h){const r=this.ci++,n=this.li(t,i,s,e);if(this.ai.set(r,{constraint:n,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:h}),h){try{this.hi?.addConstraint(n)}catch{this.hi=void 0}this.ri=!0,this.dirty=!0}return r}removeConstraint(t){const i=this.ai.get(t);if(void 0===i)throw Error("UISolverWrapper.removeConstraint.index: constraint does not exist");if(i.enabled)try{this.hi?.removeConstraint(i.constraint)}catch{this.hi=void 0}this.ai.delete(t),this.ri=!0,this.dirty=!0}setConstraintLHS(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintLHS.index: constraint does not exist");s.lhs.copy(i),this.pi(s),this.ri=!0,this.dirty=!0}setConstraintRHS(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRHS.index: constraint does not exist");s.rhs.copy(i),this.pi(s),this.ri=!0,this.dirty=!0}setConstraintRelation(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRelation.index: constraint does not exist");s.relation!==i&&(s.relation=i,this.pi(s),this.ri=!0,this.dirty=!0)}setConstraintPriority(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintPriority.index: constraint does not exist");s.priority!==i&&(s.priority=i,this.pi(s),this.ri=!0,this.dirty=!0)}setConstraintEnabled(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintEnabled.index: constraint does not exist");if(i!==s.enabled){s.enabled=i;try{s.enabled?this.hi?.addConstraint(s.constraint):this.hi?.removeConstraint(s.constraint)}catch{this.hi=void 0}this.ri=!0,this.dirty=!0}}fi(t,i){const s=[];for(const i of this.ai.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this.hi?.removeConstraint(i.constraint)}catch{this.hi=void 0}s.push(i)}this.hi?.removeEditVariable(i.variable),this.hi?.addEditVariable(i.variable,q(i.priority));for(const t of s)t.constraint=this.li(t.lhs,t.rhs,t.relation,t.priority);for(const t of s)try{this.hi?.addConstraint(t.constraint)}catch{this.hi=void 0;break}}pi(t){t.constraint=t.enabled?this.ui(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.li(t.lhs,t.rhs,t.relation,t.priority)}ui(t,i,s,e,h){try{this.hi?.removeConstraint(t)}catch{this.hi=void 0}const r=this.li(i,s,e,h);try{this.hi?.addConstraint(r)}catch{this.hi=void 0}return r}li(t,i,s,e){return new k(this.wi(t),(t=>{switch(t){case Bt.EQUAL:return D.Eq;case Bt.LESS_THAN:return D.Le;case Bt.GREATER_THAN:return D.Ge;default:throw Error("convertRelation.relation: invalid relation")}})(s),this.wi(i),q(e))}wi(t){return new B(...t.prepareTerms().map(([t,i])=>{const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.convertExpression.expression: variable does not exist");return[i,s.variable]}),t.constant)}di(){if(this.hi)throw Error("UISolverWrapper.rebuildSolver: solver already exists");this.hi=new N;for(const t of this.ni.values())t.constraint?this.hi.addConstraint(t.constraint):(this.hi.addEditVariable(t.variable,q(t.priority)),this.hi.suggestValue(t.variable,t.value));for(const t of this.ai.values())t.enabled&&this.hi.addConstraint(t.constraint);this.ri=!0,this.dirty=!0}}(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.MODE_CHANGED="mode_changed",t.RENDERING="rendering"})(Lt||(Lt={}));const kt=M.VISIBLE;class Wt extends E{constructor(t){super(),this.name="",this.inputWrapperInternal=new X,this.gi=new Dt;const i=t.width??1024,s=t.height??1024;this.yi=new Vt(i,s),this.name=t.name??"",this.mi=t.mode??kt,this._i=i>s?C.HORIZONTAL:C.VERTICAL,this.xVariable=this.gi.createVariable(0,Y.P0),this.yVariable=this.gi.createVariable(0,Y.P0),this.wVariable=this.gi.createVariable(i,Y.P0),this.hVariable=this.gi.createVariable(s,Y.P0)}get sceneWrapper(){return this.yi}get solverWrapper(){return this.gi}get inputWrapper(){return this.inputWrapperInternal}get x(){return this.gi.readVariableValue(this.xVariable)}get y(){return this.gi.readVariableValue(this.yVariable)}get width(){return this.gi.readVariableValue(this.wVariable)}get height(){return this.gi.readVariableValue(this.hVariable)}get mode(){return this.mi}get orientation(){return this._i}set mode(t){t!==this.mi&&(this.mi=t,this.emit(Lt.MODE_CHANGED,this.mi,this))}resizeInternal(t,i){this.gi.suggestVariableValue(this.wVariable,t),this.gi.suggestVariableValue(this.hVariable,i),this.yi.resize(t,i);const s=t>i?C.HORIZONTAL:C.VERTICAL;s!==this._i&&(this._i=s,this.emit(Lt.ORIENTATION_CHANGED,this._i,this))}renderInternal(t,i){P(this.mode)&&(this.emit(Lt.RENDERING,t,i,this),this.yi.render(t)),this.gi.dirty=!1,this.inputWrapperInternal.dirty=!1}}function Nt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Wt}function zt(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function Ft(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}const Ot=1e-6;function jt(){}function $t(t,i,s){if(t instanceof Wt)return t;if(Nt(t))return t.layer;if(i instanceof Wt)return i;if(Nt(i))return i.layer;throw Error(s+": no valid subjects found")}function Gt(t,i,s){if(Nt(i))return i.layer;if(Nt(s))return s.layer;if(i instanceof Wt)return i;if(s instanceof Wt)return s;throw Error(t+": no valid subjects found")}class Yt{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=i??""}}class qt extends Yt{constructor(t,i){var s,e,h;super(t,i?.name),this.bi=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.xi=(s=i?.priority,s??Y.P0),this.Si=(e=i?.relation,e??Bt.EQUAL),this._i=(h=i?.orientation,h??C.ALWAYS),this.layer.on(Lt.ORIENTATION_CHANGED,this.bi)}get priority(){return this.xi}get relation(){return this.Si}get orientation(){return this._i}set priority(t){t!==this.xi&&(this.xi=t,this.solverWrapper.setConstraintPriority(this.constraint,this.xi))}set relation(t){t!==this.Si&&(this.Si=t,this.solverWrapper.setConstraintRelation(this.constraint,this.Si))}set orientation(t){t!==this._i&&(this._i=t,this.bi())}destroy(){this.layer.off(Lt.ORIENTATION_CHANGED,this.bi),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this._i===C.ALWAYS||this._i===this.layer.orientation}}class Xt extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.Ei=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new Rt(0,[[this.Ii.hVariable,1]]),new Rt(this.Ei),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Ei}set height(t){this.Ei!==t&&(this.Ei=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(t)))}}class Zt extends qt{constructor(t,i,s={}){super($t(t,i,"UIHorizontalDistanceConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Ti=s.anchorA??.5,this.Pi=s.anchorB??.5,this.Hi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(this.Hi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Hi}get anchorA(){return this.Ti}get anchorB(){return this.Pi}set distance(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(this.Hi)))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.xVariable,1],[this.Mi.wVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.xVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.xVariable,1],[this.Ci.wVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.xVariable,1)}return Rt.minus(i,t)}}class Jt extends qt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Gt("UIHorizontalInterpolationConstraint.constructor",t,i),e),this.Mi=t,this.Ci=i,this.Ui=s,this.Ti=h,this.Pi=h,this.Vi=e.anchorC??.5,this.Ri=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Ri}get anchorA(){return this.Ti}get anchorB(){return this.Pi}get anchorC(){return this.Vi}set t(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorC(t){this.Vi!==t&&(this.Vi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i,s;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.xVariable,1],[this.Mi.wVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.xVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.xVariable,1],[this.Ci.wVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.xVariable,1)}if(Ft(this.Ui))s=new Rt(0,[[this.Ui.xVariable,1],[this.Ui.wVariable,this.Vi]]);else{if(!zt(this.Ui))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Rt).plus(this.Ui.xVariable,1)}const e=t.clone().multiply(1-this.Ri),h=i.clone().multiply(this.Ri);return Rt.minus(Rt.minus(s,e),h)}}class Kt extends qt{constructor(t,i,s={}){super($t(t,i,"UIHorizontalProportionConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Bi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Rt(0),this.Li(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Bi}set proportion(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Li()))}Li(){return Rt.minus(new Rt(0,[[this.Mi.wVariable,this.Bi]]),new Rt(0,[[this.Ci.wVariable,1]]))}}class Qt extends qt{constructor(t,i,s={}){super($t(t,i,"UIVerticalDistanceConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Ti=s.anchorA??.5,this.Pi=s.anchorB??.5,this.Hi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(this.Hi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Hi}get anchorA(){return this.Ti}get anchorB(){return this.Pi}set distance(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(this.Hi)))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.yVariable,1],[this.Mi.hVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.yVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.yVariable,1],[this.Ci.hVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.yVariable,1)}return Rt.minus(i,t)}}class ti extends qt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Gt("UIVerticalInterpolationConstraint.constructor",t,i),e),this.Mi=t,this.Ci=i,this.Ui=s,this.Ti=h,this.Pi=h,this.Vi=e.anchorC??.5,this.Ri=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Ri}get anchorA(){return this.Ti}get anchorB(){return this.Pi}get anchorC(){return this.Vi}set t(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorC(t){this.Vi!==t&&(this.Vi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i,s;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.yVariable,1],[this.Mi.hVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.yVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.yVariable,1],[this.Ci.hVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.yVariable,1)}if(Ft(this.Ui))s=new Rt(0,[[this.Ui.yVariable,1],[this.Ui.hVariable,this.Vi]]);else{if(!zt(this.Ui))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Rt).plus(this.Ui.yVariable,1)}const e=t.clone().multiply(1-this.Ri),h=i.clone().multiply(this.Ri);return Rt.minus(Rt.minus(s,e),h)}}class ii extends qt{constructor(t,i,s={}){super($t(t,i,"UIVerticalProportionConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Bi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Rt(0),this.Li(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Bi}set proportion(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Li()))}Li(){return Rt.minus(new Rt(0,[[this.Mi.hVariable,this.Bi]]),new Rt(0,[[this.Ci.hVariable,1]]))}}class si extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.Di=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new Rt(0,[[this.Ii.wVariable,1]]),new Rt(this.Di),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.Di}set width(t){this.Di!==t&&(this.Di=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(t)))}}function ei(t){return void 0===t?{}:Array.isArray(t)?{h:t[0],v:t[1]}:"object"==typeof t&&null!==t&&("h"in t||"v"in t)?t:{h:t,v:t}}class hi{static size(t,i={}){const s=ei(i.size),e=ei(i.priority),h=ei(i.relation),r=ei(i.orientation);return{h:new si(t,{width:s.h,priority:e.h,relation:h.h,orientation:r.h}),v:new Xt(t,{height:s.v,priority:e.v,relation:h.v,orientation:r.v})}}static distance(t,i,s={}){const e=ei(s.anchorA),h=ei(s.anchorB),r=ei(s.distance),n=ei(s.priority),o=ei(s.relation),a=ei(s.orientation);return{h:new Zt(t,i,{anchorA:e.h,anchorB:h.h,distance:r.h,priority:n.h,relation:o.h,orientation:a.h}),v:new Qt(t,i,{anchorA:e.v,anchorB:h.v,distance:r.v,priority:n.v,relation:o.v,orientation:a.v})}}static proportion(t,i,s={}){const e=ei(s.proportion),h=ei(s.priority),r=ei(s.relation),n=ei(s.orientation);return{h:new Kt(t,i,{proportion:e.h,priority:h.h,relation:r.h,orientation:n.h}),v:new ii(t,i,{proportion:e.v,priority:h.v,relation:r.v,orientation:n.v})}}static interpolation(t,i,s,e={}){const h=ei(e.anchorA),r=ei(e.anchorB),n=ei(e.anchorC),o=ei(e.t),a=ei(e.priority),c=ei(e.relation),l=ei(e.orientation);return{h:new Jt(t,i,s,{anchorA:h.h,anchorB:r.h,anchorC:n.h,t:o.h,priority:a.h,relation:c.h,orientation:l.h}),v:new ti(t,i,s,{anchorA:h.v,anchorB:r.v,anchorC:n.v,t:o.v,priority:a.v,relation:c.v,orientation:l.v})}}}class ri extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.ki=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.ki}set aspect(t){this.ki!==t&&(this.ki=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){return new Rt(0,[[this.Ii.wVariable,1],[this.Ii.hVariable,-this.ki]])}}const ni=.5;class oi{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ri(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Zt(t,i,{anchorA:s.anchorH??ni,anchorB:s.anchorH??ni,orientation:s.orientation}),yConstraint:new Qt(t,i,{anchorA:s.anchorV??ni,anchorB:s.anchorV??ni,orientation:s.orientation}),widthConstraint:new Kt(t,i,{proportion:1,relation:Bt.GREATER_THAN,orientation:s.orientation}),heightConstraint:new ii(t,i,{proportion:1,priority:Y.P1,orientation:s.orientation})}}}const ai=.5;class ci{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ri(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Zt(t,i,{anchorA:s.anchorH??ai,anchorB:s.anchorH??ai,orientation:s.orientation}),yConstraint:new Qt(t,i,{anchorA:s.anchorV??ai,anchorB:s.anchorV??ai,orientation:s.orientation}),widthConstraint:new Kt(t,i,{proportion:1,relation:Bt.LESS_THAN,orientation:s.orientation}),heightConstraint:new ii(t,i,{proportion:1,priority:Y.P1,orientation:s.orientation})}}}class li extends qt{constructor(t,i,s,e={}){super(t,e),this.Wi=i,this.Ni=s,this.constraint=this.solverWrapper.createConstraint(this.Wi,this.Ni,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Wi}get rhs(){return this.Ni}setLHS(t){this.Wi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Wi)}setRHS(t){this.Ni=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Ni)}}class ui extends E{constructor(t,i){const s=i?.x??0,e=i?.y??0;super(),this.layer=t,this.name="",this.solverWrapper=this.layer.solverWrapper,this.xVariable=this.solverWrapper.createVariable(s,Y.P7),this.yVariable=this.solverWrapper.createVariable(e,Y.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}var fi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(fi||(fi={}));const di=.5,pi=fi.ROTATION_SCALE,vi=new r,wi=new v,gi=new r,yi=new o,mi=new r(0,0,1);function _i(t,i,s,e,h,r,n,o,a,c,l,u,f,d,p,v,w){const g=s-d-p,y=e-v-w,m=o*s*c,_=a*e*l,b=Math.cos(u),x=Math.sin(u),S=m*b-_*x,I=m*x+_*b,E=d*c,M=w*l,C=E*b-M*x,T=E*x+M*b;if(f===fi.POSITION_ROTATION_SCALE)vi.x=t+r-S+C,vi.y=i+n-I+T;else{const h=a*e;vi.x=t+o*s-S+r+C,vi.y=i+h-I+n+T}return vi.z=h,gi.x=g*c,gi.y=y*l,wi.setFromAxisAngle(mi,u),yi.compose(vi,wi,gi),yi}const bi=new e;var xi;(t=>{t[t.DIMENSIONS_CHANGED=0]="DIMENSIONS_CHANGED"})(xi||(xi={}));class Si extends E{constructor(t){super(),this.zi=bi,this.Fi=2,this.Oi=2,this.ji=0,this.$i=0,this.Gi=2,this.Yi=2,this.qi=!1,this.Xi=1,this.Zi=0,this.Ji=0,this.Ki=0,this.Qi=0,this.ts=!1,this.ss=!1,this.es=!1,void 0!==t&&this.set(t)}get width(){return this.Fi/this.Xi}get height(){return this.Oi/this.Xi}get trimmedWidth(){return(this.qi?this.Yi:this.Gi)/this.Xi}get trimmedHeight(){return(this.qi?this.Gi:this.Yi)/this.Xi}get texture(){return this.zi}get rotated(){return this.qi}get scale(){return this.Xi}get trim(){const t=this.Xi;return{left:this.Zi/t,right:this.Ji/t,top:this.Ki/t,bottom:this.Qi/t}}get textureDirty(){return this.ts}get uvTransformDirty(){return this.ss}get trimDirty(){return this.es}setTextureDirtyFalse(){this.ts=!1}setUVTransformDirtyFalse(){this.ss=!1}setTrimDirtyFalse(){this.es=!1}calculateUVTransform(t=new n){const i=this.zi.image?.naturalWidth??2,s=this.zi.image?.naturalHeight??2;if(this.qi){const e=this.Gi,h=e/s;t.set(0,this.Yi/i,this.ji/i,-h,0,(s-this.$i-e)/s+h,0,0,1)}else t.set(this.Gi/i,0,this.ji/i,0,this.Yi/s,(s-this.$i-this.Yi)/s,0,0,1);return t}getResolution(t=new h){return t.set(this.width,this.height)}set(t){const i=this.width,s=this.height;t instanceof e?this.hs(t):this.rs(t),this.width===i&&this.height===s||this.emit(xi.DIMENSIONS_CHANGED,this.width,this.height,this)}hs(t){const i=t.image?.naturalWidth??2,s=t.image?.naturalHeight??2;this.Fi=i,this.Oi=s,this.texture!==t&&(this.zi=t,this.ts=!0),(0!==this.ji||0!==this.$i||this.Gi!==i||this.Yi!==s||1!==this.Xi||this.qi)&&(this.ji=0,this.$i=0,this.Gi=i,this.Yi=s,this.qi=!1,this.Xi=1,this.ss=!0),0===this.Zi&&0===this.Ji&&0===this.Ki&&0===this.Qi||(this.Zi=0,this.Ji=0,this.Ki=0,this.Qi=0,this.es=!0)}rs(t){this.Fi=t.sourceSize.w,this.Oi=t.sourceSize.h,this.texture!==t.texture&&(this.zi=t.texture,this.ts=!0);const i=t.scale??1,s=t.rotated??!1;0===this.ji&&0===this.$i&&this.Gi===t.frame.w&&this.Yi===t.frame.h&&this.Xi===i&&this.qi===s||(this.ji=t.frame.x,this.$i=t.frame.y,this.Gi=t.frame.w,this.Yi=t.frame.h,this.Xi=i,this.qi=s,this.ss=!0);const e=t.spriteSourceSize,h=e.x,r=e.y,n=this.Fi-e.x-e.w,o=this.Oi-e.y-e.h;this.Zi===h&&this.Ji===n&&this.Ki===r&&this.Qi===o||(this.Zi=h,this.Ji=n,this.Ki=r,this.Qi=o,this.es=!0)}}var Ii,Ei="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return texture2D(p_texture,transformedUV)*p_color;}";class Mi{constructor(t){this.xt=!0,this.ns=t?.x??0,this.cs=t?.y??0,this.ls=t?.anchorX??di,this.us=t?.anchorY??di,this.fs=t?.scaleX??1,this.ds=t?.scaleY??1,this.ps=t?.rotation??0,this.vs=t?.anchorMode??pi}get x(){return this.ns}get y(){return this.cs}get anchorX(){return this.ls}get anchorY(){return this.us}get scaleX(){return this.fs}get scaleY(){return this.ds}get angle(){return t.radToDeg(this.ps)}get anchorMode(){return this.vs}get rotation(){return this.ps}get dirty(){return this.xt}set x(t){t!==this.ns&&(this.ns=t,this.xt=!0)}set y(t){t!==this.cs&&(this.cs=t,this.xt=!0)}set anchorX(t){t!==this.ls&&(this.ls=t,this.xt=!0)}set anchorY(t){t!==this.us&&(this.us=t,this.xt=!0)}set scaleX(t){t!==this.fs&&(this.fs=t,this.xt=!0)}set scaleY(t){t!==this.ds&&(this.ds=t,this.xt=!0)}set angle(i){const s=t.degToRad(i);s!==this.ps&&(this.ps=s,this.xt=!0)}set rotation(t){t!==this.ps&&(this.ps=t,this.xt=!0)}set anchorMode(t){t!==this.vs&&(this.vs=t,this.xt=!0)}setDirtyFalse(){this.xt=!1}reset(){0===this.ns&&0===this.cs&&this.ls===di&&this.us===di&&1===this.fs&&1===this.ds&&0===this.ps||(this.ns=0,this.cs=0,this.ls=di,this.us=di,this.fs=1,this.ds=1,this.ps=0,this.xt=!0)}copy(t){this.ns===t.ns&&this.cs===t.cs&&this.ls===t.ls&&this.us===t.us&&this.fs===t.fs&&this.ds===t.ds&&this.ps===t.ps&&this.vs===t.vs||(this.ns=t.ns,this.cs=t.cs,this.ls=t.ls,this.us=t.us,this.fs=t.fs,this.ds=t.ds,this.ps=t.ps,this.vs=t.vs,this.xt=!0)}}class Ci{}class Ti extends Ci{constructor(t,i,s,e){super(),this.x=t,this.y=i,this.width=s,this.height=e}contains(t,i){return!(this.x>t||t>this.x+this.width||this.y>i||i>this.y+this.height)}}(t=>{t.PRESSED="pointerdown",t.MOVED="pointermove",t.RELEASED="pointerup",t.ENTERED="pointerenter",t.LEFT="pointerleave"})(Ii||(Ii={}));const Pi=M.VISIBLE;class Hi extends ui{constructor(t,i){const s=i?.width??64,e=i?.height??32;super(t,i),this.ws=!1,this.catchPointerDown=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.PRESSED),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.MOVED),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.RELEASED),this.interactionArea=i?.interactionArea??new Ti(0,0,1,1),this.modeInternal=i?.mode??Pi,this.inputWrapper=this.layer.inputWrapper,this.wVariable=this.solverWrapper.createVariable(s,Y.P6),this.hVariable=this.solverWrapper.createVariable(e,Y.P6),this.gs=this.inputWrapper.createInputCatcher(this.catchPointerDown,this.catchPointerMove,this.catchPointerUp,0),this.inputWrapper.setActive(this.gs,T(this.modeInternal))}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get oppositeX(){return this.x+this.width}get oppositeY(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get mode(){return this.modeInternal}get zIndex(){return this.inputWrapper.getZIndex(this.gs)}set width(t){this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){this.solverWrapper.suggestVariableValue(this.hVariable,t)}set oppositeX(t){this.x=t-this.width}set oppositeY(t){this.y=t-this.height}set centerX(t){this.x=t-this.width/2}set centerY(t){this.y=t-this.height/2}set mode(t){if(this.modeInternal!==t){const i=T(t);this.inputWrapper.setActive(this.gs,i),this.modeInternal=t}}set zIndex(t){this.inputWrapper.setZIndex(this.gs,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.inputWrapper.destroyInputCatcher(this.gs),super.destroy()}handleInputEvent(i,s,e,h){const r=this.interactionArea.contains(t.mapLinear(i,this.x,this.oppositeX,0,1),t.mapLinear(s,this.y,this.oppositeY,0,1));return r&&this.emit(h,i,s,e,this),this.ws&&!r?this.emit(Ii.LEFT,i,s,e,this):!this.ws&&r&&this.emit(Ii.ENTERED,i,s,e,this),this.ws=r,this.modeInternal!==M.INTERACTIVE_TRANSPARENT&&r}}const Ai=pt.BLEND;class Ui extends Hi{constructor(t,i,s,e){super(t,e),this.ys=!1,this._s=!1,this.micro=new Mi(e?.micro),this.bs=e?.transparencyMode??Ai,this.sceneWrapper=this.layer.sceneWrapper,this.planeHandler=this.sceneWrapper.createPlane(i,s,(new o).identity(),P(e?.mode??this.mode),this.bs),this.layer.on(Lt.RENDERING,this.onWillRender,this)}get transparencyMode(){return this.bs}set transparencyMode(t){this.bs!==t&&(this.bs=t,this.ys=!0)}set mode(t){this.modeInternal!==t&&(this._s=P(this.modeInternal)!==P(t),super.mode=t)}destroy(){this.layer.off(Lt.RENDERING,this.onWillRender,this),this.sceneWrapper.destroyPlane(this.planeHandler),super.destroy()}setPlaneTransform(){(this.micro.dirty||this.inputWrapper.dirty||this.solverWrapper.dirty)&&(this.sceneWrapper.setTransform(this.planeHandler,((t,i,s,e,h,r,n,o,a,c,l,u,f)=>{const d=s*this.micro.scaleX,p=e*this.micro.scaleY,v=o*d,w=a*p,g=Math.cos(u),y=Math.sin(u),m=v*g-w*y,_=v*y+w*g;if(f===fi.POSITION_ROTATION_SCALE)vi.x=t+r-m,vi.y=i+n-_;else{const h=a*e;vi.x=t+o*s-m+r,vi.y=i+h-_+n}return vi.z=h,gi.x=d,gi.y=p,wi.setFromAxisAngle(mi,u),yi.compose(vi,wi,gi),yi})(this.x,this.y,this.width,this.height,this.zIndex,this.micro.x,this.micro.y,this.micro.anchorX,this.micro.anchorY,0,0,this.micro.rotation,this.micro.anchorMode)),this.micro.setDirtyFalse())}onWillRender(t,i){this.ys&&(this.sceneWrapper.setTransparency(this.planeHandler,this.bs),this.ys=!1),this._s&&(this.sceneWrapper.setVisibility(this.planeHandler,P(this.modeInternal)),this._s=!1),this.setPlaneTransform()}}var Vi,Ri;(t=>{t[t.PLAYED=0]="PLAYED",t[t.PAUSED=1]="PAUSED",t[t.STOPPED=2]="STOPPED"})(Vi||(Vi={})),(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(Ri||(Ri={}));const Bi=Ri.LOOP;class Li extends Ui{constructor(t,i,s={}){const e=new Q(s.color),h=i.map(t=>new Si(t)),r=h[0];s.width=s.width??r.width,s.height=s.height??r.height;const n=r.calculateUVTransform();super(t,Ei,{texture:r.texture,textureTransform:n,color:e},s),this.xs=!1,this.Ss=0,this.Is=!1,this.Es=0,this.Ms=(t,i,s)=>{this.Cs[this.Ss]===s&&(this.width=t,this.height=i)},this.Ts=e,this.Cs=h,this.Ps=n,this.Hs=s.frameRate??24,this.As=s.timeScale??1,this.Us=s.loopMode??Bi,this.Vs(),!0===s.playByDefault&&this.play()}get color(){return this.Ts}get duration(){return this.Cs.length/this.Hs}get frameRate(){return this.Hs}get loopMode(){return this.Us}get sequence(){return this.Cs}get timeScale(){return this.As}set color(t){this.Ts.set(t)}set frameRate(t){this.Hs=t}set loopMode(t){this.Us=t}set sequence(t){this.stop(),this.Rs();const i=t.length,s=this.Cs.length;for(let e=0;Math.min(i,s)>e;e++)this.Cs[e].set(t[e]);if(s>i)this.Cs.length=i;else if(i>s)for(let e=s;i>e;e++)this.Cs.push(new Si(t[e]));this.Vs()}set timeScale(t){this.As=t}destroy(){this.Rs(),super.destroy()}play(){this.xs||(this.xs=!0,this.emit(Vi.PLAYED))}pause(){this.xs&&(this.xs=!1,this.emit(Vi.PAUSED))}stop(){(this.xs||this.Es>0||this.Ss>0)&&(this.xs=!1,this.Es=0,this.Ss=0,this.Is=!0,this.emit(Vi.STOPPED))}onWillRender(t,i){if(this.xs&&0!==this.As){this.Es+=i*this.As;const t=1/this.Hs,s=this.Cs.length,e=s-1;if(this.As>0)for(;this.Es>=t;){if(this.Es-=t,this.Ss+=1,this.Ss>=s)if(this.Us===Ri.LOOP)this.Ss=0;else{if(this.Us!==Ri.PING_PONG){this.Ss=e,this.xs=!1,this.emit(Vi.PAUSED);break}this.Ss=e,this.As=-this.As}this.Is=!0}else for(;-t>=this.Es;){if(this.Es+=t,this.Ss-=1,0>this.Ss)if(this.Us===Ri.LOOP)this.Ss=e;else{if(this.Us!==Ri.PING_PONG){this.Ss=0,this.xs=!1,this.emit(Vi.PAUSED);break}this.Ss=0,this.As=-this.As}this.Is=!0}}super.onWillRender(t,i)}setPlaneTransform(){let t;this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse());const i=this.Cs[this.Ss];if((i.textureDirty||this.Is)&&(t??(t={}),t.texture=i.texture,i.setTextureDirtyFalse()),(i.uvTransformDirty||this.Is)&&(t??(t={}),t.textureTransform=i.calculateUVTransform(this.Ps),i.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.Is||this.micro.dirty||i.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,s=i.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,s.left,s.right,s.top,s.bottom)),this.Is=!1,this.micro.setDirtyFalse(),i.setTrimDirtyFalse()}}Vs(){for(const t of this.Cs)t.on(xi.DIMENSIONS_CHANGED,this.Ms)}Rs(){for(const t of this.Cs)t.off(xi.DIMENSIONS_CHANGED,this.Ms)}}const Di=new Q;class ki extends Ui{constructor(t,i){const s=i?.width??2,e=i?.height??2,h=new Q(i?.color),r=new OffscreenCanvas(s,e),n=r.getContext("2d");if(!n)throw Error("UIGraphics.constructor: failed to get 2D context from OffscreenCanvas");const a=new w(r);a.colorSpace=g,a.minFilter=y,a.magFilter=y,a.needsUpdate=!0,super(t,Ei,{texture:a,textureTransform:new o,color:h},i),this.Bs=r,this.Ls=n,this.Ds=a,this.Ts=h}get color(){return this.Ts}set color(t){this.Ts.set(t)}clear(t){return this.Ls.clearRect(0,0,this.Bs.width,this.Bs.height),void 0!==t&&(this.Ls.fillStyle=Di.set(t).toCSSColor(),this.Ls.fillRect(0,0,this.Bs.width,this.Bs.height)),this.Ds.needsUpdate=!0,this}drawRect(t,i,s,e,h){return this.Ls.fillStyle=Di.set(h).toCSSColor(),this.Ls.fillRect(t,i,s,e),this.Ds.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.Ls.fillStyle=Di.set(e).toCSSColor(),this.Ls.beginPath(),this.Ls.arc(t,i,s,0,2*Math.PI),this.Ls.fill(),this.Ds.needsUpdate=!0,this}drawArc(t,i,s,e,h,r){return this.Ls.fillStyle=Di.set(r).toCSSColor(),this.Ls.beginPath(),this.Ls.arc(t,i,s,e,h),this.Ls.fill(),this.Ds.needsUpdate=!0,this}drawPolyline(t,i,s=1){if(2>t.length)return this;this.Ls.strokeStyle=Di.set(i).toCSSColor(),this.Ls.lineWidth=s,this.Ls.beginPath(),this.Ls.moveTo(t[0][0],t[0][1]);for(let i=1;t.length>i;i++)this.Ls.lineTo(t[i][0],t[i][1]);return this.Ls.stroke(),this.Ds.needsUpdate=!0,this}destroy(){this.Ds.dispose(),super.destroy()}onWillRender(t,i){this.Ts.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Ts}),this.Ts.setDirtyFalse()),super.onWillRender(t,i)}}class Wi extends Ui{constructor(t,i,s={}){const e=new Q(s.color),h=new Si(i),r=h.calculateUVTransform();s.width=s.width??h.width,s.height=s.height??h.height,super(t,Ei,{texture:h.texture,textureTransform:r,color:e},s),this.Ms=(t,i)=>{this.width=t,this.height=i},this.texture=h,this.Ps=r,this.Ts=e,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}set color(t){this.Ts.set(t)}destroy(){this.texture.off(xi.DIMENSIONS_CHANGED,this.Ms),super.destroy()}setPlaneTransform(){let t;if(this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class Ni{constructor(t){this.bt=0,this.dt=0,this.Ri=0,this.wt=0,this.xt=!1,this.set(t)}get left(){return this.bt}get right(){return this.dt}get top(){return this.Ri}get bottom(){return this.wt}get dirty(){return this.xt}set left(t){this.bt!==t&&(this.bt=t,this.xt=!0)}set right(t){this.dt!==t&&(this.dt=t,this.xt=!0)}set top(t){this.Ri!==t&&(this.Ri=t,this.xt=!0)}set bottom(t){this.wt!==t&&(this.wt=t,this.xt=!0)}setHorizontal(t){this.bt===t&&this.dt===t||(this.bt=t,this.dt=t,this.xt=!0)}setVertical(t){this.Ri===t&&this.wt===t||(this.Ri=t,this.wt=t,this.xt=!0)}setUnified(t){this.bt===t&&this.dt===t&&this.Ri===t&&this.wt===t||(this.bt=t,this.dt=t,this.Ri=t,this.wt=t,this.xt=!0)}set(t){const i=this.bt,s=this.dt,e=this.Ri,h=this.wt;if(void 0===t)this.bt=0,this.dt=0,this.Ri=0,this.wt=0;else if("number"==typeof t)this.bt=t,this.dt=t,this.Ri=t,this.wt=t;else if(Array.isArray(t))if(2===t.length){const i=t[0],s=t[1];this.bt=i,this.dt=i,this.Ri=s,this.wt=s}else{const i=t[1],s=t[2],e=t[3];this.bt=t[0],this.dt=i,this.Ri=s,this.wt=e}else if("left"in t){const i=t.right,s=t.top,e=t.bottom;this.bt=t.left,this.dt=i,this.Ri=s,this.wt=e}else{const i=t.horizontal,s=t.vertical;this.bt=i,this.dt=i,this.Ri=s,this.wt=s}this.bt===i&&this.dt===s&&this.Ri===e&&this.wt===h||(this.xt=!0)}setVector4(t){this.bt===t.x&&this.dt===t.y&&this.Ri===t.z&&this.wt===t.w||(this.bt=t.x,this.dt=t.y,this.Ri=t.z,this.wt=t.w,this.xt=!0)}toVector4(t=new s){return t.set(this.bt,this.dt,this.Ri,this.wt)}reset(){this.setUnified(0)}copy(t){this.bt===t.bt&&this.dt===t.dt&&this.Ri===t.Ri&&this.wt===t.wt||(this.bt=t.bt,this.dt=t.dt,this.Ri=t.Ri,this.wt=t.wt,this.xt=!0)}setDirtyFalse(){this.xt=!1}}var zi;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(zi||(zi={}));const Fi=zi.WORLD;class Oi extends Ui{constructor(t,i,e={}){const h=new Q(e.color),r=new Si(i),n=r.calculateUVTransform();e.width=e.width??r.width,e.height=e.height??r.height;const o=new Ni(e.sliceBorders??.1),a=new Ni(e.sliceRegions??.1),c=e.regionMode??Fi,l=new s,u=new s;super(t,"vec4 draw(){vec2 localUV=p_uv;float left=p_sliceBorders.x;float right=p_sliceBorders.y;float top=p_sliceBorders.z;float bottom=p_sliceBorders.w;float leftFill=p_sliceRegions.x;float rightFill=p_sliceRegions.y;float topFill=p_sliceRegions.z;float bottomFill=p_sliceRegions.w;float lB=leftFill;float rB=1.0-rightFill;float bB=bottomFill;float tB=1.0-topFill;{float regionL=step(p_uv.x,lB);float regionR=step(rB,p_uv.x);float regionM=1.0-regionL-regionR;float xL=(p_uv.x/lB)*left;float xR=1.0-right+((p_uv.x-rB)/rightFill)*right;float xM=left+((p_uv.x-lB)/(rB-lB))*(1.0-left-right);localUV.x=regionL*xL+regionM*xM+regionR*xR;}{float regionB=step(p_uv.y,bB);float regionT=step(tB,p_uv.y);float regionC=1.0-regionB-regionT;float yB=(p_uv.y/bB)*bottom;float yT=1.0-top+((p_uv.y-tB)/topFill)*top;float yC=bottom+((p_uv.y-bB)/(tB-bB))*(1.0-bottom-top);localUV.y=regionB*yB+regionC*yC+regionT*yT;}vec2 transformedUV=(p_textureTransform*vec3(localUV,1.0)).xy;return texture2D(p_texture,transformedUV)*p_color;}",{texture:r.texture,textureTransform:n,color:h,sliceBorders:l,sliceRegions:u},e),this.ks=!0,this.Ws=new s,this.Ns=new s,this.zs=!0,this.Ms=()=>{this.zs=!0},this.texture=r,this.Ps=n,this.Ts=h,this.Fs=o,this.Os=a,this.js=c,this.Ws=l,this.Ns=u,this.$s=this.width,this.Gs=this.height,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}get regionMode(){return this.js}get sliceBorders(){return this.Fs}get sliceRegions(){return this.Os}set color(t){this.Ts.set(t)}set regionMode(t){this.js!==t&&(this.js=t,this.ks=!0)}set sliceBorders(t){this.Fs.set(t)}set sliceRegions(t){this.Os.set(t)}destroy(){this.texture.off(xi.DIMENSIONS_CHANGED,this.Ms),super.destroy()}setPlaneTransform(){let t;if((this.zs||this.Fs.dirty||this.texture.trimDirty)&&(t??(t={}),t.sliceBorders=this.Ys(this.Ws),this.Fs.setDirtyFalse(),this.zs=!1),(this.Os.dirty||this.ks||this.js===zi.WORLD&&this.qs())&&(t??(t={}),t.sliceRegions=this.Xs(this.Ns),this.Os.setDirtyFalse(),this.ks=!1,this.Zs()),this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}Ys(t){const i=this.texture.width,s=this.texture.height,e=this.texture.trim,h=e.right/i,r=e.top/s,n=e.bottom/s,o=(i-e.left-e.right)/i,a=(s-e.top-e.bottom)/s,c=this.Fs.right,l=this.Fs.top,u=this.Fs.bottom,f=Math.max(0,this.Fs.left-e.left/i)/o,d=Math.max(0,c-h)/o,p=Math.max(0,l-r)/a,v=Math.max(0,u-n)/a;return t.set(Math.min(1,f),Math.min(1,d),Math.min(1,p),Math.min(1,v))}Xs(t){if(this.js===zi.NORMALIZED)return t.set(this.Os.left,this.Os.right,this.Os.top,this.Os.bottom);const i=this.width,s=this.height;return t.set(this.Os.left/i,this.Os.right/i,this.Os.top/s,this.Os.bottom/s)}qs(){return this.solverWrapper.dirty&&(this.$s!==Math.round(this.width)||this.Gs!==Math.round(this.height))}Zs(){this.$s=Math.round(this.width),this.Gs=Math.round(this.height)}}class ji{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class $i extends ji{constructor(t={x:1,y:0}){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 halfExtents=vec2(aspect,1.0)*0.5;float maxProjection=dot(halfExtents,abs(p_direction));vec2 correctedUV=(p_uv-0.5)*vec2(aspect,1.0);float projection=dot(correctedUV,p_direction);float offset=(projection/maxProjection+1.0)*0.5;return step(offset,p_progress);}"),this.direction=new h,this.Js=new h,this.direction.copy(t).normalize(),this.Js.copy(this.direction)}get dirty(){return this.Ks(),this.dirtyInternal||!this.Js.equals(this.direction)}setDirtyFalse(){this.Ks(),this.Js.copy(this.direction),super.setDirtyFalse()}enumerateProperties(){return this.Ks(),{direction:this.direction}}Ks(){const t=this.direction.lengthSq();Math.abs(t)>Ot?Math.abs(t-1)>Ot&&this.direction.divideScalar(t):this.direction.set(1,0)}}var Gi,Yi="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;vec4 diffuseColor=texture2D(p_texture,transformedUV)*p_color;diffuseColor.a*=calculateMask();return diffuseColor;}";class qi extends Ui{constructor(i,s,e={}){const h=new Q(e.color),r=new Si(s),n=r.calculateUVTransform(),o=r.getResolution();e.width=e.width??r.width,e.height=e.height??r.height;const a=t.clamp(e.progress??1,0,1),c=e.maskFunction??new $i;super(i,c.source+Yi,{texture:r.texture,textureTransform:n,textureResolution:o,color:h,progress:a,...c.enumerateProperties()},e),this.Qs=!1,this.te=!1,this.Ms=(t,i)=>{this.width===t&&this.height===i||(this.width=t,this.height=i,this.te=!0)},this.texture=r,this.Ps=n,this.ie=o,this.Ts=h,this.se=a,this.ee=c,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}get maskFunction(){return this.ee}get progress(){return this.se}set color(t){this.Ts.set(t)}set maskFunction(t){this.ee!==t&&(this.ee=t,this.he())}set progress(i){i=t.clamp(i,0,1),this.se!==i&&(this.se=i,this.Qs=!0)}setPlaneTransform(){let t;if(this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),this.Qs&&(t??(t={}),t.progress=this.se,this.Qs=!1),this.te&&(t??(t={}),t.textureResolution=this.texture.getResolution(this.ie),this.te=!1),this.maskFunction.dirty){t??(t={});const i=this.maskFunction.enumerateProperties();for(const s in i)t[s]=i[s];this.maskFunction.setDirtyFalse()}if(t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}he(){this.sceneWrapper.destroyPlane(this.planeHandler);const t=this.micro,i=this.texture.trim;this.planeHandler=this.sceneWrapper.createPlane(this.ee.source+Yi,{texture:this.texture.texture,textureTransform:this.texture.calculateUVTransform(this.Ps),textureResolution:this.texture.getResolution(this.ie),color:this.Ts,progress:this.se,...this.ee.enumerateProperties()},_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom),P(this.mode),this.transparencyMode),this.Ts.setDirtyFalse(),this.texture.setTextureDirtyFalse(),this.texture.setUVTransformDirtyFalse(),this.texture.setTrimDirtyFalse(),this.Qs=!1,this.te=!1,this.ee.setDirtyFalse(),this.micro.setDirtyFalse()}}(t=>{t[t.EVERY_FRAME=1]="EVERY_FRAME",t[t.EVERY_SECOND_FRAME=2]="EVERY_SECOND_FRAME",t[t.ON_PROPERTIES_CHANGE=3]="ON_PROPERTIES_CHANGE",t[t.ON_DIMENSIONS_CHANGE=4]="ON_DIMENSIONS_CHANGE",t[t.MANUAL=5]="MANUAL"})(Gi||(Gi={}));const Xi=Gi.ON_PROPERTIES_CHANGE,Zi=new Q(0,0,0,1);class Ji extends Ui{constructor(i,s={}){const e=t.clamp(s.resolutionFactor??.5,.1,2),h=s.width??64,r=s.height??32,o=new m(h*e,r*e,{format:b,minFilter:y,magFilter:y,type:_,depthBuffer:s.enableDepthBuffer??!0,stencilBuffer:!1}),a=new Q(s.color);super(i,Ei,{texture:o.texture,textureTransform:new n,color:a},s),this.re=!0,this.ne=!1,this.oe=!1,this.ae=!1,this.Ts=a,this.ce=new Q(s.clearColor??Zi),this.le=o,this.ue=s.scene??new d,this.fe=s.camera??new x(60,h/r,.1,100),this.de=e,this.pe=s.updateMode??Xi,this.ae=s.updateMode!==Gi.MANUAL}get camera(){return this.fe}get clearColor(){return this.ce}get color(){return this.Ts}get resolutionFactor(){return this.de}get scene(){return this.ue}get updateMode(){return this.pe}set camera(t){this.fe!==t&&(this.fe=t,this.ae=!0)}set clearColor(t){this.ce.set(t)}set color(t){this.Ts.set(t)}set resolutionFactor(i){i=t.clamp(i,.1,2),this.de!==i&&(this.de=i,this.oe=!0)}set scene(t){this.ue!==t&&(this.ue=t,this.ae=!0)}set updateMode(t){this.pe!==t&&(this.pe=t,this.ae=!0)}destroy(){this.le.dispose(),super.destroy()}requestUpdate(){this.ne=!0}onWillRender(t,i){this.re=!this.re,(this.ne||this.pe===Gi.EVERY_FRAME||this.pe===Gi.EVERY_SECOND_FRAME&&this.re||this.pe===Gi.ON_PROPERTIES_CHANGE&&this.ae||this.Ts.dirty||this.ce.dirty||this.pe===Gi.ON_DIMENSIONS_CHANGE&&(this.oe||this.solverWrapper.dirty))&&((this.oe||this.solverWrapper.dirty)&&(this.le.setSize(this.width*this.de,this.height*this.de),this.oe=!1),this.Ts.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Ts}),this.Ts.setDirtyFalse()),t.setClearColor(this.ce.getHexRGB(),this.ce.a),t.setRenderTarget(this.le),t.clear(!0,!0,!1),t.render(this.ue,this.fe),this.ae=!1,this.ne=!1),super.onWillRender(t,i)}}const Ki="#000000",Qi="left",ts="Arial",is="normal",ss="normal",es=!1,hs="transparent",rs=!1,ns="#000000";class os{constructor(t){this.xt=!0,this.Ts=t?.color,this.ve=t?.align,this.we=t?.fontFamily,this.ge=t?.fontSize,this.ye=t?.fontStyle,this.me=t?.fontWeight,this._e=t?.lineHeight,this.be=t?.enableShadow,this.xe=t?.shadowOffsetX,this.Se=t?.shadowOffsetY,this.Ie=t?.shadowBlur,this.Ee=t?.shadowColor,this.Me=t?.enableStroke,this.Ce=t?.strokeColor,this.Te=t?.strokeThickness}get color(){return this.Ts}get align(){return this.ve}get fontFamily(){return this.we}get fontSize(){return this.ge}get fontStyle(){return this.ye}get fontWeight(){return this.me}get lineHeight(){return this._e}get enableShadow(){return this.be}get shadowOffsetX(){return this.xe}get shadowOffsetY(){return this.Se}get shadowBlur(){return this.Ie}get shadowColor(){return this.Ee}get enableStroke(){return this.Me}get strokeColor(){return this.Ce}get strokeThickness(){return this.Te}get dirty(){return this.xt}set color(t){t!==this.Ts&&(this.Ts=t,this.xt=!0)}set align(t){t!==this.ve&&(this.ve=t,this.xt=!0)}set fontFamily(t){t!==this.we&&(this.we=t,this.xt=!0)}set fontSize(t){t!==this.ge&&(this.ge=t,this.xt=!0)}set fontStyle(t){t!==this.ye&&(this.ye=t,this.xt=!0)}set fontWeight(t){t!==this.me&&(this.me=t,this.xt=!0)}set lineHeight(t){t!==this._e&&(this._e=t,this.xt=!0)}set enableShadow(t){t!==this.be&&(this.be=t,this.xt=!0)}set shadowOffsetX(t){t!==this.xe&&(this.xe=t,this.xt=!0)}set shadowOffsetY(t){t!==this.Se&&(this.Se=t,this.xt=!0)}set shadowBlur(t){t!==this.Ie&&(this.Ie=t,this.xt=!0)}set shadowColor(t){t!==this.Ee&&(this.Ee=t,this.xt=!0)}set enableStroke(t){t!==this.Me&&(this.Me=t,this.xt=!0)}set strokeColor(t){t!==this.Ce&&(this.Ce=t,this.xt=!0)}set strokeThickness(t){t!==this.Te&&(this.Te=t,this.xt=!0)}static resolve(t,i){const s=t.ge??i.ge??16;return{color:t.Ts??i.Ts??Ki,align:t.ve??i.ve??Qi,fontFamily:t.we??i.we??ts,fontSize:s,fontStyle:t.ye??i.ye??is,fontWeight:t.me??i.me??ss,lineHeight:t._e??i._e??1.2*s,enableShadow:t.be??i.be??es,shadowOffsetX:t.xe??i.xe??0,shadowOffsetY:t.Se??i.Se??0,shadowBlur:t.Ie??i.Ie??0,shadowColor:t.Ee??i.Ee??hs,enableStroke:t.Me??i.Me??rs,strokeColor:t.Ce??i.Ce??ns,strokeThickness:t.Te??i.Te??0}}setDirtyFalse(){this.xt=!1}setDefaults(){this.Ts===Ki&&this.ve===Qi&&this.we===ts&&16===this.ge&&this.ye===is&&this.me===ss&&19.2===this._e&&this.be===es&&0===this.xe&&0===this.Se&&0===this.Ie&&this.Ee===hs&&this.Me===rs&&this.Ce===ns&&0===this.Te||(this.Ts=Ki,this.ve=Qi,this.we=ts,this.ge=16,this.ye=is,this.me=ss,this._e=19.2,this.be=es,this.xe=0,this.Se=0,this.Ie=0,this.Ee=hs,this.Me=rs,this.Ce=ns,this.Te=0,this.xt=!0)}clear(){void 0===this.Ts&&void 0===this.ve&&void 0===this.we&&void 0===this.ge&&void 0===this.ye&&void 0===this.me&&void 0===this._e&&void 0===this.be&&void 0===this.xe&&void 0===this.Se&&void 0===this.Ie&&void 0===this.Ee&&void 0===this.Me&&void 0===this.Ce&&void 0===this.Te||(this.Ts=void 0,this.ve=void 0,this.we=void 0,this.ge=void 0,this.ye=void 0,this.me=void 0,this._e=void 0,this.be=void 0,this.xe=void 0,this.Se=void 0,this.Ie=void 0,this.Ee=void 0,this.Me=void 0,this.Ce=void 0,this.Te=void 0,this.xt=!0)}copy(t){this.Ts===t.Ts&&this.ve===t.ve&&this.we===t.we&&this.ge===t.ge&&this.ye===t.ye&&this.me===t.me&&this._e===t._e&&this.be===t.be&&this.xe===t.xe&&this.Se===t.Se&&this.Ie===t.Ie&&this.Ee===t.Ee&&this.Me===t.Me&&this.Ce===t.Ce&&this.Te===t.Te||(this.Ts=t.Ts,this.ve=t.ve,this.we=t.we,this.ge=t.ge,this.ye=t.ye,this.me=t.me,this._e=t._e,this.be=t.be,this.xe=t.xe,this.Se=t.Se,this.Ie=t.Ie,this.Ee=t.Ee,this.Me=t.Me,this.Ce=t.Ce,this.Te=t.Te,this.xt=!0)}calculatePadding(){let t=0;if(void 0!==this.Me&&(t+=this.Te??0),void 0!==this.be){const i=this.Se??0,s=2*(this.Ie??0);t+=Math.max(Math.abs(this.xe??0)+s,Math.abs(i)+s)}return Math.ceil(t)}}class as{constructor(t){this.xt=!0,this.Pe=t.text,this.style=new os(t.style)}get text(){return this.Pe}get dirty(){return this.xt||this.style.dirty}set text(t){t!==this.Pe&&(this.Pe=t,this.xt=!0)}setDirtyFalse(){this.xt=!1,this.style.setDirtyFalse()}}var cs;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(cs||(cs={}));const ls=cs.SCALE;function us(t){return t.match(/\S+|\s|\n/g)??[]}function fs(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px "${s.fontFamily}"`,"\n"===i)return{width:1,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const e=t.measureText(i);return{width:Math.ceil(e.width),height:Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent),baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function ds(t,i){const s=((t,i)=>{const s=[];let e=[],h=0,r=0,n=0,o=0;for(const a of i)"\n"!==a.text?0!==e.length&&h+a.metrics.width>t?(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})(i,t),e=(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}return{width:i,height:s}})(s);return{lines:s,size:e}}function ps(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.strokeThickness,h.strokeText(s,t,i)),h.fillStyle=e.color,h.fillText(s,t,i)}function vs(t,i,s,e){let h=t,r=0;for(const t of s)r=Math.max(t.width,r);for(let t=0;s.length>t;t++){const n=s[t],o=n.chunks[0]?.style.align??Qi,a=n.chunks.every(t=>t.style.align===o)?o:Qi;let c=0;"center"===a?c=(r-n.width)/2:"right"===a&&(c=r-n.width);let l=i+c;h+=0===t?n.height:n.lineHeight;for(const t of n.chunks)ps(l,h,t.text,t.style,e),l+=t.metrics.width}}class ws extends Ui{constructor(t,i,s={}){const e=new OffscreenCanvas(2,2),h=e.getContext("2d");if(!h)throw Error("UIText.constructor: failed to create canvas context");const r=new w(e);r.colorSpace=g,r.needsUpdate=!0;const o=new Q(s.color);switch(super(t,Ei,{texture:r,textureTransform:new n,color:o}),this.He=[],this.Ae=!1,this.Ue=!1,this.Ve=!1,this.Re=[],this.Be=!1,this.Ts=o,this.De=new Ni(s.padding),this.commonStyle=new os(s.commonStyle),this.ke=s.maxLineWidth??1024,this.We=s.resizeMode??ls,this.Bs=e,this.Ls=h,this.Ds=r,this.content=i,this.Ne=this.width,this.ze=this.height,void 0===s.padding&&this.De.setUnified(this.content.reduce((t,i)=>Math.max(t,i.style.calculatePadding()),this.commonStyle.calculatePadding())),this.We){case cs.SCALE:this.Fe();break;case cs.BREAK:this.Oe()}}get color(){return this.Ts}get content(){return this.He}get maxLineWidth(){return this.ke}get padding(){return this.De}get resizeMode(){return this.We}set color(t){this.Ts.set(t)}set content(t){this.He!==t&&(this.He="string"==typeof t?[new as({text:t,style:new os})]:Array.isArray(t)?t.map(t=>new as("string"==typeof t?{text:t,style:new os}:{text:t.text,style:new os(t.style)})):[new as({text:t.text,style:new os(t.style)})],this.Ae=!0,this.Be=!0)}set maxLineWidth(t){this.ke!==t&&(this.ke=t,this.Ue=!0)}set padding(t){this.De.set(t)}set resizeMode(t){this.We!==t&&(this.We=t,this.Ve=!0)}destroy(){this.Ds.dispose(),super.destroy()}onWillRender(t,i){switch(this.We){case cs.SCALE:this.Fe();break;case cs.BREAK:this.Oe()}super.onWillRender(t,i)}Fe(){if(!(this.Ts.dirty||this.Ve||this.Ue||this.De.dirty||this.solverWrapper.dirty&&this.Ne/this.ze!==Math.round(this.width)/Math.round(this.height)||this.je()))return;const t=this.$e(),{lines:i,size:s}=ds(t,this.ke),e=s.height+(this.De.top+this.De.bottom),h=s.width+(this.De.left+this.De.right);this.width=h,this.height=e/h*Math.round(this.width),this.width=h/e*Math.round(this.height);const r=this.Ne!==e||this.ze!==h;r&&(this.Bs.height=e,this.Bs.width=h),vs(this.De.top,this.De.left,i,this.Ls),this.Ye(r),this.Ve=!1,this.Ue=!1,this.De.setDirtyFalse(),this.qe(),this.Xe()}Oe(){if(!(this.Ts.dirty||this.Ve||this.Ue||this.De.dirty||this.Ze()||this.je()))return;const t=this.$e(),{size:i}=ds(t,this.ke),s=this.De.top+this.De.bottom,e=this.De.left+this.De.right;this.height=i.height+s,this.width=i.width+e;const{lines:h,size:r}=ds(t,Math.round(this.width)-e);this.height=r.height+s,this.width=r.width+e;const n=Math.max(Math.round(this.width),2),o=Math.max(Math.round(this.height),2),a=this.Ne!==n||this.ze!==o;a&&(this.Bs.width=n,this.Bs.height=o),vs(this.De.top,this.De.left,h,this.Ls),this.Ye(a),this.Ve=!1,this.Ue=!1,this.De.setDirtyFalse(),this.qe(),this.Xe()}Ye(t){let i;this.Ts.dirty&&(i??(i={}),i.color=this.Ts,this.Ts.setDirtyFalse()),t&&(this.Ds.dispose(),this.Ds=new w(this.Bs),this.Ds.colorSpace=g,this.Ds.needsUpdate=!0,i??(i={}),i.texture=this.Ds),i&&this.sceneWrapper.setProperties(this.planeHandler,i)}$e(){return this.Be&&(this.Re=((t,i,s)=>{const e=[];for(const h of i){const i=os.resolve(h.style,s);for(const s of us(h.text)){const h=fs(t,s,i);e.push({text:s,style:i,metrics:h})}}return e})(this.Ls,this.He,this.commonStyle),this.Be=!1),this.Re}Ze(){return this.solverWrapper.dirty&&(this.Ne!==Math.round(this.width)||this.ze!==Math.round(this.height))}qe(){this.Ne=Math.round(this.width),this.ze=Math.round(this.height)}je(){return this.Ae||this.content.some(t=>t.dirty)}Xe(){this.Ae=!1;for(const t of this.content)t.setDirtyFalse()}}class gs{constructor(){this.dirty=!1}}class ys extends gs{calculateScale(t,i){return 1}}const ms=new ys;class _s extends Wt{constructor(t){const i=t?.resizePolicy??ms,s=i.calculateScale(window.innerWidth,window.innerHeight);super({width:window.innerWidth*s,height:window.innerHeight*s,...t}),this.Je=!1,this.Ke=()=>{const t=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight);this.resizePolicy.dirty=!1,this.Je=!1,this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.Qe=t=>{this.th(t,"onPointerDown",Ii.PRESSED)},this.ih=t=>{this.th(t,"onPointerMove",Ii.MOVED)},this.sh=t=>{this.th(t,"onPointerUp",Ii.RELEASED)},this.eh=i,window.addEventListener("resize",this.Ke),window.addEventListener("pointerdown",this.Qe),window.addEventListener("pointermove",this.ih),window.addEventListener("pointerup",this.sh)}get resizePolicy(){return this.eh}set resizePolicy(t){this.eh!==t&&(this.eh=t,this.Je=!0)}destroy(){window.removeEventListener("resize",this.Ke),window.removeEventListener("pointerdown",this.Qe),window.removeEventListener("pointermove",this.ih),window.removeEventListener("pointerup",this.sh)}render(t,i){(this.resizePolicy.dirty||this.Je)&&this.Ke(),super.renderInternal(t,i)}projectWorldPosition(i,s,e=new r){return e.copy(i).project(s),e.x=t.mapLinear(e.x,-1,1,this.x,this.width),e.y=t.mapLinear(e.y,-1,1,this.y,this.height),e}projectLayerPosition(i,s,e=-1,h=new r){return h.set(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),e).unproject(s)}buildRay(i,s,e=new S){const h=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),-1).unproject(s),n=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),1).unproject(s).sub(h).normalize();return e.set(h,n)}th(t,i,s){const e=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,h=e?t.clientX-e.left:t.clientX,r=e?e.bottom-t.clientY:window.innerHeight-t.clientY,n=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight),o=h*n,a=r*n;T(this.mode)&&(this.emit(s,o,a,t.pointerId),this.inputWrapperInternal[i](o,a,t.pointerId))}}class bs extends Ci{constructor(t,i,s){super(),this.centerX=t,this.centerY=i,this.radius=s}contains(t,i){const s=t-this.centerX,e=i-this.centerY;return this.radius*this.radius>=s*s+e*e}}class xs extends Ci{constructor(t){super(),this.vertices=t}contains(t,i){const s=this.vertices.length;if(3>s)return!1;let e=!1;for(let h=0,r=s-1;s>h;r=h++){const s=this.vertices[h],n=this.vertices[r],o=s.x,a=s.y,c=n.y;a>i!=c>i&&(n.x-o)*(i-a)/(c-a)+o>t&&(e=!e)}return e}}class Ss extends Ci{constructor(t,i,s,e,h){super(),this.x=t,this.y=i,this.width=s,this.height=e,this.radius=h,this.radius=Math.min(h,Math.min(s,e)/2)}contains(t,i){const s=this.x,e=this.x+this.width,h=this.y,r=this.y+this.height;if(s>t||t>e||h>i||i>r)return!1;const n=s+this.radius,o=e-this.radius,a=h+this.radius,c=r-this.radius;if(t>=n&&o>=t)return!0;if(i>=a&&c>=i)return!0;let l,u;l=n>t?n:o,u=a>i?a:c;const f=t-l,d=i-u;return this.radius*this.radius>=f*f+d*d}}class Is extends ji{constructor(t=0,i=!1){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 p=(p_uv-0.5)*vec2(aspect,1.0);float angle=atan(p.y,p.x);angle=(angle+PI)/(2.0*PI);float adjusted=angle-p_startAngle;adjusted=p_direction>0.0 ? adjusted :-adjusted;adjusted=fract(adjusted);return step(adjusted,p_progress);}"),this.hh=t,this.rh=i}get startAngle(){return this.hh}get inverseDirection(){return this.rh}set startAngle(t){this.hh!==t&&(this.hh=t,this.dirtyInternal=!0)}set inverseDirection(t){this.rh!==t&&(this.rh=t,this.dirtyInternal=!0)}enumerateProperties(){return{direction:this.rh?-1:1,startAngle:this.hh}}}class Es extends gs{constructor(t,i){super(),this.nh=t,this.oh=i}get rectWidth(){return this.nh}get rectHeight(){return this.oh}set rectWidth(t){t!==this.nh&&(this.nh=t,this.dirty=!0)}set rectHeight(t){t!==this.oh&&(this.oh=t,this.dirty=!0)}calculateScale(t,i){return Math.min(this.nh/t,this.oh/i)}}class Ms extends gs{constructor(t,i){super(),this.ah=t,this.uh=i}get fixedWidthLandscape(){return this.ah}get fixedHeightPortrait(){return this.uh}set fixedWidthLandscape(t){t!==this.ah&&(this.ah=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.uh&&(this.uh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ah/t:this.uh/i}}class Cs extends gs{constructor(t,i){super(),this.fh=t,this.dh=i}get fixedHeightLandscape(){return this.fh}get fixedWidthPortrait(){return this.dh}set fixedHeightLandscape(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.fh/i:this.dh/t}}class Ts extends gs{constructor(t,i){super(),this.nh=t,this.oh=i}get rectWidth(){return this.nh}get rectHeight(){return this.oh}set rectWidth(t){t!==this.nh&&(this.nh=t,this.dirty=!0)}set rectHeight(t){t!==this.oh&&(this.oh=t,this.dirty=!0)}calculateScale(t,i){return Math.max(this.nh/t,this.oh/i)}}class Ps extends gs{constructor(t,i){super(),this.fh=t,this.uh=i}get fixedHeightLandscape(){return this.fh}get fixedHeightPortrait(){return this.uh}set fixedHeightLandscape(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.uh&&(this.uh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.fh/i:this.uh/i}}class Hs extends gs{constructor(t,i){super(),this.ah=t,this.dh=i}get fixedWidthLandscape(){return this.ah}get fixedWidthPortrait(){return this.dh}set fixedWidthLandscape(t){t!==this.ah&&(this.ah=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ah/t:this.dh/t}}export{ui as UIAnchor,Li as UIAnimatedImage,Ri as UIAnimatedImageLoopMode,bs as UIAreaCircle,xs as UIAreaPolygon,Ti as UIAreaRectangle,Ss as UIAreaRoundedRectangle,ri as UIAspectConstraint,Q as UIColor,hi as UIConstraint2DBuilder,oi as UICoverConstraintBuilder,li as UICustomConstraint,Rt as UIExpression,ci as UIFitConstraintBuilder,_s as UIFullscreenLayer,ki as UIGraphics,Xt as UIHeightConstraint,Zt as UIHorizontalDistanceConstraint,Jt as UIHorizontalInterpolationConstraint,Kt as UIHorizontalProportionConstraint,Wi as UIImage,Hi as UIInputDummy,Ii as UIInputEvent,Mi as UIMicro,fi as UIMicroAnchorMode,M as UIMode,Oi as UINineSlice,zi as UINineSliceRegionMode,C as UIOrientation,Y as UIPriority,qi as UIProgress,Is as UIProgressMaskFunctionCircular,$i as UIProgressMaskFunctionDirectional,Bt as UIRelation,Es as UIResizePolicyCover,Ms as UIResizePolicyCross,Cs as UIResizePolicyCrossInverted,Ts as UIResizePolicyFit,Ps as UIResizePolicyFixedHeight,Hs as UIResizePolicyFixedWidth,ys as UIResizePolicyNone,Ji as UIScene,Gi as UISceneUpdateMode,qt as UISingleParameterConstraint,ws as UIText,cs as UITextResizeMode,pt as UITransparencyMode,Qt as UIVerticalDistanceConstraint,ti as UIVerticalInterpolationConstraint,ii as UIVerticalProportionConstraint,si as UIWidthConstraint};
|
|
1
|
+
import{MathUtils as t,Color as i,Vector4 as s,Texture as e,Vector2 as h,Vector3 as r,Matrix3 as n,Matrix4 as o,PlaneGeometry as a,InstancedBufferGeometry as c,ShaderMaterial as l,InstancedBufferAttribute as u,Mesh as f,Scene as d,OrthographicCamera as p,Quaternion as v,CanvasTexture as w,SRGBColorSpace as g,LinearFilter as y,WebGLRenderTarget as m,UnsignedByteType as _,RGBAFormat as b,PerspectiveCamera as x,Ray as S}from"three";class I{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 E{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._,i.p)}return this}{const r=h.length;if(h[0]._===i&&h[0].p===s)return 1===r?this.o.delete(t):h.shift(),this;const n=r-1;if(h[n]._===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._===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]._===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._.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._,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:[{_:e,p:h,M:s,k:i,m:!1}],u:!1,l:new I(e,h,s)});if(r.l.has(e,h))throw Error("Event listener already exists");r.l.insert(e,h,s);const n={_: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)}}}}var M,C;function T(t){return t===M.INTERACTIVE||t===M.INTERACTIVE_TRANSPARENT}function P(t){return t!==M.HIDDEN}function H(){return new A}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE",t[t.INTERACTIVE_TRANSPARENT=3]="INTERACTIVE_TRANSPARENT"})(M||(M={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(C||(C={}));class A{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 U(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 U(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 A;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 U{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new U(this.first,this.second)}}class V{constructor(t=""){this.S=t}id(){return this.I}name(){return this.S}setName(t){this.S=t}context(){return this.C}setContext(t){this.C=t}value(){return this.T}setValue(t){this.T=t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}toJSON(){return{name:this.S,value:this.T}}toString(){return this.C+"["+this.S+":"+this.T+"]"}S;T=0;C=null;I=R++}let R=0;class B{constructor(){let t=(t=>{let i=0,s=()=>0,e=H();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 B){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 B))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.P=t.terms,this.H=t.constant}terms(){return this.P}constant(){return this.H}value(){let t=this.H;for(let i=0,s=this.P.size();s>i;i++){let s=this.P.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new B(this,t)}minus(t){return new B(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new B([t,this])}divide(t){return new B([1/t,this])}isConstant(){return 0==this.P.size()}toString(){let t=this.P.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.H||(t+=" + "),t+=this.H,t}P;H}class L{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=L.create(1e3,1e3,1e3);static strong=L.create(1,0,0);static medium=L.create(0,1,0);static weak=L.create(0,0,1);static clip(t){return Math.max(0,Math.min(L.required,t))}}var D;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(D||(D={}));class k{constructor(t,i,s,e=L.required){this.A=i,this.U=L.clip(e),this.V=void 0===s&&t instanceof B?t:t.minus(s)}id(){return this.I}expression(){return this.V}op(){return this.A}strength(){return this.U}toString(){return this.V+" "+["<=",">=","="][this.A]+" 0 ("+this.U+")"}V;A;U;I=W++}let W=0;class N{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=L.required){let h=new k(t,i,s,e);return this.addConstraint(h),h}addConstraint(t){if(void 0!==this.R.find(t))throw Error("duplicate constraint");let i=this.B(t),s=i.row,e=i.tag,h=this.L(s,e);if(h.type()===F.Invalid&&s.allDummies()){if(!z(s.constant()))throw Error("unsatisfiable constraint");h=e.marker}if(h.type()===F.Invalid){if(!this.D(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.W(h,s),this.N.insert(h,s);this.R.insert(t,e),this.F(this.O)}removeConstraint(t){let i=this.R.erase(t);if(void 0===i)throw Error("unknown constraint");this.j(t,i.second);let s=i.second.marker,e=this.N.erase(s);if(void 0===e){let t=this.$(s);if(t.type()===F.Invalid)throw Error("failed to find leaving row");e=this.N.erase(t),e.second.solveForEx(t,s),this.W(s,e.second)}this.F(this.O)}hasConstraint(t){return this.R.contains(t)}getConstraints(){return this.R.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.G.find(t))throw Error("duplicate edit variable");if((i=L.clip(i))===L.required)throw Error("bad required strength");let s=new B(t),e=new k(s,D.Eq,void 0,i);this.addConstraint(e);let h=this.R.find(e).second;this.G.insert(t,{tag:h,constraint:e,constant:0})}removeEditVariable(t){let i=this.G.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.G.contains(t)}suggestValue(t,i){let s=this.G.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.N,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.Y.push(n),void this.q();let a=h.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(r)&&this.Y.push(a),void this.q();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()!==F.External&&this.Y.push(i.first)}this.q()}updateVariables(){let t=this.X,i=this.N;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)}}Z(t){return this.X.setDefault(t,()=>this.J(F.External)).second}B(t){let i=t.expression(),s=new $(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!z(i.second)){let t=this.Z(i.first),e=this.N.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let h=this.O,r=t.strength(),n={marker:j,other:j};switch(t.op()){case D.Le:case D.Ge:{let i=t.op()===D.Le?1:-1,e=this.J(F.Slack);if(n.marker=e,s.insertSymbol(e,i),L.required>r){let t=this.J(F.Error);n.other=t,s.insertSymbol(t,-i),h.insertSymbol(t,r)}break}case D.Eq:if(L.required>r){let t=this.J(F.Error),i=this.J(F.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(F.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}L(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()===F.External)return i.first}let e=i.marker.type();return e!==F.Slack&&e!==F.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==F.Slack&&e!==F.Error||t.coefficientFor(i.other)>=0?j:i.other):i.marker}D(t){let i=this.J(F.Slack);this.N.insert(i,t.copy()),this.K=t.copy(),this.F(this.K);let s=z(this.K.constant());this.K=null;let e=this.N.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let h=this.tt(t);if(h.type()===F.Invalid)return!1;t.solveForEx(i,h),this.W(h,t),this.N.insert(h,t)}let h=this.N;for(let t=0,s=h.size();s>t;++t)h.itemAt(t).second.removeSymbol(i);return this.O.removeSymbol(i),s}W(t,i){let s=this.N;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()!==F.External&&this.Y.push(h.first)}this.O.substitute(t,i),this.K&&this.K.substitute(t,i)}F(t){let i=0;for(;this.maxIterations>i;){let s=this.it(t);if(s.type()===F.Invalid)return;let e=this.st(s);if(e.type()===F.Invalid)throw Error("the objective is unbounded");let h=this.N.erase(e).second;h.solveForEx(e,s),this.W(s,h),this.N.insert(s,h),i++}throw Error("solver iterations exceeded")}q(){let t=this.N,i=this.Y;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.et(e.second);if(i.type()===F.Invalid)throw Error("dual optimize failed");let h=e.second;t.erase(s),h.solveForEx(s,i),this.W(i,h),t.insert(i,h)}}}it(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()!==F.Dummy)return e}return j}et(t){let i=Number.MAX_VALUE,s=j,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()!==F.Dummy){let t=this.O.coefficientFor(r)/n;i>t&&(i=t,s=r)}}return s}st(t){let i=Number.MAX_VALUE,s=j,e=this.N;for(let h=0,r=e.size();r>h;++h){let r=e.itemAt(h),n=r.first;if(n.type()!==F.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}$(t){let i=Number.MAX_VALUE,s=i,e=i,h=j,r=h,n=h,o=h,a=this.N;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()===F.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()===F.Error&&this.ht(i.marker,t.strength()),i.other.type()===F.Error&&this.ht(i.other,t.strength())}ht(t,i){let s=this.N.find(t);void 0!==s?this.O.insertRow(s.second,-i):this.O.insertSymbol(t,-i)}tt(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===F.Slack||e===F.Error)return s.first}return j}J(t){return new O(t,this.rt++)}R=(()=>H())();N=(()=>H())();X=(()=>H())();G=(()=>H())();Y=[];O=new $;K=null;rt=0}function z(t){return 0>t?1e-8>-t:1e-8>t}var F;(t=>{t[t.Invalid=0]="Invalid",t[t.External=1]="External",t[t.Slack=2]="Slack",t[t.Error=3]="Error",t[t.Dummy=4]="Dummy"})(F||(F={}));class O{constructor(t,i){this.I=i,this.nt=t}id(){return this.I}type(){return this.nt}I;nt}let j=new O(F.Invalid,-1);class ${constructor(t=0){this.H=t}cells(){return this.ot}constant(){return this.H}isConstant(){return this.ot.empty()}allDummies(){let t=this.ot;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==F.Dummy)return!1;return!0}copy(){let t=new $(this.H);return t.ot=this.ot.copy(),t}add(t){return this.H+=t}insertSymbol(t,i=1){z(this.ot.setDefault(t,()=>0).second+=i)&&this.ot.erase(t)}insertRow(t,i=1){this.H+=t.H*i;let s=t.ot;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.ot.erase(t)}reverseSign(){this.H=-this.H;let t=this.ot;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.ot,s=-1/i.erase(t).second;this.H*=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.ot.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.ot.erase(t);void 0!==s&&this.insertRow(i,s.second)}ot=H();H}const G=1e3;var Y;function q(t){switch(t){case Y.P0:return L.create(G,G,G);case Y.P1:return L.create(100,0,0);case Y.P2:return L.create(10,0,0);case Y.P3:return L.create(0,100,0);case Y.P4:return L.create(0,10,0);case Y.P5:return L.create(0,0,100);case Y.P6:return L.create(0,0,10);case Y.P7:return L.create(0,0,1);default:throw Error("convertPriority.priority: invalid priority")}}(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"})(Y||(Y={}));class X{constructor(){this.dirty=!1,this.ct=!1,this.lt=[],this.ut=0}createInputCatcher(t,i,s,e){const h=this.ut++;return this.lt.push({handler:h,catchPointerDown:t,catchPointerMove:i,catchPointerUp:s,zIndex:e,active:!0}),this.ct=!0,this.dirty=!0,h}destroyInputCatcher(t){const i=this.lt.findIndex(i=>i.handler===t);if(-1===i)throw Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");this.lt.splice(i,1)}getZIndex(t){this.ft();const i=this.lt.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getZIndex.handler: handler not found");return i.zIndex}setZIndex(t,i){const s=this.lt.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setZIndex.handler: handler not found");s.zIndex!==i&&(s.zIndex=i,this.ct=!0,this.dirty=!0)}getActive(t){const i=this.lt.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getActive.handler: handler not found");return i.active}setActive(t,i){const s=this.lt.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setActive.handler: handler not found");s.active!==i&&(s.active=i)}onPointerDown(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerDown(t,i,s))break}}onPointerMove(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerMove(t,i,s))break}}onPointerUp(t,i,s){this.ft();for(let e=this.lt.length-1;e>=0;e--){const h=this.lt[e];if(h.active&&h.catchPointerUp(t,i,s))break}}ft(){if(this.ct){this.lt.sort((t,i)=>t.zIndex-i.zIndex);const t=this.lt.length,i=1024>t?1:1024/t;for(let s=0;t>s;s++)this.lt[s].zIndex=s*i;this.ct=!1}}}function Z(t){return.04045>t?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function J(t){return.0031308>t?12.92*t:1.055*Math.pow(t,.41666)-.055}const K={black:0,white:16777215,red:16711680,green:32768,blue:255,yellow:16776960,cyan:65535,magenta:16711935,gray:8421504,grey:8421504,silver:12632256,maroon:8388608,olive:8421376,lime:65280,aqua:65535,teal:32896,navy:128,fuchsia:16711935,purple:8388736,orange:16753920,pink:16761035,brown:10824234,gold:16766720,violet:15631086,indigo:4915330,coral:16744272,salmon:16416882,khaki:15787660,plum:14524637,orchid:14315734,tan:13808780,beige:16119260,mint:10025880,lavender:15132410,crimson:14423100,azure:15794175,ivory:16777200,snow:16775930};class Q{constructor(...t){this.dt=1,this.vt=1,this.wt=1,this.gt=1,this.yt=0,this._t=0,this.bt=1,this.xt=!1,this.St=!1,this.It=!1,t.length>0&&this.set(...t)}static get black(){return new Q("black")}static get white(){return new Q("white")}static get red(){return new Q("red")}static get green(){return new Q("green")}static get blue(){return new Q("blue")}static get yellow(){return new Q("yellow")}static get cyan(){return new Q("cyan")}static get magenta(){return new Q("magenta")}static get gray(){return new Q("gray")}static get grey(){return new Q("grey")}static get silver(){return new Q("silver")}static get maroon(){return new Q("maroon")}static get olive(){return new Q("olive")}static get lime(){return new Q("lime")}static get aqua(){return new Q("aqua")}static get teal(){return new Q("teal")}static get navy(){return new Q("navy")}static get fuchsia(){return new Q("fuchsia")}static get purple(){return new Q("purple")}static get orange(){return new Q("orange")}static get pink(){return new Q("pink")}static get brown(){return new Q("brown")}static get gold(){return new Q("gold")}static get violet(){return new Q("violet")}static get indigo(){return new Q("indigo")}static get coral(){return new Q("coral")}static get salmon(){return new Q("salmon")}static get khaki(){return new Q("khaki")}static get plum(){return new Q("plum")}static get orchid(){return new Q("orchid")}static get tan(){return new Q("tan")}static get beige(){return new Q("beige")}static get mint(){return new Q("mint")}static get lavender(){return new Q("lavender")}static get crimson(){return new Q("crimson")}static get azure(){return new Q("azure")}static get ivory(){return new Q("ivory")}static get snow(){return new Q("snow")}get r(){return this.Et(),this.dt}get g(){return this.Et(),this.vt}get b(){return this.Et(),this.wt}get a(){return this.gt}get hue(){return this.Mt(),this.yt}get saturation(){return this.Mt(),this._t}get lightness(){return this.Mt(),this.bt}get dirty(){return this.xt}set r(i){i=t.clamp(i,0,1),this.Et(),i!==this.dt&&(this.dt=i,this.It=!0,this.xt=!0)}set g(i){i=t.clamp(i,0,1),this.Et(),i!==this.vt&&(this.vt=i,this.It=!0,this.xt=!0)}set b(i){i=t.clamp(i,0,1),this.Et(),i!==this.wt&&(this.wt=i,this.It=!0,this.xt=!0)}set a(i){(i=t.clamp(i,0,1))!==this.gt&&(this.gt=i,this.xt=!0)}set hue(i){i=t.clamp(i,0,360),this.Mt(),i!==this.yt&&(this.yt=i,this.St=!0,this.xt=!0)}set saturation(i){i=t.clamp(i,0,1),this.Mt(),i!==this._t&&(this._t=i,this.St=!0,this.xt=!0)}set lightness(i){i=t.clamp(i,0,1),this.Mt(),i!==this.bt&&(this.bt=i,this.St=!0,this.xt=!0)}setDirtyFalse(){this.xt=!1}set(...t){if(0===t.length||void 0===t[0])return this.setRGBA(1,1,1,1);if(t.length>=3&&"number"==typeof t[0]){const[i,s,e,h=1]=t;return this.setRGBA(i,s,e,h)}const[s,e=1]=t;if("string"==typeof s)return s.startsWith("#")?this.setHexString(s):this.setColorName(s,e);if(s instanceof Q)return this.copy(s);if(s instanceof i)return this.setThreeColor(s,e);if("number"==typeof s)return this.setHexRGB(s,e);throw Error("UIColor.set: cannot create color from provided arguments")}setRGBA(i,s,e,h=this.gt){return i=t.clamp(i,0,1),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Et(),i===this.dt&&s===this.vt&&e===this.wt&&h===this.gt||(this.dt=i,this.vt=s,this.wt=e,this.gt=h,this.It=!0,this.xt=!0),this}getHexRGBA(){return this.Et(),Math.round(255*this.dt)<<24|Math.round(255*this.vt)<<16|Math.round(255*this.wt)<<8|Math.round(255*this.gt)}getHexRGB(){return this.Et(),Math.round(255*this.dt)<<16|Math.round(255*this.vt)<<8|Math.round(255*this.wt)}getHexStringRGB(){return"#"+this.getHexRGB().toString(16).padStart(6,"0")}getHexStringRGBA(){return"#"+this.getHexRGBA().toString(16).padStart(8,"0")}setHexRGBA(t){this.Et();const i=(t>>16&255)/255,s=(t>>8&255)/255,e=(255&t)/255,h=(t>>24&255)/255;return i===this.dt&&s===this.vt&&e===this.wt&&h===this.gt||(this.dt=i,this.vt=s,this.wt=e,this.gt=h,this.It=!0,this.xt=!0),this}setHexRGB(i,s=this.gt){s=t.clamp(s,0,1),this.Et();const e=(i>>16&255)/255,h=(i>>8&255)/255,r=(255&i)/255;return e===this.dt&&h===this.vt&&r===this.wt&&s===this.gt||(this.dt=e,this.vt=h,this.wt=r,this.gt=s,this.It=!0,this.xt=!0),this}setHexString(t){if(!t.startsWith("#"))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');const i=t.slice(1);if(6===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGB(t)}if(8===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGBA(t)}throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"')}setHSL(i,s,e,h=this.gt){return i=t.clamp(i,0,360),s=t.clamp(s,0,1),e=t.clamp(e,0,1),h=t.clamp(h,0,1),this.Mt(),i===this.yt&&s===this._t&&e===this.bt&&h===this.gt||(this.yt=i,this._t=s,this.bt=e,this.gt=h,this.St=!0,this.xt=!0),this}setColorName(i,s=this.gt){s=t.clamp(s,0,1);const e=i.toLowerCase().trim(),h=K[e];if(void 0===h)throw Error("UIColor.setColorName.colorName: unknown color name");return this.setHexRGB(h,s)}setGLSLColor(i,s,e,h=this.gt){h=t.clamp(h,0,1),this.Et();const r=J(i),n=J(s),o=J(e);return r===this.dt&&n===this.vt&&o===this.wt&&h===this.gt||(this.dt=r,this.vt=n,this.wt=o,this.gt=h,this.It=!0,this.xt=!0),this}setThreeColor(i,s=this.gt){return s=t.clamp(s,0,1),this.Et(),i.r===this.dt&&i.g===this.vt&&i.b===this.wt&&s===this.gt||(this.dt=i.r,this.vt=i.g,this.wt=i.b,this.gt=s,this.It=!0,this.xt=!0),this}toCSSColor(){return this.Et(),`rgba(${Math.round(255*this.dt)}, ${Math.round(255*this.vt)}, ${Math.round(255*this.wt)}, ${this.gt})`}toGLSLColor(t=new s){return this.Et(),t.x=Z(this.dt),t.y=Z(this.vt),t.z=Z(this.wt),t.w=this.gt,t}toThreeColor(t=new i){return this.Et(),t.r=this.dt,t.g=this.vt,t.b=this.wt,t}copy(t){return t instanceof Q?(this.Et(),t.Et(),this.dt===t.dt&&this.vt===t.vt&&this.wt===t.wt&&this.gt===t.gt||(this.dt=t.dt,this.vt=t.vt,this.wt=t.wt,this.gt=t.gt,this.It=!0,this.xt=!0)):(this.Et(),this.dt===t.r&&this.vt===t.g&&this.wt===t.b&&1===this.gt||(this.dt=t.r,this.vt=t.g,this.wt=t.b,this.gt=1,this.It=!0,this.xt=!0)),this}clone(){return this.Et(),new Q(this.dt,this.vt,this.wt,this.gt)}Et(){if(this.St){const{yt:t,_t:i,bt:s}=this,e=(1-Math.abs(2*s-1))*i,h=t/60,r=e*(1-Math.abs(h%2-1));let[n,o,a]=1>h?[e,r,0]:2>h?[r,e,0]:3>h?[0,e,r]:4>h?[0,r,e]:5>h?[r,0,e]:[e,0,r];const c=s-e/2;this.dt=n+c,this.vt=o+c,this.wt=a+c,this.St=!1}}Mt(){if(this.It){const{dt:t,vt:i,wt:s}=this,e=Math.max(t,i,s),h=Math.min(t,i,s),r=e-h,n=(e+h)/2;let o=0;0!==r&&(o=e===t?(i-s)/r+(s>i?6:0):e===i?(s-t)/r+2:(t-i)/r+4,o*=60);const a=0===r?0:r/(1-Math.abs(2*n-1));this.yt=o,this._t=a,this.bt=n,this.It=!1}}}const tt=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),it=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),st=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),et=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),ht=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),rt=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),nt=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function ot(t){if("string"==typeof t)switch(t){case"number":return tt;case"Texture":return it;case"UIColor":case"Vector4":return ht;case"Vector2":return st;case"Vector3":return et;case"Matrix3":return rt;case"Matrix4":return nt;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return tt;if(t===e)return it;if(t===Q)return ht;if(t===h)return st;if(t===r)return et;if(t===s)return ht;if(t===n)return rt;if(t===o)return nt;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return tt;if(t instanceof e)return it;if(t instanceof Q)return ht;if(t instanceof h)return st;if(t instanceof r)return et;if(t instanceof s)return ht;if(t instanceof n)return rt;if(t instanceof o)return nt;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function at(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function ct(t,i){for(const s in i){if(!(s in t))return!1;const e=t[s].glslTypeInfo;if(e.glslTypeName!==i[s].glslTypeInfo.glslTypeName)return!1;if(!e.instantiable&&t[s]!==i[s])return!1}return!0}function lt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:ot(e)}}return i}function ut(t){return"number"==typeof t||t instanceof e?t:t.clone()}function ft(t){const i={};for(const s in t)i[s]=ut(t[s]);return i}function dt(t,i,s){return`\n // Defines\n #define PI 3.14159265359\n\n // Uniforms\n ${t.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${i.join("\n")}\n\n #include <alphahash_pars_fragment>\n\n // Source must define vec4 draw() function\n ${s}\n\n void main() {\n vec4 diffuseColor = draw();\n\n #ifdef USE_ALPHATEST\n if (diffuseColor.a < 0.50) {\n discard;\n }\n #endif\n\n #ifdef USE_ALPHAHASH\n if (diffuseColor.a < getAlphaHashThreshold(p_position)) {\n discard;\n }\n #endif\n\n gl_FragColor = linearToOutputTexel(diffuseColor);\n }\n `}var pt;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(pt||(pt={}));const vt=(()=>{const t=new a(1,1);t.translate(.5,.5,0);const i=new c;return i.index=t.index,i.setAttribute("position",t.attributes.position),i.setAttribute("uv",t.attributes.uv),t.dispose(),i})(),wt=new s,gt=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function yt(t,i,e){if(t instanceof Q)t.toGLSLColor(wt),i[e]=wt.x,i[e+1]=wt.y,i[e+2]=wt.z,i[e+3]=wt.w;else if(t instanceof h)i[e]=t.x,i[e+1]=t.y;else if(t instanceof r)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z;else if(t instanceof s)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z,i[e+3]=t.w;else if(t instanceof n||t instanceof o){const s=t.elements;for(let t=0;s.length>t;t++)i[e+t]=s[t]}else"number"==typeof t&&(i[e]=t)}function mt(t,i){const s=ot(t);if(!s.instantiable)throw Error("buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type");return new u(new Float32Array(i*s.bufferSize),s.bufferSize)}function _t(t,i,e){if("number"==typeof t)return i[e];if(t instanceof h)return new h(i[e],i[e+1]);if(t instanceof r)return new r(i[e],i[e+1],i[e+2]);if(t instanceof s)return new s(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof Q)return(new Q).setGLSLColor(i[e],i[e+1],i[e+2],i[e+3]);if(t instanceof n){const t=new n;return t.fromArray(i,e),t}if(t instanceof o){const t=new o;return t.fromArray(i,e),t}throw Error("reconstructValue.referenceValue: cannot reconstruct value for type")}class bt extends f{constructor(t,i,s,e=4){const h={},r={instanceVisibility:{value:1,glslTypeInfo:ot("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:ot("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?r[t]=s:h[t]=s}const n=vt.clone(),a=((t,i,s,e)=>{const h={},r=[],n=[],o=[],a=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof Q?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}for(const t in s){const{glslTypeInfo:i}=s[t];n.push(`attribute ${i.glslTypeName} a_${t};`),o.push(`varying ${i.glslTypeName} p_${t};`),a.push(`p_${t} = a_${t};`)}const c=`\n // User attributes\n ${n.join("\n")}\n\n // Uniforms\n ${r.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${o.join("\n")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${a.join("\n")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `,u=dt(r,o,t);return new l({uniforms:h,vertexShader:c,fragmentShader:u,transparent:e===pt.BLEND,alphaTest:e===pt.CLIP?.5:0,alphaHash:e===pt.HASH,depthWrite:e!==pt.BLEND,depthTest:!0})})(t,h,r,s);super(n,a),this.source=t,this.transparency=s,this.Ct=new Map,this.Tt=new Map,this.ut=0,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1,this.Pt=n,this.Pt.instanceCount=0,this.Ht=a,this.At=h,this.Ut=r,this.Vt=Math.max(4*Math.ceil(e/4),4);for(const t in this.Ut){const{value:i}=this.Ut[t],s=mt(i,this.Vt);this.Pt.setAttribute("a_"+t,s),this.Tt.set(t,s)}for(const t in this.At){const{value:i}=this.At[t];at(t,this.Ht).value=i}this.Ht.uniformsNeedUpdate=!0}get instanceCount(){return this.Pt.instanceCount}createInstance(){const t=this.ut++,i=this.Pt.instanceCount;this.Rt(i+1),this.Ct.set(t,i),this.Pt.instanceCount++;{const t=this.Tt.get("instanceVisibility"),s=this.Tt.get("instanceTransform");((t,i,s)=>{t[s]=1;const e=16*s;for(let t=0;16>t;t++)i[e+t]=gt[t]})(t.array,s.array,i),t.needsUpdate=!0,s.needsUpdate=!0}return t}destroyInstance(t){const i=this.Bt(t);this.Ct.delete(t);const s=this.Pt.instanceCount-1;s>i&&(this.Lt(s,i),this.Dt(s,i)),this.Pt.instanceCount--}setProperties(t,i){const s=this.Bt(t);for(const t in i){const{value:e,glslTypeInfo:h}=i[t];if(h.instantiable){const i=this.kt(t);yt(e,i.array,s*i.itemSize),i.needsUpdate=!0}else at(t,this.Ht).value=e,this.Ht.uniformsNeedUpdate=!0}}setTransform(t,i){const s=this.Bt(t),e=this.kt("instanceTransform"),h=e.array,r=16*s,n=i.elements;for(let t=0;16>t;t++)h[r+t]=n[t];e.needsUpdate=!0}setVisibility(t,i){const s=this.Bt(t),e=this.kt("instanceVisibility");e.array[s]=i?1:0,e.needsUpdate=!0}isPartiallyCompatible(t,i,s=pt.BLEND){return this.transparency===s&&this.source===t&&ct({...this.At,...this.Ut},i)}arePropertiesPartiallyCompatible(t){return ct({...this.At,...this.Ut},t)}extractInstanceData(t){return{source:this.source,properties:this.Wt(t),transparency:this.transparency,transform:this.Nt(t),visibility:this.zt(t)}}destroy(){this.Pt.dispose(),this.Ht.dispose(),this.Tt.clear(),this.Ct.clear()}Wt(t){const i=this.Bt(t),s={};for(const t in this.At)s[t]=this.At[t];for(const t in this.Ut){const{value:e,glslTypeInfo:h}=this.Ut[t],r=this.Tt.get(t);s[t]={value:_t(e,r.array,i*r.itemSize),glslTypeInfo:h}}return s}Nt(t){const i=this.Bt(t),s=this.Tt.get("instanceTransform").array,e=new o;return e.fromArray(s,16*i),e}zt(t){const i=this.Bt(t);return this.Tt.get("instanceVisibility").array[i]>=.5}Rt(t){if(this.Vt>=t)return;const i=4*Math.ceil(t/4);for(const[t,s]of this.Tt){const e=s.itemSize,h=new Float32Array(i*e);h.set(s.array);const r=new u(h,e);this.Pt.setAttribute("a_"+t,r),this.Tt.set(t,r)}this.Vt=i}Lt(t,i){for(const s of this.Tt.values()){const e=s.array,h=s.itemSize,r=t*h,n=i*h;for(let t=0;h>t;t++)e[n+t]=e[r+t];s.needsUpdate=!0}}Dt(t,i){for(const[s,e]of this.Ct)if(e===t){this.Ct.set(s,i);break}}Bt(t){const i=this.Ct.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveIndex.handler: invalid handler");return i}kt(t){const i=this.Tt.get(t);if(void 0===i)throw Error("UIGenericInstancedPlane.resolveAttribute.name: unknown attribute");return i}}const xt=new a(1,1).translate(.5,.5,0);class St extends f{constructor(t,i,s,e,h){const r=((t,i,s,e)=>{const h={p_transform:{value:e}},r=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof Q?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}const n=`\n // Default uniform declarations\n uniform mat4 p_transform;\n\n // Custom uniform declarations\n ${r.join("\n")}\n\n // Default varying declarations\n varying vec3 p_position;\n varying vec2 p_uv;\n\n void main() {\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * p_transform * vec4(position, 1.0);\n }\n `,o=dt(r,[],t);return new l({uniforms:h,vertexShader:n,fragmentShader:o,transparent:s===pt.BLEND,alphaTest:s===pt.CLIP?.5:0,alphaHash:s===pt.HASH,depthWrite:s!==pt.BLEND,depthTest:!0})})(t,i,h,s);super(xt,r),this.Ft=t,this.Ht=r,this.Ot=i,this.jt=h,this.$t=s,this.visible=e,this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1}get transparency(){return this.jt}setProperties(t){for(const i in t){const s=t[i],h=at(i,this.Ht),r=s.value;if(s.value instanceof Q)s.value.toGLSLColor(h.value),this.Ot[i].value.copy(s.value);else if("number"==typeof r||r instanceof e)h.value=s.value,this.Ot[i].value=s.value;else{const t=s.value;h.value.copy(t),this.Ot[i].value.copy(t)}}this.Ht.uniformsNeedUpdate=!0}setTransform(t){at("transform",this.Ht).value.copy(t),this.Ht.uniformsNeedUpdate=!0,this.$t.copy(t)}setVisibility(t){this.visible=t}setTransparency(t){this.jt!==t&&(this.Ht.transparent=t===pt.BLEND,this.Ht.alphaTest=t===pt.CLIP?.5:0,this.Ht.alphaHash=t===pt.HASH,this.Ht.depthWrite=t!==pt.BLEND,this.Ht.needsUpdate=!0,this.jt=t)}extractPlaneData(){return{source:this.Ft,properties:{...this.Ot},transform:this.$t.clone(),visibility:this.visible,transparency:this.jt}}isPartiallyCompatible(t,i,s){return this.jt===s&&this.Ft===t&&ct(this.Ot,i)}arePropertiesPartiallyCompatible(t){return ct(this.Ot,t)}destroy(){this.Ht.dispose()}}function It(t){return!("instanceHandler"in t)}function Et(t){return"instanceHandler"in t}class Mt{constructor(t){this.Gt=t,this.ut=0,this.Yt=new Map}createPlane(t,i,s,e,h){const r=this.ut++;return this.qt(r,{source:t,properties:lt(ft(i)),transform:s.clone(),visibility:e,transparency:h}),r}destroyPlane(t){const i=this.Xt(t);if(It(i))this.Gt.remove(i.plane),i.plane.destroy();else{const t=i.plane;1===t.instanceCount?(this.Gt.remove(t),t.destroy()):2===t.instanceCount?this.Zt(t,i):t.destroyInstance(i.instanceHandler)}this.Yt.delete(t)}setProperties(t,i){const s=this.Xt(t),e=lt(i);if(It(s))return void s.plane.setProperties(e);if(s.plane.arePropertiesPartiallyCompatible(e))return void s.plane.setProperties(s.instanceHandler,e);const h=s.plane.extractInstanceData(s.instanceHandler);for(const t in e)h.properties[t]={value:ut(e[t].value),glslTypeInfo:e[t].glslTypeInfo};this.destroyPlane(t),this.qt(t,h)}setTransform(t,i){const s=this.Xt(t);It(s)?s.plane.setTransform(i):s.plane.setTransform(s.instanceHandler,i)}setVisibility(t,i){const s=this.Xt(t);It(s)?s.plane.setVisibility(i):s.plane.setVisibility(s.instanceHandler,i)}setTransparency(t,i){const s=this.Xt(t);if(s.plane.transparency===i)return;if(It(s))return void s.plane.setTransparency(i);const e=s.plane.extractInstanceData(s.instanceHandler);this.destroyPlane(t),this.qt(t,{...e,transparency:i})}Jt(t,i){const{source:s,properties:e,transform:h,visibility:r,transparency:n}=i.plane.extractPlaneData();this.destroyPlane(t);const o=new bt(s,e,n),a=o.createInstance();return o.setProperties(a,e),o.setTransform(a,h),o.setVisibility(a,r),this.Gt.add(o),this.Yt.set(t,{plane:o,instanceHandler:a}),o}Zt(t,i){let s;for(const[e,h]of this.Yt)if(Et(h)&&h!==i&&h.plane===t){s=[e,h];break}if(!s)throw Error("UIGenericPlaneRegistry.demoteInstancedPlaneToSinglePlane.instancedPlane: remaining pair not found");const{source:e,properties:h,transform:r,visibility:n,transparency:o}=t.extractInstanceData(s[1].instanceHandler);this.Gt.remove(t),t.destroy();const a=new St(e,h,r,n,o);this.Gt.add(a),this.Yt.set(s[0],{plane:a})}Kt(t,i,s,e,h){const r=i.createInstance();i.setProperties(r,s),i.setTransform(r,e),i.setVisibility(r,h),this.Yt.set(t,{plane:i,instanceHandler:r})}qt(t,i){const{source:s,properties:e,transparency:h,transform:r,visibility:n}=i,o=this.Qt(s,e,h);if(o)return void this.Kt(t,o,e,r,n);const a=this.ti(s,e,h);if(a){const i=this.Jt(a[0],a[1]);return void this.Kt(t,i,e,r,n)}const c=new St(s,e,r,n,h);this.Gt.add(c),this.Yt.set(t,{plane:c})}ti(t,i,s){for(const e of this.Yt){const h=e[1];if(It(h)&&h.plane.isPartiallyCompatible(t,i,s))return[e[0],h]}}Qt(t,i,s){for(const e of this.Yt){const h=e[1];if(Et(h)&&h.plane.isPartiallyCompatible(t,i,s))return h.plane}}Xt(t){const i=this.Yt.get(t);if(!i)throw Error("UIGenericPlaneRegistry.resolvePlaneDescriptor.handler: descriptor not found");return i}}let Ct=new i,Tt=0,Pt=!1,Ht=!1,At=!1,Ut=!1;class Vt{constructor(t,i){this.Gt=new d,this.ii=new Mt(this.Gt),this.si=new p(0,t,i,0,-1024,1024)}createPlane(t,i,s,e,h){return this.ii.createPlane(t,i,s,e,h)}destroyPlane(t){this.ii.destroyPlane(t)}setTransform(t,i){this.ii.setTransform(t,i)}setProperties(t,i){this.ii.setProperties(t,i)}setVisibility(t,i){this.ii.setVisibility(t,i)}setTransparency(t,i){this.ii.setTransparency(t,i)}insertCustomObject(t){return this.Gt.add(t),this}removeCustomObject(t){return this.Gt.remove(t),this}resize(t,i){return this.si.right=t,this.si.top=i,this.si.updateProjectionMatrix(),this}render(t){return Ct=t.getClearColor(Ct),Tt=t.getClearAlpha(),Pt=t.autoClear,Ht=t.autoClearColor,At=t.autoClearDepth,Ut=t.autoClearStencil,t.autoClear=!1,t.autoClearColor=!1,t.autoClearDepth=!1,t.autoClearStencil=!1,t.setClearColor(0,1),t.clear(!1,!0,!0),t.render(this.Gt,this.si),t.setClearColor(Ct),t.setClearAlpha(Tt),t.autoClear=Pt,t.autoClearColor=Ht,t.autoClearDepth=At,t.autoClearStencil=Ut,this}}class Rt{constructor(t=0,i){if(this.constant=t,this.ei=i?new Map(i):new Map,i)for(let t=0;i.length>t;t++)jt()}static plus(t,i){const s=new Rt(t.constant+i.constant,Array.from(t.ei.entries()));for(const[t,e]of i.ei)s.plus(t,e);return s}static minus(t,i){const s=new Rt(t.constant-i.constant,Array.from(t.ei.entries()));for(const[t,e]of i.ei)s.minus(t,e);return s}plus(t,i){return this.ei.set(t,(this.ei.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this.ei)this.ei.set(i,s*t);return this}divide(t){if(0===t)throw Error("UIExpression.divide.value: cannot divide by zero");return this.multiply(1/t)}hasTerm(t){return this.ei.has(t)}copy(t){this.constant=t.constant,this.ei.clear();for(const[i,s]of t.ei)this.ei.set(i,s);return this}clone(){return new Rt(this.constant,Array.from(this.ei.entries()))}prepareTerms(){return Array.from(this.ei.entries())}}var Bt,Lt;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(Bt||(Bt={}));class Dt{constructor(){this.dirty=!1,this.hi=new N,this.ri=!1,this.ni=new Map,this.oi=0,this.ai=new Map,this.ci=0}createVariable(t,i){const s=this.oi++,e=new V;if(i===Y.P0){const h={variable:e,priority:i,value:t};this.ni.set(s,h),h.constraint=this.li(new Rt(0,[[s,1]]),new Rt(t),Bt.EQUAL,i);try{this.hi?.addConstraint(h.constraint)}catch{this.hi=void 0}}else{this.ni.set(s,{variable:e,priority:i,value:t});try{this.hi?.addEditVariable(e,q(i)),this.hi?.suggestValue(e,t)}catch{this.hi=void 0}}return this.ri=!0,this.dirty=!0,s}removeVariable(t){const i=this.ni.get(t);if(void 0===i)throw Error("UISolverWrapper.removeVariable.index: variable does not exist");for(const i of this.ai.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error("UISolverWrapper.removeVariable.index: variable is used in constraint");try{i.constraint?this.hi?.removeConstraint(i.constraint):this.hi?.removeEditVariable(i.variable)}catch{this.hi=void 0}this.ni.delete(t),this.ri=!0,this.dirty=!0}suggestVariableValue(t,i){const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.suggestVariableValue.index: variable does not exist");s.value!==i&&(s.value=i,s.constraint?s.constraint=this.ui(s.constraint,(new Rt).plus(t,1),new Rt(s.value),Bt.EQUAL,s.priority):this.hi?.suggestValue(s.variable,i),this.ri=!0,this.dirty=!0)}setVariablePriority(t,i){const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.setVariablePriority.index: variable does not exist");if(i!==s.priority){if(s.priority=i,s.priority===Y.P0){const i=(new Rt).plus(t,1),e=new Rt(s.value);s.constraint=this.li(i,e,Bt.EQUAL,s.priority);try{this.hi?.addConstraint(s.constraint)}catch{this.hi=void 0}}else{if(s.constraint)try{this.hi?.removeConstraint(s.constraint)}catch{this.hi=void 0}s.constraint=void 0,this.fi(t,s)}this.ri=!0,this.dirty=!0}}readVariableValue(t){const i=this.ni.get(t);if(void 0===i)throw Error("UISolverWrapper.readVariableValue.index: variable does not exist");return void 0===this.hi&&this.di(),this.ri&&(this.hi?.updateVariables(),this.ri=!1),i.variable.value()}createConstraint(t,i,s,e,h){const r=this.ci++,n=this.li(t,i,s,e);if(this.ai.set(r,{constraint:n,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:h}),h){try{this.hi?.addConstraint(n)}catch{this.hi=void 0}this.ri=!0,this.dirty=!0}return r}removeConstraint(t){const i=this.ai.get(t);if(void 0===i)throw Error("UISolverWrapper.removeConstraint.index: constraint does not exist");if(i.enabled)try{this.hi?.removeConstraint(i.constraint)}catch{this.hi=void 0}this.ai.delete(t),this.ri=!0,this.dirty=!0}setConstraintLHS(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintLHS.index: constraint does not exist");s.lhs.copy(i),this.pi(s),this.ri=!0,this.dirty=!0}setConstraintRHS(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRHS.index: constraint does not exist");s.rhs.copy(i),this.pi(s),this.ri=!0,this.dirty=!0}setConstraintRelation(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRelation.index: constraint does not exist");s.relation!==i&&(s.relation=i,this.pi(s),this.ri=!0,this.dirty=!0)}setConstraintPriority(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintPriority.index: constraint does not exist");s.priority!==i&&(s.priority=i,this.pi(s),this.ri=!0,this.dirty=!0)}setConstraintEnabled(t,i){const s=this.ai.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintEnabled.index: constraint does not exist");if(i!==s.enabled){s.enabled=i;try{s.enabled?this.hi?.addConstraint(s.constraint):this.hi?.removeConstraint(s.constraint)}catch{this.hi=void 0}this.ri=!0,this.dirty=!0}}fi(t,i){const s=[];for(const i of this.ai.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this.hi?.removeConstraint(i.constraint)}catch{this.hi=void 0}s.push(i)}this.hi?.removeEditVariable(i.variable),this.hi?.addEditVariable(i.variable,q(i.priority));for(const t of s)t.constraint=this.li(t.lhs,t.rhs,t.relation,t.priority);for(const t of s)try{this.hi?.addConstraint(t.constraint)}catch{this.hi=void 0;break}}pi(t){t.constraint=t.enabled?this.ui(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.li(t.lhs,t.rhs,t.relation,t.priority)}ui(t,i,s,e,h){try{this.hi?.removeConstraint(t)}catch{this.hi=void 0}const r=this.li(i,s,e,h);try{this.hi?.addConstraint(r)}catch{this.hi=void 0}return r}li(t,i,s,e){return new k(this.wi(t),(t=>{switch(t){case Bt.EQUAL:return D.Eq;case Bt.LESS_THAN:return D.Le;case Bt.GREATER_THAN:return D.Ge;default:throw Error("convertRelation.relation: invalid relation")}})(s),this.wi(i),q(e))}wi(t){return new B(...t.prepareTerms().map(([t,i])=>{const s=this.ni.get(t);if(void 0===s)throw Error("UISolverWrapper.convertExpression.expression: variable does not exist");return[i,s.variable]}),t.constant)}di(){if(this.hi)throw Error("UISolverWrapper.rebuildSolver: solver already exists");this.hi=new N;for(const t of this.ni.values())t.constraint?this.hi.addConstraint(t.constraint):(this.hi.addEditVariable(t.variable,q(t.priority)),this.hi.suggestValue(t.variable,t.value));for(const t of this.ai.values())t.enabled&&this.hi.addConstraint(t.constraint);this.ri=!0,this.dirty=!0}}(t=>{t.ORIENTATION_CHANGED="orientation_changed",t.MODE_CHANGED="mode_changed",t.RENDERING="rendering"})(Lt||(Lt={}));const kt=M.VISIBLE;class Wt extends E{constructor(t){super(),this.name="",this.inputWrapperInternal=new X,this.gi=new Dt;const i=t.width??1024,s=t.height??1024;this.yi=new Vt(i,s),this.name=t.name??"",this.mi=t.mode??kt,this._i=i>s?C.HORIZONTAL:C.VERTICAL,this.xVariable=this.gi.createVariable(0,Y.P0),this.yVariable=this.gi.createVariable(0,Y.P0),this.wVariable=this.gi.createVariable(i,Y.P0),this.hVariable=this.gi.createVariable(s,Y.P0)}get sceneWrapper(){return this.yi}get solverWrapper(){return this.gi}get inputWrapper(){return this.inputWrapperInternal}get x(){return this.gi.readVariableValue(this.xVariable)}get y(){return this.gi.readVariableValue(this.yVariable)}get width(){return this.gi.readVariableValue(this.wVariable)}get height(){return this.gi.readVariableValue(this.hVariable)}get mode(){return this.mi}get orientation(){return this._i}set mode(t){t!==this.mi&&(this.mi=t,this.emit(Lt.MODE_CHANGED,this.mi,this))}resizeInternal(t,i){this.gi.suggestVariableValue(this.wVariable,t),this.gi.suggestVariableValue(this.hVariable,i),this.yi.resize(t,i);const s=t>i?C.HORIZONTAL:C.VERTICAL;s!==this._i&&(this._i=s,this.emit(Lt.ORIENTATION_CHANGED,this._i,this))}renderInternal(t,i){P(this.mode)&&(this.emit(Lt.RENDERING,t,i,this),this.yi.render(t)),this.gi.dirty=!1,this.inputWrapperInternal.dirty=!1}}function Nt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Wt}function zt(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function Ft(t){return"object"==typeof t&&null!==t&&"wVariable"in t&&"number"==typeof t.wVariable&&"hVariable"in t&&"number"==typeof t.hVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}const Ot=1e-6;function jt(){}function $t(t,i,s){if(t instanceof Wt)return t;if(Nt(t))return t.layer;if(i instanceof Wt)return i;if(Nt(i))return i.layer;throw Error(s+": no valid subjects found")}function Gt(t,i,s){if(Nt(i))return i.layer;if(Nt(s))return s.layer;if(i instanceof Wt)return i;if(s instanceof Wt)return s;throw Error(t+": no valid subjects found")}class Yt{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=i??""}}class qt extends Yt{constructor(t,i){var s,e,h;super(t,i?.name),this.bi=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.xi=(s=i?.priority,s??Y.P0),this.Si=(e=i?.relation,e??Bt.EQUAL),this._i=(h=i?.orientation,h??C.ALWAYS),this.layer.on(Lt.ORIENTATION_CHANGED,this.bi)}get priority(){return this.xi}get relation(){return this.Si}get orientation(){return this._i}set priority(t){t!==this.xi&&(this.xi=t,this.solverWrapper.setConstraintPriority(this.constraint,this.xi))}set relation(t){t!==this.Si&&(this.Si=t,this.solverWrapper.setConstraintRelation(this.constraint,this.Si))}set orientation(t){t!==this._i&&(this._i=t,this.bi())}destroy(){this.layer.off(Lt.ORIENTATION_CHANGED,this.bi),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this._i===C.ALWAYS||this._i===this.layer.orientation}}class Xt extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.Ei=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new Rt(0,[[this.Ii.hVariable,1]]),new Rt(this.Ei),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Ei}set height(t){this.Ei!==t&&(this.Ei=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(t)))}}class Zt extends qt{constructor(t,i,s={}){super($t(t,i,"UIHorizontalDistanceConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Ti=s.anchorA??.5,this.Pi=s.anchorB??.5,this.Hi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(this.Hi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Hi}get anchorA(){return this.Ti}get anchorB(){return this.Pi}set distance(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(this.Hi)))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.xVariable,1],[this.Mi.wVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.xVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.xVariable,1],[this.Ci.wVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.xVariable,1)}return Rt.minus(i,t)}}class Jt extends qt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Gt("UIHorizontalInterpolationConstraint.constructor",t,i),e),this.Mi=t,this.Ci=i,this.Ui=s,this.Ti=h,this.Pi=h,this.Vi=e.anchorC??.5,this.Ri=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Ri}get anchorA(){return this.Ti}get anchorB(){return this.Pi}get anchorC(){return this.Vi}set t(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorC(t){this.Vi!==t&&(this.Vi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i,s;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.xVariable,1],[this.Mi.wVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.xVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.xVariable,1],[this.Ci.wVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.xVariable,1)}if(Ft(this.Ui))s=new Rt(0,[[this.Ui.xVariable,1],[this.Ui.wVariable,this.Vi]]);else{if(!zt(this.Ui))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Rt).plus(this.Ui.xVariable,1)}const e=t.clone().multiply(1-this.Ri),h=i.clone().multiply(this.Ri);return Rt.minus(Rt.minus(s,e),h)}}class Kt extends qt{constructor(t,i,s={}){super($t(t,i,"UIHorizontalProportionConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Bi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Rt(0),this.Li(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Bi}set proportion(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Li()))}Li(){return Rt.minus(new Rt(0,[[this.Mi.wVariable,this.Bi]]),new Rt(0,[[this.Ci.wVariable,1]]))}}class Qt extends qt{constructor(t,i,s={}){super($t(t,i,"UIVerticalDistanceConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Ti=s.anchorA??.5,this.Pi=s.anchorB??.5,this.Hi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(this.Hi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Hi}get anchorA(){return this.Ti}get anchorB(){return this.Pi}set distance(t){this.Hi!==t&&(this.Hi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(this.Hi)))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.yVariable,1],[this.Mi.hVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.yVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.yVariable,1],[this.Ci.hVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.yVariable,1)}return Rt.minus(i,t)}}class ti extends qt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Gt("UIVerticalInterpolationConstraint.constructor",t,i),e),this.Mi=t,this.Ci=i,this.Ui=s,this.Ti=h,this.Pi=h,this.Vi=e.anchorC??.5,this.Ri=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.Ri}get anchorA(){return this.Ti}get anchorB(){return this.Pi}get anchorC(){return this.Vi}set t(t){this.Ri!==t&&(this.Ri=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorA(t){this.Ti!==t&&(this.Ti=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorB(t){this.Pi!==t&&(this.Pi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}set anchorC(t){this.Vi!==t&&(this.Vi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){let t,i,s;if(Ft(this.Mi))t=new Rt(0,[[this.Mi.yVariable,1],[this.Mi.hVariable,this.Ti]]);else{if(!zt(this.Mi))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Rt).plus(this.Mi.yVariable,1)}if(Ft(this.Ci))i=new Rt(0,[[this.Ci.yVariable,1],[this.Ci.hVariable,this.Pi]]);else{if(!zt(this.Ci))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Rt).plus(this.Ci.yVariable,1)}if(Ft(this.Ui))s=new Rt(0,[[this.Ui.yVariable,1],[this.Ui.hVariable,this.Vi]]);else{if(!zt(this.Ui))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Rt).plus(this.Ui.yVariable,1)}const e=t.clone().multiply(1-this.Ri),h=i.clone().multiply(this.Ri);return Rt.minus(Rt.minus(s,e),h)}}class ii extends qt{constructor(t,i,s={}){super($t(t,i,"UIVerticalProportionConstraint.constructor"),s),this.Mi=t,this.Ci=i,this.Bi=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Rt(0),this.Li(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.Bi}set proportion(t){this.Bi!==t&&(this.Bi=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Li()))}Li(){return Rt.minus(new Rt(0,[[this.Mi.hVariable,this.Bi]]),new Rt(0,[[this.Ci.hVariable,1]]))}}class si extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.Di=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new Rt(0,[[this.Ii.wVariable,1]]),new Rt(this.Di),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.Di}set width(t){this.Di!==t&&(this.Di=t,this.solverWrapper.setConstraintRHS(this.constraint,new Rt(t)))}}function ei(t){return void 0===t?{}:Array.isArray(t)?{h:t[0],v:t[1]}:"object"==typeof t&&null!==t&&("h"in t||"v"in t)?t:{h:t,v:t}}class hi{static size(t,i={}){const s=ei(i.size),e=ei(i.priority),h=ei(i.relation),r=ei(i.orientation);return{h:new si(t,{width:s.h,priority:e.h,relation:h.h,orientation:r.h}),v:new Xt(t,{height:s.v,priority:e.v,relation:h.v,orientation:r.v})}}static distance(t,i,s={}){const e=ei(s.anchorA),h=ei(s.anchorB),r=ei(s.distance),n=ei(s.priority),o=ei(s.relation),a=ei(s.orientation);return{h:new Zt(t,i,{anchorA:e.h,anchorB:h.h,distance:r.h,priority:n.h,relation:o.h,orientation:a.h}),v:new Qt(t,i,{anchorA:e.v,anchorB:h.v,distance:r.v,priority:n.v,relation:o.v,orientation:a.v})}}static proportion(t,i,s={}){const e=ei(s.proportion),h=ei(s.priority),r=ei(s.relation),n=ei(s.orientation);return{h:new Kt(t,i,{proportion:e.h,priority:h.h,relation:r.h,orientation:n.h}),v:new ii(t,i,{proportion:e.v,priority:h.v,relation:r.v,orientation:n.v})}}static interpolation(t,i,s,e={}){const h=ei(e.anchorA),r=ei(e.anchorB),n=ei(e.anchorC),o=ei(e.t),a=ei(e.priority),c=ei(e.relation),l=ei(e.orientation);return{h:new Jt(t,i,s,{anchorA:h.h,anchorB:r.h,anchorC:n.h,t:o.h,priority:a.h,relation:c.h,orientation:l.h}),v:new ti(t,i,s,{anchorA:h.v,anchorB:r.v,anchorC:n.v,t:o.v,priority:a.v,relation:c.v,orientation:l.v})}}}class ri extends qt{constructor(t,i={}){super(t.layer,i),this.Ii=t,this.ki=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Ai(),new Rt(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.ki}set aspect(t){this.ki!==t&&(this.ki=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ai()))}Ai(){return new Rt(0,[[this.Ii.wVariable,1],[this.Ii.hVariable,-this.ki]])}}const ni=.5;class oi{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ri(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Zt(t,i,{anchorA:s.anchorH??ni,anchorB:s.anchorH??ni,orientation:s.orientation}),yConstraint:new Qt(t,i,{anchorA:s.anchorV??ni,anchorB:s.anchorV??ni,orientation:s.orientation}),widthConstraint:new Kt(t,i,{proportion:1,relation:Bt.GREATER_THAN,orientation:s.orientation}),heightConstraint:new ii(t,i,{proportion:1,priority:Y.P1,orientation:s.orientation})}}}const ai=.5;class ci{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ri(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new Zt(t,i,{anchorA:s.anchorH??ai,anchorB:s.anchorH??ai,orientation:s.orientation}),yConstraint:new Qt(t,i,{anchorA:s.anchorV??ai,anchorB:s.anchorV??ai,orientation:s.orientation}),widthConstraint:new Kt(t,i,{proportion:1,relation:Bt.LESS_THAN,orientation:s.orientation}),heightConstraint:new ii(t,i,{proportion:1,priority:Y.P1,orientation:s.orientation})}}}class li extends qt{constructor(t,i,s,e={}){super(t,e),this.Wi=i,this.Ni=s,this.constraint=this.solverWrapper.createConstraint(this.Wi,this.Ni,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.Wi}get rhs(){return this.Ni}setLHS(t){this.Wi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Wi)}setRHS(t){this.Ni=t,this.solverWrapper.setConstraintRHS(this.constraint,this.Ni)}}class ui extends E{constructor(t,i){const s=i?.x??0,e=i?.y??0;super(),this.layer=t,this.name="",this.solverWrapper=this.layer.solverWrapper,this.xVariable=this.solverWrapper.createVariable(s,Y.P7),this.yVariable=this.solverWrapper.createVariable(e,Y.P7)}get x(){return this.solverWrapper.readVariableValue(this.xVariable)}get y(){return this.solverWrapper.readVariableValue(this.yVariable)}set x(t){this.solverWrapper.suggestVariableValue(this.xVariable,t)}set y(t){this.solverWrapper.suggestVariableValue(this.yVariable,t)}destroy(){this.solverWrapper.removeVariable(this.yVariable),this.solverWrapper.removeVariable(this.xVariable)}}var fi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(fi||(fi={}));const di=.5,pi=fi.ROTATION_SCALE,vi=new r,wi=new v,gi=new r,yi=new o,mi=new r(0,0,1);function _i(t,i,s,e,h,r,n,o,a,c,l,u,f,d,p,v,w){const g=s-d-p,y=e-v-w,m=o*s*c,_=a*e*l,b=Math.cos(u),x=Math.sin(u),S=m*b-_*x,I=m*x+_*b,E=d*c,M=w*l,C=E*b-M*x,T=E*x+M*b;if(f===fi.POSITION_ROTATION_SCALE)vi.x=t+r-S+C,vi.y=i+n-I+T;else{const h=a*e;vi.x=t+o*s-S+r+C,vi.y=i+h-I+n+T}return vi.z=h,gi.x=g*c,gi.y=y*l,wi.setFromAxisAngle(mi,u),yi.compose(vi,wi,gi),yi}const bi=new e;var xi;(t=>{t[t.DIMENSIONS_CHANGED=0]="DIMENSIONS_CHANGED"})(xi||(xi={}));class Si extends E{constructor(t){super(),this.zi=bi,this.Fi=2,this.Oi=2,this.ji=0,this.$i=0,this.Gi=2,this.Yi=2,this.qi=!1,this.Xi=1,this.Zi=0,this.Ji=0,this.Ki=0,this.Qi=0,this.ts=!1,this.ss=!1,this.es=!1,void 0!==t&&this.set(t)}get width(){return this.Fi/this.Xi}get height(){return this.Oi/this.Xi}get trimmedWidth(){return(this.qi?this.Yi:this.Gi)/this.Xi}get trimmedHeight(){return(this.qi?this.Gi:this.Yi)/this.Xi}get texture(){return this.zi}get rotated(){return this.qi}get scale(){return this.Xi}get trim(){const t=this.Xi;return{left:this.Zi/t,right:this.Ji/t,top:this.Ki/t,bottom:this.Qi/t}}get textureDirty(){return this.ts}get uvTransformDirty(){return this.ss}get trimDirty(){return this.es}setTextureDirtyFalse(){this.ts=!1}setUVTransformDirtyFalse(){this.ss=!1}setTrimDirtyFalse(){this.es=!1}calculateUVTransform(t=new n){const i=this.zi.image?.naturalWidth??2,s=this.zi.image?.naturalHeight??2;if(this.qi){const e=this.Gi,h=e/s;t.set(0,this.Yi/i,this.ji/i,-h,0,(s-this.$i-e)/s+h,0,0,1)}else t.set(this.Gi/i,0,this.ji/i,0,this.Yi/s,(s-this.$i-this.Yi)/s,0,0,1);return t}getResolution(t=new h){return t.set(this.width,this.height)}set(t){const i=this.width,s=this.height;t instanceof e?this.hs(t):this.rs(t),this.width===i&&this.height===s||this.emit(xi.DIMENSIONS_CHANGED,this.width,this.height,this)}hs(t){const i=t.image?.naturalWidth??2,s=t.image?.naturalHeight??2;this.Fi=i,this.Oi=s,this.texture!==t&&(this.zi=t,this.ts=!0),(0!==this.ji||0!==this.$i||this.Gi!==i||this.Yi!==s||1!==this.Xi||this.qi)&&(this.ji=0,this.$i=0,this.Gi=i,this.Yi=s,this.qi=!1,this.Xi=1,this.ss=!0),0===this.Zi&&0===this.Ji&&0===this.Ki&&0===this.Qi||(this.Zi=0,this.Ji=0,this.Ki=0,this.Qi=0,this.es=!0)}rs(t){this.Fi=t.sourceSize.w,this.Oi=t.sourceSize.h,this.texture!==t.texture&&(this.zi=t.texture,this.ts=!0);const i=t.scale??1,s=t.rotated??!1;0===this.ji&&0===this.$i&&this.Gi===t.frame.w&&this.Yi===t.frame.h&&this.Xi===i&&this.qi===s||(this.ji=t.frame.x,this.$i=t.frame.y,this.Gi=t.frame.w,this.Yi=t.frame.h,this.Xi=i,this.qi=s,this.ss=!0);const e=t.spriteSourceSize,h=e.x,r=e.y,n=this.Fi-e.x-e.w,o=this.Oi-e.y-e.h;this.Zi===h&&this.Ji===n&&this.Ki===r&&this.Qi===o||(this.Zi=h,this.Ji=n,this.Ki=r,this.Qi=o,this.es=!0)}}var Ii,Ei="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return texture2D(p_texture,transformedUV)*p_color;}";class Mi{constructor(t){this.xt=!0,this.ns=t?.x??0,this.cs=t?.y??0,this.ls=t?.anchorX??di,this.us=t?.anchorY??di,this.fs=t?.scaleX??1,this.ds=t?.scaleY??1,this.ps=t?.rotation??0,this.vs=t?.anchorMode??pi}get x(){return this.ns}get y(){return this.cs}get anchorX(){return this.ls}get anchorY(){return this.us}get scaleX(){return this.fs}get scaleY(){return this.ds}get angle(){return t.radToDeg(this.ps)}get anchorMode(){return this.vs}get rotation(){return this.ps}get dirty(){return this.xt}set x(t){t!==this.ns&&(this.ns=t,this.xt=!0)}set y(t){t!==this.cs&&(this.cs=t,this.xt=!0)}set anchorX(t){t!==this.ls&&(this.ls=t,this.xt=!0)}set anchorY(t){t!==this.us&&(this.us=t,this.xt=!0)}set scaleX(t){t!==this.fs&&(this.fs=t,this.xt=!0)}set scaleY(t){t!==this.ds&&(this.ds=t,this.xt=!0)}set angle(i){const s=t.degToRad(i);s!==this.ps&&(this.ps=s,this.xt=!0)}set rotation(t){t!==this.ps&&(this.ps=t,this.xt=!0)}set anchorMode(t){t!==this.vs&&(this.vs=t,this.xt=!0)}setDirtyFalse(){this.xt=!1}reset(){0===this.ns&&0===this.cs&&this.ls===di&&this.us===di&&1===this.fs&&1===this.ds&&0===this.ps||(this.ns=0,this.cs=0,this.ls=di,this.us=di,this.fs=1,this.ds=1,this.ps=0,this.xt=!0)}copy(t){this.ns===t.ns&&this.cs===t.cs&&this.ls===t.ls&&this.us===t.us&&this.fs===t.fs&&this.ds===t.ds&&this.ps===t.ps&&this.vs===t.vs||(this.ns=t.ns,this.cs=t.cs,this.ls=t.ls,this.us=t.us,this.fs=t.fs,this.ds=t.ds,this.ps=t.ps,this.vs=t.vs,this.xt=!0)}}class Ci{}class Ti extends Ci{constructor(t,i,s,e){super(),this.x=t,this.y=i,this.width=s,this.height=e}contains(t,i){return!(this.x>t||t>this.x+this.width||this.y>i||i>this.y+this.height)}}(t=>{t.PRESSED="pointerdown",t.MOVED="pointermove",t.RELEASED="pointerup",t.ENTERED="pointerenter",t.LEFT="pointerleave"})(Ii||(Ii={}));const Pi=M.VISIBLE;class Hi extends ui{constructor(t,i){const s=i?.width??64,e=i?.height??32;super(t,i),this.ws=!1,this.catchPointerDown=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.PRESSED),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.MOVED),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,Ii.RELEASED),this.interactionArea=i?.interactionArea??new Ti(0,0,1,1),this.modeInternal=i?.mode??Pi,this.inputWrapper=this.layer.inputWrapper,this.wVariable=this.solverWrapper.createVariable(s,Y.P6),this.hVariable=this.solverWrapper.createVariable(e,Y.P6),this.gs=this.inputWrapper.createInputCatcher(this.catchPointerDown,this.catchPointerMove,this.catchPointerUp,0),this.inputWrapper.setActive(this.gs,T(this.modeInternal))}get width(){return this.solverWrapper.readVariableValue(this.wVariable)}get height(){return this.solverWrapper.readVariableValue(this.hVariable)}get oppositeX(){return this.x+this.width}get oppositeY(){return this.y+this.height}get centerX(){return this.x+this.width/2}get centerY(){return this.y+this.height/2}get mode(){return this.modeInternal}get zIndex(){return this.inputWrapper.getZIndex(this.gs)}set width(t){this.solverWrapper.suggestVariableValue(this.wVariable,t)}set height(t){this.solverWrapper.suggestVariableValue(this.hVariable,t)}set oppositeX(t){this.x=t-this.width}set oppositeY(t){this.y=t-this.height}set centerX(t){this.x=t-this.width/2}set centerY(t){this.y=t-this.height/2}set mode(t){if(this.modeInternal!==t){const i=T(t);this.inputWrapper.setActive(this.gs,i),this.modeInternal=t}}set zIndex(t){this.inputWrapper.setZIndex(this.gs,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.inputWrapper.destroyInputCatcher(this.gs),super.destroy()}handleInputEvent(i,s,e,h){const r=this.interactionArea.contains(t.mapLinear(i,this.x,this.oppositeX,0,1),t.mapLinear(s,this.y,this.oppositeY,0,1));return r&&this.emit(h,i,s,e,this),this.ws&&!r?this.emit(Ii.LEFT,i,s,e,this):!this.ws&&r&&this.emit(Ii.ENTERED,i,s,e,this),this.ws=r,this.modeInternal!==M.INTERACTIVE_TRANSPARENT&&r}}const Ai=pt.BLEND;class Ui extends Hi{constructor(t,i,s,e){super(t,e),this.ys=!1,this._s=!1,this.micro=new Mi(e?.micro),this.bs=e?.transparencyMode??Ai,this.sceneWrapper=this.layer.sceneWrapper,this.planeHandler=this.sceneWrapper.createPlane(i,s,(new o).identity(),P(e?.mode??this.mode),this.bs),this.layer.on(Lt.RENDERING,this.onWillRender,this)}get transparencyMode(){return this.bs}set transparencyMode(t){this.bs!==t&&(this.bs=t,this.ys=!0)}set mode(t){this.modeInternal!==t&&(this._s=P(this.modeInternal)!==P(t),super.mode=t)}destroy(){this.layer.off(Lt.RENDERING,this.onWillRender,this),this.sceneWrapper.destroyPlane(this.planeHandler),super.destroy()}setPlaneTransform(){(this.micro.dirty||this.inputWrapper.dirty||this.solverWrapper.dirty)&&(this.sceneWrapper.setTransform(this.planeHandler,((t,i,s,e,h,r,n,o,a,c,l,u,f)=>{const d=s*this.micro.scaleX,p=e*this.micro.scaleY,v=o*d,w=a*p,g=Math.cos(u),y=Math.sin(u),m=v*g-w*y,_=v*y+w*g;if(f===fi.POSITION_ROTATION_SCALE)vi.x=t+r-m,vi.y=i+n-_;else{const h=a*e;vi.x=t+o*s-m+r,vi.y=i+h-_+n}return vi.z=h,gi.x=d,gi.y=p,wi.setFromAxisAngle(mi,u),yi.compose(vi,wi,gi),yi})(this.x,this.y,this.width,this.height,this.zIndex,this.micro.x,this.micro.y,this.micro.anchorX,this.micro.anchorY,0,0,this.micro.rotation,this.micro.anchorMode)),this.micro.setDirtyFalse())}onWillRender(t,i){this.ys&&(this.sceneWrapper.setTransparency(this.planeHandler,this.bs),this.ys=!1),this._s&&(this.sceneWrapper.setVisibility(this.planeHandler,P(this.modeInternal)),this._s=!1),this.setPlaneTransform()}}var Vi,Ri;(t=>{t[t.PLAYED=0]="PLAYED",t[t.PAUSED=1]="PAUSED",t[t.STOPPED=2]="STOPPED"})(Vi||(Vi={})),(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(Ri||(Ri={}));const Bi=Ri.LOOP;class Li extends Ui{constructor(t,i,s={}){const e=new Q(s.color),h=i.map(t=>new Si(t)),r=h[0];s.width=s.width??r.width,s.height=s.height??r.height;const n=r.calculateUVTransform();super(t,Ei,{texture:r.texture,textureTransform:n,color:e},s),this.xs=!1,this.Ss=0,this.Is=!1,this.Es=0,this.Ms=(t,i,s)=>{this.Cs[this.Ss]===s&&(this.width=t,this.height=i)},this.Ts=e,this.Cs=h,this.Ps=n,this.Hs=s.frameRate??24,this.As=s.timeScale??1,this.Us=s.loopMode??Bi,this.Vs(),!0===s.playByDefault&&this.play()}get color(){return this.Ts}get duration(){return this.Cs.length/this.Hs}get frameRate(){return this.Hs}get loopMode(){return this.Us}get sequence(){return this.Cs}get timeScale(){return this.As}set color(t){this.Ts.set(t)}set frameRate(t){this.Hs=t}set loopMode(t){this.Us=t}set sequence(t){this.stop(),this.Rs();const i=t.length,s=this.Cs.length;for(let e=0;Math.min(i,s)>e;e++)this.Cs[e].set(t[e]);if(s>i)this.Cs.length=i;else if(i>s)for(let e=s;i>e;e++)this.Cs.push(new Si(t[e]));this.Vs()}set timeScale(t){this.As=t}destroy(){this.Rs(),super.destroy()}play(){this.xs||(this.xs=!0,this.emit(Vi.PLAYED))}pause(){this.xs&&(this.xs=!1,this.emit(Vi.PAUSED))}stop(){(this.xs||this.Es>0||this.Ss>0)&&(this.xs=!1,this.Es=0,this.Ss=0,this.Is=!0,this.emit(Vi.STOPPED))}onWillRender(t,i){if(this.xs&&0!==this.As){this.Es+=i*this.As;const t=1/this.Hs,s=this.Cs.length,e=s-1;if(this.As>0)for(;this.Es>=t;){if(this.Es-=t,this.Ss+=1,this.Ss>=s)if(this.Us===Ri.LOOP)this.Ss=0;else{if(this.Us!==Ri.PING_PONG){this.Ss=e,this.xs=!1,this.emit(Vi.PAUSED);break}this.Ss=e,this.As=-this.As}this.Is=!0}else for(;-t>=this.Es;){if(this.Es+=t,this.Ss-=1,0>this.Ss)if(this.Us===Ri.LOOP)this.Ss=e;else{if(this.Us!==Ri.PING_PONG){this.Ss=0,this.xs=!1,this.emit(Vi.PAUSED);break}this.Ss=0,this.As=-this.As}this.Is=!0}}super.onWillRender(t,i)}setPlaneTransform(){let t;this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse());const i=this.Cs[this.Ss];if((i.textureDirty||this.Is)&&(t??(t={}),t.texture=i.texture,i.setTextureDirtyFalse()),(i.uvTransformDirty||this.Is)&&(t??(t={}),t.textureTransform=i.calculateUVTransform(this.Ps),i.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.Is||this.micro.dirty||i.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,s=i.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,s.left,s.right,s.top,s.bottom)),this.Is=!1,this.micro.setDirtyFalse(),i.setTrimDirtyFalse()}}Vs(){for(const t of this.Cs)t.on(xi.DIMENSIONS_CHANGED,this.Ms)}Rs(){for(const t of this.Cs)t.off(xi.DIMENSIONS_CHANGED,this.Ms)}}function Di(t,i){if("undefined"!=typeof OffscreenCanvas)return new OffscreenCanvas(t,i);const s=document.createElement("canvas");return s.width=t,s.height=i,s}const ki=new Q;class Wi extends Ui{constructor(t,i){const s=i?.width??2,e=i?.height??2,h=new Q(i?.color),r=Di(s,e),o=r.getContext("2d");if(!o)throw Error("UIGraphics.constructor: failed to get 2D context from canvas");const a=new w(r);a.colorSpace=g,a.minFilter=y,a.magFilter=y,a.needsUpdate=!0,super(t,Ei,{texture:a,textureTransform:new n,color:h},i),this.Bs=r,this.Ls=o,this.Ds=a,this.Ts=h}get color(){return this.Ts}set color(t){this.Ts.set(t)}clear(t){return this.Ls.clearRect(0,0,this.Bs.width,this.Bs.height),void 0!==t&&(this.Ls.fillStyle=ki.set(t).toCSSColor(),this.Ls.fillRect(0,0,this.Bs.width,this.Bs.height)),this.Ds.needsUpdate=!0,this}drawRect(t,i,s,e,h){return this.Ls.fillStyle=ki.set(h).toCSSColor(),this.Ls.fillRect(t,i,s,e),this.Ds.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.Ls.fillStyle=ki.set(e).toCSSColor(),this.Ls.beginPath(),this.Ls.arc(t,i,s,0,2*Math.PI),this.Ls.fill(),this.Ds.needsUpdate=!0,this}drawArc(t,i,s,e,h,r){return this.Ls.fillStyle=ki.set(r).toCSSColor(),this.Ls.beginPath(),this.Ls.arc(t,i,s,e,h),this.Ls.fill(),this.Ds.needsUpdate=!0,this}drawPolyline(t,i,s=1){if(2>t.length)return this;this.Ls.strokeStyle=ki.set(i).toCSSColor(),this.Ls.lineWidth=s,this.Ls.beginPath(),this.Ls.moveTo(t[0][0],t[0][1]);for(let i=1;t.length>i;i++)this.Ls.lineTo(t[i][0],t[i][1]);return this.Ls.stroke(),this.Ds.needsUpdate=!0,this}destroy(){this.Ds.dispose(),super.destroy()}onWillRender(t,i){this.Ts.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Ts}),this.Ts.setDirtyFalse()),super.onWillRender(t,i)}}class Ni extends Ui{constructor(t,i,s={}){const e=new Q(s.color),h=new Si(i),r=h.calculateUVTransform();s.width=s.width??h.width,s.height=s.height??h.height,super(t,Ei,{texture:h.texture,textureTransform:r,color:e},s),this.Ms=(t,i)=>{this.width=t,this.height=i},this.texture=h,this.Ps=r,this.Ts=e,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}set color(t){this.Ts.set(t)}destroy(){this.texture.off(xi.DIMENSIONS_CHANGED,this.Ms),super.destroy()}setPlaneTransform(){let t;if(this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class zi{constructor(t){this.bt=0,this.dt=0,this.Ri=0,this.wt=0,this.xt=!1,this.set(t)}get left(){return this.bt}get right(){return this.dt}get top(){return this.Ri}get bottom(){return this.wt}get dirty(){return this.xt}set left(t){this.bt!==t&&(this.bt=t,this.xt=!0)}set right(t){this.dt!==t&&(this.dt=t,this.xt=!0)}set top(t){this.Ri!==t&&(this.Ri=t,this.xt=!0)}set bottom(t){this.wt!==t&&(this.wt=t,this.xt=!0)}setHorizontal(t){this.bt===t&&this.dt===t||(this.bt=t,this.dt=t,this.xt=!0)}setVertical(t){this.Ri===t&&this.wt===t||(this.Ri=t,this.wt=t,this.xt=!0)}setUnified(t){this.bt===t&&this.dt===t&&this.Ri===t&&this.wt===t||(this.bt=t,this.dt=t,this.Ri=t,this.wt=t,this.xt=!0)}set(t){const i=this.bt,s=this.dt,e=this.Ri,h=this.wt;if(void 0===t)this.bt=0,this.dt=0,this.Ri=0,this.wt=0;else if("number"==typeof t)this.bt=t,this.dt=t,this.Ri=t,this.wt=t;else if(Array.isArray(t))if(2===t.length){const i=t[0],s=t[1];this.bt=i,this.dt=i,this.Ri=s,this.wt=s}else{const i=t[1],s=t[2],e=t[3];this.bt=t[0],this.dt=i,this.Ri=s,this.wt=e}else if("left"in t){const i=t.right,s=t.top,e=t.bottom;this.bt=t.left,this.dt=i,this.Ri=s,this.wt=e}else{const i=t.horizontal,s=t.vertical;this.bt=i,this.dt=i,this.Ri=s,this.wt=s}this.bt===i&&this.dt===s&&this.Ri===e&&this.wt===h||(this.xt=!0)}setVector4(t){this.bt===t.x&&this.dt===t.y&&this.Ri===t.z&&this.wt===t.w||(this.bt=t.x,this.dt=t.y,this.Ri=t.z,this.wt=t.w,this.xt=!0)}toVector4(t=new s){return t.set(this.bt,this.dt,this.Ri,this.wt)}reset(){this.setUnified(0)}copy(t){this.bt===t.bt&&this.dt===t.dt&&this.Ri===t.Ri&&this.wt===t.wt||(this.bt=t.bt,this.dt=t.dt,this.Ri=t.Ri,this.wt=t.wt,this.xt=!0)}setDirtyFalse(){this.xt=!1}}var Fi;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(Fi||(Fi={}));const Oi=Fi.WORLD;class ji extends Ui{constructor(t,i,e={}){const h=new Q(e.color),r=new Si(i),n=r.calculateUVTransform();e.width=e.width??r.width,e.height=e.height??r.height;const o=new zi(e.sliceBorders??.1),a=new zi(e.sliceRegions??.1),c=e.regionMode??Oi,l=new s,u=new s;super(t,"vec4 draw(){vec2 localUV=p_uv;float left=p_sliceBorders.x;float right=p_sliceBorders.y;float top=p_sliceBorders.z;float bottom=p_sliceBorders.w;float leftFill=p_sliceRegions.x;float rightFill=p_sliceRegions.y;float topFill=p_sliceRegions.z;float bottomFill=p_sliceRegions.w;float lB=leftFill;float rB=1.0-rightFill;float bB=bottomFill;float tB=1.0-topFill;{float regionL=step(p_uv.x,lB);float regionR=step(rB,p_uv.x);float regionM=1.0-regionL-regionR;float xL=(p_uv.x/lB)*left;float xR=1.0-right+((p_uv.x-rB)/rightFill)*right;float xM=left+((p_uv.x-lB)/(rB-lB))*(1.0-left-right);localUV.x=regionL*xL+regionM*xM+regionR*xR;}{float regionB=step(p_uv.y,bB);float regionT=step(tB,p_uv.y);float regionC=1.0-regionB-regionT;float yB=(p_uv.y/bB)*bottom;float yT=1.0-top+((p_uv.y-tB)/topFill)*top;float yC=bottom+((p_uv.y-bB)/(tB-bB))*(1.0-bottom-top);localUV.y=regionB*yB+regionC*yC+regionT*yT;}vec2 transformedUV=(p_textureTransform*vec3(localUV,1.0)).xy;return texture2D(p_texture,transformedUV)*p_color;}",{texture:r.texture,textureTransform:n,color:h,sliceBorders:l,sliceRegions:u},e),this.ks=!0,this.Ws=new s,this.Ns=new s,this.zs=!0,this.Ms=()=>{this.zs=!0},this.texture=r,this.Ps=n,this.Ts=h,this.Fs=o,this.Os=a,this.js=c,this.Ws=l,this.Ns=u,this.$s=this.width,this.Gs=this.height,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}get regionMode(){return this.js}get sliceBorders(){return this.Fs}get sliceRegions(){return this.Os}set color(t){this.Ts.set(t)}set regionMode(t){this.js!==t&&(this.js=t,this.ks=!0)}set sliceBorders(t){this.Fs.set(t)}set sliceRegions(t){this.Os.set(t)}destroy(){this.texture.off(xi.DIMENSIONS_CHANGED,this.Ms),super.destroy()}setPlaneTransform(){let t;if((this.zs||this.Fs.dirty||this.texture.trimDirty)&&(t??(t={}),t.sliceBorders=this.Ys(this.Ws),this.Fs.setDirtyFalse(),this.zs=!1),(this.Os.dirty||this.ks||this.js===Fi.WORLD&&this.qs())&&(t??(t={}),t.sliceRegions=this.Xs(this.Ns),this.Os.setDirtyFalse(),this.ks=!1,this.Zs()),this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}Ys(t){const i=this.texture.width,s=this.texture.height,e=this.texture.trim,h=e.right/i,r=e.top/s,n=e.bottom/s,o=(i-e.left-e.right)/i,a=(s-e.top-e.bottom)/s,c=this.Fs.right,l=this.Fs.top,u=this.Fs.bottom,f=Math.max(0,this.Fs.left-e.left/i)/o,d=Math.max(0,c-h)/o,p=Math.max(0,l-r)/a,v=Math.max(0,u-n)/a;return t.set(Math.min(1,f),Math.min(1,d),Math.min(1,p),Math.min(1,v))}Xs(t){if(this.js===Fi.NORMALIZED)return t.set(this.Os.left,this.Os.right,this.Os.top,this.Os.bottom);const i=this.width,s=this.height;return t.set(this.Os.left/i,this.Os.right/i,this.Os.top/s,this.Os.bottom/s)}qs(){return this.solverWrapper.dirty&&(this.$s!==Math.round(this.width)||this.Gs!==Math.round(this.height))}Zs(){this.$s=Math.round(this.width),this.Gs=Math.round(this.height)}}class $i{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class Gi extends $i{constructor(t={x:1,y:0}){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 halfExtents=vec2(aspect,1.0)*0.5;float maxProjection=dot(halfExtents,abs(p_direction));vec2 correctedUV=(p_uv-0.5)*vec2(aspect,1.0);float projection=dot(correctedUV,p_direction);float offset=(projection/maxProjection+1.0)*0.5;return step(offset,p_progress);}"),this.direction=new h,this.Js=new h,this.direction.copy(t).normalize(),this.Js.copy(this.direction)}get dirty(){return this.Ks(),this.dirtyInternal||!this.Js.equals(this.direction)}setDirtyFalse(){this.Ks(),this.Js.copy(this.direction),super.setDirtyFalse()}enumerateProperties(){return this.Ks(),{direction:this.direction}}Ks(){const t=this.direction.lengthSq();Math.abs(t)>Ot?Math.abs(t-1)>Ot&&this.direction.divideScalar(t):this.direction.set(1,0)}}var Yi,qi="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;vec4 diffuseColor=texture2D(p_texture,transformedUV)*p_color;diffuseColor.a*=calculateMask();return diffuseColor;}";class Xi extends Ui{constructor(i,s,e={}){const h=new Q(e.color),r=new Si(s),n=r.calculateUVTransform(),o=r.getResolution();e.width=e.width??r.width,e.height=e.height??r.height;const a=t.clamp(e.progress??1,0,1),c=e.maskFunction??new Gi;super(i,c.source+qi,{texture:r.texture,textureTransform:n,textureResolution:o,color:h,progress:a,...c.enumerateProperties()},e),this.Qs=!1,this.te=!1,this.Ms=(t,i)=>{this.width===t&&this.height===i||(this.width=t,this.height=i,this.te=!0)},this.texture=r,this.Ps=n,this.ie=o,this.Ts=h,this.se=a,this.ee=c,this.texture.on(xi.DIMENSIONS_CHANGED,this.Ms)}get color(){return this.Ts}get maskFunction(){return this.ee}get progress(){return this.se}set color(t){this.Ts.set(t)}set maskFunction(t){this.ee!==t&&(this.ee=t,this.he())}set progress(i){i=t.clamp(i,0,1),this.se!==i&&(this.se=i,this.Qs=!0)}setPlaneTransform(){let t;if(this.Ts.dirty&&(t??(t={}),t.color=this.Ts,this.Ts.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.Ps),this.texture.setUVTransformDirtyFalse()),this.Qs&&(t??(t={}),t.progress=this.se,this.Qs=!1),this.te&&(t??(t={}),t.textureResolution=this.texture.getResolution(this.ie),this.te=!1),this.maskFunction.dirty){t??(t={});const i=this.maskFunction.enumerateProperties();for(const s in i)t[s]=i[s];this.maskFunction.setDirtyFalse()}if(t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}he(){this.sceneWrapper.destroyPlane(this.planeHandler);const t=this.micro,i=this.texture.trim;this.planeHandler=this.sceneWrapper.createPlane(this.ee.source+qi,{texture:this.texture.texture,textureTransform:this.texture.calculateUVTransform(this.Ps),textureResolution:this.texture.getResolution(this.ie),color:this.Ts,progress:this.se,...this.ee.enumerateProperties()},_i(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom),P(this.mode),this.transparencyMode),this.Ts.setDirtyFalse(),this.texture.setTextureDirtyFalse(),this.texture.setUVTransformDirtyFalse(),this.texture.setTrimDirtyFalse(),this.Qs=!1,this.te=!1,this.ee.setDirtyFalse(),this.micro.setDirtyFalse()}}(t=>{t[t.EVERY_FRAME=1]="EVERY_FRAME",t[t.EVERY_SECOND_FRAME=2]="EVERY_SECOND_FRAME",t[t.ON_PROPERTIES_CHANGE=3]="ON_PROPERTIES_CHANGE",t[t.ON_DIMENSIONS_CHANGE=4]="ON_DIMENSIONS_CHANGE",t[t.MANUAL=5]="MANUAL"})(Yi||(Yi={}));const Zi=Yi.ON_PROPERTIES_CHANGE,Ji=new Q(0,0,0,1);class Ki extends Ui{constructor(i,s={}){const e=t.clamp(s.resolutionFactor??.5,.1,2),h=s.width??64,r=s.height??32,o=new m(h*e,r*e,{format:b,minFilter:y,magFilter:y,type:_,depthBuffer:s.enableDepthBuffer??!0,stencilBuffer:!1}),a=new Q(s.color);super(i,Ei,{texture:o.texture,textureTransform:new n,color:a},s),this.re=!0,this.ne=!1,this.oe=!1,this.ae=!1,this.Ts=a,this.ce=new Q(s.clearColor??Ji),this.le=o,this.ue=s.scene??new d,this.fe=s.camera??new x(60,h/r,.1,100),this.de=e,this.pe=s.updateMode??Zi,this.ae=s.updateMode!==Yi.MANUAL}get camera(){return this.fe}get clearColor(){return this.ce}get color(){return this.Ts}get resolutionFactor(){return this.de}get scene(){return this.ue}get updateMode(){return this.pe}set camera(t){this.fe!==t&&(this.fe=t,this.ae=!0)}set clearColor(t){this.ce.set(t)}set color(t){this.Ts.set(t)}set resolutionFactor(i){i=t.clamp(i,.1,2),this.de!==i&&(this.de=i,this.oe=!0)}set scene(t){this.ue!==t&&(this.ue=t,this.ae=!0)}set updateMode(t){this.pe!==t&&(this.pe=t,this.ae=!0)}destroy(){this.le.dispose(),super.destroy()}requestUpdate(){this.ne=!0}onWillRender(t,i){this.re=!this.re,(this.ne||this.pe===Yi.EVERY_FRAME||this.pe===Yi.EVERY_SECOND_FRAME&&this.re||this.pe===Yi.ON_PROPERTIES_CHANGE&&this.ae||this.Ts.dirty||this.ce.dirty||this.pe===Yi.ON_DIMENSIONS_CHANGE&&(this.oe||this.solverWrapper.dirty))&&((this.oe||this.solverWrapper.dirty)&&(this.le.setSize(this.width*this.de,this.height*this.de),this.oe=!1),this.Ts.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.Ts}),this.Ts.setDirtyFalse()),t.setClearColor(this.ce.getHexRGB(),this.ce.a),t.setRenderTarget(this.le),t.clear(!0,!0,!1),t.render(this.ue,this.fe),this.ae=!1,this.ne=!1),super.onWillRender(t,i)}}const Qi="#000000",ts="left",is="Arial",ss="normal",es="normal",hs=!1,rs="transparent",ns=!1,os="#000000";class as{constructor(t){this.xt=!0,this.Ts=t?.color,this.ve=t?.align,this.we=t?.fontFamily,this.ge=t?.fontSize,this.ye=t?.fontStyle,this.me=t?.fontWeight,this._e=t?.lineHeight,this.be=t?.enableShadow,this.xe=t?.shadowOffsetX,this.Se=t?.shadowOffsetY,this.Ie=t?.shadowBlur,this.Ee=t?.shadowColor,this.Me=t?.enableStroke,this.Ce=t?.strokeColor,this.Te=t?.strokeThickness}get color(){return this.Ts}get align(){return this.ve}get fontFamily(){return this.we}get fontSize(){return this.ge}get fontStyle(){return this.ye}get fontWeight(){return this.me}get lineHeight(){return this._e}get enableShadow(){return this.be}get shadowOffsetX(){return this.xe}get shadowOffsetY(){return this.Se}get shadowBlur(){return this.Ie}get shadowColor(){return this.Ee}get enableStroke(){return this.Me}get strokeColor(){return this.Ce}get strokeThickness(){return this.Te}get dirty(){return this.xt}set color(t){t!==this.Ts&&(this.Ts=t,this.xt=!0)}set align(t){t!==this.ve&&(this.ve=t,this.xt=!0)}set fontFamily(t){t!==this.we&&(this.we=t,this.xt=!0)}set fontSize(t){t!==this.ge&&(this.ge=t,this.xt=!0)}set fontStyle(t){t!==this.ye&&(this.ye=t,this.xt=!0)}set fontWeight(t){t!==this.me&&(this.me=t,this.xt=!0)}set lineHeight(t){t!==this._e&&(this._e=t,this.xt=!0)}set enableShadow(t){t!==this.be&&(this.be=t,this.xt=!0)}set shadowOffsetX(t){t!==this.xe&&(this.xe=t,this.xt=!0)}set shadowOffsetY(t){t!==this.Se&&(this.Se=t,this.xt=!0)}set shadowBlur(t){t!==this.Ie&&(this.Ie=t,this.xt=!0)}set shadowColor(t){t!==this.Ee&&(this.Ee=t,this.xt=!0)}set enableStroke(t){t!==this.Me&&(this.Me=t,this.xt=!0)}set strokeColor(t){t!==this.Ce&&(this.Ce=t,this.xt=!0)}set strokeThickness(t){t!==this.Te&&(this.Te=t,this.xt=!0)}static resolve(t,i){const s=t.ge??i.ge??16;return{color:t.Ts??i.Ts??Qi,align:t.ve??i.ve??ts,fontFamily:t.we??i.we??is,fontSize:s,fontStyle:t.ye??i.ye??ss,fontWeight:t.me??i.me??es,lineHeight:t._e??i._e??1.2*s,enableShadow:t.be??i.be??hs,shadowOffsetX:t.xe??i.xe??0,shadowOffsetY:t.Se??i.Se??0,shadowBlur:t.Ie??i.Ie??0,shadowColor:t.Ee??i.Ee??rs,enableStroke:t.Me??i.Me??ns,strokeColor:t.Ce??i.Ce??os,strokeThickness:t.Te??i.Te??0}}setDirtyFalse(){this.xt=!1}setDefaults(){this.Ts===Qi&&this.ve===ts&&this.we===is&&16===this.ge&&this.ye===ss&&this.me===es&&19.2===this._e&&this.be===hs&&0===this.xe&&0===this.Se&&0===this.Ie&&this.Ee===rs&&this.Me===ns&&this.Ce===os&&0===this.Te||(this.Ts=Qi,this.ve=ts,this.we=is,this.ge=16,this.ye=ss,this.me=es,this._e=19.2,this.be=hs,this.xe=0,this.Se=0,this.Ie=0,this.Ee=rs,this.Me=ns,this.Ce=os,this.Te=0,this.xt=!0)}clear(){void 0===this.Ts&&void 0===this.ve&&void 0===this.we&&void 0===this.ge&&void 0===this.ye&&void 0===this.me&&void 0===this._e&&void 0===this.be&&void 0===this.xe&&void 0===this.Se&&void 0===this.Ie&&void 0===this.Ee&&void 0===this.Me&&void 0===this.Ce&&void 0===this.Te||(this.Ts=void 0,this.ve=void 0,this.we=void 0,this.ge=void 0,this.ye=void 0,this.me=void 0,this._e=void 0,this.be=void 0,this.xe=void 0,this.Se=void 0,this.Ie=void 0,this.Ee=void 0,this.Me=void 0,this.Ce=void 0,this.Te=void 0,this.xt=!0)}copy(t){this.Ts===t.Ts&&this.ve===t.ve&&this.we===t.we&&this.ge===t.ge&&this.ye===t.ye&&this.me===t.me&&this._e===t._e&&this.be===t.be&&this.xe===t.xe&&this.Se===t.Se&&this.Ie===t.Ie&&this.Ee===t.Ee&&this.Me===t.Me&&this.Ce===t.Ce&&this.Te===t.Te||(this.Ts=t.Ts,this.ve=t.ve,this.we=t.we,this.ge=t.ge,this.ye=t.ye,this.me=t.me,this._e=t._e,this.be=t.be,this.xe=t.xe,this.Se=t.Se,this.Ie=t.Ie,this.Ee=t.Ee,this.Me=t.Me,this.Ce=t.Ce,this.Te=t.Te,this.xt=!0)}calculatePadding(){let t=0;if(void 0!==this.Me&&(t+=this.Te??0),void 0!==this.be){const i=this.Se??0,s=2*(this.Ie??0);t+=Math.max(Math.abs(this.xe??0)+s,Math.abs(i)+s)}return Math.ceil(t)}}class cs{constructor(t){this.xt=!0,this.Pe=t.text,this.style=new as(t.style)}get text(){return this.Pe}get dirty(){return this.xt||this.style.dirty}set text(t){t!==this.Pe&&(this.Pe=t,this.xt=!0)}setDirtyFalse(){this.xt=!1,this.style.setDirtyFalse()}}var ls;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(ls||(ls={}));const us=ls.SCALE;function fs(t){return t.match(/\S+|\s|\n/g)??[]}function ds(t,i,s){if(t.font=`${s.fontStyle} ${s.fontWeight} ${s.fontSize}px "${s.fontFamily}"`,"\n"===i)return{width:1,height:s.lineHeight,baseline:0,lineHeight:s.lineHeight};const e=t.measureText(i);return{width:Math.ceil(e.width),height:Math.ceil(e.actualBoundingBoxAscent+e.actualBoundingBoxDescent),baseline:e.actualBoundingBoxDescent,lineHeight:s.lineHeight}}function ps(t,i){const s=((t,i)=>{const s=[];let e=[],h=0,r=0,n=0,o=0;for(const a of i)"\n"!==a.text?0!==e.length&&h+a.metrics.width>t?(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})(i,t),e=(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}return{width:i,height:s}})(s);return{lines:s,size:e}}function vs(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.strokeThickness,h.strokeText(s,t,i)),h.fillStyle=e.color,h.fillText(s,t,i)}function ws(t,i,s,e){let h=t,r=0;for(const t of s)r=Math.max(t.width,r);for(let t=0;s.length>t;t++){const n=s[t],o=n.chunks[0]?.style.align??ts,a=n.chunks.every(t=>t.style.align===o)?o:ts;let c=0;"center"===a?c=(r-n.width)/2:"right"===a&&(c=r-n.width);let l=i+c;h+=0===t?n.height:n.lineHeight;for(const t of n.chunks)vs(l,h,t.text,t.style,e),l+=t.metrics.width}}class gs extends Ui{constructor(t,i,s={}){const e=Di(2,2),h=e.getContext("2d");if(!h)throw Error("UIText.constructor: failed to create canvas context");const r=new w(e);r.colorSpace=g,r.needsUpdate=!0;const o=new Q(s.color);switch(super(t,Ei,{texture:r,textureTransform:new n,color:o}),this.He=[],this.Ae=!1,this.Ue=!1,this.Ve=!1,this.Re=[],this.Be=!1,this.Ts=o,this.De=new zi(s.padding),this.commonStyle=new as(s.commonStyle),this.ke=s.maxLineWidth??1024,this.We=s.resizeMode??us,this.Bs=e,this.Ls=h,this.Ds=r,this.content=i,this.Ne=this.width,this.ze=this.height,void 0===s.padding&&this.De.setUnified(this.content.reduce((t,i)=>Math.max(t,i.style.calculatePadding()),this.commonStyle.calculatePadding())),this.We){case ls.SCALE:this.Fe();break;case ls.BREAK:this.Oe()}}get color(){return this.Ts}get content(){return this.He}get maxLineWidth(){return this.ke}get padding(){return this.De}get resizeMode(){return this.We}set color(t){this.Ts.set(t)}set content(t){this.He!==t&&(this.He="string"==typeof t?[new cs({text:t,style:new as})]:Array.isArray(t)?t.map(t=>new cs("string"==typeof t?{text:t,style:new as}:{text:t.text,style:new as(t.style)})):[new cs({text:t.text,style:new as(t.style)})],this.Ae=!0,this.Be=!0)}set maxLineWidth(t){this.ke!==t&&(this.ke=t,this.Ue=!0)}set padding(t){this.De.set(t)}set resizeMode(t){this.We!==t&&(this.We=t,this.Ve=!0)}destroy(){this.Ds.dispose(),super.destroy()}onWillRender(t,i){switch(this.We){case ls.SCALE:this.Fe();break;case ls.BREAK:this.Oe()}super.onWillRender(t,i)}Fe(){if(!(this.Ts.dirty||this.Ve||this.Ue||this.De.dirty||this.solverWrapper.dirty&&this.Ne/this.ze!==Math.round(this.width)/Math.round(this.height)||this.je()))return;const t=this.$e(),{lines:i,size:s}=ps(t,this.ke),e=s.height+(this.De.top+this.De.bottom),h=s.width+(this.De.left+this.De.right);this.width=h,this.height=e/h*Math.round(this.width),this.width=h/e*Math.round(this.height);const r=this.Ne!==e||this.ze!==h;r&&(this.Bs.height=e,this.Bs.width=h),ws(this.De.top,this.De.left,i,this.Ls),this.Ye(r),this.Ve=!1,this.Ue=!1,this.De.setDirtyFalse(),this.qe(),this.Xe()}Oe(){if(!(this.Ts.dirty||this.Ve||this.Ue||this.De.dirty||this.Ze()||this.je()))return;const t=this.$e(),{size:i}=ps(t,this.ke),s=this.De.top+this.De.bottom,e=this.De.left+this.De.right;this.height=i.height+s,this.width=i.width+e;const{lines:h,size:r}=ps(t,Math.round(this.width)-e);this.height=r.height+s,this.width=r.width+e;const n=Math.max(Math.round(this.width),2),o=Math.max(Math.round(this.height),2),a=this.Ne!==n||this.ze!==o;a&&(this.Bs.width=n,this.Bs.height=o),ws(this.De.top,this.De.left,h,this.Ls),this.Ye(a),this.Ve=!1,this.Ue=!1,this.De.setDirtyFalse(),this.qe(),this.Xe()}Ye(t){let i;this.Ts.dirty&&(i??(i={}),i.color=this.Ts,this.Ts.setDirtyFalse()),t&&(this.Ds.dispose(),this.Ds=new w(this.Bs),this.Ds.colorSpace=g,this.Ds.needsUpdate=!0,i??(i={}),i.texture=this.Ds),i&&this.sceneWrapper.setProperties(this.planeHandler,i)}$e(){return this.Be&&(this.Re=((t,i,s)=>{const e=[];for(const h of i){const i=as.resolve(h.style,s);for(const s of fs(h.text)){const h=ds(t,s,i);e.push({text:s,style:i,metrics:h})}}return e})(this.Ls,this.He,this.commonStyle),this.Be=!1),this.Re}Ze(){return this.solverWrapper.dirty&&(this.Ne!==Math.round(this.width)||this.ze!==Math.round(this.height))}qe(){this.Ne=Math.round(this.width),this.ze=Math.round(this.height)}je(){return this.Ae||this.content.some(t=>t.dirty)}Xe(){this.Ae=!1;for(const t of this.content)t.setDirtyFalse()}}class ys{constructor(){this.dirty=!1}}class ms extends ys{calculateScale(t,i){return 1}}const _s=new ms;class bs extends Wt{constructor(t){const i=t?.resizePolicy??_s,s=i.calculateScale(window.innerWidth,window.innerHeight);super({width:window.innerWidth*s,height:window.innerHeight*s,...t}),this.Je=!1,this.Ke=()=>{const t=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight);this.resizePolicy.dirty=!1,this.Je=!1,this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.Qe=t=>{this.th(t,"onPointerDown",Ii.PRESSED)},this.ih=t=>{this.th(t,"onPointerMove",Ii.MOVED)},this.sh=t=>{this.th(t,"onPointerUp",Ii.RELEASED)},this.eh=i,window.addEventListener("resize",this.Ke),window.addEventListener("pointerdown",this.Qe),window.addEventListener("pointermove",this.ih),window.addEventListener("pointerup",this.sh)}get resizePolicy(){return this.eh}set resizePolicy(t){this.eh!==t&&(this.eh=t,this.Je=!0)}destroy(){window.removeEventListener("resize",this.Ke),window.removeEventListener("pointerdown",this.Qe),window.removeEventListener("pointermove",this.ih),window.removeEventListener("pointerup",this.sh)}render(t,i){(this.resizePolicy.dirty||this.Je)&&this.Ke(),super.renderInternal(t,i)}projectWorldPosition(i,s,e=new r){return e.copy(i).project(s),e.x=t.mapLinear(e.x,-1,1,this.x,this.width),e.y=t.mapLinear(e.y,-1,1,this.y,this.height),e}projectLayerPosition(i,s,e=-1,h=new r){return h.set(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),e).unproject(s)}buildRay(i,s,e=new S){const h=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),-1).unproject(s),n=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),1).unproject(s).sub(h).normalize();return e.set(h,n)}th(t,i,s){const e=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,h=e?t.clientX-e.left:t.clientX,r=e?e.bottom-t.clientY:window.innerHeight-t.clientY,n=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight),o=h*n,a=r*n;T(this.mode)&&(this.emit(s,o,a,t.pointerId),this.inputWrapperInternal[i](o,a,t.pointerId))}}class xs extends Ci{constructor(t,i,s){super(),this.centerX=t,this.centerY=i,this.radius=s}contains(t,i){const s=t-this.centerX,e=i-this.centerY;return this.radius*this.radius>=s*s+e*e}}class Ss extends Ci{constructor(t){super(),this.vertices=t}contains(t,i){const s=this.vertices.length;if(3>s)return!1;let e=!1;for(let h=0,r=s-1;s>h;r=h++){const s=this.vertices[h],n=this.vertices[r],o=s.x,a=s.y,c=n.y;a>i!=c>i&&(n.x-o)*(i-a)/(c-a)+o>t&&(e=!e)}return e}}class Is extends Ci{constructor(t,i,s,e,h){super(),this.x=t,this.y=i,this.width=s,this.height=e,this.radius=h,this.radius=Math.min(h,Math.min(s,e)/2)}contains(t,i){const s=this.x,e=this.x+this.width,h=this.y,r=this.y+this.height;if(s>t||t>e||h>i||i>r)return!1;const n=s+this.radius,o=e-this.radius,a=h+this.radius,c=r-this.radius;if(t>=n&&o>=t)return!0;if(i>=a&&c>=i)return!0;let l,u;l=n>t?n:o,u=a>i?a:c;const f=t-l,d=i-u;return this.radius*this.radius>=f*f+d*d}}class Es extends $i{constructor(t=0,i=!1){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 p=(p_uv-0.5)*vec2(aspect,1.0);float angle=atan(p.y,p.x);angle=(angle+PI)/(2.0*PI);float adjusted=angle-p_startAngle;adjusted=p_direction>0.0 ? adjusted :-adjusted;adjusted=fract(adjusted);return step(adjusted,p_progress);}"),this.hh=t,this.rh=i}get startAngle(){return this.hh}get inverseDirection(){return this.rh}set startAngle(t){this.hh!==t&&(this.hh=t,this.dirtyInternal=!0)}set inverseDirection(t){this.rh!==t&&(this.rh=t,this.dirtyInternal=!0)}enumerateProperties(){return{direction:this.rh?-1:1,startAngle:this.hh}}}class Ms extends ys{constructor(t,i){super(),this.nh=t,this.oh=i}get rectWidth(){return this.nh}get rectHeight(){return this.oh}set rectWidth(t){t!==this.nh&&(this.nh=t,this.dirty=!0)}set rectHeight(t){t!==this.oh&&(this.oh=t,this.dirty=!0)}calculateScale(t,i){return Math.min(this.nh/t,this.oh/i)}}class Cs extends ys{constructor(t,i){super(),this.ah=t,this.uh=i}get fixedWidthLandscape(){return this.ah}get fixedHeightPortrait(){return this.uh}set fixedWidthLandscape(t){t!==this.ah&&(this.ah=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.uh&&(this.uh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ah/t:this.uh/i}}class Ts extends ys{constructor(t,i){super(),this.fh=t,this.dh=i}get fixedHeightLandscape(){return this.fh}get fixedWidthPortrait(){return this.dh}set fixedHeightLandscape(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.fh/i:this.dh/t}}class Ps extends ys{constructor(t,i){super(),this.nh=t,this.oh=i}get rectWidth(){return this.nh}get rectHeight(){return this.oh}set rectWidth(t){t!==this.nh&&(this.nh=t,this.dirty=!0)}set rectHeight(t){t!==this.oh&&(this.oh=t,this.dirty=!0)}calculateScale(t,i){return Math.max(this.nh/t,this.oh/i)}}class Hs extends ys{constructor(t,i){super(),this.fh=t,this.uh=i}get fixedHeightLandscape(){return this.fh}get fixedHeightPortrait(){return this.uh}set fixedHeightLandscape(t){t!==this.fh&&(this.fh=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.uh&&(this.uh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.fh/i:this.uh/i}}class As extends ys{constructor(t,i){super(),this.ah=t,this.dh=i}get fixedWidthLandscape(){return this.ah}get fixedWidthPortrait(){return this.dh}set fixedWidthLandscape(t){t!==this.ah&&(this.ah=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.dh&&(this.dh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.ah/t:this.dh/t}}export{ui as UIAnchor,Li as UIAnimatedImage,Ri as UIAnimatedImageLoopMode,xs as UIAreaCircle,Ss as UIAreaPolygon,Ti as UIAreaRectangle,Is as UIAreaRoundedRectangle,ri as UIAspectConstraint,Q as UIColor,hi as UIConstraint2DBuilder,oi as UICoverConstraintBuilder,li as UICustomConstraint,Rt as UIExpression,ci as UIFitConstraintBuilder,bs as UIFullscreenLayer,Wi as UIGraphics,Xt as UIHeightConstraint,Zt as UIHorizontalDistanceConstraint,Jt as UIHorizontalInterpolationConstraint,Kt as UIHorizontalProportionConstraint,Ni as UIImage,Hi as UIInputDummy,Ii as UIInputEvent,Mi as UIMicro,fi as UIMicroAnchorMode,M as UIMode,ji as UINineSlice,Fi as UINineSliceRegionMode,C as UIOrientation,Y as UIPriority,Xi as UIProgress,Es as UIProgressMaskFunctionCircular,Gi as UIProgressMaskFunctionDirectional,Bt as UIRelation,Ms as UIResizePolicyCover,Cs as UIResizePolicyCross,Ts as UIResizePolicyCrossInverted,Ps as UIResizePolicyFit,Hs as UIResizePolicyFixedHeight,As as UIResizePolicyFixedWidth,ms as UIResizePolicyNone,Ki as UIScene,Yi as UISceneUpdateMode,qt as UISingleParameterConstraint,gs as UIText,ls as UITextResizeMode,pt as UITransparencyMode,Qt as UIVerticalDistanceConstraint,ti as UIVerticalInterpolationConstraint,ii as UIVerticalProportionConstraint,si as UIWidthConstraint};
|
|
2
2
|
//# sourceMappingURL=index.min.js.map
|