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