laymur 0.14.1 → 0.15.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.
Files changed (26) hide show
  1. package/README.md +69 -13
  2. package/dist/elements/UIAnchor/UIAnchor.d.ts +1 -2
  3. package/dist/elements/UIAnimatedImage/UIAnimatedImage.Internal.d.ts +0 -9
  4. package/dist/elements/UIAnimatedImage/UIAnimatedImage.d.ts +10 -0
  5. package/dist/elements/UIGraphics/UIGraphics.d.ts +1 -1
  6. package/dist/elements/UIInputDummy/UIInputDummy.Internal.d.ts +12 -0
  7. package/dist/elements/UIInputDummy/UIInputDummy.d.ts +19 -3
  8. package/dist/index.d.ts +0 -1
  9. package/dist/index.js +8328 -8162
  10. package/dist/index.js.map +1 -1
  11. package/dist/index.min.js +1 -1
  12. package/dist/index.min.js.map +1 -1
  13. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.Internal.d.ts +12 -0
  14. package/dist/layers/UIFullscreenLayer/UIFullscreenLayer.d.ts +11 -1
  15. package/dist/layers/UILayer/UILayer.Internal.d.ts +0 -9
  16. package/dist/layers/UILayer/UILayer.d.ts +11 -2
  17. package/dist/miscellaneous/generic-plane/UIGenericInstancedPlane/UIGenericInstancedPlane.Internal.d.ts +10 -1
  18. package/dist/miscellaneous/generic-plane/UIGenericPlaneRegistry/UIGenericPlaneRegistry.Internal.d.ts +13 -9
  19. package/dist/miscellaneous/generic-plane/shared.d.ts +5 -0
  20. package/dist/miscellaneous/mask-function/UIProgressMaskFunctionDirectional.d.ts +1 -1
  21. package/dist/miscellaneous/texture/UITextureView.Internal.d.ts +0 -5
  22. package/dist/miscellaneous/texture/UITextureView.d.ts +4 -2
  23. package/package.json +3 -6
  24. package/dist/miscellaneous/UIInputEvent.d.ts +0 -13
  25. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.Internal.d.ts +0 -6
  26. package/dist/miscellaneous/generic-plane/UIGenericPlane/UIGenericPlane.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 r,Vector3 as h,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,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 l=n;for(let t=o;l>=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 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,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 l=r.tag.other;if(o=e.find(l),void 0!==o)return 0>o.second.add(h)&&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,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,l=this._rowMap;for(let i=0,r=l.size();r>i;++i){let r=l.itemAt(i),a=r.second,u=a.coefficientFor(t);if(0===u)continue;let c=r.first;if(c.type()===Y.External)o=c;else if(0>u){let t=-a.constant()/u;s>t&&(s=t,h=c)}else{let t=a.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),l=st(e);return n===this.P&&o===this.H&&l===this.A&&h===this.U||(this.P=n,this.H=o,this.A=l,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,l]=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 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),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 l=0===h?0:h/(1-Math.abs(2*n-1));this.R=o,this.V=l,this.B=n,this.O=!1}}}let ht,nt;const ot=()=>(null!=nt||(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}})()),nt),lt=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),at=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),ut=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),ct=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),dt=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),ft=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),vt=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function pt(t){if("string"==typeof t)switch(t){case"number":return lt;case"Texture":return at;case"UIColor":case"Vector4":return dt;case"Vector2":return ut;case"Vector3":return ct;case"Matrix3":return ft;case"Matrix4":return vt;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return lt;if(t===e)return at;if(t===rt)return dt;if(t===r)return ut;if(t===h)return ct;if(t===s)return dt;if(t===n)return ft;if(t===o)return vt;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return lt;if(t instanceof e)return at;if(t instanceof rt)return dt;if(t instanceof r)return ut;if(t instanceof h)return ct;if(t instanceof s)return dt;if(t instanceof n)return ft;if(t instanceof o)return vt;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function wt(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function gt(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 yt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:pt(e)}}return i}function mt(t){return"number"==typeof t||t instanceof e?t:t.clone()}function bt(t){const i={};for(const s in t)i[s]=mt(t[s]);return i}function _t(t,i,s){return`\n // Defines\n #define PI 3.14159265359\n #define SRGB_SUPPORTED ${ot()?"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 xt;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(xt||(xt={}));const St=(()=>{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})(),Et=new s,It=[1,0,0,0,0,1,0,0,0,0,1,0,0,0,0,1];function Mt(t,i,e){if(t instanceof rt)t.toGLSLColor(Et),i[e]=Et.x,i[e+1]=Et.y,i[e+2]=Et.z,i[e+3]=Et.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 Ct(t,i){const s=pt(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 Tt(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 Pt extends d{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:4;const h={},n={instanceVisibility:{value:1,glslTypeInfo:pt("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:pt("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?n[t]=s:h[t]=s}const l=St.clone(),a=((t,i,s,e)=>{const r={},h=[],n=[],o=[],l=[];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};`),l.push(`p_${t} = a_${t};`)}const a=`\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 ${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=_t(h,o,t);return new u({uniforms:r,vertexShader:a,fragmentShader:c,transparent:e===xt.BLEND,alphaTest:e===xt.CLIP?.5:0,alphaHash:e===xt.HASH,depthWrite:e!==xt.BLEND,depthTest:!0})})(t,h,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=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=Ct(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];wt(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]=It[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);Mt(e,i.array,s*i.itemSize),i.needsUpdate=!0}else wt(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:xt.BLEND)&&this.source===t&&gt(Object.assign(Object.assign({},this.Y),this.X),i)}arePropertiesPartiallyCompatible(t){return gt(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:Tt(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 Ht=new l(1,1).translate(.5,.5,0);class At 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=_t(h,[],t);return new u({uniforms:r,vertexShader:n,fragmentShader:o,transparent:s===xt.BLEND,alphaTest:s===xt.CLIP?.5:0,alphaHash:s===xt.HASH,depthWrite:s!==xt.BLEND,depthTest:!0})})(t,i,r,s);super(Ht,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=wt(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){wt("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===xt.BLEND,this.$.alphaTest=t===xt.CLIP?.5:0,this.$.alphaHash=t===xt.HASH,this.$.depthWrite=t!==xt.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&&gt(this.nt,i)}arePropertiesPartiallyCompatible(t){return gt(this.nt,t)}destroy(){this.$.dispose()}}function Ut(t){return!("instanceHandler"in t)}function Rt(t){return"instanceHandler"in t}class Vt{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:yt(bt(i)),transform:s.clone(),visibility:e,transparency:r}),h}destroyPlane(t){const i=this.ft(t);if(Ut(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=yt(i);if(Ut(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:mt(e[t].value),glslTypeInfo:e[t].glslTypeInfo};this.destroyPlane(t),this.dt(t,r)}setTransform(t,i){const s=this.ft(t);Ut(s)?s.plane.setTransform(i):s.plane.setTransform(s.instanceHandler,i)}setVisibility(t,i){const s=this.ft(t);Ut(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(Ut(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 Pt(s,e,n),l=o.createInstance();return o.setProperties(l,e),o.setTransform(l,r),o.setVisibility(l,h),this.ut.add(o),this.ct.set(t,{plane:o,instanceHandler:l}),o}vt(t,i){let s;for(const[e,r]of this.ct)if(Rt(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 l=new At(e,r,h,n,o);this.ut.add(l),this.ct.set(s[0],{plane:l})}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 l=this.bt(s,e,r);if(l){const i=this.wt(l[0],l[1]);return void this.gt(t,i,e,h,n)}const a=new At(s,e,h,n,r);this.ut.add(a),this.ct.set(t,{plane:a})}bt(t,i,s){for(const e of this.ct){const r=e[1];if(Ut(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(Rt(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 Bt=new i,Dt=0,Lt=!1,kt=!1,Ot=!1,Wt=!1;class Nt{constructor(t,i){this.ut=new f,this._t=new Vt(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 Bt=t.getClearColor(Bt),Dt=t.getClearAlpha(),Lt=t.autoClear,kt=t.autoClearColor,Ot=t.autoClearDepth,Wt=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(Bt),t.setClearAlpha(Dt),t.autoClear=Lt,t.autoClearColor=kt,t.autoClearDepth=Ot,t.autoClearStencil=Wt,this}}class jt{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++)Kt()}static plus(t,i){const s=new jt(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 jt(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 jt(this.constant,Array.from(this.St.entries()))}prepareTerms(){return Array.from(this.St.entries())}}var zt,Ft;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})(zt||(zt={}));class Gt{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 jt(0,[[h,1]]),new jt(t),zt.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 jt).plus(t,1),new jt(e.value),zt.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 jt).plus(t,1),e=new jt(r.value);r.constraint=this.Ht(i,e,zt.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 zt.EQUAL:return N.Eq;case zt.LESS_THAN:return N.Le;case zt.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"})(Ft||(Ft={}));const $t=P.VISIBLE;class Yt extends T{constructor(t){var i,s,e,r;super(),this.name="",this.inputWrapperInternal=new tt,this.Dt=new Gt;const h=null!==(i=t.width)&&void 0!==i?i:1024,n=null!==(s=t.height)&&void 0!==s?s:1024;this.Lt=new Nt(h,n),this.name=null!==(e=t.name)&&void 0!==e?e:"",this.kt=null!==(r=t.mode)&&void 0!==r?r:$t,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(Ft.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(Ft.ORIENTATION_CHANGED,this.Ot,this))}renderInternal(t,i){U(this.mode)&&(this.emit(Ft.RENDERING,t,i,this),this.Lt.render(t)),this.Dt.dirty=!1,this.inputWrapperInternal.dirty=!1}}const Xt=1e-6;function qt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Yt}function Zt(t){return"object"==typeof t&&null!==t&&"xVariable"in t&&"number"==typeof t.xVariable&&"yVariable"in t&&"number"==typeof t.yVariable&&"width"in t&&"number"==typeof t.width&&"height"in t&&"number"==typeof t.height}function Jt(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 Kt(){}function Qt(t,i,s){if(t instanceof Yt)return t;if(qt(t))return t.layer;if(i instanceof Yt)return i;if(qt(i))return i.layer;throw Error(s+": no valid subjects found")}function ti(t,i,s){if(qt(i))return i.layer;if(qt(s))return s.layer;if(i instanceof Yt)return i;if(s instanceof Yt)return s;throw Error(t+": no valid subjects found")}class ii{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=null!=i?i:""}}class si extends ii{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:zt.EQUAL,this.Ot=null!=(r=null==i?void 0:i.orientation)?r:H.ALWAYS,this.layer.on(Ft.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(Ft.ORIENTATION_CHANGED,this.Wt),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.Ot===H.ALWAYS||this.Ot===this.layer.orientation}}class ei extends si{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 jt(0,[[this.zt.hVariable,1]]),new jt(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 jt(t)))}}class ri extends si{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n;super(Qt(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 jt(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 jt(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(Jt(this.Gt))t=new jt(0,[[this.Gt.xVariable,1],[this.Gt.wVariable,this.Yt]]);else{if(!Zt(this.Gt))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new jt).plus(this.Gt.xVariable,1)}if(Jt(this.$t))i=new jt(0,[[this.$t.xVariable,1],[this.$t.wVariable,this.Xt]]);else{if(!Zt(this.$t))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new jt).plus(this.$t.xVariable,1)}return jt.minus(i,t)}}class hi extends si{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:{};var h,n,o;const l=null!==(h=r.anchorA)&&void 0!==h?h:.5;super(ti("UIHorizontalInterpolationConstraint.constructor",t,i),r),this.Gt=t,this.$t=i,this.Jt=s,this.Yt=l,this.Xt=l,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 jt(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(Jt(this.Gt))t=new jt(0,[[this.Gt.xVariable,1],[this.Gt.wVariable,this.Yt]]);else{if(!Zt(this.Gt))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new jt).plus(this.Gt.xVariable,1)}if(Jt(this.$t))i=new jt(0,[[this.$t.xVariable,1],[this.$t.wVariable,this.Xt]]);else{if(!Zt(this.$t))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new jt).plus(this.$t.xVariable,1)}if(Jt(this.Jt))s=new jt(0,[[this.Jt.xVariable,1],[this.Jt.wVariable,this.Kt]]);else{if(!Zt(this.Jt))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new jt).plus(this.Jt.xVariable,1)}const e=t.clone().multiply(1-this.Qt),r=i.clone().multiply(this.Qt);return jt.minus(jt.minus(s,e),r)}}class ni extends si{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r;super(Qt(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 jt(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 jt.minus(new jt(0,[[this.Gt.wVariable,this.ti]]),new jt(0,[[this.$t.wVariable,1]]))}}class oi extends si{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n;super(Qt(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 jt(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 jt(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(Jt(this.Gt))t=new jt(0,[[this.Gt.yVariable,1],[this.Gt.hVariable,this.Yt]]);else{if(!Zt(this.Gt))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new jt).plus(this.Gt.yVariable,1)}if(Jt(this.$t))i=new jt(0,[[this.$t.yVariable,1],[this.$t.hVariable,this.Xt]]);else{if(!Zt(this.$t))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new jt).plus(this.$t.yVariable,1)}return jt.minus(i,t)}}class li extends si{constructor(t,i,s,e){let r=arguments.length>3&&void 0!==e?e:{};var h,n,o;const l=null!==(h=r.anchorA)&&void 0!==h?h:.5;super(ti("UIVerticalInterpolationConstraint.constructor",t,i),r),this.Gt=t,this.$t=i,this.Jt=s,this.Yt=l,this.Xt=l,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 jt(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(Jt(this.Gt))t=new jt(0,[[this.Gt.yVariable,1],[this.Gt.hVariable,this.Yt]]);else{if(!Zt(this.Gt))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new jt).plus(this.Gt.yVariable,1)}if(Jt(this.$t))i=new jt(0,[[this.$t.yVariable,1],[this.$t.hVariable,this.Xt]]);else{if(!Zt(this.$t))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new jt).plus(this.$t.yVariable,1)}if(Jt(this.Jt))s=new jt(0,[[this.Jt.yVariable,1],[this.Jt.hVariable,this.Kt]]);else{if(!Zt(this.Jt))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new jt).plus(this.Jt.yVariable,1)}const e=t.clone().multiply(1-this.Qt),r=i.clone().multiply(this.Qt);return jt.minus(jt.minus(s,e),r)}}class ai extends si{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r;super(Qt(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 jt(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 jt.minus(new jt(0,[[this.Gt.hVariable,this.ti]]),new jt(0,[[this.$t.hVariable,1]]))}}class ui extends si{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 jt(0,[[this.zt.wVariable,1]]),new jt(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 jt(t)))}}function ci(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 di{static size(t,i){let s=arguments.length>1&&void 0!==i?i:{};const e=ci(s.size),r=ci(s.priority),h=ci(s.relation),n=ci(s.orientation);return{h:new ui(t,{width:e.h,priority:r.h,relation:h.h,orientation:n.h}),v:new ei(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=ci(e.anchorA),h=ci(e.anchorB),n=ci(e.distance),o=ci(e.priority),l=ci(e.relation),a=ci(e.orientation);return{h:new ri(t,i,{anchorA:r.h,anchorB:h.h,distance:n.h,priority:o.h,relation:l.h,orientation:a.h}),v:new oi(t,i,{anchorA:r.v,anchorB:h.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 r=ci(e.proportion),h=ci(e.priority),n=ci(e.relation),o=ci(e.orientation);return{h:new ni(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=ci(r.anchorA),n=ci(r.anchorB),o=ci(r.anchorC),l=ci(r.t),a=ci(r.priority),u=ci(r.relation),c=ci(r.orientation);return{h:new hi(t,i,s,{anchorA:h.h,anchorB:n.h,anchorC:o.h,t:l.h,priority:a.h,relation:u.h,orientation:c.h}),v:new li(t,i,s,{anchorA:h.v,anchorB:n.v,anchorC:o.v,t:l.v,priority:a.v,relation:u.v,orientation:c.v})}}}class fi extends si{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 jt(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 jt(0,[[this.zt.wVariable,1],[this.zt.hVariable,-this.ei]])}}const vi=.5;class pi{static build(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o;let l;return!0===e.keepActiveAspect&&(l=new fi(i,{orientation:e.orientation})),{activeAspectConstraint:l,xConstraint:new ri(t,i,{anchorA:null!==(r=e.anchorH)&&void 0!==r?r:vi,anchorB:null!==(h=e.anchorH)&&void 0!==h?h:vi,orientation:e.orientation}),yConstraint:new oi(t,i,{anchorA:null!==(n=e.anchorV)&&void 0!==n?n:vi,anchorB:null!==(o=e.anchorV)&&void 0!==o?o:vi,orientation:e.orientation}),widthConstraint:new ni(t,i,{proportion:1,relation:zt.GREATER_THAN,orientation:e.orientation}),heightConstraint:new ai(t,i,{proportion:1,priority:K.P1,orientation:e.orientation})}}}const wi=.5;class gi{static build(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o;let l;return!0===e.keepActiveAspect&&(l=new fi(i,{orientation:e.orientation})),{activeAspectConstraint:l,xConstraint:new ri(t,i,{anchorA:null!==(r=e.anchorH)&&void 0!==r?r:wi,anchorB:null!==(h=e.anchorH)&&void 0!==h?h:wi,orientation:e.orientation}),yConstraint:new oi(t,i,{anchorA:null!==(n=e.anchorV)&&void 0!==n?n:wi,anchorB:null!==(o=e.anchorV)&&void 0!==o?o:wi,orientation:e.orientation}),widthConstraint:new ni(t,i,{proportion:1,relation:zt.LESS_THAN,orientation:e.orientation}),heightConstraint:new ai(t,i,{proportion:1,priority:K.P1,orientation:e.orientation})}}}class yi extends si{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 mi 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 bi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(bi||(bi={}));const _i=.5,xi=bi.ROTATION_SCALE,Si=new h,Ei=new p,Ii=new h,Mi=new o,Ci=new h(0,0,1);function Ti(t,i,s,e,r,h,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===bi.POSITION_ROTATION_SCALE)Si.x=t+h-S+C,Si.y=i+n-E+T;else{const r=l*e;Si.x=t+o*s-S+h+C,Si.y=i+r-E+n+T}return Si.z=r,Ii.x=g*a,Ii.y=y*u,Ei.setFromAxisAngle(Ci,c),Mi.compose(Si,Ei,Ii),Mi}const Pi=new e;var Hi;(t=>{t[t.DIMENSIONS_CHANGED=0]="DIMENSIONS_CHANGED"})(Hi||(Hi={}));class Ai extends T{constructor(t){super(),this.ni=Pi,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,r,h;const o=null!==(e=null===(s=this.ni.image)||void 0===s?void 0:s.naturalWidth)&&void 0!==e?e:2,l=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/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 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(Hi.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.li=n,this.texture!==t&&(this.ni=t,this.bi=!0),(0!==this.ai||0!==this.ui||this.ci!==h||this.di!==n||1!==this.pi||this.fi)&&(this.ai=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.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,r=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===r||(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=r,this._i=!0);const h=t.spriteSourceSize,n=h.x,o=h.y,l=this.oi-h.x-h.w,a=this.li-h.y-h.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 Ui,Ri="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}";class Vi{constructor(t){var i,s,e,r,h,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:_i,this.Ti=null!==(r=null==t?void 0:t.anchorY)&&void 0!==r?r:_i,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!==(l=null==t?void 0:t.anchorMode)&&void 0!==l?l:xi}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===_i&&this.Ti===_i&&1===this.Pi&&1===this.Hi&&0===this.Ai||(this.Ii=0,this.Mi=0,this.Ci=_i,this.Ti=_i,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 Bi{}class Di extends Bi{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"})(Ui||(Ui={}));const Li=P.VISIBLE;class ki extends mi{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,Ui.PRESSED),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,Ui.MOVED),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,Ui.RELEASED),this.interactionArea=null!==(r=null==i?void 0:i.interactionArea)&&void 0!==r?r:new Di(0,0,1,1),this.modeInternal=null!==(h=null==i?void 0:i.mode)&&void 0!==h?h:Li,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(Ui.LEFT,i,s,e,this):!this.Ri&&h&&this.emit(Ui.ENTERED,i,s,e,this),this.Ri=h,this.modeInternal!==P.INTERACTIVE_TRANSPARENT&&h}}const Oi=xt.BLEND;class Wi extends ki{constructor(t,i,s,e){var r,h;super(t,e),this.Bi=!1,this.Di=!1,this.micro=new Vi(null==e?void 0:e.micro),this.Li=null!==(r=null==e?void 0:e.transparencyMode)&&void 0!==r?r:Oi,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(Ft.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(Ft.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,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===bi.POSITION_ROTATION_SCALE)Si.x=t+h-m,Si.y=i+n-b;else{const r=l*e;Si.x=t+o*s-m+h,Si.y=i+r-b+n}return Si.z=r,Ii.x=f,Ii.y=v,Ei.setFromAxisAngle(Ci,c),Mi.compose(Si,Ei,Ii),Mi})(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 Ni,ji;(t=>{t[t.PLAYED=0]="PLAYED",t[t.PAUSED=1]="PAUSED",t[t.STOPPED=2]="STOPPED"})(Ni||(Ni={})),(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(ji||(ji={}));const zi=ji.LOOP;class Fi extends Wi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h,n,o,l;const a=new rt(e.color),u=i.map(t=>new Ai(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,Ri,{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:zi,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 Ai(t[e]));this.qi()}set timeScale(t){this.Yi=t}destroy(){this.Zi(),super.destroy()}play(){this.ki||(this.ki=!0,this.emit(Ni.PLAYED))}pause(){this.ki&&(this.ki=!1,this.emit(Ni.PAUSED))}stop(){(this.ki||this.Ni>0||this.Oi>0)&&(this.ki=!1,this.Ni=0,this.Oi=0,this.Wi=!0,this.emit(Ni.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===ji.LOOP)this.Oi=0;else{if(this.Xi!==ji.PING_PONG){this.Oi=e,this.ki=!1,this.emit(Ni.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===ji.LOOP)this.Oi=e;else{if(this.Xi!==ji.PING_PONG){this.Oi=0,this.ki=!1,this.emit(Ni.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,Ti(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(Hi.DIMENSIONS_CHANGED,this.ji)}Zi(){for(const t of this.zi)t.off(Hi.DIMENSIONS_CHANGED,this.ji)}}function Gi(t,i){if(null!=ht||(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}})()),ht)return new OffscreenCanvas(t,i);const s=document.createElement("canvas");return s.width=t,s.height=i,s}function $i(t){const i=new w(t,g,y,y,m,m,b,_,1);return i.colorSpace=ot()?x:S,i.generateMipmaps=!1,i}const Yi=new rt;class Xi extends Wi{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),l=Gi(r,h),a=l.getContext("2d");if(!a)throw Error("UIGraphics.constructor: failed to get 2D context from canvas");const u=$i(l);u.needsUpdate=!0,super(t,Ri,{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=Yi.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=Yi.set(r).toCSSColor(),this.Ki.fillRect(t,i,s,e),this.Qi.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.Ki.fillStyle=Yi.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=Yi.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=Yi.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 qi extends Wi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h;const n=new rt(e.color),o=new Ai(i),l=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,Ri,{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(Hi.DIMENSIONS_CHANGED,this.ji)}get color(){return this.Fi}set color(t){this.Fi.set(t)}destroy(){this.texture.off(Hi.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,Ti(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class Zi{constructor(t){this.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 Ji;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(Ji||(Ji={}));const Ki=Ji.WORLD;class Qi extends Wi{constructor(t,i,e){let r=arguments.length>2&&void 0!==e?e:{};var h,n,o,l,a;const u=new rt(r.color),c=new Ai(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 Zi(null!==(o=r.sliceBorders)&&void 0!==o?o:.1),v=new Zi(null!==(l=r.sliceRegions)&&void 0!==l?l:.1),p=null!==(a=r.regionMode)&&void 0!==a?a:Ki,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(Hi.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(Hi.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===Ji.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,Ti(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,l=(s-e.top-e.bottom)/s,a=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,a-r)/o,v=Math.max(0,u-h)/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===Ji.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 ts{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class is extends ts{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)>Xt?Math.abs(t-1)>Xt&&this.direction.divideScalar(t):this.direction.set(1,0)}}var ss,es="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 rs extends Wi{constructor(i,s,e){let r=arguments.length>2&&void 0!==e?e:{};var h,n,o,l;const a=new rt(r.color),u=new Ai(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!==(l=r.maskFunction)&&void 0!==l?l:new is;super(i,v.source+es,Object.assign({texture:u.texture,textureTransform:c,textureResolution:d,color:a,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=a,this.xs=f,this.Ss=v,this.texture.on(Hi.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,Ti(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+es,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()),Ti(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"})(ss||(ss={}));const hs=ss.ON_PROPERTIES_CHANGE,ns=new rt(0,0,0,1);class os extends Wi{constructor(i,s){let e=arguments.length>1&&void 0!==s?s:{};var r,h,o,l,a,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===(l=e.enableDepthBuffer)||void 0===l||l,stencilBuffer:!1}),y=new rt(e.color);super(i,Ri,{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!==(a=e.clearColor)&&void 0!==a?a:ns),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:hs,this.Ts=e.updateMode!==ss.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===ss.EVERY_FRAME||this.Vs===ss.EVERY_SECOND_FRAME&&this.Is||this.Vs===ss.ON_PROPERTIES_CHANGE&&this.Ts||this.Fi.dirty||this.Ps.dirty||this.Vs===ss.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 ls="#000000",as="left",us="Arial",cs="normal",ds="normal",fs=!1,vs="transparent",ps=!1,ws="#000000";class gs{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,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!==(h=null!==(r=t.Fi)&&void 0!==r?r:i.Fi)&&void 0!==h?h:ls,align:null!==(o=null!==(n=t.Bs)&&void 0!==n?n:i.Bs)&&void 0!==o?o:as,fontFamily:null!==(a=null!==(l=t.Ds)&&void 0!==l?l:i.Ds)&&void 0!==a?a:us,fontSize:U,fontStyle:null!==(c=null!==(u=t.ks)&&void 0!==u?u:i.ks)&&void 0!==c?c:cs,fontWeight:null!==(f=null!==(d=t.Os)&&void 0!==d?d:i.Os)&&void 0!==f?f:ds,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:fs,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:vs,enableStroke:null!==(C=null!==(M=t.$s)&&void 0!==M?M:i.$s)&&void 0!==C?C:ps,strokeColor:null!==(P=null!==(T=t.Ys)&&void 0!==T?T:i.Ys)&&void 0!==P?P:ws,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===ls&&this.Bs===as&&this.Ds===us&&16===this.Ls&&this.ks===cs&&this.Os===ds&&19.2===this.Ws&&this.Ns===fs&&0===this.js&&0===this.zs&&0===this.Fs&&this.Gs===vs&&this.$s===ps&&this.Ys===ws&&0===this.Xs||(this.Fi=ls,this.Bs=as,this.Ds=us,this.Ls=16,this.ks=cs,this.Os=ds,this.Ws=19.2,this.Ns=fs,this.js=0,this.zs=0,this.Fs=0,this.Gs=vs,this.$s=ps,this.Ys=ws,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 ys{constructor(t){this.D=!0,this.qs=t.text,this.style=new gs(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 ms;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(ms||(ms={}));const bs=ms.SCALE;function _s(t){var i;return null!==(i=t.match(/\S+|\s|\n/g))&&void 0!==i?i:[]}function xs(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 Ss(t,i){const s=((t,i)=>{const s=[];let e=[],r=0,h=0,n=0,o=0;for(const l of i)"\n"!==l.text?0!==e.length&&r+l.metrics.width>t?(s.push({chunks:e,width:r,height:h,baseline:n,lineHeight:o}),e=[l],r=l.metrics.width,h=l.metrics.height,n=l.metrics.baseline,o=l.metrics.lineHeight):(e.push(l),r+=l.metrics.width,h=Math.max(h,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: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 Es(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 Is(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 l=s[t],a=null!==(h=null===(r=l.chunks[0])||void 0===r?void 0:r.style.align)&&void 0!==h?h:as,u=l.chunks.every(t=>t.style.align===a)?a:as;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)Es(d,n,t.text,t.style,e),d+=t.metrics.width}}class Ms extends Wi{constructor(t,i,s){let e=arguments.length>2&&void 0!==s?s:{};var r,h;const o=Gi(2,2),l=o.getContext("2d");if(!l)throw Error("UIText.constructor: failed to create canvas context");const a=$i(o);a.needsUpdate=!0;const u=new rt(e.color);switch(super(t,Ri,{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 Zi(e.padding),this.commonStyle=new gs(e.commonStyle),this.ee=null!==(r=e.maxLineWidth)&&void 0!==r?r:1024,this.re=null!==(h=e.resizeMode)&&void 0!==h?h:bs,this.Ji=o,this.Ki=l,this.Qi=a,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 ms.SCALE:this.oe();break;case ms.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.re}set color(t){this.Fi.set(t)}set content(t){this.Zs!==t&&(this.Zs="string"==typeof t?[new ys({text:t,style:new gs})]:Array.isArray(t)?t.map(t=>new ys("string"==typeof t?{text:t,style:new gs}:{text:t.text,style:new gs(t.style)})):[new ys({text:t.text,style:new gs(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 ms.SCALE:this.oe();break;case ms.BREAK:this.le()}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.ae()))return;const t=this.ue(),{lines:i,size:s}=Ss(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),Is(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()}le(){if(!(this.Fi.dirty||this.Qs||this.Ks||this.se.dirty||this.ve()||this.ae()))return;const t=this.ue(),{size:i}=Ss(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}=Ss(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),l=this.he!==n||this.ne!==o;l&&(this.Ji.width=n,this.Ji.height=o),Is(this.se.top,this.se.left,r,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=$i(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=gs.resolve(r.style,s);for(const s of _s(r.text)){const r=xs(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)}ae(){return this.Js||this.content.some(t=>t.dirty)}fe(){this.Js=!1;for(const t of this.content)t.setDirtyFalse()}}class Cs{constructor(){this.dirty=!1}}class Ts extends Cs{calculateScale(t,i){return 1}}const Ps=new Ts;class Hs extends Yt{constructor(t){var i;const s=null!==(i=null==t?void 0:t.resizePolicy)&&void 0!==i?i:Ps,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",Ui.PRESSED)},this.me=t=>{this.ye(t,"onPointerMove",Ui.MOVED)},this.be=t=>{this.ye(t,"onPointerUp",Ui.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,l=h*n;A(this.mode)&&(this.emit(s,o,l,t.pointerId),this.inputWrapperInternal[i](o,l,t.pointerId))}}class As extends Bi{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 Us extends Bi{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,l=s.y,a=n.y;l>i!=a>i&&(n.x-o)*(i-l)/(a-l)+o>t&&(e=!e)}return e}}class Rs extends Bi{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,l=r+this.radius,a=h-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 Vs extends ts{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 Bs extends Cs{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 Ds extends Cs{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 Ls extends Cs{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 ks extends Cs{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 Os extends Cs{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 Ws extends Cs{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{mi as UIAnchor,Fi as UIAnimatedImage,ji as UIAnimatedImageLoopMode,As as UIAreaCircle,Us as UIAreaPolygon,Di as UIAreaRectangle,Rs as UIAreaRoundedRectangle,fi as UIAspectConstraint,rt as UIColor,di as UIConstraint2DBuilder,pi as UICoverConstraintBuilder,yi as UICustomConstraint,jt as UIExpression,gi as UIFitConstraintBuilder,Hs as UIFullscreenLayer,Xi as UIGraphics,ei as UIHeightConstraint,ri as UIHorizontalDistanceConstraint,hi as UIHorizontalInterpolationConstraint,ni as UIHorizontalProportionConstraint,qi as UIImage,ki as UIInputDummy,Ui as UIInputEvent,Vi as UIMicro,bi as UIMicroAnchorMode,P as UIMode,Qi as UINineSlice,Ji as UINineSliceRegionMode,H as UIOrientation,K as UIPriority,rs as UIProgress,Vs as UIProgressMaskFunctionCircular,is as UIProgressMaskFunctionDirectional,zt as UIRelation,Bs as UIResizePolicyCover,Ds as UIResizePolicyCross,Ls as UIResizePolicyCrossInverted,ks as UIResizePolicyFit,Os as UIResizePolicyFixedHeight,Ws as UIResizePolicyFixedWidth,Ts as UIResizePolicyNone,os as UIScene,ss as UISceneUpdateMode,si as UISingleParameterConstraint,Ms as UIText,ms as UITextResizeMode,xt as UITransparencyMode,oi as UIVerticalDistanceConstraint,li as UIVerticalInterpolationConstraint,ai as UIVerticalProportionConstraint,ui as UIWidthConstraint};
1
+ import{MathUtils as t,Color as i,Vector4 as s,Texture as e,Vector2 as h,Vector3 as r,Matrix3 as n,Matrix4 as o,PlaneGeometry as a,InstancedBufferGeometry as c,ShaderMaterial as l,InstancedBufferAttribute as u,Mesh as f,Scene as d,OrthographicCamera as p,Quaternion as v,CanvasTexture as g,UVMapping as w,ClampToEdgeWrapping as y,LinearFilter as m,RGBAFormat as x,UnsignedByteType as b,SRGBColorSpace as _,NoColorSpace as I,WebGLRenderTarget as S,PerspectiveCamera as E,Ray as M}from"three";class C{constructor(){this.i=0,this.t=!1}on(t){this.i>0?(this.h??(this.h=[])).push(t):this.o(t)}once(t){if(this.i>0)return(this.h??(this.h=[])).push(t),void(this.v??(this.v=new Set)).add(t);(this.l??(this.l=new Set)).add(t),this.o(t)}off(t){if(void 0!==this.h){const i=this.h.indexOf(t);if(-1!==i)return this.h.splice(i,1),void this.v?.delete(t)}this.l?.delete(t),this.i>0?this._(t):this.u(t)}m(){if(void 0!==this.l&&this.l.size>0&&(this.l.forEach(t=>{this._(t)}),this.l=void 0),this.t&&(this.t=!1,this.p()),void 0!==this.h&&this.h.length>0){for(let t=0;this.h.length>t;t++){const i=this.h[t];!0===this.v?.has(i)&&(this.l??(this.l=new Set)).add(i),this.o(i)}this.h=void 0,this.v=void 0}}o(t){void 0!==this.S?void 0!==this.I?void 0!==this.R?void 0!==this.k?void 0!==this.C?void 0!==this.F?void 0!==this.N?void 0!==this.j?void 0!==this.q?void 0!==this.A?(this.B??(this.B=[])).push(t):this.A=t:this.q=t:this.j=t:this.N=t:this.F=t:this.C=t:this.k=t:this.R=t:this.I=t:this.S=t}_(t){if(this.t=!0,this.S!==t)if(this.I!==t)if(this.R!==t)if(this.k!==t)if(this.C!==t)if(this.F!==t)if(this.N!==t)if(this.j!==t)if(this.q!==t)if(this.A!==t){if(void 0!==this.B){const i=this.B.indexOf(t);-1!==i&&(this.B[i]=void 0)}}else this.A=void 0;else this.q=void 0;else this.j=void 0;else this.N=void 0;else this.F=void 0;else this.C=void 0;else this.k=void 0;else this.R=void 0;else this.I=void 0;else this.S=void 0}u(t){if(this.S===t)return this.S=void 0,void this.p();if(this.I===t)return this.I=void 0,void this.p();if(this.R===t)return this.R=void 0,void this.p();if(this.k===t)return this.k=void 0,void this.p();if(this.C===t)return this.C=void 0,void this.p();if(this.F===t)return this.F=void 0,void this.p();if(this.N===t)return this.N=void 0,void this.p();if(this.j===t)return this.j=void 0,void this.p();if(this.q===t)return this.q=void 0,void this.p();if(this.A===t)return this.A=void 0,void this.p();if(void 0!==this.B){const i=this.B.indexOf(t);-1!==i&&(this.B.splice(i,1),0===this.B.length&&(this.B=void 0))}}p(){const t=[];if(void 0!==this.S&&t.push(this.S),void 0!==this.I&&t.push(this.I),void 0!==this.R&&t.push(this.R),void 0!==this.k&&t.push(this.k),void 0!==this.C&&t.push(this.C),void 0!==this.F&&t.push(this.F),void 0!==this.N&&t.push(this.N),void 0!==this.j&&t.push(this.j),void 0!==this.q&&t.push(this.q),void 0!==this.A&&t.push(this.A),void 0!==this.B){for(let i=0;this.B.length>i;i++){const s=this.B[i];void 0!==s&&t.push(s)}this.B=void 0}const i=t.length;this.S=i>0?t[0]:void 0,this.I=i>1?t[1]:void 0,this.R=i>2?t[2]:void 0,this.k=i>3?t[3]:void 0,this.C=i>4?t[4]:void 0,this.F=i>5?t[5]:void 0,this.N=i>6?t[6]:void 0,this.j=i>7?t[7]:void 0,this.q=i>8?t[8]:void 0,this.A=i>9?t[9]:void 0,i>10&&(this.B=t.slice(10))}D(t){return this.S===t||this.I===t||this.R===t||this.k===t||this.C===t||this.F===t||this.N===t||this.j===t||this.q===t||this.A===t}G(t){return!!this.D(t)||!0===this.B?.includes(t)||!0===this.h?.includes(t)}H(t){}J(t){}}class T extends C{emit(){if(this.i++,this.S?.(),this.I?.(),this.R?.(),this.k?.(),this.C?.(),this.F?.(),this.N?.(),this.j?.(),this.q?.(),this.A?.(),void 0!==this.B)for(let t=0;this.B.length>t;t++)this.B[t]?.();this.i--,0===this.i&&this.m()}}class P extends C{emit(t){if(this.i++,this.S?.(t),this.I?.(t),this.R?.(t),this.k?.(t),this.C?.(t),this.F?.(t),this.N?.(t),this.j?.(t),this.q?.(t),this.A?.(t),void 0!==this.B)for(let i=0;this.B.length>i;i++)this.B[i]?.(t);this.i--,0===this.i&&this.m()}}class A extends C{emit(t,i){if(this.i++,this.S?.(t,i),this.I?.(t,i),this.R?.(t,i),this.k?.(t,i),this.C?.(t,i),this.F?.(t,i),this.N?.(t,i),this.j?.(t,i),this.q?.(t,i),this.A?.(t,i),void 0!==this.B)for(let s=0;this.B.length>s;s++){const e=this.B[s];e?.(t,i)}this.i--,0===this.i&&this.m()}}class U extends C{emit(t,i,s){if(this.i++,this.S?.(t,i,s),this.I?.(t,i,s),this.R?.(t,i,s),this.k?.(t,i,s),this.C?.(t,i,s),this.F?.(t,i,s),this.N?.(t,i,s),this.j?.(t,i,s),this.q?.(t,i,s),this.A?.(t,i,s),void 0!==this.B)for(let e=0;this.B.length>e;e++){const h=this.B[e];h?.(t,i,s)}this.i--,0===this.i&&this.m()}}var H,R;function B(t){return t===H.INTERACTIVE||t===H.INTERACTIVE_TRANSPARENT}function V(t){return t!==H.HIDDEN}function L(){return new D}(t=>{t[t.HIDDEN=0]="HIDDEN",t[t.VISIBLE=1]="VISIBLE",t[t.INTERACTIVE=2]="INTERACTIVE",t[t.INTERACTIVE_TRANSPARENT=3]="INTERACTIVE_TRANSPARENT"})(H||(H={})),(t=>{t[t.HORIZONTAL=0]="HORIZONTAL",t[t.VERTICAL=1]="VERTICAL",t[t.ALWAYS=2]="ALWAYS"})(R||(R={}));class D{index={};array=[];size(){return this.array.length}empty(){return 0===this.array.length}itemAt(t){return this.array[t]}contains(t){return void 0!==this.index[t.id()]}find(t){const i=this.index[t.id()];return void 0===i?void 0:this.array[i]}setDefault(t,i){const s=this.index[t.id()];if(void 0===s){const s=new k(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 k(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 D;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 k{first;second;constructor(t,i){this.first=t,this.second=i}copy(){return new k(this.first,this.second)}}class W{constructor(t=""){this.M=t}id(){return this.T}name(){return this.M}setName(t){this.M=t}context(){return this.P}setContext(t){this.P=t}value(){return this.U}setValue(t){this.U=t}plus(t){return new z(this,t)}minus(t){return new z(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new z([t,this])}divide(t){return new z([1/t,this])}toJSON(){return{name:this.M,value:this.U}}toString(){return this.P+"["+this.M+":"+this.U+"]"}M;U=0;P=null;T=$++}let $=0;class z{constructor(){let t=(t=>{let i=0,s=()=>0,e=L();for(let h=0,r=t.length;r>h;++h){let r=t[h];if("number"==typeof r)i+=r;else if(r instanceof W)e.setDefault(r,s).second+=1;else if(r instanceof z){i+=r.constant();let t=r.terms();for(let i=0,h=t.size();h>i;i++){let h=t.itemAt(i);e.setDefault(h.first,s).second+=h.second}}else{if(!(r instanceof Array))throw Error("invalid Expression argument: "+r);{if(2!==r.length)throw Error("array must have length 2");let t=r[0],h=r[1];if("number"!=typeof t)throw Error("array item 0 must be a number");if(h instanceof W)e.setDefault(h,s).second+=t;else{if(!(h instanceof z))throw Error("array item 1 must be a variable or expression");{i+=h.constant()*t;let r=h.terms();for(let i=0,h=r.size();h>i;i++){let h=r.itemAt(i);e.setDefault(h.first,s).second+=h.second*t}}}}}}return{terms:e,constant:i}})(arguments);this.V=t.terms,this.L=t.constant}terms(){return this.V}constant(){return this.L}value(){let t=this.L;for(let i=0,s=this.V.size();s>i;i++){let s=this.V.itemAt(i);t+=s.first.value()*s.second}return t}plus(t){return new z(this,t)}minus(t){return new z(this,"number"==typeof t?-t:[-1,t])}multiply(t){return new z([t,this])}divide(t){return new z([1/t,this])}isConstant(){return 0==this.V.size()}toString(){let t=this.V.array.map(t=>t.second+"*"+t.first).join(" + ");return this.isConstant()||0===this.L||(t+=" + "),t+=this.L,t}V;L}class F{static create(t,i,s,e=1){let h=0;return h+=1e6*Math.max(0,Math.min(1e3,t*e)),h+=1e3*Math.max(0,Math.min(1e3,i*e)),h+=Math.max(0,Math.min(1e3,s*e)),h}static required=F.create(1e3,1e3,1e3);static strong=F.create(1,0,0);static medium=F.create(0,1,0);static weak=F.create(0,0,1);static clip(t){return Math.max(0,Math.min(F.required,t))}}var N;(t=>{t[t.Le=0]="Le",t[t.Ge=1]="Ge",t[t.Eq=2]="Eq"})(N||(N={}));class O{constructor(t,i,s,e=F.required){this.W=i,this.$=F.clip(e),this.O=void 0===s&&t instanceof z?t:t.minus(s)}id(){return this.T}expression(){return this.O}op(){return this.W}strength(){return this.$}toString(){return this.O+" "+["<=",">=","="][this.W]+" 0 ("+this.$+")"}O;W;$;T=G++}let G=0;class j{maxIterations=1e3;constructor(){}createConstraint(t,i,s,e=F.required){let h=new O(t,i,s,e);return this.addConstraint(h),h}addConstraint(t){if(void 0!==this.Y.find(t))throw Error("duplicate constraint");let i=this.X(t),s=i.row,e=i.tag,h=this.Z(s,e);if(h.type()===X.Invalid&&s.allDummies()){if(!Y(s.constant()))throw Error("unsatisfiable constraint");h=e.marker}if(h.type()===X.Invalid){if(!this.K(s))throw Error("unsatisfiable constraint")}else s.solveFor(h),this.tt(h,s),this.it.insert(h,s);this.Y.insert(t,e),this.st(this.et)}removeConstraint(t){let i=this.Y.erase(t);if(void 0===i)throw Error("unknown constraint");this.ht(t,i.second);let s=i.second.marker,e=this.it.erase(s);if(void 0===e){let t=this.rt(s);if(t.type()===X.Invalid)throw Error("failed to find leaving row");e=this.it.erase(t),e.second.solveForEx(t,s),this.tt(s,e.second)}this.st(this.et)}hasConstraint(t){return this.Y.contains(t)}getConstraints(){return this.Y.array.map(({first:t})=>t)}addEditVariable(t,i){if(void 0!==this.nt.find(t))throw Error("duplicate edit variable");if((i=F.clip(i))===F.required)throw Error("bad required strength");let s=new z(t),e=new O(s,N.Eq,void 0,i);this.addConstraint(e);let h=this.Y.find(e).second;this.nt.insert(t,{tag:h,constraint:e,constant:0})}removeEditVariable(t){let i=this.nt.erase(t);if(void 0===i)throw Error("unknown edit variable");this.removeConstraint(i.second.constraint)}hasEditVariable(t){return this.nt.contains(t)}suggestValue(t,i){let s=this.nt.find(t);if(void 0===s)throw Error("unknown edit variable");let e=this.it,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.ot.push(n),void this.ct();let a=h.tag.other;if(o=e.find(a),void 0!==o)return 0>o.second.add(r)&&this.ot.push(a),void this.ct();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()!==X.External&&this.ot.push(i.first)}this.ct()}updateVariables(){let t=this.lt,i=this.it;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)}}ut(t){return this.lt.setDefault(t,()=>this.ft(X.External)).second}X(t){let i=t.expression(),s=new J(i.constant()),e=i.terms();for(let t=0,i=e.size();i>t;++t){let i=e.itemAt(t);if(!Y(i.second)){let t=this.ut(i.first),e=this.it.find(t);void 0!==e?s.insertRow(e.second,i.second):s.insertSymbol(t,i.second)}}let h=this.et,r=t.strength(),n={marker:Z,other:Z};switch(t.op()){case N.Le:case N.Ge:{let i=t.op()===N.Le?1:-1,e=this.ft(X.Slack);if(n.marker=e,s.insertSymbol(e,i),F.required>r){let t=this.ft(X.Error);n.other=t,s.insertSymbol(t,-i),h.insertSymbol(t,r)}break}case N.Eq:if(F.required>r){let t=this.ft(X.Error),i=this.ft(X.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.ft(X.Dummy);n.marker=t,s.insertSymbol(t)}}return 0>s.constant()&&s.reverseSign(),{row:s,tag:n}}Z(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()===X.External)return i.first}let e=i.marker.type();return e!==X.Slack&&e!==X.Error||t.coefficientFor(i.marker)>=0?(e=i.other.type(),e!==X.Slack&&e!==X.Error||t.coefficientFor(i.other)>=0?Z:i.other):i.marker}K(t){let i=this.ft(X.Slack);this.it.insert(i,t.copy()),this.dt=t.copy(),this.st(this.dt);let s=Y(this.dt.constant());this.dt=null;let e=this.it.erase(i);if(void 0!==e){let t=e.second;if(t.isConstant())return s;let h=this.vt(t);if(h.type()===X.Invalid)return!1;t.solveForEx(i,h),this.tt(h,t),this.it.insert(h,t)}let h=this.it;for(let t=0,s=h.size();s>t;++t)h.itemAt(t).second.removeSymbol(i);return this.et.removeSymbol(i),s}tt(t,i){let s=this.it;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()!==X.External&&this.ot.push(h.first)}this.et.substitute(t,i),this.dt&&this.dt.substitute(t,i)}st(t){let i=0;for(;this.maxIterations>i;){let s=this.gt(t);if(s.type()===X.Invalid)return;let e=this.wt(s);if(e.type()===X.Invalid)throw Error("the objective is unbounded");let h=this.it.erase(e).second;h.solveForEx(e,s),this.tt(s,h),this.it.insert(s,h),i++}throw Error("solver iterations exceeded")}ct(){let t=this.it,i=this.ot;for(;0!==i.length;){let s=i.pop(),e=t.find(s);if(void 0!==e&&0>e.second.constant()){let i=this.yt(e.second);if(i.type()===X.Invalid)throw Error("dual optimize failed");let h=e.second;t.erase(s),h.solveForEx(s,i),this.tt(i,h),t.insert(i,h)}}}gt(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()!==X.Dummy)return e}return Z}yt(t){let i=Number.MAX_VALUE,s=Z,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()!==X.Dummy){let t=this.et.coefficientFor(r)/n;i>t&&(i=t,s=r)}}return s}wt(t){let i=Number.MAX_VALUE,s=Z,e=this.it;for(let h=0,r=e.size();r>h;++h){let r=e.itemAt(h),n=r.first;if(n.type()!==X.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}rt(t){let i=Number.MAX_VALUE,s=i,e=i,h=Z,r=h,n=h,o=h,a=this.it;for(let i=0,h=a.size();h>i;++i){let h=a.itemAt(i),c=h.second,l=c.coefficientFor(t);if(0===l)continue;let u=h.first;if(u.type()===X.External)o=u;else if(0>l){let t=-c.constant()/l;s>t&&(s=t,r=u)}else{let t=c.constant()/l;e>t&&(e=t,n=u)}}return r!==h?r:n!==h?n:o}ht(t,i){i.marker.type()===X.Error&&this.xt(i.marker,t.strength()),i.other.type()===X.Error&&this.xt(i.other,t.strength())}xt(t,i){let s=this.it.find(t);void 0!==s?this.et.insertRow(s.second,-i):this.et.insertSymbol(t,-i)}vt(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===X.Slack||e===X.Error)return s.first}return Z}ft(t){return new q(t,this.bt++)}Y=(()=>L())();it=(()=>L())();lt=(()=>L())();nt=(()=>L())();ot=[];et=new J;dt=null;bt=0}function Y(t){return 0>t?1e-8>-t:1e-8>t}var X;(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"})(X||(X={}));class q{constructor(t,i){this.T=i,this._t=t}id(){return this.T}type(){return this._t}T;_t}let Z=new q(X.Invalid,-1);class J{constructor(t=0){this.L=t}cells(){return this.It}constant(){return this.L}isConstant(){return this.It.empty()}allDummies(){let t=this.It;for(let i=0,s=t.size();s>i;++i)if(t.itemAt(i).first.type()!==X.Dummy)return!1;return!0}copy(){let t=new J(this.L);return t.It=this.It.copy(),t}add(t){return this.L+=t}insertSymbol(t,i=1){Y(this.It.setDefault(t,()=>0).second+=i)&&this.It.erase(t)}insertRow(t,i=1){this.L+=t.L*i;let s=t.It;for(let t=0,e=s.size();e>t;++t){let e=s.itemAt(t);this.insertSymbol(e.first,e.second*i)}}removeSymbol(t){this.It.erase(t)}reverseSign(){this.L=-this.L;let t=this.It;for(let i=0,s=t.size();s>i;++i){let s=t.itemAt(i);s.second=-s.second}}solveFor(t){let i=this.It,s=-1/i.erase(t).second;this.L*=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.It.find(t);return void 0!==i?i.second:0}substitute(t,i){let s=this.It.erase(t);void 0!==s&&this.insertRow(i,s.second)}It=L();L}const K=1e3;var Q;function tt(t){switch(t){case Q.P0:return F.create(K,K,K);case Q.P1:return F.create(100,0,0);case Q.P2:return F.create(10,0,0);case Q.P3:return F.create(0,100,0);case Q.P4:return F.create(0,10,0);case Q.P5:return F.create(0,0,100);case Q.P6:return F.create(0,0,10);case Q.P7:return F.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"})(Q||(Q={}));class it{constructor(){this.dirty=!1,this.St=!1,this.Et=[],this.Mt=0}createInputCatcher(t,i,s,e){const h=this.Mt++;return this.Et.push({handler:h,catchPointerDown:t,catchPointerMove:i,catchPointerUp:s,zIndex:e,active:!0}),this.St=!0,this.dirty=!0,h}destroyInputCatcher(t){const i=this.Et.findIndex(i=>i.handler===t);if(-1===i)throw Error("UIInputWrapper.destroyInputCatcher.handler: handler not found");this.Et.splice(i,1)}getZIndex(t){this.Ct();const i=this.Et.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getZIndex.handler: handler not found");return i.zIndex}setZIndex(t,i){const s=this.Et.find(i=>i.handler===t);if(!s)throw Error("UIInputWrapper.setZIndex.handler: handler not found");s.zIndex!==i&&(s.zIndex=i,this.St=!0,this.dirty=!0)}getActive(t){const i=this.Et.find(i=>i.handler===t);if(!i)throw Error("UIInputWrapper.getActive.handler: handler not found");return i.active}setActive(t,i){const s=this.Et.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.Ct();for(let e=this.Et.length-1;e>=0;e--){const h=this.Et[e];if(h.active&&h.catchPointerDown(t,i,s))break}}onPointerMove(t,i,s){this.Ct();for(let e=this.Et.length-1;e>=0;e--){const h=this.Et[e];if(h.active&&h.catchPointerMove(t,i,s))break}}onPointerUp(t,i,s){this.Ct();for(let e=this.Et.length-1;e>=0;e--){const h=this.Et[e];if(h.active&&h.catchPointerUp(t,i,s))break}}Ct(){if(this.St){this.Et.sort((t,i)=>t.zIndex-i.zIndex);const t=this.Et.length,i=1024>t?1:1024/t;for(let s=0;t>s;s++)this.Et[s].zIndex=s*i;this.St=!1}}}function st(t){return.04045>t?.0773993808*t:Math.pow(.9478672986*t+.0521327014,2.4)}function et(t){return.0031308>t?12.92*t:1.055*Math.pow(t,.41666)-.055}const ht={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(...t){this.Tt=1,this.Pt=1,this.At=1,this.Ut=1,this.Ht=0,this.Rt=0,this.Bt=1,this.Vt=!1,this.Lt=!1,this.Dt=!1,t.length>0&&this.set(...t)}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.kt(),this.Tt}get g(){return this.kt(),this.Pt}get b(){return this.kt(),this.At}get a(){return this.Ut}get hue(){return this.Wt(),this.Ht}get saturation(){return this.Wt(),this.Rt}get lightness(){return this.Wt(),this.Bt}get dirty(){return this.Vt}set r(i){i=t.clamp(i,0,1),this.kt(),i!==this.Tt&&(this.Tt=i,this.Dt=!0,this.Vt=!0)}set g(i){i=t.clamp(i,0,1),this.kt(),i!==this.Pt&&(this.Pt=i,this.Dt=!0,this.Vt=!0)}set b(i){i=t.clamp(i,0,1),this.kt(),i!==this.At&&(this.At=i,this.Dt=!0,this.Vt=!0)}set a(i){(i=t.clamp(i,0,1))!==this.Ut&&(this.Ut=i,this.Vt=!0)}set hue(i){i=t.clamp(i,0,360),this.Wt(),i!==this.Ht&&(this.Ht=i,this.Lt=!0,this.Vt=!0)}set saturation(i){i=t.clamp(i,0,1),this.Wt(),i!==this.Rt&&(this.Rt=i,this.Lt=!0,this.Vt=!0)}set lightness(i){i=t.clamp(i,0,1),this.Wt(),i!==this.Bt&&(this.Bt=i,this.Lt=!0,this.Vt=!0)}setDirtyFalse(){this.Vt=!1}set(...t){if(0===t.length||void 0===t[0])return this.setRGBA(1,1,1,1);if(t.length>=3&&"number"==typeof t[0]){const[i,s,e,h=1]=t;return this.setRGBA(i,s,e,h)}const[s,e=1]=t;if("string"==typeof s)return s.startsWith("#")?this.setHexString(s):this.setColorName(s,e);if(s instanceof rt)return this.copy(s);if(s instanceof i)return this.setThreeColor(s,e);if("number"==typeof s)return this.setHexRGB(s,e);throw Error("UIColor.set: cannot create color from provided arguments")}setRGBA(i,s,e,h=this.Ut){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.kt(),i===this.Tt&&s===this.Pt&&e===this.At&&h===this.Ut||(this.Tt=i,this.Pt=s,this.At=e,this.Ut=h,this.Dt=!0,this.Vt=!0),this}getHexRGBA(){return this.kt(),Math.round(255*this.Tt)<<24|Math.round(255*this.Pt)<<16|Math.round(255*this.At)<<8|Math.round(255*this.Ut)}getHexRGB(){return this.kt(),Math.round(255*this.Tt)<<16|Math.round(255*this.Pt)<<8|Math.round(255*this.At)}getHexStringRGB(){return"#"+this.getHexRGB().toString(16).padStart(6,"0")}getHexStringRGBA(){return"#"+this.getHexRGBA().toString(16).padStart(8,"0")}setHexRGBA(t){this.kt();const i=(t>>16&255)/255,s=(t>>8&255)/255,e=(255&t)/255,h=(t>>24&255)/255;return i===this.Tt&&s===this.Pt&&e===this.At&&h===this.Ut||(this.Tt=i,this.Pt=s,this.At=e,this.Ut=h,this.Dt=!0,this.Vt=!0),this}setHexRGB(i,s=this.Ut){s=t.clamp(s,0,1),this.kt();const e=(i>>16&255)/255,h=(i>>8&255)/255,r=(255&i)/255;return e===this.Tt&&h===this.Pt&&r===this.At&&s===this.Ut||(this.Tt=e,this.Pt=h,this.At=r,this.Ut=s,this.Dt=!0,this.Vt=!0),this}setHexString(t){if(!t.startsWith("#"))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');const i=t.slice(1);if(6===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGB(t)}if(8===i.length){const t=parseInt(i,16);if(isNaN(t))throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"');return this.setHexRGBA(t)}throw Error('UIColor.setHexString.hexString: invalid hex string format. expected format: "#ffffff" or "#ffffffff"')}setHSL(i,s,e,h=this.Ut){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.Wt(),i===this.Ht&&s===this.Rt&&e===this.Bt&&h===this.Ut||(this.Ht=i,this.Rt=s,this.Bt=e,this.Ut=h,this.Lt=!0,this.Vt=!0),this}setColorName(i,s=this.Ut){s=t.clamp(s,0,1);const e=i.toLowerCase().trim(),h=ht[e];if(void 0===h)throw Error("UIColor.setColorName.colorName: unknown color name");return this.setHexRGB(h,s)}setGLSLColor(i,s,e,h=this.Ut){h=t.clamp(h,0,1),this.kt();const r=et(i),n=et(s),o=et(e);return r===this.Tt&&n===this.Pt&&o===this.At&&h===this.Ut||(this.Tt=r,this.Pt=n,this.At=o,this.Ut=h,this.Dt=!0,this.Vt=!0),this}setThreeColor(i,s=this.Ut){return s=t.clamp(s,0,1),this.kt(),i.r===this.Tt&&i.g===this.Pt&&i.b===this.At&&s===this.Ut||(this.Tt=i.r,this.Pt=i.g,this.At=i.b,this.Ut=s,this.Dt=!0,this.Vt=!0),this}toCSSColor(){return this.kt(),`rgba(${Math.round(255*this.Tt)}, ${Math.round(255*this.Pt)}, ${Math.round(255*this.At)}, ${this.Ut})`}toGLSLColor(t=new s){return this.kt(),t.x=st(this.Tt),t.y=st(this.Pt),t.z=st(this.At),t.w=this.Ut,t}toThreeColor(t=new i){return this.kt(),t.r=this.Tt,t.g=this.Pt,t.b=this.At,t}copy(t){return t instanceof rt?(this.kt(),t.kt(),this.Tt===t.Tt&&this.Pt===t.Pt&&this.At===t.At&&this.Ut===t.Ut||(this.Tt=t.Tt,this.Pt=t.Pt,this.At=t.At,this.Ut=t.Ut,this.Dt=!0,this.Vt=!0)):(this.kt(),this.Tt===t.r&&this.Pt===t.g&&this.At===t.b&&1===this.Ut||(this.Tt=t.r,this.Pt=t.g,this.At=t.b,this.Ut=1,this.Dt=!0,this.Vt=!0)),this}clone(){return this.kt(),new rt(this.Tt,this.Pt,this.At,this.Ut)}kt(){if(this.Lt){const{Ht:t,Rt:i,Bt:s}=this,e=(1-Math.abs(2*s-1))*i,h=t/60,r=e*(1-Math.abs(h%2-1));let[n,o,a]=1>h?[e,r,0]:2>h?[r,e,0]:3>h?[0,e,r]:4>h?[0,r,e]:5>h?[r,0,e]:[e,0,r];const c=s-e/2;this.Tt=n+c,this.Pt=o+c,this.At=a+c,this.Lt=!1}}Wt(){if(this.Dt){const{Tt:t,Pt:i,At:s}=this,e=Math.max(t,i,s),h=Math.min(t,i,s),r=e-h,n=(e+h)/2;let o=0;0!==r&&(o=e===t?(i-s)/r+(s>i?6:0):e===i?(s-t)/r+2:(t-i)/r+4,o*=60);const a=0===r?0:r/(1-Math.abs(2*n-1));this.Ht=o,this.Rt=a,this.Bt=n,this.Dt=!1}}}let nt,ot;const at=()=>(ot??(ot=(()=>{const t=document.createElement("canvas"),i=t.getContext("webgl2")??t.getContext("webgl");if(!i)return!1;if(i instanceof WebGL2RenderingContext)try{const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texStorage2D(i.TEXTURE_2D,1,i.SRGB8_ALPHA8,2,2);const s=i.getError();return i.deleteTexture(t),s===i.NO_ERROR}catch{return!1}const s=i.getExtension("EXT_sRGB");if(!s)return!1;try{const t=i.createTexture();i.bindTexture(i.TEXTURE_2D,t),i.texImage2D(i.TEXTURE_2D,0,s.SRGB_ALPHA_EXT,2,2,0,s.SRGB_ALPHA_EXT,i.UNSIGNED_BYTE,null);const e=i.getError();return i.deleteTexture(t),e===i.NO_ERROR}catch{return!1}})()),ot),ct=Object.freeze({glslTypeName:"float",bufferSize:1,instantiable:!0}),lt=Object.freeze({glslTypeName:"sampler2D",bufferSize:-1,instantiable:!1}),ut=Object.freeze({glslTypeName:"vec2",bufferSize:2,instantiable:!0}),ft=Object.freeze({glslTypeName:"vec3",bufferSize:3,instantiable:!0}),dt=Object.freeze({glslTypeName:"vec4",bufferSize:4,instantiable:!0}),pt=Object.freeze({glslTypeName:"mat3",bufferSize:9,instantiable:!0}),vt=Object.freeze({glslTypeName:"mat4",bufferSize:16,instantiable:!0});function gt(t){if("string"==typeof t)switch(t){case"number":return ct;case"Texture":return lt;case"UIColor":case"Vector4":return dt;case"Vector2":return ut;case"Vector3":return ft;case"Matrix3":return pt;case"Matrix4":return vt;default:throw Error("resolveGLSLTypeInfo.value: unsupported property type name")}if("function"==typeof t){if(t===Number)return ct;if(t===e)return lt;if(t===rt)return dt;if(t===h)return ut;if(t===r)return ft;if(t===s)return dt;if(t===n)return pt;if(t===o)return vt;throw Error("resolveGLSLTypeInfo.value: unsupported property type constructor")}if("number"==typeof t)return ct;if(t instanceof e)return lt;if(t instanceof rt)return dt;if(t instanceof h)return ut;if(t instanceof r)return ft;if(t instanceof s)return dt;if(t instanceof n)return pt;if(t instanceof o)return vt;throw Error("resolveGLSLTypeInfo.value: unsupported property type")}function wt(t,i){const s=i.uniforms["p_"+t];if(void 0===s)throw Error("resolvePropertyUniform.name: unknown uniform");return s}function yt(t){const i={};for(const s in t){const e=t[s];i[s]={value:e,glslTypeInfo:gt(e)}}return i}function mt(t){return"number"==typeof t||t instanceof e?t:t.clone()}function xt(t){const i={};for(const s in t){const e=t[s];i[s]={value:mt(e.value),glslTypeInfo:e.glslTypeInfo}}return i}function bt(t){return t.elements[14]}var _t;(t=>{t[t.CLIP=0]="CLIP",t[t.HASH=1]="HASH",t[t.BLEND=2]="BLEND"})(_t||(_t={}));const It=(()=>{const t=new a(1,1);t.translate(.5,.5,0);const i=new c;return i.index=t.index,i.setAttribute("position",t.attributes.position),i.setAttribute("uv",t.attributes.uv),t.dispose(),i})(),St=new s;function Et(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 h)i[e]=t.x,i[e+1]=t.y;else if(t instanceof r)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z;else if(t instanceof s)i[e]=t.x,i[e+1]=t.y,i[e+2]=t.z,i[e+3]=t.w;else if(t instanceof n||t instanceof o){const s=t.elements;for(let t=0;s.length>t;t++)i[e+t]=s[t]}else"number"==typeof t&&(i[e]=t)}function Mt(t,i){const s=gt(t);if(!s.instantiable)throw Error("buildEmptyInstancedBufferAttribute.value: cannot create instanced attribute for non-instantiable type");return new u(new Float32Array(i*s.bufferSize),s.bufferSize)}function Ct(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 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")}function Tt(t,i,s,e,h){if(0>=e||0===h)return;const r=s*i;t.copyWithin((s+h)*i,r,r+e*i)}function Pt(t,i,s,e,h){for(let r=0;h>r;r++)s[e+r]=t[i+r]}class At extends f{constructor(t,i,s,e=1){const h={},r={instanceVisibility:{value:1,glslTypeInfo:gt("number")},instanceTransform:{value:(new o).identity(),glslTypeInfo:gt("Matrix4")}};for(const t in i){const s=i[t];s.glslTypeInfo.instantiable?r[t]=s:h[t]=s}const n=It.clone(),a=((t,i,s,e)=>{const h={},r=[],n=[],o=[],a=[];for(const t in i){const{value:s,glslTypeInfo:e}=i[t];h["p_"+t]={value:s instanceof rt?s.toGLSLColor():s},r.push(`uniform ${e.glslTypeName} p_${t};`)}for(const t in s){const{glslTypeInfo:i}=s[t];n.push(`attribute ${i.glslTypeName} a_${t};`),o.push(`varying ${i.glslTypeName} p_${t};`),a.push(`p_${t} = a_${t};`)}const c=`\n // User attributes\n ${n.join("\n")}\n\n // Uniforms\n ${r.join("\n")}\n\n // Builtin varyings\n varying vec3 p_position;\n varying vec2 p_uv;\n\n // User varyings\n ${o.join("\n")}\n\n void main() {\n if (a_instanceVisibility < 0.5) {\n gl_Position = vec4(2.0, 2.0, 2.0, 1.0);\n return;\n }\n\n ${a.join("\n")}\n\n p_position = position;\n p_uv = uv;\n\n gl_Position = projectionMatrix * a_instanceTransform * vec4(position, 1.0);\n }\n `,u=((t,i,s)=>`\n // Defines\n #define PI 3.14159265359\n #define SRGB_SUPPORTED ${at()?"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 `)(r,o,t);return new l({uniforms:h,vertexShader:c,fragmentShader:u,transparent:e===_t.BLEND,alphaTest:e===_t.CLIP?.5:0,alphaHash:e===_t.HASH,depthWrite:e!==_t.BLEND,depthTest:!0})})(t,h,r,s);super(n,a),this.frustumCulled=!1,this.matrixAutoUpdate=!1,this.matrixWorldAutoUpdate=!1,this.source=t,this.transparency=s,this.$t=n,this.zt=a,this.Ft=h,this.Nt=r,this.Ot=new Map,this.Gt=Math.max(4*Math.ceil(e/4),4),this.jt=0,this.$t.instanceCount=0;for(const t in this.Nt){const{value:i}=this.Nt[t],s=Mt(i,this.Gt);this.$t.setAttribute("a_"+t,s),this.Ot.set(t,s)}for(const t in this.Ft){const{value:i}=this.Ft[t];wt(t,this.zt).value=i}this.zt.uniformsNeedUpdate=!0}get instancesCount(){return this.jt}insertAt(t,i,s,e){if(0>t||t>this.jt)throw Error(`UIGenericInstancedPlane.insertAt.index: out of bounds (index=${t}, count=${this.jt})`);this.Yt(this.jt+1),this.jt>t&&this.Xt(t,1),this.qt(t,i,s,e),this.jt++,this.$t.instanceCount=this.jt}removeAt(t){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.removeAt.index: out of bounds (index=${t}, count=${this.jt})`);this.jt-1>t&&this.Zt(t+1,1),this.jt--,this.$t.instanceCount=this.jt}setPropertiesAt(t,i){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.setPropertiesAt.index: out of bounds (index=${t}, count=${this.jt})`);for(const s in i){const{value:e,glslTypeInfo:h}=i[s];if(h.instantiable){const i=this.Jt(s);Et(e,i.array,t*i.itemSize),i.needsUpdate=!0}else wt(s,this.zt).value=e,this.zt.uniformsNeedUpdate=!0}}setTransformAt(t,i){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.setTransformAt.index: out of bounds (index=${t}, count=${this.jt})`);const s=this.Jt("instanceTransform"),e=s.array,h=16*t,r=i.elements;for(let t=0;16>t;t++)e[h+t]=r[t];s.needsUpdate=!0}setVisibilityAt(t,i){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.setVisibilityAt.index: out of bounds (index=${t}, count=${this.jt})`);const s=this.Jt("instanceVisibility");s.array[t]=i?1:0,s.needsUpdate=!0}extractDataAt(t){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.extractDataAt.index: out of bounds (index=${t}, count=${this.jt})`);const i={};for(const t in this.Ft){const s=this.Ft[t];i[t]={value:mt(s.value),glslTypeInfo:s.glslTypeInfo}}for(const s in this.Nt){if("instanceVisibility"===s||"instanceTransform"===s)continue;const{value:e,glslTypeInfo:h}=this.Nt[s],r=this.Ot.get(s);i[s]={value:Ct(e,r.array,t*r.itemSize),glslTypeInfo:h}}const s=this.Ot.get("instanceTransform").array,e=new o;e.fromArray(s,16*t);const h=this.Ot.get("instanceVisibility");return{source:this.source,properties:i,transform:e,visibility:h.array[t]>=.5,transparency:this.transparency}}getZIndexAt(t){if(0>t||t>=this.jt)throw Error(`UIGenericInstancedPlane.getZIndexAt.index: out of bounds (index=${t}, count=${this.jt})`);return this.Ot.get("instanceTransform").array[16*t+14]}merge(t){if(0!==t.jt){this.Yt(this.jt+t.jt);for(const[i,s]of this.Ot){const e=t.Ot.get(i);if(!e)throw Error(`UIGenericInstancedPlane.merge: missing attribute ${i} in source`);const h=s.itemSize;Pt(e.array,0,s.array,this.jt*h,t.jt*h),s.needsUpdate=!0}this.jt+=t.jt,this.$t.instanceCount=this.jt,t.jt=0,t.$t.instanceCount=0}}split(t){if(0>=t||t>=this.jt)throw Error(`UIGenericInstancedPlane.split.atIndex: must be in range (0, count) (atIndex=${t}, count=${this.jt})`);const i=this.jt-t,s=new At(this.source,xt({...this.Ft,...this.Nt}),this.transparency,i);for(const[e,h]of this.Ot){const r=s.Ot.get(e);if(!r)throw Error(`UIGenericInstancedPlane.split: missing attribute ${e} in new plane`);const n=h.itemSize;Pt(h.array,t*n,r.array,0,i*n),r.needsUpdate=!0}return s.jt=i,s.$t.instanceCount=i,this.jt=t,this.$t.instanceCount=t,s}isCompatibleWith(t,i,s){return this.source===t&&this.transparency===s&&((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].value!==i[s].value)return!1}return!0})({...this.Ft,...this.Nt},i)}getProperties(){return{...this.Ft,...this.Nt}}clearInstances(){this.jt=0,this.$t.instanceCount=0}destroy(){this.$t.dispose(),this.zt.dispose(),this.Ot.clear()}Yt(t){if(this.Gt>=t)return;const i=4*Math.ceil(t/4);for(const[t,s]of this.Ot){const e=s.itemSize,h=new Float32Array(i*e);h.set(s.array);const r=new u(h,e);this.$t.setAttribute("a_"+t,r),this.Ot.set(t,r)}this.Gt=i}Xt(t,i){const s=this.jt-t;if(s>0)for(const e of this.Ot.values())Tt(e.array,e.itemSize,t,s,i),e.needsUpdate=!0}Zt(t,i){const s=this.jt-t;if(s>0)for(const e of this.Ot.values())Tt(e.array,e.itemSize,t,s,-i),e.needsUpdate=!0}qt(t,i,s,e){const h=this.Jt("instanceVisibility");h.array[t]=e?1:0,h.needsUpdate=!0;const r=this.Jt("instanceTransform"),n=r.array,o=16*t,a=s.elements;for(let t=0;16>t;t++)n[o+t]=a[t];r.needsUpdate=!0;for(const s in i){const{value:e,glslTypeInfo:h}=i[s];if(h.instantiable){const i=this.Ot.get(s);i&&(Et(e,i.array,t*i.itemSize),i.needsUpdate=!0)}else wt(s,this.zt).value=e,this.zt.uniformsNeedUpdate=!0}}Jt(t){const i=this.Ot.get(t);if(void 0===i)throw Error(`UIGenericInstancedPlane.resolveAttribute.name: unknown attribute "${t}"`);return i}}class Ut{constructor(t){this.Kt=new Map,this.Mt=0,this.Qt=[],this.ti=new Map,this.ii=new Set,this.si=new Set,this.ei=new Set,this.hi=!1,this.ri=t}createPlane(t,i,s,e,h){const r=this.Mt++,n=yt((t=>{const i={};for(const s in t)i[s]=mt(t[s]);return i})(i)),o=bt(s),a={source:t,properties:n,transform:s.clone(),visibility:e,transparency:h,zIndex:o};return this.Kt.set(r,a),this.ii.add(r),this.hi=!0,r}destroyPlane(t){if(!this.Kt.has(t))throw Error(`UIPlaneRegistry.destroyPlane: handler ${t} not found`);this.Kt.delete(t),this.ii.has(t)?this.ii.delete(t):(this.ei.delete(t),this.si.add(t),this.hi=!0)}setProperties(t,i){const s=this.ni(t),e=yt(i);let h=!1;for(const t in e){const i=e[t];i.glslTypeInfo.instantiable||s.properties[t].value!==i.value&&(h=!0),s.properties[t]={value:i.value,glslTypeInfo:i.glslTypeInfo}}if(h&&!this.ii.has(t))this.ei.add(t),this.hi=!0;else{const i=this.ti.get(t);i&&i.mesh.setPropertiesAt(i.instanceIndex,e)}}setTransform(t,i){const s=this.ni(t),e=bt(i),h=s.zIndex;if(s.transform.copy(i),s.zIndex=e,h===e||this.ii.has(t)){const s=this.ti.get(t);s&&s.mesh.setTransformAt(s.instanceIndex,i)}else this.ei.add(t),this.hi=!0}setVisibility(t,i){this.ni(t).visibility=i;const s=this.ti.get(t);s&&s.mesh.setVisibilityAt(s.instanceIndex,i)}setTransparency(t,i){const s=this.ni(t);s.transparency!==i&&(s.transparency=i,this.ii.has(t)||(this.ei.add(t),this.hi=!0))}flush(){this.hi&&(this.oi(),this.ai(),this.ci(),this.li(),this.ui(),this.fi(),this.ii.clear(),this.si.clear(),this.ei.clear(),this.hi=!1)}oi(){for(const t of this.si){const i=this.ti.get(t);if(!i)continue;const{mesh:s,instanceIndex:e}=i;s.removeAt(e),this.di(s,e+1,-1),this.ti.delete(t)}}ai(){for(const t of this.ei){const i=this.ti.get(t);if(!i)continue;const{mesh:s,instanceIndex:e}=i;s.removeAt(e),this.di(s,e+1,-1),this.ti.delete(t),this.ii.add(t)}}ci(){if(0===this.ii.size)return;const t=[];for(const i of this.ii){const s=this.Kt.get(i);s&&t.push({handler:i,state:s})}t.sort((t,i)=>t.state.zIndex-i.state.zIndex);for(let i=1;t.length>i;i++)if(t[i].state.zIndex===t[i-1].state.zIndex)throw Error(`UIPlaneRegistry.flush: duplicate zIndex=${t[i].state.zIndex} for handlers ${t[i-1].handler} and ${t[i].handler}`);for(const{handler:i,state:s}of t)this.pi(i,s)}pi(t,i){const{source:s,properties:e,transform:h,visibility:r,transparency:n,zIndex:o}=i;let a=null;for(const t of this.Qt){if(!t.isCompatibleWith(s,e,n))continue;if(0===t.instancesCount){a=t;break}const i=t.getZIndexAt(0),h=t.getZIndexAt(t.instancesCount-1);if(o>=i-1&&h+1>=o){a=t;break}}if(a){const i=this.gi(a,o);a.insertAt(i,e,h,r),this.di(a,i,1),this.ti.set(t,{mesh:a,instanceIndex:i})}else{const i=this.wi(o),a=new At(s,xt(e),n);a.insertAt(0,e,h,r),this.Qt.splice(i,0,a),this.ri.add(a),this.ti.set(t,{mesh:a,instanceIndex:0})}}li(){let t=0;for(;this.Qt.length-1>t;){const i=this.Qt[t],s=this.Qt[t+1];if(0===i.instancesCount||0===s.instancesCount){t++;continue}const e=i.getZIndexAt(i.instancesCount-1);if(s.getZIndexAt(0)>e&&i.isCompatibleWith(s.source,s.getProperties(),s.transparency)){const e=i.instancesCount;i.merge(s),this.yi(s,i,e),this.ri.remove(s),s.destroy(),this.Qt.splice(t+1,1);continue}t++}}ui(){for(let t=this.Qt.length-1;t>=0;t--){const i=this.Qt[t];0===i.instancesCount&&(this.ri.remove(i),i.destroy(),this.Qt.splice(t,1))}}ni(t){const i=this.Kt.get(t);if(!i)throw Error(`UIPlaneRegistry.resolveState: handler ${t} not found`);return i}wi(t){for(let i=0;this.Qt.length>i;i++){const s=this.Qt[i];if(s.instancesCount>0&&s.getZIndexAt(0)>t)return i}return this.Qt.length}gi(t,i){for(let s=0;t.instancesCount>s;s++)if(t.getZIndexAt(s)>i)return s;return t.instancesCount}di(t,i,s){for(const e of this.ti.values())e.mesh!==t||i>e.instanceIndex||(e.instanceIndex+=s)}yi(t,i,s){for(const e of this.ti.values())e.mesh===t&&(e.mesh=i,e.instanceIndex+=s)}fi(){this.Qt.sort((t,i)=>(t.instancesCount>0?t.getZIndexAt(0):0)-(i.instancesCount>0?i.getZIndexAt(0):0));for(let t=0;this.Qt.length>t;t++)this.Qt[t].renderOrder=t}}let Ht=new i,Rt=0,Bt=!1,Vt=!1,Lt=!1,Dt=!1;class kt{constructor(t,i){this.ri=new d,this.mi=new Ut(this.ri),this.xi=new p(0,t,i,0,-1024,1024),this.xi.matrixAutoUpdate=!1,this.xi.matrixWorldAutoUpdate=!1}createPlane(t,i,s,e,h){return this.mi.createPlane(t,i,s,e,h)}destroyPlane(t){this.mi.destroyPlane(t)}setTransform(t,i){this.mi.setTransform(t,i)}setProperties(t,i){this.mi.setProperties(t,i)}setVisibility(t,i){this.mi.setVisibility(t,i)}setTransparency(t,i){this.mi.setTransparency(t,i)}insertCustomObject(t){return this.ri.add(t),this}removeCustomObject(t){return this.ri.remove(t),this}resize(t,i){return this.xi.right=t,this.xi.top=i,this.xi.updateProjectionMatrix(),this}render(t){return this.mi.flush(),Ht=t.getClearColor(Ht),Rt=t.getClearAlpha(),Bt=t.autoClear,Vt=t.autoClearColor,Lt=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.ri,this.xi),t.setClearColor(Ht),t.setClearAlpha(Rt),t.autoClear=Bt,t.autoClearColor=Vt,t.autoClearDepth=Lt,t.autoClearStencil=Dt,this}}class Wt{constructor(t=0,i){if(this.constant=t,this.bi=i?new Map(i):new Map,i)for(let t=0;i.length>t;t++)Xt()}static plus(t,i){const s=new Wt(t.constant+i.constant,Array.from(t.bi.entries()));for(const[t,e]of i.bi)s.plus(t,e);return s}static minus(t,i){const s=new Wt(t.constant-i.constant,Array.from(t.bi.entries()));for(const[t,e]of i.bi)s.minus(t,e);return s}plus(t,i){return this.bi.set(t,(this.bi.get(t)??0)+i),this}minus(t,i){return this.plus(t,-i)}multiply(t){this.constant*=t;for(const[i,s]of this.bi)this.bi.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.bi.has(t)}copy(t){this.constant=t.constant,this.bi.clear();for(const[i,s]of t.bi)this.bi.set(i,s);return this}clone(){return new Wt(this.constant,Array.from(this.bi.entries()))}prepareTerms(){return Array.from(this.bi.entries())}}var $t;(t=>{t[t.EQUAL=0]="EQUAL",t[t.LESS_THAN=1]="LESS_THAN",t[t.GREATER_THAN=2]="GREATER_THAN"})($t||($t={}));class zt{constructor(){this.dirty=!1,this._i=new j,this.Ii=!1,this.Si=new Map,this.Ei=0,this.Mi=new Map,this.Ci=0}createVariable(t,i){const s=this.Ei++,e=new W;if(i===Q.P0){const h={variable:e,priority:i,value:t};this.Si.set(s,h),h.constraint=this.Ti(new Wt(0,[[s,1]]),new Wt(t),$t.EQUAL,i);try{this._i?.addConstraint(h.constraint)}catch{this._i=void 0}}else{this.Si.set(s,{variable:e,priority:i,value:t});try{this._i?.addEditVariable(e,tt(i)),this._i?.suggestValue(e,t)}catch{this._i=void 0}}return this.Ii=!0,this.dirty=!0,s}removeVariable(t){const i=this.Si.get(t);if(void 0===i)throw Error("UISolverWrapper.removeVariable.index: variable does not exist");for(const i of this.Mi.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t))throw Error("UISolverWrapper.removeVariable.index: variable is used in constraint");try{i.constraint?this._i?.removeConstraint(i.constraint):this._i?.removeEditVariable(i.variable)}catch{this._i=void 0}this.Si.delete(t),this.Ii=!0,this.dirty=!0}suggestVariableValue(t,i){const s=this.Si.get(t);if(void 0===s)throw Error("UISolverWrapper.suggestVariableValue.index: variable does not exist");s.value!==i&&(s.value=i,s.constraint?s.constraint=this.Pi(s.constraint,(new Wt).plus(t,1),new Wt(s.value),$t.EQUAL,s.priority):this._i?.suggestValue(s.variable,i),this.Ii=!0,this.dirty=!0)}setVariablePriority(t,i){const s=this.Si.get(t);if(void 0===s)throw Error("UISolverWrapper.setVariablePriority.index: variable does not exist");if(i!==s.priority){if(s.priority=i,s.priority===Q.P0){const i=(new Wt).plus(t,1),e=new Wt(s.value);s.constraint=this.Ti(i,e,$t.EQUAL,s.priority);try{this._i?.addConstraint(s.constraint)}catch{this._i=void 0}}else{if(s.constraint)try{this._i?.removeConstraint(s.constraint)}catch{this._i=void 0}s.constraint=void 0,this.Ai(t,s)}this.Ii=!0,this.dirty=!0}}readVariableValue(t){const i=this.Si.get(t);if(void 0===i)throw Error("UISolverWrapper.readVariableValue.index: variable does not exist");return void 0===this._i&&this.Ui(),this.Ii&&(this._i?.updateVariables(),this.Ii=!1),i.variable.value()}createConstraint(t,i,s,e,h){const r=this.Ci++,n=this.Ti(t,i,s,e);if(this.Mi.set(r,{constraint:n,lhs:t.clone(),rhs:i.clone(),priority:e,relation:s,enabled:h}),h){try{this._i?.addConstraint(n)}catch{this._i=void 0}this.Ii=!0,this.dirty=!0}return r}removeConstraint(t){const i=this.Mi.get(t);if(void 0===i)throw Error("UISolverWrapper.removeConstraint.index: constraint does not exist");if(i.enabled)try{this._i?.removeConstraint(i.constraint)}catch{this._i=void 0}this.Mi.delete(t),this.Ii=!0,this.dirty=!0}setConstraintLHS(t,i){const s=this.Mi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintLHS.index: constraint does not exist");s.lhs.copy(i),this.Hi(s),this.Ii=!0,this.dirty=!0}setConstraintRHS(t,i){const s=this.Mi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRHS.index: constraint does not exist");s.rhs.copy(i),this.Hi(s),this.Ii=!0,this.dirty=!0}setConstraintRelation(t,i){const s=this.Mi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintRelation.index: constraint does not exist");s.relation!==i&&(s.relation=i,this.Hi(s),this.Ii=!0,this.dirty=!0)}setConstraintPriority(t,i){const s=this.Mi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintPriority.index: constraint does not exist");s.priority!==i&&(s.priority=i,this.Hi(s),this.Ii=!0,this.dirty=!0)}setConstraintEnabled(t,i){const s=this.Mi.get(t);if(void 0===s)throw Error("UISolverWrapper.setConstraintEnabled.index: constraint does not exist");if(i!==s.enabled){s.enabled=i;try{s.enabled?this._i?.addConstraint(s.constraint):this._i?.removeConstraint(s.constraint)}catch{this._i=void 0}this.Ii=!0,this.dirty=!0}}Ai(t,i){const s=[];for(const i of this.Mi.values())if(i.lhs.hasTerm(t)||i.rhs.hasTerm(t)){try{this._i?.removeConstraint(i.constraint)}catch{this._i=void 0}s.push(i)}this._i?.removeEditVariable(i.variable),this._i?.addEditVariable(i.variable,tt(i.priority));for(const t of s)t.constraint=this.Ti(t.lhs,t.rhs,t.relation,t.priority);for(const t of s)try{this._i?.addConstraint(t.constraint)}catch{this._i=void 0;break}}Hi(t){t.constraint=t.enabled?this.Pi(t.constraint,t.lhs,t.rhs,t.relation,t.priority):this.Ti(t.lhs,t.rhs,t.relation,t.priority)}Pi(t,i,s,e,h){try{this._i?.removeConstraint(t)}catch{this._i=void 0}const r=this.Ti(i,s,e,h);try{this._i?.addConstraint(r)}catch{this._i=void 0}return r}Ti(t,i,s,e){return new O(this.Ri(t),(t=>{switch(t){case $t.EQUAL:return N.Eq;case $t.LESS_THAN:return N.Le;case $t.GREATER_THAN:return N.Ge;default:throw Error("convertRelation.relation: invalid relation")}})(s),this.Ri(i),tt(e))}Ri(t){return new z(...t.prepareTerms().map(([t,i])=>{const s=this.Si.get(t);if(void 0===s)throw Error("UISolverWrapper.convertExpression.expression: variable does not exist");return[i,s.variable]}),t.constant)}Ui(){if(this._i)throw Error("UISolverWrapper.rebuildSolver: solver already exists");this._i=new j;for(const t of this.Si.values())t.constraint?this._i.addConstraint(t.constraint):(this._i.addEditVariable(t.variable,tt(t.priority)),this._i.suggestValue(t.variable,t.value));for(const t of this.Mi.values())t.enabled&&this._i.addConstraint(t.constraint);this.Ii=!0,this.dirty=!0}}const Ft=H.VISIBLE;class Nt{constructor(t){this.name="",this.inputWrapperInternal=new it,this.Bi=new zt,this.Vi=new A,this.Li=new A,this.Di=new U;const i=t.width??1024,s=t.height??1024;this.ki=new kt(i,s),this.name=t.name??"",this.Wi=t.mode??Ft,this.$i=i>s?R.HORIZONTAL:R.VERTICAL,this.xVariable=this.Bi.createVariable(0,Q.P0),this.yVariable=this.Bi.createVariable(0,Q.P0),this.wVariable=this.Bi.createVariable(i,Q.P0),this.hVariable=this.Bi.createVariable(s,Q.P0)}get sceneWrapper(){return this.ki}get solverWrapper(){return this.Bi}get inputWrapper(){return this.inputWrapperInternal}get x(){return this.Bi.readVariableValue(this.xVariable)}get y(){return this.Bi.readVariableValue(this.yVariable)}get width(){return this.Bi.readVariableValue(this.wVariable)}get height(){return this.Bi.readVariableValue(this.hVariable)}get mode(){return this.Wi}get orientation(){return this.$i}get signalOrientationChanged(){return this.Vi}get signalModeChanged(){return this.Li}get signalRendering(){return this.Di}set mode(t){t!==this.Wi&&(this.Wi=t,this.Li.emit(this.Wi,this))}resizeInternal(t,i){this.Bi.suggestVariableValue(this.wVariable,t),this.Bi.suggestVariableValue(this.hVariable,i),this.ki.resize(t,i);const s=t>i?R.HORIZONTAL:R.VERTICAL;s!==this.$i&&(this.$i=s,this.Vi.emit(this.$i,this))}renderInternal(t,i){V(this.mode)&&(this.Di.emit(t,i,this),this.ki.render(t)),this.Bi.dirty=!1,this.inputWrapperInternal.dirty=!1}}const Ot=1e-6;function Gt(t){return"object"==typeof t&&null!==t&&"layer"in t&&t.layer instanceof Nt}function jt(t){return"object"==typeof t&&null!==t&&"number"==typeof t.xVariable&&"number"==typeof t.yVariable&&"number"==typeof t.x&&"number"==typeof t.y}function Yt(t){return jt(t)&&"number"==typeof t.wVariable&&"number"==typeof t.hVariable&&"number"==typeof t.width&&"number"==typeof t.height}function Xt(){}function qt(t,i,s){if(t instanceof Nt)return t;if(Gt(t))return t.layer;if(i instanceof Nt)return i;if(Gt(i))return i.layer;throw Error(s+": no valid subjects found")}function Zt(t,i,s){if(Gt(i))return i.layer;if(Gt(s))return s.layer;if(i instanceof Nt)return i;if(s instanceof Nt)return s;throw Error(t+": no valid subjects found")}class Jt{constructor(t,i){this.layer=t,this.solverWrapper=this.layer.solverWrapper,this.name=i??""}}class Kt extends Jt{constructor(t,i){var s,e,h;super(t,i?.name),this.zi=()=>{this.solverWrapper.setConstraintEnabled(this.constraint,this.isConstraintEnabled())},this.Fi=(s=i?.priority,s??Q.P0),this.Ni=(e=i?.relation,e??$t.EQUAL),this.$i=(h=i?.orientation,h??R.ALWAYS),this.layer.signalOrientationChanged.on(this.zi)}get priority(){return this.Fi}get relation(){return this.Ni}get orientation(){return this.$i}set priority(t){t!==this.Fi&&(this.Fi=t,this.solverWrapper.setConstraintPriority(this.constraint,this.Fi))}set relation(t){t!==this.Ni&&(this.Ni=t,this.solverWrapper.setConstraintRelation(this.constraint,this.Ni))}set orientation(t){t!==this.$i&&(this.$i=t,this.zi())}destroy(){this.layer.signalOrientationChanged.off(this.zi),this.solverWrapper.removeConstraint(this.constraint)}isConstraintEnabled(){return this.$i===R.ALWAYS||this.$i===this.layer.orientation}}class Qt extends Kt{constructor(t,i={}){super(t.layer,i),this.Oi=t,this.Gi=i.height??t.height,this.constraint=this.solverWrapper.createConstraint(new Wt(0,[[this.Oi.hVariable,1]]),new Wt(this.Gi),this.relation,this.priority,this.isConstraintEnabled())}get height(){return this.Gi}set height(t){this.Gi!==t&&(this.Gi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Wt(t)))}}class ti extends Kt{constructor(t,i,s={}){super(qt(t,i,"UIHorizontalDistanceConstraint.constructor"),s),this.ji=t,this.Yi=i,this.Xi=s.anchorA??.5,this.qi=s.anchorB??.5,this.Zi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ji(),new Wt(this.Zi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Zi}get anchorA(){return this.Xi}get anchorB(){return this.qi}set distance(t){this.Zi!==t&&(this.Zi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Wt(this.Zi)))}set anchorA(t){this.Xi!==t&&(this.Xi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorB(t){this.qi!==t&&(this.qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}Ji(){let t,i;if(Yt(this.ji))t=new Wt(0,[[this.ji.xVariable,1],[this.ji.wVariable,this.Xi]]);else{if(!jt(this.ji))throw Error("UIHorizontalDistanceConstraint.buildLHS.a: invalid element type");t=(new Wt).plus(this.ji.xVariable,1)}if(Yt(this.Yi))i=new Wt(0,[[this.Yi.xVariable,1],[this.Yi.wVariable,this.qi]]);else{if(!jt(this.Yi))throw Error("UIHorizontalDistanceConstraint.buildLHS.b: invalid element type");i=(new Wt).plus(this.Yi.xVariable,1)}return Wt.minus(i,t)}}class ii extends Kt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Zt("UIHorizontalInterpolationConstraint.constructor",t,i),e),this.ji=t,this.Yi=i,this.Ki=s,this.Xi=h,this.qi=h,this.Qi=e.anchorC??.5,this.ts=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ji(),new Wt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.ts}get anchorA(){return this.Xi}get anchorB(){return this.qi}get anchorC(){return this.Qi}set t(t){this.ts!==t&&(this.ts=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorA(t){this.Xi!==t&&(this.Xi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorB(t){this.qi!==t&&(this.qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorC(t){this.Qi!==t&&(this.Qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}Ji(){let t,i,s;if(Yt(this.ji))t=new Wt(0,[[this.ji.xVariable,1],[this.ji.wVariable,this.Xi]]);else{if(!jt(this.ji))throw Error("UIHorizontalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Wt).plus(this.ji.xVariable,1)}if(Yt(this.Yi))i=new Wt(0,[[this.Yi.xVariable,1],[this.Yi.wVariable,this.qi]]);else{if(!jt(this.Yi))throw Error("UIHorizontalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Wt).plus(this.Yi.xVariable,1)}if(Yt(this.Ki))s=new Wt(0,[[this.Ki.xVariable,1],[this.Ki.wVariable,this.Qi]]);else{if(!jt(this.Ki))throw Error("UIHorizontalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Wt).plus(this.Ki.xVariable,1)}const e=t.clone().multiply(1-this.ts),h=i.clone().multiply(this.ts);return Wt.minus(Wt.minus(s,e),h)}}class si extends Kt{constructor(t,i,s={}){super(qt(t,i,"UIHorizontalProportionConstraint.constructor"),s),this.ji=t,this.Yi=i,this.ss=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Wt(0),this.es(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.ss}set proportion(t){this.ss!==t&&(this.ss=t,this.solverWrapper.setConstraintRHS(this.constraint,this.es()))}es(){return Wt.minus(new Wt(0,[[this.ji.wVariable,this.ss]]),new Wt(0,[[this.Yi.wVariable,1]]))}}class ei extends Kt{constructor(t,i,s={}){super(qt(t,i,"UIVerticalDistanceConstraint.constructor"),s),this.ji=t,this.Yi=i,this.Xi=s.anchorA??.5,this.qi=s.anchorB??.5,this.Zi=s.distance??0,this.constraint=this.solverWrapper.createConstraint(this.Ji(),new Wt(this.Zi),this.relation,this.priority,this.isConstraintEnabled())}get distance(){return this.Zi}get anchorA(){return this.Xi}get anchorB(){return this.qi}set distance(t){this.Zi!==t&&(this.Zi=t,this.solverWrapper.setConstraintRHS(this.constraint,new Wt(this.Zi)))}set anchorA(t){this.Xi!==t&&(this.Xi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorB(t){this.qi!==t&&(this.qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}Ji(){let t,i;if(Yt(this.ji))t=new Wt(0,[[this.ji.yVariable,1],[this.ji.hVariable,this.Xi]]);else{if(!jt(this.ji))throw Error("UIVerticalDistanceConstraint.buildLHS.a: invalid element type");t=(new Wt).plus(this.ji.yVariable,1)}if(Yt(this.Yi))i=new Wt(0,[[this.Yi.yVariable,1],[this.Yi.hVariable,this.qi]]);else{if(!jt(this.Yi))throw Error("UIVerticalDistanceConstraint.buildLHS.b: invalid element type");i=(new Wt).plus(this.Yi.yVariable,1)}return Wt.minus(i,t)}}class hi extends Kt{constructor(t,i,s,e={}){const h=e.anchorA??.5;super(Zt("UIVerticalInterpolationConstraint.constructor",t,i),e),this.ji=t,this.Yi=i,this.Ki=s,this.Xi=h,this.qi=h,this.Qi=e.anchorC??.5,this.ts=e.t??.5,this.constraint=this.solverWrapper.createConstraint(this.Ji(),new Wt(0),this.relation,this.priority,this.isConstraintEnabled())}get t(){return this.ts}get anchorA(){return this.Xi}get anchorB(){return this.qi}get anchorC(){return this.Qi}set t(t){this.ts!==t&&(this.ts=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorA(t){this.Xi!==t&&(this.Xi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorB(t){this.qi!==t&&(this.qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}set anchorC(t){this.Qi!==t&&(this.Qi=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}Ji(){let t,i,s;if(Yt(this.ji))t=new Wt(0,[[this.ji.yVariable,1],[this.ji.hVariable,this.Xi]]);else{if(!jt(this.ji))throw Error("UIVerticalInterpolationConstraint.buildLHS.a: invalid element type");t=(new Wt).plus(this.ji.yVariable,1)}if(Yt(this.Yi))i=new Wt(0,[[this.Yi.yVariable,1],[this.Yi.hVariable,this.qi]]);else{if(!jt(this.Yi))throw Error("UIVerticalInterpolationConstraint.buildLHS.b: invalid element type");i=(new Wt).plus(this.Yi.yVariable,1)}if(Yt(this.Ki))s=new Wt(0,[[this.Ki.yVariable,1],[this.Ki.hVariable,this.Qi]]);else{if(!jt(this.Ki))throw Error("UIVerticalInterpolationConstraint.buildLHS.c: invalid element type");s=(new Wt).plus(this.Ki.yVariable,1)}const e=t.clone().multiply(1-this.ts),h=i.clone().multiply(this.ts);return Wt.minus(Wt.minus(s,e),h)}}class ri extends Kt{constructor(t,i,s={}){super(qt(t,i,"UIVerticalProportionConstraint.constructor"),s),this.ji=t,this.Yi=i,this.ss=s.proportion??1,this.constraint=this.solverWrapper.createConstraint(new Wt(0),this.es(),this.relation,this.priority,this.isConstraintEnabled())}get proportion(){return this.ss}set proportion(t){this.ss!==t&&(this.ss=t,this.solverWrapper.setConstraintRHS(this.constraint,this.es()))}es(){return Wt.minus(new Wt(0,[[this.ji.hVariable,this.ss]]),new Wt(0,[[this.Yi.hVariable,1]]))}}class ni extends Kt{constructor(t,i={}){super(t.layer,i),this.Oi=t,this.hs=i.width??t.width,this.constraint=this.solverWrapper.createConstraint(new Wt(0,[[this.Oi.wVariable,1]]),new Wt(this.hs),this.relation,this.priority,this.isConstraintEnabled())}get width(){return this.hs}set width(t){this.hs!==t&&(this.hs=t,this.solverWrapper.setConstraintRHS(this.constraint,new Wt(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 ai{static size(t,i={}){const s=oi(i.size),e=oi(i.priority),h=oi(i.relation),r=oi(i.orientation);return{h:new ni(t,{width:s.h,priority:e.h,relation:h.h,orientation:r.h}),v:new Qt(t,{height:s.v,priority:e.v,relation:h.v,orientation:r.v})}}static distance(t,i,s={}){const e=oi(s.anchorA),h=oi(s.anchorB),r=oi(s.distance),n=oi(s.priority),o=oi(s.relation),a=oi(s.orientation);return{h:new ti(t,i,{anchorA:e.h,anchorB:h.h,distance:r.h,priority:n.h,relation:o.h,orientation:a.h}),v:new ei(t,i,{anchorA:e.v,anchorB:h.v,distance:r.v,priority:n.v,relation:o.v,orientation:a.v})}}static proportion(t,i,s={}){const e=oi(s.proportion),h=oi(s.priority),r=oi(s.relation),n=oi(s.orientation);return{h:new si(t,i,{proportion:e.h,priority:h.h,relation:r.h,orientation:n.h}),v:new ri(t,i,{proportion:e.v,priority:h.v,relation:r.v,orientation:n.v})}}static interpolation(t,i,s,e={}){const h=oi(e.anchorA),r=oi(e.anchorB),n=oi(e.anchorC),o=oi(e.t),a=oi(e.priority),c=oi(e.relation),l=oi(e.orientation);return{h:new ii(t,i,s,{anchorA:h.h,anchorB:r.h,anchorC:n.h,t:o.h,priority:a.h,relation:c.h,orientation:l.h}),v:new hi(t,i,s,{anchorA:h.v,anchorB:r.v,anchorC:n.v,t:o.v,priority:a.v,relation:c.v,orientation:l.v})}}}class ci extends Kt{constructor(t,i={}){super(t.layer,i),this.Oi=t,this.rs=i.aspect??t.width/t.height,this.constraint=this.solverWrapper.createConstraint(this.Ji(),new Wt(0),this.relation,this.priority,this.isConstraintEnabled())}get aspect(){return this.rs}set aspect(t){this.rs!==t&&(this.rs=t,this.solverWrapper.setConstraintLHS(this.constraint,this.Ji()))}Ji(){return new Wt(0,[[this.Oi.wVariable,1],[this.Oi.hVariable,-this.rs]])}}const li=.5;class ui{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ci(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new ti(t,i,{anchorA:s.anchorH??li,anchorB:s.anchorH??li,orientation:s.orientation}),yConstraint:new ei(t,i,{anchorA:s.anchorV??li,anchorB:s.anchorV??li,orientation:s.orientation}),widthConstraint:new si(t,i,{proportion:1,relation:$t.GREATER_THAN,orientation:s.orientation}),heightConstraint:new ri(t,i,{proportion:1,priority:Q.P1,orientation:s.orientation})}}}const fi=.5;class di{static build(t,i,s={}){let e;return!0===s.keepActiveAspect&&(e=new ci(i,{orientation:s.orientation})),{activeAspectConstraint:e,xConstraint:new ti(t,i,{anchorA:s.anchorH??fi,anchorB:s.anchorH??fi,orientation:s.orientation}),yConstraint:new ei(t,i,{anchorA:s.anchorV??fi,anchorB:s.anchorV??fi,orientation:s.orientation}),widthConstraint:new si(t,i,{proportion:1,relation:$t.LESS_THAN,orientation:s.orientation}),heightConstraint:new ri(t,i,{proportion:1,priority:Q.P1,orientation:s.orientation})}}}class pi extends Kt{constructor(t,i,s,e={}){super(t,e),this.ns=i,this.cs=s,this.constraint=this.solverWrapper.createConstraint(this.ns,this.cs,this.relation,this.priority,this.isConstraintEnabled())}get lhs(){return this.ns}get rhs(){return this.cs}setLHS(t){this.ns=t,this.solverWrapper.setConstraintLHS(this.constraint,this.ns)}setRHS(t){this.cs=t,this.solverWrapper.setConstraintRHS(this.constraint,this.cs)}}class vi{constructor(t,i){this.layer=t,this.name="";const s=i?.x??0,e=i?.y??0;this.solverWrapper=this.layer.solverWrapper,this.xVariable=this.solverWrapper.createVariable(s,Q.P7),this.yVariable=this.solverWrapper.createVariable(e,Q.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 gi;(t=>{t[t.ROTATION_SCALE=0]="ROTATION_SCALE",t[t.POSITION_ROTATION_SCALE=1]="POSITION_ROTATION_SCALE"})(gi||(gi={}));const wi=.5,yi=gi.ROTATION_SCALE,mi=new r,xi=new v,bi=new r,_i=new o,Ii=new r(0,0,1);function Si(t,i,s,e,h,r,n,o,a,c,l,u,f,d,p,v,g){const w=s-d-p,y=e-v-g,m=o*s*c,x=a*e*l,b=Math.cos(u),_=Math.sin(u),I=m*b-x*_,S=m*_+x*b,E=d*c,M=g*l,C=E*b-M*_,T=E*_+M*b;if(f===gi.POSITION_ROTATION_SCALE)mi.x=t+r-I+C,mi.y=i+n-S+T;else{const h=a*e;mi.x=t+o*s-I+r+C,mi.y=i+h-S+n+T}return mi.z=h,bi.x=w*c,bi.y=y*l,xi.setFromAxisAngle(Ii,u),_i.compose(mi,xi,bi),_i}const Ei=new e;class Mi{constructor(t){this.ls=Ei,this.us=2,this.fs=2,this.ds=0,this.ps=0,this.vs=2,this.gs=2,this.ws=!1,this.ys=1,this.xs=0,this.bs=0,this._s=0,this.Is=0,this.Ss=!1,this.Es=!1,this.Ms=!1,this.Cs=new U,void 0!==t&&this.set(t)}get width(){return this.us/this.ys}get height(){return this.fs/this.ys}get trimmedWidth(){return(this.ws?this.gs:this.vs)/this.ys}get trimmedHeight(){return(this.ws?this.vs:this.gs)/this.ys}get texture(){return this.ls}get rotated(){return this.ws}get scale(){return this.ys}get trim(){const t=this.ys;return{left:this.xs/t,right:this.bs/t,top:this._s/t,bottom:this.Is/t}}get textureDirty(){return this.Ss}get uvTransformDirty(){return this.Es}get trimDirty(){return this.Ms}get signalDiminsionsChanged(){return this.Cs}setTextureDirtyFalse(){this.Ss=!1}setUVTransformDirtyFalse(){this.Es=!1}setTrimDirtyFalse(){this.Ms=!1}calculateUVTransform(t=new n){const i=this.ls.image?.naturalWidth??2,s=this.ls.image?.naturalHeight??2;if(this.ws){const e=this.vs,h=e/s;t.set(0,this.gs/i,this.ds/i,-h,0,(s-this.ps-e)/s+h,0,0,1)}else t.set(this.vs/i,0,this.ds/i,0,this.gs/s,(s-this.ps-this.gs)/s,0,0,1);return t}getResolution(t=new h){return t.set(this.width,this.height)}set(t){const i=this.width,s=this.height;t instanceof e?this.Ts(t):this.Ps(t),this.width===i&&this.height===s||this.Cs.emit(this.width,this.height,this)}Ts(t){const i=t.image?.naturalWidth??2,s=t.image?.naturalHeight??2;this.us=i,this.fs=s,this.texture!==t&&(this.ls=t,this.Ss=!0),(0!==this.ds||0!==this.ps||this.vs!==i||this.gs!==s||1!==this.ys||this.ws)&&(this.ds=0,this.ps=0,this.vs=i,this.gs=s,this.ws=!1,this.ys=1,this.Es=!0),0===this.xs&&0===this.bs&&0===this._s&&0===this.Is||(this.xs=0,this.bs=0,this._s=0,this.Is=0,this.Ms=!0)}Ps(t){this.us=t.sourceSize.w,this.fs=t.sourceSize.h,this.texture!==t.texture&&(this.ls=t.texture,this.Ss=!0);const i=t.scale??1,s=t.rotated??!1;0===this.ds&&0===this.ps&&this.vs===t.frame.w&&this.gs===t.frame.h&&this.ys===i&&this.ws===s||(this.ds=t.frame.x,this.ps=t.frame.y,this.vs=t.frame.w,this.gs=t.frame.h,this.ys=i,this.ws=s,this.Es=!0);const e=t.spriteSourceSize,h=e.x,r=e.y,n=this.us-e.x-e.w,o=this.fs-e.y-e.h;this.xs===h&&this.bs===n&&this._s===r&&this.Is===o||(this.xs=h,this.bs=n,this._s=r,this.Is=o,this.Ms=!0)}}var Ci="vec4 draw(){vec2 transformedUV=(p_textureTransform*vec3(p_uv,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}";class Ti{constructor(t){this.Vt=!0,this.As=t?.x??0,this.Us=t?.y??0,this.Hs=t?.anchorX??wi,this.Rs=t?.anchorY??wi,this.Bs=t?.scaleX??1,this.Vs=t?.scaleY??1,this.Ls=t?.rotation??0,this.Ds=t?.anchorMode??yi}get x(){return this.As}get y(){return this.Us}get anchorX(){return this.Hs}get anchorY(){return this.Rs}get scaleX(){return this.Bs}get scaleY(){return this.Vs}get angle(){return t.radToDeg(this.Ls)}get anchorMode(){return this.Ds}get rotation(){return this.Ls}get dirty(){return this.Vt}set x(t){t!==this.As&&(this.As=t,this.Vt=!0)}set y(t){t!==this.Us&&(this.Us=t,this.Vt=!0)}set anchorX(t){t!==this.Hs&&(this.Hs=t,this.Vt=!0)}set anchorY(t){t!==this.Rs&&(this.Rs=t,this.Vt=!0)}set scaleX(t){t!==this.Bs&&(this.Bs=t,this.Vt=!0)}set scaleY(t){t!==this.Vs&&(this.Vs=t,this.Vt=!0)}set angle(i){const s=t.degToRad(i);s!==this.Ls&&(this.Ls=s,this.Vt=!0)}set rotation(t){t!==this.Ls&&(this.Ls=t,this.Vt=!0)}set anchorMode(t){t!==this.Ds&&(this.Ds=t,this.Vt=!0)}setDirtyFalse(){this.Vt=!1}reset(){0===this.As&&0===this.Us&&this.Hs===wi&&this.Rs===wi&&1===this.Bs&&1===this.Vs&&0===this.Ls||(this.As=0,this.Us=0,this.Hs=wi,this.Rs=wi,this.Bs=1,this.Vs=1,this.Ls=0,this.Vt=!0)}copy(t){this.As===t.As&&this.Us===t.Us&&this.Hs===t.Hs&&this.Rs===t.Rs&&this.Bs===t.Bs&&this.Vs===t.Vs&&this.Ls===t.Ls&&this.Ds===t.Ds||(this.As=t.As,this.Us=t.Us,this.Hs=t.Hs,this.Rs=t.Rs,this.Bs=t.Bs,this.Vs=t.Vs,this.Ls=t.Ls,this.Ds=t.Ds,this.Vt=!0)}}class Pi{}class Ai extends Pi{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)}}const Ui=H.VISIBLE;class Hi extends vi{constructor(t,i){const s=i?.width??64,e=i?.height??32;super(t,i),this.ks=!1,this.Ws=new P,this.$s=new P,this.zs=new P,this.Fs=new P,this.Ns=new P,this.catchPointerDown=(t,i,s)=>this.handleInputEvent(t,i,s,this.Ws),this.catchPointerMove=(t,i,s)=>this.handleInputEvent(t,i,s,this.$s),this.catchPointerUp=(t,i,s)=>this.handleInputEvent(t,i,s,this.zs),this.interactionArea=i?.interactionArea??new Ai(0,0,1,1),this.modeInternal=i?.mode??Ui,this.inputWrapper=this.layer.inputWrapper,this.wVariable=this.solverWrapper.createVariable(s,Q.P6),this.hVariable=this.solverWrapper.createVariable(e,Q.P6),this.Os=this.inputWrapper.createInputCatcher(this.catchPointerDown,this.catchPointerMove,this.catchPointerUp,0),this.inputWrapper.setActive(this.Os,B(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.Os)}get signalPressed(){return this.Ws}get signalMoved(){return this.$s}get signalReleased(){return this.zs}get signalEntered(){return this.Fs}get signalLeft(){return this.Ns}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=B(t);this.inputWrapper.setActive(this.Os,i),this.modeInternal=t}}set zIndex(t){this.inputWrapper.setZIndex(this.Os,t)}destroy(){this.solverWrapper.removeVariable(this.hVariable),this.solverWrapper.removeVariable(this.wVariable),this.inputWrapper.destroyInputCatcher(this.Os),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&&h.emit({x:i,y:s,identifier:e,element:this}),this.ks&&!r?this.Ns.emit({x:i,y:s,identifier:e,element:this}):!this.ks&&r&&this.Fs.emit({x:i,y:s,identifier:e,element:this}),this.ks=r,this.modeInternal!==H.INTERACTIVE_TRANSPARENT&&r}}const Ri=_t.BLEND;class Bi extends Hi{constructor(t,i,s,e){super(t,e),this.Gs=!1,this.js=!1,this.micro=new Ti(e?.micro),this.Ys=e?.transparencyMode??Ri,this.sceneWrapper=this.layer.sceneWrapper,this.planeHandler=this.sceneWrapper.createPlane(i,s,(new o).identity(),V(e?.mode??this.mode),this.Ys),this.layer.signalRendering.on(this.onWillRender)}get transparencyMode(){return this.Ys}set transparencyMode(t){this.Ys!==t&&(this.Ys=t,this.Gs=!0)}set mode(t){this.modeInternal!==t&&(this.js=V(this.modeInternal)!==V(t),super.mode=t)}destroy(){this.layer.signalRendering.off(this.onWillRender),this.sceneWrapper.destroyPlane(this.planeHandler),super.destroy()}setPlaneTransform(){(this.micro.dirty||this.inputWrapper.dirty||this.solverWrapper.dirty)&&(this.sceneWrapper.setTransform(this.planeHandler,((t,i,s,e,h,r,n,o,a,c,l,u,f)=>{const d=s*this.micro.scaleX,p=e*this.micro.scaleY,v=o*d,g=a*p,w=Math.cos(u),y=Math.sin(u),m=v*w-g*y,x=v*y+g*w;if(f===gi.POSITION_ROTATION_SCALE)mi.x=t+r-m,mi.y=i+n-x;else{const h=a*e;mi.x=t+o*s-m+r,mi.y=i+h-x+n}return mi.z=h,bi.x=d,bi.y=p,xi.setFromAxisAngle(Ii,u),_i.compose(mi,xi,bi),_i})(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.Gs&&(this.sceneWrapper.setTransparency(this.planeHandler,this.Ys),this.Gs=!1),this.js&&(this.sceneWrapper.setVisibility(this.planeHandler,V(this.modeInternal)),this.js=!1),this.setPlaneTransform()}}var Vi;(t=>{t[t.NONE=0]="NONE",t[t.LOOP=1]="LOOP",t[t.PING_PONG=2]="PING_PONG"})(Vi||(Vi={}));const Li=Vi.LOOP;class Di extends Bi{constructor(t,i,s={}){const e=new rt(s.color),h=i.map(t=>new Mi(t)),r=h[0];s.width=s.width??r.width,s.height=s.height??r.height;const n=r.calculateUVTransform();super(t,Ci,{texture:r.texture,textureTransform:n,color:e},s),this.Xs=!1,this.qs=0,this.Zs=!1,this.Js=0,this.Ks=new T,this.Qs=new T,this.te=new T,this.ie=(t,i,s)=>{this.se[this.qs]===s&&(this.width=t,this.height=i)},this.ee=e,this.se=h,this.he=n,this.re=s.frameRate??24,this.ne=s.timeScale??1,this.oe=s.loopMode??Li,this.ae(),!0===s.playByDefault&&this.play()}get color(){return this.ee}get duration(){return this.se.length/this.re}get frameRate(){return this.re}get loopMode(){return this.oe}get sequence(){return this.se}get timeScale(){return this.ne}get signalPlayed(){return this.Ks}get signalPaused(){return this.Qs}get signalStopped(){return this.te}set color(t){this.ee.set(t)}set frameRate(t){this.re=t}set loopMode(t){this.oe=t}set sequence(t){this.stop(),this.ce();const i=t.length,s=this.se.length;for(let e=0;Math.min(i,s)>e;e++)this.se[e].set(t[e]);if(s>i)this.se.length=i;else if(i>s)for(let e=s;i>e;e++)this.se.push(new Mi(t[e]));this.ae()}set timeScale(t){this.ne=t}destroy(){this.ce(),super.destroy()}play(){this.Xs||(this.Xs=!0,this.Ks.emit())}pause(){this.Xs&&(this.Xs=!1,this.Qs.emit())}stop(){(this.Xs||this.Js>0||this.qs>0)&&(this.Xs=!1,this.Js=0,this.qs=0,this.Zs=!0,this.te.emit())}onWillRender(t,i){if(this.Xs&&0!==this.ne){this.Js+=i*this.ne;const t=1/this.re,s=this.se.length,e=s-1;if(this.ne>0)for(;this.Js>=t;){if(this.Js-=t,this.qs+=1,this.qs>=s)if(this.oe===Vi.LOOP)this.qs=0;else{if(this.oe!==Vi.PING_PONG){this.qs=e,this.Xs=!1,this.Qs.emit();break}this.qs=e,this.ne=-this.ne}this.Zs=!0}else for(;-t>=this.Js;){if(this.Js+=t,this.qs-=1,0>this.qs)if(this.oe===Vi.LOOP)this.qs=e;else{if(this.oe!==Vi.PING_PONG){this.qs=0,this.Xs=!1,this.Qs.emit();break}this.qs=0,this.ne=-this.ne}this.Zs=!0}}super.onWillRender(t,i)}setPlaneTransform(){let t;this.ee.dirty&&(t??(t={}),t.color=this.ee,this.ee.setDirtyFalse());const i=this.se[this.qs];if((i.textureDirty||this.Zs)&&(t??(t={}),t.texture=i.texture,i.setTextureDirtyFalse()),(i.uvTransformDirty||this.Zs)&&(t??(t={}),t.textureTransform=i.calculateUVTransform(this.he),i.setUVTransformDirtyFalse()),t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.Zs||this.micro.dirty||i.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,s=i.trim;this.sceneWrapper.setTransform(this.planeHandler,Si(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.Zs=!1,this.micro.setDirtyFalse(),i.setTrimDirtyFalse()}}ae(){for(const t of this.se)t.signalDiminsionsChanged.on(this.ie)}ce(){for(const t of this.se)t.signalDiminsionsChanged.off(this.ie)}}function ki(t,i){if(nt??(nt=(()=>{if("undefined"==typeof OffscreenCanvas)return!1;const t=document.createElement("canvas");t.width=4,t.height=4;const i=t.getContext("webgl")??t.getContext("webgl2");if(!i)return!1;try{const t=new OffscreenCanvas(4,4),s=t.getContext("2d");if(!s)return!1;s.fillStyle="#ff0000",s.fillRect(0,0,4,4);const e=i.createTexture();if(i.bindTexture(i.TEXTURE_2D,e),i.texImage2D(i.TEXTURE_2D,0,i.RGBA,i.RGBA,i.UNSIGNED_BYTE,t),i.getError()!==i.NO_ERROR)return i.deleteTexture(e),!1;const h=i.createFramebuffer();if(i.bindFramebuffer(i.FRAMEBUFFER,h),i.framebufferTexture2D(i.FRAMEBUFFER,i.COLOR_ATTACHMENT0,i.TEXTURE_2D,e,0),i.checkFramebufferStatus(i.FRAMEBUFFER)!==i.FRAMEBUFFER_COMPLETE)return i.deleteFramebuffer(h),i.deleteTexture(e),!1;const r=new Uint8Array(4);return i.readPixels(0,0,1,1,i.RGBA,i.UNSIGNED_BYTE,r),i.bindFramebuffer(i.FRAMEBUFFER,null),i.deleteFramebuffer(h),i.deleteTexture(e),!!(r[0]>200&&50>r[1]&&50>r[2]&&r[3]>200)}catch(t){return!1}})()),nt)return new OffscreenCanvas(t,i);const s=document.createElement("canvas");return s.width=t,s.height=i,s}function Wi(t){const i=new g(t,w,y,y,m,m,x,b,1);return i.colorSpace=at()?_:I,i.generateMipmaps=!1,i}const $i=new rt;class zi extends Bi{constructor(t,i){const s=i?.width??2,e=i?.height??2,h=new rt(i?.color),r=ki(s,e),o=r.getContext("2d");if(!o)throw Error("UIGraphics.constructor: failed to get 2D context from canvas");const a=Wi(r);a.needsUpdate=!0,super(t,Ci,{texture:a,textureTransform:new n,color:h},i),this.le=r,this.ue=o,this.fe=a,this.ee=h}get color(){return this.ee}set color(t){this.ee.set(t)}clear(t){return this.ue.clearRect(0,0,this.le.width,this.le.height),void 0!==t&&(this.ue.fillStyle=$i.set(t).toCSSColor(),this.ue.fillRect(0,0,this.le.width,this.le.height)),this.fe.needsUpdate=!0,this}drawRect(t,i,s,e,h){return this.ue.fillStyle=$i.set(h).toCSSColor(),this.ue.fillRect(t,i,s,e),this.fe.needsUpdate=!0,this}drawCircle(t,i,s,e){return this.ue.fillStyle=$i.set(e).toCSSColor(),this.ue.beginPath(),this.ue.arc(t,i,s,0,2*Math.PI),this.ue.fill(),this.fe.needsUpdate=!0,this}drawArc(t,i,s,e,h,r){return this.ue.fillStyle=$i.set(r).toCSSColor(),this.ue.beginPath(),this.ue.arc(t,i,s,e,h),this.ue.fill(),this.fe.needsUpdate=!0,this}drawPolyline(t,i,s=1){if(2>t.length)return this;this.ue.strokeStyle=$i.set(i).toCSSColor(),this.ue.lineWidth=s,this.ue.beginPath(),this.ue.moveTo(t[0][0],t[0][1]);for(let i=1;t.length>i;i++)this.ue.lineTo(t[i][0],t[i][1]);return this.ue.stroke(),this.fe.needsUpdate=!0,this}destroy(){this.fe.dispose(),super.destroy()}onWillRender(t,i){this.ee.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.ee}),this.ee.setDirtyFalse()),super.onWillRender(t,i)}}class Fi extends Bi{constructor(t,i,s={}){const e=new rt(s.color),h=new Mi(i),r=h.calculateUVTransform();s.width=s.width??h.width,s.height=s.height??h.height,super(t,Ci,{texture:h.texture,textureTransform:r,color:e},s),this.ie=(t,i)=>{this.width=t,this.height=i},this.texture=h,this.he=r,this.ee=e,this.texture.signalDiminsionsChanged.on(this.ie)}get color(){return this.ee}set color(t){this.ee.set(t)}destroy(){this.texture.signalDiminsionsChanged.off(this.ie),super.destroy()}setPlaneTransform(){let t;if(this.ee.dirty&&(t??(t={}),t.color=this.ee,this.ee.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.he),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,Si(this.x,this.y,this.width,this.height,this.zIndex,t.x,t.y,t.anchorX,t.anchorY,t.scaleX,t.scaleY,t.rotation,t.anchorMode,i.left,i.right,i.top,i.bottom)),this.micro.setDirtyFalse(),this.texture.setTrimDirtyFalse()}}}class Ni{constructor(t){this.Bt=0,this.Tt=0,this.ts=0,this.At=0,this.Vt=!1,this.set(t)}get left(){return this.Bt}get right(){return this.Tt}get top(){return this.ts}get bottom(){return this.At}get dirty(){return this.Vt}set left(t){this.Bt!==t&&(this.Bt=t,this.Vt=!0)}set right(t){this.Tt!==t&&(this.Tt=t,this.Vt=!0)}set top(t){this.ts!==t&&(this.ts=t,this.Vt=!0)}set bottom(t){this.At!==t&&(this.At=t,this.Vt=!0)}setHorizontal(t){this.Bt===t&&this.Tt===t||(this.Bt=t,this.Tt=t,this.Vt=!0)}setVertical(t){this.ts===t&&this.At===t||(this.ts=t,this.At=t,this.Vt=!0)}setUnified(t){this.Bt===t&&this.Tt===t&&this.ts===t&&this.At===t||(this.Bt=t,this.Tt=t,this.ts=t,this.At=t,this.Vt=!0)}set(t){const i=this.Bt,s=this.Tt,e=this.ts,h=this.At;if(void 0===t)this.Bt=0,this.Tt=0,this.ts=0,this.At=0;else if("number"==typeof t)this.Bt=t,this.Tt=t,this.ts=t,this.At=t;else if(Array.isArray(t))if(2===t.length){const i=t[0],s=t[1];this.Bt=i,this.Tt=i,this.ts=s,this.At=s}else{const i=t[1],s=t[2],e=t[3];this.Bt=t[0],this.Tt=i,this.ts=s,this.At=e}else if("left"in t){const i=t.right,s=t.top,e=t.bottom;this.Bt=t.left,this.Tt=i,this.ts=s,this.At=e}else{const i=t.horizontal,s=t.vertical;this.Bt=i,this.Tt=i,this.ts=s,this.At=s}this.Bt===i&&this.Tt===s&&this.ts===e&&this.At===h||(this.Vt=!0)}setVector4(t){this.Bt===t.x&&this.Tt===t.y&&this.ts===t.z&&this.At===t.w||(this.Bt=t.x,this.Tt=t.y,this.ts=t.z,this.At=t.w,this.Vt=!0)}toVector4(t=new s){return t.set(this.Bt,this.Tt,this.ts,this.At)}reset(){this.setUnified(0)}copy(t){this.Bt===t.Bt&&this.Tt===t.Tt&&this.ts===t.ts&&this.At===t.At||(this.Bt=t.Bt,this.Tt=t.Tt,this.ts=t.ts,this.At=t.At,this.Vt=!0)}setDirtyFalse(){this.Vt=!1}}var Oi;(t=>{t[t.NORMALIZED=0]="NORMALIZED",t[t.WORLD=1]="WORLD"})(Oi||(Oi={}));const Gi=Oi.WORLD;class ji extends Bi{constructor(t,i,e={}){const h=new rt(e.color),r=new Mi(i),n=r.calculateUVTransform();e.width=e.width??r.width,e.height=e.height??r.height;const o=new Ni(e.sliceBorders??.1),a=new Ni(e.sliceRegions??.1),c=e.regionMode??Gi,l=new s,u=new s;super(t,"vec4 draw(){vec2 localUV=p_uv;float left=p_sliceBorders.x;float right=p_sliceBorders.y;float top=p_sliceBorders.z;float bottom=p_sliceBorders.w;float leftFill=p_sliceRegions.x;float rightFill=p_sliceRegions.y;float topFill=p_sliceRegions.z;float bottomFill=p_sliceRegions.w;float lB=leftFill;float rB=1.0-rightFill;float bB=bottomFill;float tB=1.0-topFill;{float regionL=step(p_uv.x,lB);float regionR=step(rB,p_uv.x);float regionM=1.0-regionL-regionR;float xL=(p_uv.x/lB)*left;float xR=1.0-right+((p_uv.x-rB)/rightFill)*right;float xM=left+((p_uv.x-lB)/(rB-lB))*(1.0-left-right);localUV.x=regionL*xL+regionM*xM+regionR*xR;}{float regionB=step(p_uv.y,bB);float regionT=step(tB,p_uv.y);float regionC=1.0-regionB-regionT;float yB=(p_uv.y/bB)*bottom;float yT=1.0-top+((p_uv.y-tB)/topFill)*top;float yC=bottom+((p_uv.y-bB)/(tB-bB))*(1.0-bottom-top);localUV.y=regionB*yB+regionC*yC+regionT*yT;}vec2 transformedUV=(p_textureTransform*vec3(localUV,1.0)).xy;return srgbTexture2D(p_texture,transformedUV)*p_color;}",{texture:r.texture,textureTransform:n,color:h,sliceBorders:l,sliceRegions:u},e),this.de=!0,this.pe=new s,this.ve=new s,this.ge=!0,this.ie=()=>{this.ge=!0},this.texture=r,this.he=n,this.ee=h,this.we=o,this.ye=a,this.me=c,this.pe=l,this.ve=u,this.xe=this.width,this.be=this.height,this.texture.signalDiminsionsChanged.on(this.ie)}get color(){return this.ee}get regionMode(){return this.me}get sliceBorders(){return this.we}get sliceRegions(){return this.ye}set color(t){this.ee.set(t)}set regionMode(t){this.me!==t&&(this.me=t,this.de=!0)}set sliceBorders(t){this.we.set(t)}set sliceRegions(t){this.ye.set(t)}destroy(){this.texture.signalDiminsionsChanged.off(this.ie),super.destroy()}setPlaneTransform(){let t;if((this.ge||this.we.dirty||this.texture.trimDirty)&&(t??(t={}),t.sliceBorders=this._e(this.pe),this.we.setDirtyFalse(),this.ge=!1),(this.ye.dirty||this.de||this.me===Oi.WORLD&&this.Ie())&&(t??(t={}),t.sliceRegions=this.Se(this.ve),this.ye.setDirtyFalse(),this.de=!1,this.Ee()),this.ee.dirty&&(t??(t={}),t.color=this.ee,this.ee.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.he),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,Si(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()}}_e(t){const i=this.texture.width,s=this.texture.height,e=this.texture.trim,h=e.right/i,r=e.top/s,n=e.bottom/s,o=(i-e.left-e.right)/i,a=(s-e.top-e.bottom)/s,c=this.we.right,l=this.we.top,u=this.we.bottom,f=Math.max(0,this.we.left-e.left/i)/o,d=Math.max(0,c-h)/o,p=Math.max(0,l-r)/a,v=Math.max(0,u-n)/a;return t.set(Math.min(1,f),Math.min(1,d),Math.min(1,p),Math.min(1,v))}Se(t){if(this.me===Oi.NORMALIZED)return t.set(this.ye.left,this.ye.right,this.ye.top,this.ye.bottom);const i=this.width,s=this.height;return t.set(this.ye.left/i,this.ye.right/i,this.ye.top/s,this.ye.bottom/s)}Ie(){return this.solverWrapper.dirty&&(this.xe!==Math.round(this.width)||this.be!==Math.round(this.height))}Ee(){this.xe=Math.round(this.width),this.be=Math.round(this.height)}}class Yi{constructor(t){this.source=t,this.dirtyInternal=!1}get dirty(){return this.dirtyInternal}setDirtyFalse(){this.dirtyInternal=!1}}class Xi extends Yi{constructor(t={x:1,y:0}){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 halfExtents=vec2(aspect,1.0)*0.5;float maxProjection=dot(halfExtents,abs(p_direction));vec2 correctedUV=(p_uv-0.5)*vec2(aspect,1.0);float projection=dot(correctedUV,p_direction);float offset=(projection/maxProjection+1.0)*0.5;return step(offset,p_progress);}"),this.direction=new h,this.Me=new h,this.direction.set(t.x,t.y).normalize(),this.Me.copy(this.direction)}get dirty(){return this.Ce(),this.dirtyInternal||!this.Me.equals(this.direction)}setDirtyFalse(){this.Ce(),this.Me.copy(this.direction),super.setDirtyFalse()}enumerateProperties(){return this.Ce(),{direction:this.direction}}Ce(){const t=this.direction.lengthSq();Math.abs(t)>Ot?Math.abs(t-1)>Ot&&this.direction.divideScalar(t):this.direction.set(1,0)}}var qi,Zi="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 Ji extends Bi{constructor(i,s,e={}){const h=new rt(e.color),r=new Mi(s),n=r.calculateUVTransform(),o=r.getResolution();e.width=e.width??r.width,e.height=e.height??r.height;const a=t.clamp(e.progress??1,0,1),c=e.maskFunction??new Xi;super(i,c.source+Zi,{texture:r.texture,textureTransform:n,textureResolution:o,color:h,progress:a,...c.enumerateProperties()},e),this.Te=!1,this.Pe=!1,this.ie=(t,i)=>{this.width===t&&this.height===i||(this.width=t,this.height=i,this.Pe=!0)},this.texture=r,this.he=n,this.Ae=o,this.ee=h,this.Ue=a,this.He=c,this.texture.signalDiminsionsChanged.on(this.ie)}get color(){return this.ee}get maskFunction(){return this.He}get progress(){return this.Ue}set color(t){this.ee.set(t)}set maskFunction(t){this.He!==t&&(this.He=t,this.Re())}set progress(i){i=t.clamp(i,0,1),this.Ue!==i&&(this.Ue=i,this.Te=!0)}setPlaneTransform(){let t;if(this.ee.dirty&&(t??(t={}),t.color=this.ee,this.ee.setDirtyFalse()),this.texture.textureDirty&&(t??(t={}),t.texture=this.texture.texture,this.texture.setTextureDirtyFalse()),this.texture.uvTransformDirty&&(t??(t={}),t.textureTransform=this.texture.calculateUVTransform(this.he),this.texture.setUVTransformDirtyFalse()),this.Te&&(t??(t={}),t.progress=this.Ue,this.Te=!1),this.Pe&&(t??(t={}),t.textureResolution=this.texture.getResolution(this.Ae),this.Pe=!1),this.maskFunction.dirty){t??(t={});const i=this.maskFunction.enumerateProperties();for(const s in i)t[s]=i[s];this.maskFunction.setDirtyFalse()}if(t&&this.sceneWrapper.setProperties(this.planeHandler,t),this.micro.dirty||this.texture.trimDirty||this.inputWrapper.dirty||this.solverWrapper.dirty){const t=this.micro,i=this.texture.trim;this.sceneWrapper.setTransform(this.planeHandler,Si(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()}}Re(){this.sceneWrapper.destroyPlane(this.planeHandler);const t=this.micro,i=this.texture.trim;this.planeHandler=this.sceneWrapper.createPlane(this.He.source+Zi,{texture:this.texture.texture,textureTransform:this.texture.calculateUVTransform(this.he),textureResolution:this.texture.getResolution(this.Ae),color:this.ee,progress:this.Ue,...this.He.enumerateProperties()},Si(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),V(this.mode),this.transparencyMode),this.ee.setDirtyFalse(),this.texture.setTextureDirtyFalse(),this.texture.setUVTransformDirtyFalse(),this.texture.setTrimDirtyFalse(),this.Te=!1,this.Pe=!1,this.He.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"})(qi||(qi={}));const Ki=qi.ON_PROPERTIES_CHANGE,Qi=new rt(0,0,0,1);class ts extends Bi{constructor(i,s={}){const e=t.clamp(s.resolutionFactor??.5,.1,2),h=s.width??64,r=s.height??32,o=new S(h*e,r*e,{format:x,minFilter:m,magFilter:m,type:b,depthBuffer:s.enableDepthBuffer??!0,stencilBuffer:!1}),a=new rt(s.color);super(i,Ci,{texture:o.texture,textureTransform:new n,color:a},s),this.Be=!0,this.Ve=!1,this.De=!1,this.ke=!1,this.ee=a,this.We=new rt(s.clearColor??Qi),this.$e=o,this.ze=s.scene??new d,this.Fe=s.camera??new E(60,h/r,.1,100),this.Ne=e,this.Oe=s.updateMode??Ki,this.ke=s.updateMode!==qi.MANUAL}get camera(){return this.Fe}get clearColor(){return this.We}get color(){return this.ee}get resolutionFactor(){return this.Ne}get scene(){return this.ze}get updateMode(){return this.Oe}set camera(t){this.Fe!==t&&(this.Fe=t,this.ke=!0)}set clearColor(t){this.We.set(t)}set color(t){this.ee.set(t)}set resolutionFactor(i){i=t.clamp(i,.1,2),this.Ne!==i&&(this.Ne=i,this.De=!0)}set scene(t){this.ze!==t&&(this.ze=t,this.ke=!0)}set updateMode(t){this.Oe!==t&&(this.Oe=t,this.ke=!0)}destroy(){this.$e.dispose(),super.destroy()}requestUpdate(){this.Ve=!0}onWillRender(t,i){this.Be=!this.Be,(this.Ve||this.Oe===qi.EVERY_FRAME||this.Oe===qi.EVERY_SECOND_FRAME&&this.Be||this.Oe===qi.ON_PROPERTIES_CHANGE&&this.ke||this.ee.dirty||this.We.dirty||this.Oe===qi.ON_DIMENSIONS_CHANGE&&(this.De||this.solverWrapper.dirty))&&((this.De||this.solverWrapper.dirty)&&(this.$e.setSize(this.width*this.Ne,this.height*this.Ne),this.De=!1),this.ee.dirty&&(this.sceneWrapper.setProperties(this.planeHandler,{color:this.ee}),this.ee.setDirtyFalse()),t.setClearColor(this.We.getHexRGB(),this.We.a),t.setRenderTarget(this.$e),t.clear(!0,!0,!1),t.render(this.ze,this.Fe),this.ke=!1,this.Ve=!1),super.onWillRender(t,i)}}const is="#000000",ss="left",es="Arial",hs="normal",rs="normal",ns=!1,os="transparent",as=!1,cs="#000000";class ls{constructor(t){this.Vt=!0,this.ee=t?.color,this.je=t?.align,this.Ye=t?.fontFamily,this.Xe=t?.fontSize,this.qe=t?.fontStyle,this.Ze=t?.fontWeight,this.Je=t?.lineHeight,this.Ke=t?.enableShadow,this.Qe=t?.shadowOffsetX,this.th=t?.shadowOffsetY,this.ih=t?.shadowBlur,this.sh=t?.shadowColor,this.eh=t?.enableStroke,this.hh=t?.strokeColor,this.rh=t?.strokeThickness}get color(){return this.ee}get align(){return this.je}get fontFamily(){return this.Ye}get fontSize(){return this.Xe}get fontStyle(){return this.qe}get fontWeight(){return this.Ze}get lineHeight(){return this.Je}get enableShadow(){return this.Ke}get shadowOffsetX(){return this.Qe}get shadowOffsetY(){return this.th}get shadowBlur(){return this.ih}get shadowColor(){return this.sh}get enableStroke(){return this.eh}get strokeColor(){return this.hh}get strokeThickness(){return this.rh}get dirty(){return this.Vt}set color(t){t!==this.ee&&(this.ee=t,this.Vt=!0)}set align(t){t!==this.je&&(this.je=t,this.Vt=!0)}set fontFamily(t){t!==this.Ye&&(this.Ye=t,this.Vt=!0)}set fontSize(t){t!==this.Xe&&(this.Xe=t,this.Vt=!0)}set fontStyle(t){t!==this.qe&&(this.qe=t,this.Vt=!0)}set fontWeight(t){t!==this.Ze&&(this.Ze=t,this.Vt=!0)}set lineHeight(t){t!==this.Je&&(this.Je=t,this.Vt=!0)}set enableShadow(t){t!==this.Ke&&(this.Ke=t,this.Vt=!0)}set shadowOffsetX(t){t!==this.Qe&&(this.Qe=t,this.Vt=!0)}set shadowOffsetY(t){t!==this.th&&(this.th=t,this.Vt=!0)}set shadowBlur(t){t!==this.ih&&(this.ih=t,this.Vt=!0)}set shadowColor(t){t!==this.sh&&(this.sh=t,this.Vt=!0)}set enableStroke(t){t!==this.eh&&(this.eh=t,this.Vt=!0)}set strokeColor(t){t!==this.hh&&(this.hh=t,this.Vt=!0)}set strokeThickness(t){t!==this.rh&&(this.rh=t,this.Vt=!0)}static resolve(t,i){const s=t.Xe??i.Xe??16;return{color:t.ee??i.ee??is,align:t.je??i.je??ss,fontFamily:t.Ye??i.Ye??es,fontSize:s,fontStyle:t.qe??i.qe??hs,fontWeight:t.Ze??i.Ze??rs,lineHeight:t.Je??i.Je??1.2*s,enableShadow:t.Ke??i.Ke??ns,shadowOffsetX:t.Qe??i.Qe??0,shadowOffsetY:t.th??i.th??0,shadowBlur:t.ih??i.ih??0,shadowColor:t.sh??i.sh??os,enableStroke:t.eh??i.eh??as,strokeColor:t.hh??i.hh??cs,strokeThickness:t.rh??i.rh??0}}setDirtyFalse(){this.Vt=!1}setDefaults(){this.ee===is&&this.je===ss&&this.Ye===es&&16===this.Xe&&this.qe===hs&&this.Ze===rs&&19.2===this.Je&&this.Ke===ns&&0===this.Qe&&0===this.th&&0===this.ih&&this.sh===os&&this.eh===as&&this.hh===cs&&0===this.rh||(this.ee=is,this.je=ss,this.Ye=es,this.Xe=16,this.qe=hs,this.Ze=rs,this.Je=19.2,this.Ke=ns,this.Qe=0,this.th=0,this.ih=0,this.sh=os,this.eh=as,this.hh=cs,this.rh=0,this.Vt=!0)}clear(){void 0===this.ee&&void 0===this.je&&void 0===this.Ye&&void 0===this.Xe&&void 0===this.qe&&void 0===this.Ze&&void 0===this.Je&&void 0===this.Ke&&void 0===this.Qe&&void 0===this.th&&void 0===this.ih&&void 0===this.sh&&void 0===this.eh&&void 0===this.hh&&void 0===this.rh||(this.ee=void 0,this.je=void 0,this.Ye=void 0,this.Xe=void 0,this.qe=void 0,this.Ze=void 0,this.Je=void 0,this.Ke=void 0,this.Qe=void 0,this.th=void 0,this.ih=void 0,this.sh=void 0,this.eh=void 0,this.hh=void 0,this.rh=void 0,this.Vt=!0)}copy(t){this.ee===t.ee&&this.je===t.je&&this.Ye===t.Ye&&this.Xe===t.Xe&&this.qe===t.qe&&this.Ze===t.Ze&&this.Je===t.Je&&this.Ke===t.Ke&&this.Qe===t.Qe&&this.th===t.th&&this.ih===t.ih&&this.sh===t.sh&&this.eh===t.eh&&this.hh===t.hh&&this.rh===t.rh||(this.ee=t.ee,this.je=t.je,this.Ye=t.Ye,this.Xe=t.Xe,this.qe=t.qe,this.Ze=t.Ze,this.Je=t.Je,this.Ke=t.Ke,this.Qe=t.Qe,this.th=t.th,this.ih=t.ih,this.sh=t.sh,this.eh=t.eh,this.hh=t.hh,this.rh=t.rh,this.Vt=!0)}calculatePadding(){let t=0;if(void 0!==this.eh&&(t+=this.rh??0),void 0!==this.Ke){const i=this.th??0,s=2*(this.ih??0);t+=Math.max(Math.abs(this.Qe??0)+s,Math.abs(i)+s)}return Math.ceil(t)}}class us{constructor(t){this.Vt=!0,this.nh=t.text,this.style=new ls(t.style)}get text(){return this.nh}get dirty(){return this.Vt||this.style.dirty}set text(t){t!==this.nh&&(this.nh=t,this.Vt=!0)}setDirtyFalse(){this.Vt=!1,this.style.setDirtyFalse()}}var fs;(t=>{t[t.BREAK=0]="BREAK",t[t.SCALE=1]="SCALE"})(fs||(fs={}));const ds=fs.SCALE;function ps(t){return t.match(/\S+|\s|\n/g)??[]}function vs(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 gs(t,i){const s=((t,i)=>{const s=[];let e=[],h=0,r=0,n=0,o=0;for(const a of i)"\n"!==a.text?0!==e.length&&h+a.metrics.width>t?(s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[a],h=a.metrics.width,r=a.metrics.height,n=a.metrics.baseline,o=a.metrics.lineHeight):(e.push(a),h+=a.metrics.width,r=Math.max(r,a.metrics.height),n=Math.max(n,a.metrics.baseline),o=Math.max(o,a.metrics.lineHeight)):(e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),e=[],h=0,r=0,n=0,o=0);return e.length>0&&s.push({chunks:e,width:h,height:r,baseline:n,lineHeight:o}),s})(i,t),e=(t=>{if(0===t.length)return{width:0,height:0};const i=Math.max(...t.map(t=>t.width));let s=0;for(let i=0;t.length>i;i++){const e=t[i];s+=0===i?e.height:e.lineHeight}return{width:i,height:s}})(s);return{lines:s,size:e}}function ws(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 ys(t,i,s,e){let h=t,r=0;for(const t of s)r=Math.max(t.width,r);for(let t=0;s.length>t;t++){const n=s[t],o=n.chunks[0]?.style.align??ss,a=n.chunks.every(t=>t.style.align===o)?o:ss;let c=0;"center"===a?c=(r-n.width)/2:"right"===a&&(c=r-n.width);let l=i+c;h+=0===t?n.height:n.lineHeight;for(const t of n.chunks)ws(l,h,t.text,t.style,e),l+=t.metrics.width}}class ms extends Bi{constructor(t,i,s={}){const e=ki(2,2),h=e.getContext("2d");if(!h)throw Error("UIText.constructor: failed to create canvas context");const r=Wi(e);r.needsUpdate=!0;const o=new rt(s.color);switch(super(t,Ci,{texture:r,textureTransform:new n,color:o}),this.oh=[],this.ah=!1,this.uh=!1,this.fh=!1,this.dh=[],this.ph=!1,this.ee=o,this.gh=new Ni(s.padding),this.commonStyle=new ls(s.commonStyle),this.wh=s.maxLineWidth??1024,this.yh=s.resizeMode??ds,this.le=e,this.ue=h,this.fe=r,this.content=i,this.mh=this.width,this.xh=this.height,void 0===s.padding&&this.gh.setUnified(this.content.reduce((t,i)=>Math.max(t,i.style.calculatePadding()),this.commonStyle.calculatePadding())),this.yh){case fs.SCALE:this.bh();break;case fs.BREAK:this._h()}}get color(){return this.ee}get content(){return this.oh}get maxLineWidth(){return this.wh}get padding(){return this.gh}get resizeMode(){return this.yh}set color(t){this.ee.set(t)}set content(t){this.oh!==t&&(this.oh="string"==typeof t?[new us({text:t,style:new ls})]:Array.isArray(t)?t.map(t=>new us("string"==typeof t?{text:t,style:new ls}:{text:t.text,style:new ls(t.style)})):[new us({text:t.text,style:new ls(t.style)})],this.ah=!0,this.ph=!0)}set maxLineWidth(t){this.wh!==t&&(this.wh=t,this.uh=!0)}set padding(t){this.gh.set(t)}set resizeMode(t){this.yh!==t&&(this.yh=t,this.fh=!0)}destroy(){this.fe.dispose(),super.destroy()}onWillRender(t,i){switch(this.yh){case fs.SCALE:this.bh();break;case fs.BREAK:this._h()}super.onWillRender(t,i)}bh(){if(!(this.ee.dirty||this.fh||this.uh||this.gh.dirty||this.solverWrapper.dirty&&this.mh/this.xh!==Math.round(this.width)/Math.round(this.height)||this.Ih()))return;const t=this.Sh(),{lines:i,size:s}=gs(t,this.wh),e=s.height+(this.gh.top+this.gh.bottom),h=s.width+(this.gh.left+this.gh.right);this.width=h,this.height=e/h*Math.round(this.width),this.width=h/e*Math.round(this.height);const r=this.mh!==e||this.xh!==h;r&&(this.le.height=e,this.le.width=h),ys(this.gh.top,this.gh.left,i,this.ue),this.Eh(r),this.fh=!1,this.uh=!1,this.gh.setDirtyFalse(),this.Mh(),this.Ch()}_h(){if(!(this.ee.dirty||this.fh||this.uh||this.gh.dirty||this.Th()||this.Ih()))return;const t=this.Sh(),{size:i}=gs(t,this.wh),s=this.gh.top+this.gh.bottom,e=this.gh.left+this.gh.right;this.height=i.height+s,this.width=i.width+e;const{lines:h,size:r}=gs(t,Math.round(this.width)-e);this.height=r.height+s,this.width=r.width+e;const n=Math.max(Math.round(this.width),2),o=Math.max(Math.round(this.height),2),a=this.mh!==n||this.xh!==o;a&&(this.le.width=n,this.le.height=o),ys(this.gh.top,this.gh.left,h,this.ue),this.Eh(a),this.fh=!1,this.uh=!1,this.gh.setDirtyFalse(),this.Mh(),this.Ch()}Eh(t){let i;this.ee.dirty&&(i??(i={}),i.color=this.ee,this.ee.setDirtyFalse()),t&&(this.fe.dispose(),this.fe=Wi(this.le),this.fe.needsUpdate=!0,i??(i={}),i.texture=this.fe),i&&this.sceneWrapper.setProperties(this.planeHandler,i)}Sh(){return this.ph&&(this.dh=((t,i,s)=>{const e=[];for(const h of i){const i=ls.resolve(h.style,s);for(const s of ps(h.text)){const h=vs(t,s,i);e.push({text:s,style:i,metrics:h})}}return e})(this.ue,this.oh,this.commonStyle),this.ph=!1),this.dh}Th(){return this.solverWrapper.dirty&&(this.mh!==Math.round(this.width)||this.xh!==Math.round(this.height))}Mh(){this.mh=Math.round(this.width),this.xh=Math.round(this.height)}Ih(){return this.ah||this.content.some(t=>t.dirty)}Ch(){this.ah=!1;for(const t of this.content)t.setDirtyFalse()}}class xs{constructor(){this.dirty=!1}}class bs extends xs{calculateScale(t,i){return 1}}const _s=new bs;class Is extends Nt{constructor(t){const i=t?.resizePolicy??_s,s=i.calculateScale(window.innerWidth,window.innerHeight);super({width:window.innerWidth*s,height:window.innerHeight*s,...t}),this.Ph=!1,this.Ws=new P,this.$s=new P,this.zs=new P,this.Ah=()=>{const t=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight);this.resizePolicy.dirty=!1,this.Ph=!1,this.resizeInternal(window.innerWidth*t,window.innerHeight*t)},this.Uh=t=>{this.Hh(t,"onPointerDown",this.Ws)},this.Rh=t=>{this.Hh(t,"onPointerMove",this.$s)},this.Bh=t=>{this.Hh(t,"onPointerUp",this.zs)},this.Vh=i,window.addEventListener("resize",this.Ah),window.addEventListener("pointerdown",this.Uh),window.addEventListener("pointermove",this.Rh),window.addEventListener("pointerup",this.Bh)}get resizePolicy(){return this.Vh}get signalPressed(){return this.Ws}get signalMoved(){return this.$s}get signalReleased(){return this.zs}set resizePolicy(t){this.Vh!==t&&(this.Vh=t,this.Ph=!0)}destroy(){window.removeEventListener("resize",this.Ah),window.removeEventListener("pointerdown",this.Uh),window.removeEventListener("pointermove",this.Rh),window.removeEventListener("pointerup",this.Bh)}render(t,i){(this.resizePolicy.dirty||this.Ph)&&this.Ah(),super.renderInternal(t,i)}projectWorldPosition(i,s,e=new r){return e.copy(i).project(s),e.x=t.mapLinear(e.x,-1,1,this.x,this.width),e.y=t.mapLinear(e.y,-1,1,this.y,this.height),e}projectLayerPosition(i,s,e=-1,h=new r){return h.set(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),e).unproject(s)}buildRay(i,s,e=new M){const h=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),-1).unproject(s),n=new r(t.mapLinear(i.x,this.x,this.width,-1,1),t.mapLinear(i.y,this.y,this.height,-1,1),1).unproject(s).sub(h).normalize();return e.set(h,n)}Hh(t,i,s){const e=t.target instanceof HTMLElement?t.target.getBoundingClientRect():null,h=e?t.clientX-e.left:t.clientX,r=e?e.bottom-t.clientY:window.innerHeight-t.clientY,n=this.resizePolicy.calculateScale(window.innerWidth,window.innerHeight),o=h*n,a=r*n;B(this.mode)&&(s.emit({x:o,y:a,identifier:t.pointerId,layer:this}),this.inputWrapperInternal[i](o,a,t.pointerId))}}class Ss extends Pi{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 Es extends Pi{constructor(t){super(),this.vertices=t}contains(t,i){const s=this.vertices.length;if(3>s)return!1;let e=!1;for(let h=0,r=s-1;s>h;r=h++){const s=this.vertices[h],n=this.vertices[r],o=s.x,a=s.y,c=n.y;a>i!=c>i&&(n.x-o)*(i-a)/(c-a)+o>t&&(e=!e)}return e}}class Ms extends Pi{constructor(t,i,s,e,h){super(),this.x=t,this.y=i,this.width=s,this.height=e,this.radius=h,this.radius=Math.min(h,Math.min(s,e)/2)}contains(t,i){const s=this.x,e=this.x+this.width,h=this.y,r=this.y+this.height;if(s>t||t>e||h>i||i>r)return!1;const n=s+this.radius,o=e-this.radius,a=h+this.radius,c=r-this.radius;if(t>=n&&o>=t)return!0;if(i>=a&&c>=i)return!0;let l,u;l=n>t?n:o,u=a>i?a:c;const f=t-l,d=i-u;return this.radius*this.radius>=f*f+d*d}}class Cs extends Yi{constructor(t=0,i=!1){super("float calculateMask(){float aspect=p_textureResolution.x/p_textureResolution.y;vec2 p=(p_uv-0.5)*vec2(aspect,1.0);float angle=atan(p.y,p.x);angle=(angle+PI)/(2.0*PI);float adjusted=angle-p_startAngle;adjusted=p_direction>0.0 ? adjusted :-adjusted;adjusted=fract(adjusted);return step(adjusted,p_progress);}"),this.Lh=t,this.Dh=i}get startAngle(){return this.Lh}get inverseDirection(){return this.Dh}set startAngle(t){this.Lh!==t&&(this.Lh=t,this.dirtyInternal=!0)}set inverseDirection(t){this.Dh!==t&&(this.Dh=t,this.dirtyInternal=!0)}enumerateProperties(){return{direction:this.Dh?-1:1,startAngle:this.Lh}}}class Ts extends xs{constructor(t,i){super(),this.kh=t,this.Wh=i}get rectWidth(){return this.kh}get rectHeight(){return this.Wh}set rectWidth(t){t!==this.kh&&(this.kh=t,this.dirty=!0)}set rectHeight(t){t!==this.Wh&&(this.Wh=t,this.dirty=!0)}calculateScale(t,i){return Math.min(this.kh/t,this.Wh/i)}}class Ps extends xs{constructor(t,i){super(),this.$h=t,this.zh=i}get fixedWidthLandscape(){return this.$h}get fixedHeightPortrait(){return this.zh}set fixedWidthLandscape(t){t!==this.$h&&(this.$h=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.zh&&(this.zh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.$h/t:this.zh/i}}class As extends xs{constructor(t,i){super(),this.Fh=t,this.Nh=i}get fixedHeightLandscape(){return this.Fh}get fixedWidthPortrait(){return this.Nh}set fixedHeightLandscape(t){t!==this.Fh&&(this.Fh=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.Nh&&(this.Nh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Fh/i:this.Nh/t}}class Us extends xs{constructor(t,i){super(),this.kh=t,this.Wh=i}get rectWidth(){return this.kh}get rectHeight(){return this.Wh}set rectWidth(t){t!==this.kh&&(this.kh=t,this.dirty=!0)}set rectHeight(t){t!==this.Wh&&(this.Wh=t,this.dirty=!0)}calculateScale(t,i){return Math.max(this.kh/t,this.Wh/i)}}class Hs extends xs{constructor(t,i){super(),this.Fh=t,this.zh=i}get fixedHeightLandscape(){return this.Fh}get fixedHeightPortrait(){return this.zh}set fixedHeightLandscape(t){t!==this.Fh&&(this.Fh=t,this.dirty=!0)}set fixedHeightPortrait(t){t!==this.zh&&(this.zh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.Fh/i:this.zh/i}}class Rs extends xs{constructor(t,i){super(),this.$h=t,this.Nh=i}get fixedWidthLandscape(){return this.$h}get fixedWidthPortrait(){return this.Nh}set fixedWidthLandscape(t){t!==this.$h&&(this.$h=t,this.dirty=!0)}set fixedWidthPortrait(t){t!==this.Nh&&(this.Nh=t,this.dirty=!0)}calculateScale(t,i){return t>i?this.$h/t:this.Nh/t}}export{vi as UIAnchor,Di as UIAnimatedImage,Vi as UIAnimatedImageLoopMode,Ss as UIAreaCircle,Es as UIAreaPolygon,Ai as UIAreaRectangle,Ms as UIAreaRoundedRectangle,ci as UIAspectConstraint,rt as UIColor,ai as UIConstraint2DBuilder,ui as UICoverConstraintBuilder,pi as UICustomConstraint,Wt as UIExpression,di as UIFitConstraintBuilder,Is as UIFullscreenLayer,zi as UIGraphics,Qt as UIHeightConstraint,ti as UIHorizontalDistanceConstraint,ii as UIHorizontalInterpolationConstraint,si as UIHorizontalProportionConstraint,Fi as UIImage,Hi as UIInputDummy,Ti as UIMicro,gi as UIMicroAnchorMode,H as UIMode,ji as UINineSlice,Oi as UINineSliceRegionMode,R as UIOrientation,Q as UIPriority,Ji as UIProgress,Cs as UIProgressMaskFunctionCircular,Xi as UIProgressMaskFunctionDirectional,$t as UIRelation,Ts as UIResizePolicyCover,Ps as UIResizePolicyCross,As as UIResizePolicyCrossInverted,Us as UIResizePolicyFit,Hs as UIResizePolicyFixedHeight,Rs as UIResizePolicyFixedWidth,bs as UIResizePolicyNone,ts as UIScene,qi as UISceneUpdateMode,Kt as UISingleParameterConstraint,ms as UIText,fs as UITextResizeMode,_t as UITransparencyMode,ei as UIVerticalDistanceConstraint,hi as UIVerticalInterpolationConstraint,ri as UIVerticalProportionConstraint,ni as UIWidthConstraint};
2
2
  //# sourceMappingURL=index.min.js.map