Files
AR-Menu/AR Menu/Needle/MenuScene/node_modules/three-mesh-ui/build/three-mesh-ui.min.js
2025-11-30 08:35:03 +02:00

1 line
108 KiB
JavaScript

(()=>{"use strict";var e={};e.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}();const t={fontFamily:null,fontSize:.05,fontKerning:"auto",fontStyle:"normal",fontWeight:"normal",offset:.005,lineHeight:1.2,lineBreak:"- ,.:?!\n",whiteSpace:"pre-line",flexDirection:"column",justifyContent:"start",alignItems:"start",backgroundImage:null,textAlign:"left",boxSizing:"content-box",position:"static",color:16777215,fontColor:16777215,fontOpacity:1,opacity:1,fontPXRange:4,fontSupersampling:!0,fontSmooth:"antialiased",borderRadius:0,borderWidth:0,borderColor:"black",borderOpacity:1,backgroundSize:"cover",backgroundColor:0,backgroundOpacity:0,overflow:"visible",letterSpacing:0,invertAlpha:!1,segments:1};class i{constructor(e,t=null,i=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=i}get id(){return this._id}get value(){return this._value}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this.output(t)}output(e){}_outputValue(e){e[this._id]=this._value}process(e){}render(e){}getInheritedInput(e){if("inherit"!==this._value)return this._value;const t=e._parent._value;return t&&t[`_${this._id}`]?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return e=this._id,Object.prototype.hasOwnProperty.call(t,e)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${e}'`),t[e];var e}isValid(e){return!0}emptyStrategyLogic(){throw new Error(`ThreeMeshUI::${this.constructor.name} has empty strategy. Update has not been processed.`)}requestUpdate(){this._needsUpdate=!0}requestProcess(){this._needsProcess=!1}requestRender(){this._needsRender=!1}}class n extends i{constructor(){super("renderOrder","auto",!0),this.output=this._outputValue,this._actualValue=0}set value(e){this.isValid(e)&&(this._value=e,this._needsUpdate=!0)}update(e,t){if("auto"!==this._value)this._actualValue=this._value;else{const t=e._parent._value;if(null!==t){const i=t._renderOrder._actualValue,n=1+t._children._uis.indexOf(e);this._actualValue=i+n}}for(const t of e._children._uis){"auto"===t._renderOrder._value&&(t._renderOrder._needsUpdate=!0)}this._outputValue(t)}_outputValue(e){e[this._id]=this._actualValue}get value(){return this._value}}class s extends i{constructor(e,t=null,i=!0){super(e,t,i),this.output=this._outputValue,this._notInheritedValue=null}update(e,t){this._notInheritedValue=this._value,"inherit"===this._notInheritedValue&&(this._notInheritedValue=this.getInheritedInput(e)),this.propagate(e),this._outputValue(t)}propagate(e){for(const t of e._children._uis){const e=t[`_${this._id}`];void 0!==e&&"inherit"===e._value&&(t[`_${this._id}`]._needsUpdate=!0)}}_outputValue(e){e[this._id]=this._notInheritedValue}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return"inherit"===this._value?this._notInheritedValue:this._value}}class r extends s{constructor(){super("offset","inherit",!1)}update(e,t){super.update(e,t),null!==e._parent._value&&(e.position.z=this._notInheritedValue)}}class o extends s{constructor(){super("fontSmooth","inherit",!0),this._needsUpdate=!1,this.isValid=h,this.output=this._outputValue}}const a=["inherit","none","antialiased"];function h(e){return-1!==a.indexOf(e)||(console.warn(`.fontSmoothing value '${e}' is not valid. Aborted`),!1)}const l=THREE;class u extends i{constructor(e,t,i=!0){super(e,"unset",i),this._input="inherit",this._allowsInherit=!0,this._inheritedInput=void 0,this._inline=void 0}update(e,t){this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const t of e._children._uis){const e=t[`_${this._id}`];"inherit"===(e._input?e._input:e._value)&&(t[`_${this._id}`]._needsUpdate=!0)}this.output(t)}computeOutputValue(e){this._value=this._input}_computeFromInherited(e){this._value=this._inheritedInput}set value(e){console.warn(".(style) sub-property cannot be directly set. It must comes from inline or computed setter.")}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._input=this._inline=e,this._needsUpdate=!0)}get inline(){return this._inline}isValidValue(e){return!0}getInheritedInput(e){if("inherit"!==this._input)return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class d extends u{constructor(e,t){super(e,t,!1),this._input=new l.Vector4(0,0,0,0),this._inline=null,this._value=new l.Vector4(0,0,0,0)}get value(){return this._value}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input)}set inline(e){this._vector4ValueSetter(this._input,e),this._input.equals(this._value)||(this._needsUpdate=!0)}set top(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get top(){return this._input.x}set right(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get right(){return this._input.y}set bottom(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottom(){return this._input.z}set left(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get left(){return this._input.w}dispose(){this._computed=null,this._inline=null,this._input=null,this._output=null}_vector4ValueSetter(e,t){if(t instanceof l.Vector4)e.copy(t);else{if(("string"==typeof t||t instanceof String)&&(t=t.split(" ")),Array.isArray(t))switch((t=t.map((e=>parseFloat(e)))).length){case 1:return void e.setScalar(t[0]);case 2:return e.x=e.z=t[0],void(e.y=e.w=t[1]);case 3:return e.x=t[0],e.y=t[1],void(e.z=t[2]);case 4:return e.x=t[0],e.y=t[1],e.z=t[2],void(e.w=t[3]);default:return void console.error("StyleVector4Property::set() Four Dimension property had more than four values")}isNaN(t)||e.setScalar(t)}}}class c extends d{constructor(){super("padding",new l.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._bounds._needsUpdate=!0,e._bounds._needsRender=!0,e._layouter._needsProcess=!0,e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}class _ extends d{constructor(){super("margin",new l.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}}const f=function(e,t,i){e[t]=i},p=function(e,t,i){null!==i&&(e[t]=i)};class g{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,i,n=null){for(const e in this._definition){const s=this._definition[e];if(void 0!==i[e]){const r=s.t?s.t:f;r(t,s.m,i[e]),n&&r(n,s.m,i[e])}}}static mediate(e,t,i,n,s=null){if(t)for(const e in n){const r=n[e];if(void 0!==i[e]){const n=r.t?r.t:f;n(t,r.m,i[e]),s&&n(s,r.m,i[e])}}}}class m extends i{constructor(){super("parent",null,!1)}update(e,t){e.parent&&e.parent.isUI?this._value=e.parent:this._value=null}set value(e){console.warn("ParentProperty is readonly")}get value(){return this._value}find(e){return this._value?e(this._value)?this._value:this._value._parent.find(e):null}dispose(){this._value=null}}const v=function(e,t,i=6){return e.toFixed(i)===t.toFixed(i)};class b extends i{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(v(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}}class y extends s{constructor(e){super(e,"inherit",!0),this.isValid=w}}const x=[l.FrontSide,l.BackSide,l.DoubleSide];function w(e){return-1!==x.indexOf(e)||(console.warn(`SideProperty value '${e}' is not valid. Abort`),!1)}class S{constructor(){this._offsetX=0,this._offsetY=0,this._lineBreak=null,this._kerning=0,this._fontFactor=1,this._fontSize=0,this._cumulativeWidth=0,this._paddingLeft=0,this._paddingRight=0,this._marginLeft=0,this._marginRight=0}resetOffsets(){this._offsetX=this._offsetY=0,this._cumulativeWidth=0}get xadvance(){return 0}get xoffset(){return 0}get yoffset(){return 0}get width(){return 0}get height(){return 0}set lineBreak(e){this._lineBreak=e}get lineBreak(){return this._lineBreak}get anchor(){return 0}get kerning(){return this._kerning*this._fontFactor}set kerning(e){this._kerning=e}get fontSize(){return this._fontSize}set fontSize(e){this._fontSize=e}get lineHeight(){return 0}get offsetX(){return this._offsetX}set offsetX(e){this._offsetX=e}get offsetY(){return this._offsetY}set offsetY(e){this._offsetY=e}get cumulativeWidth(){return this._cumulativeWidth}set cumulativeWidth(e){this._cumulativeWidth=e}get marginLeft(){return this._marginLeft}set marginLeft(e){this._marginLeft=e}get marginRight(){return this._marginRight}set marginRight(e){this._marginRight=e}get paddingLeft(){return this._paddingLeft}set paddingLeft(e){this._paddingLeft=e}get paddingRight(){return this._paddingRight}set paddingRight(e){this._paddingRight=e}get lineBase(){return 0}set fontFactor(e){this._fontFactor=e}get fontFactor(){return this._fontFactor}}class V{constructor(e){this._char="",this._width=1,this._heigth=1,this._xadvance=1,this._xoffset=0,this._yoffset=0,this._font=e}get font(){return this._font}get char(){return this._char}get width(){return this._width}get height(){return this._heigth}get xadvance(){return this._xadvance}get xoffset(){return this._xoffset}get yoffset(){return this._yoffset}set yoffset(e){this._yoffset=e}clone(e){throw new Error("Abstract... Need to be implemented")}asInlineGlyph(){throw new Error("Abstract... Need to be implemented")}}class k extends S{constructor(e){super(),this._typographic=e}get typographic(){return this._typographic}get xadvance(){return this._typographic.xadvance*this._fontFactor}get xoffset(){return this._typographic.xoffset*this._fontFactor}get yoffset(){return this._typographic.yoffset*this._fontFactor}get width(){return this._typographic.width*this._fontFactor}get height(){return this._typographic.height*this._fontFactor}get char(){return this._typographic.char}get anchor(){return this.yoffset}get lineHeight(){return this._typographic.font.lineHeight*this._fontFactor}get lineBase(){return this._typographic.font.lineBase*this._fontFactor}}const R={light:"100",normal:"400",bold:"700",bolder:"900"};function U(e){if(!isNaN(e))return e.toString();const t=R[e];return t||e}class C extends l.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=U(e),this._style=t,this._size=42,this._lineHeight=42,this._lineBase=42,this._font=null}get typographic(){return this._font}get isReady(){return this._isReady}get weight(){return this._weight}get style(){return this._style}get texture(){return this._texture}set fontMaterial(e){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get fontMaterial(){throw Error(`FontVariant('${this.id}')::fontMaterial - is abstract.`)}get id(){return`${this._name}(w:${this.weight},s:${this.style})`}getTypographicGlyph(e){let t=this._chars[e];if(t)return t;if(e.match(/\s/))return this._chars[" "];const i=this._getFallbackCharacter(e);if(i&&(t=this._chars[i],t))return t;throw Error(`FontVariant('${this.id}')::getTypographicGlyph() - character('${e}') and/or fallback character were not found in provided msdf charset.`)}_getFallbackCharacter(e){throw new Error(`FontVariant(${typeof this})::_getFallbackCharacter() is abstract and should therefore be overridden.`)}getGeometricGlyph(e,t){throw new Error(`FontVariant(${typeof this})::getGeometryCharacter() is abstract and should therefore be overridden.`)}getKerningAmount(e){return this._kernings[e]?this._kernings[e]:0}adjustTypographicGlyphs(e){for(const t in e){const i=this.getTypographicGlyph(t),n=e[t];for(const s in n)i["_"+s]=e[t][s]}}_checkReadiness(){var e;this._readyCondition()&&((e=this)._isReady=!0,e.dispatchEvent(M))}_alterElementProperties(e){throw new Error(`FontVariant(${typeof this})::_alterElementProperties() is abstract and should therefore be overridden.`)}_readyCondition(){throw new Error(`FontVariant(${typeof this})::_readyCondition() is abstract and should therefore be overridden.`)}}const M={type:"ready"};const I=C;class B extends i{constructor(e=null){super("font",e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=P}output(e){e[this._id]=this._fontVariant}update(e,t){if(this._fontVariant&&!this._fontVariant.isReady&&this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._value&&this._value instanceof I)this._fontVariant=this._value;else{const t=e._fontFamily._value;t&&(this._fontVariant=t.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=function(e,t){return function(){t._needsUpdate=!0,e._glyphs._needsProcess=!0,t._fontVariant.removeEventListener("ready",t._handleFontReadyClosure),t._handleFontReadyClosure=null}}(e,this),this._fontVariant.isReady?this._handleFontReadyClosure():this._fontVariant.addEventListener("ready",this._handleFontReadyClosure),e._fontMaterial._defaultMaterial&&e._fontMaterial._defaultMaterial instanceof this._fontVariant.fontMaterial||(e._fontMaterial._defaultMaterial=new this._fontVariant.fontMaterial,e._fontMaterial._needsUpdate=!0))}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}get fontVariant(){return this._fontVariant}dispose(){this._handleFontReadyClosure&&(this._fontVariant.removeEventListener("ready",this._handleFontReadyClosure),this._handleFontReadyClosure=null),this._value=null,this._fontVariant=null}}function P(e){return e instanceof I||(console.warn(`.font value '${e}' is not valid. It requires a FontVariant instance. Aborted`),!1)}class T extends u{constructor(e){super("display",e),this._value="flex",this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=z}computeOutputValue(e){e._visible._value="none"!==this._output}}const F=["none","flex"];function z(e){return-1!==F.indexOf(e)||(console.warn(`(.style) display value '${e}' is not valid. Aborted`),!1)}class O extends u{constructor(e){super("boxSizing",e),this._allowsInherit=!1,this.isValidValue=W}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}}const A=["border-box","content-box"];function W(e){return-1!==A.indexOf(e)||(console.warn(`(.style) boxSizing value '${e}' is not valid. Aborted`),!1)}class D extends u{constructor(e,t){super(e,t,!1),this._value=new l.Color,this.output=this._outputValue}computeOutputValue(e){"inherit"!==this._input&&this._value.set(this._input)}set inline(e){this._input=this._inline=e,this._needsUpdate=!0}}class E extends u{constructor(e,t){super(e,t,!0),this.isValidValue=L,this._allowsInherit=!1,this._input=t,this._value=t,this.output=this._outputValue,this.computeOutputValue=this._computeFromInherited}_outputValue(e){e[this._id]=this._inheritedInput}}function L(e){return!(e<0&&e>1)||(console.warn(`(.style) styleFactorProperty('${this.id}') value '${e}' is not valid)`),!1)}class H extends u{constructor(e){super("backgroundImage",e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new l.Vector2(1,1),this.isValidValue=G}get value(){return this._value}output(e){e[this._id]=this._value,e.tSize=this._textureSize}computeOutputValue(e){this._value=this._inheritedInput,this._value instanceof l.Texture&&!this._value.image?console.warn("ThreeMeshUI - .backgroundImage :: Please provide preloaded texture in order to have accurate sizing."):this._needsProcess=!0}process(e){this._value?this._textureSize.set(this._value.image.width,this._value.image.height):this._textureSize.set(1,1)}}function G(e){return!0}class $ extends u{constructor(e){super("backgroundSize",e,!0),this.isValidValue=X,this.output=this._outputValue}}const j=["cover","contain","stretch"];function X(e){return-1!==j.indexOf(e)||(console.warn(`(.style) backgroundSize value '${e}' is not valid. Aborted`),!1)}class N extends u{constructor(e){super("overflow",e,!0),this.isValidValue=K,this._clippingPlanes=null,this._renderStrategy=this._emptyRender}update(e,t){void 0!==this._inline&&"unset"!==this._inline?this._input=this._inline:void 0!==this._computed&&(this._input=this._computed),this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const t of e._children._uis)t._overflow._needsUpdate=!0;this.output(t)}output(e){e.clippingPlanes=this._clippingPlanes}computeOutputValue(e){super.computeOutputValue(e),"hidden"===this._value?this._renderStrategy=this._propagateRender:(this._renderStrategy=this._emptyRender,this._clippingPlanes=null);const t=e._parent._value;if(null!==t){const e=t._overflow;if("hidden"!==e._value&&null===e._clippingPlanes||this._clippingPlanes)"visible"!==e._value&&null!==e._clippingPlanes||null===this._clippingPlanes||(this._clippingPlanes=null,this._renderStrategy=this._emptyRender,this._needsRender=!0);else{this._clippingPlanes=[new l.Plane(new l.Vector3(0,-1,0),1),new l.Plane(new l.Vector3(-1,0,0),1),new l.Plane(new l.Vector3(0,1,0),1),new l.Plane(new l.Vector3(1,0,0),1)];for(let e=0;e<this._clippingPlanes.length;e++)this._clippingPlanes[e].parent=t;null!==e._clippingPlanes&&this._clippingPlanes.push(...e._clippingPlanes),this._renderStrategy=this._hiddenRender,this._needsRender=!0}}}render(e){this._renderStrategy(e)}_emptyRender(e){}_hiddenRender(e){const t=e._parent._value,i=t._bounds._offsetHeight,n=t._bounds._offsetWidth,s=t._padding._value,r=t._borderWidth._value;for(let e=0;e<4&&e<this._clippingPlanes.length;e++){const o=this._clippingPlanes[e];switch(e%4){case 0:o.constant=i/2-(s.x+r.x);break;case 1:o.constant=n/2-(s.y+r.y);break;case 2:o.constant=i/2-(s.z+r.z);break;case 3:o.constant=n/2-(s.w+r.w)}o.applyMatrix4(t.matrixWorld)}for(let t=0;t<e._children._uis.length;t++){e._children._uis[t]._overflow._needsRender=!0}}_propagateRender(e){for(let t=0;t<e._children._uis.length;t++){e._children._uis[t]._overflow._needsRender=!0}}}const Y=["visible","hidden"];function K(e){return-1!==Y.indexOf(e)||(console.warn(`(.style) overflow value '${e}' is not valid. Aborted`),!1)}const q="rem",J="%",Q=[q,"em",J],Z=function(e){return-1===Q.indexOf(e)?q:e};class ee extends d{constructor(e){super("borderRadius",e),this._valueUV=this._value.clone(),this._input=new l.Vector4(0,0,0,0),this._mediation=!0,this._cornerTL=new l.Vector2(0,1),this._cornerTR=new l.Vector2(1,1),this._cornerBR=new l.Vector2(1,0),this._cornerBL=new l.Vector2(0,0);const t=new te(this._valueUV,["x","y"]),i=new te(this._valueUV,["z","w"]),n=new te(this._valueUV,["x","w"]),s=new te(this._valueUV,["y","z"]);t.complementaryMediation=i,i.complementaryMediation=t,n.complementaryMediation=s,s.complementaryMediation=n,this._sideMediators=[t,i,n,s],this._units=q}set units(e){this._units=Z(e),this._needsProcess=!0}get units(){return this._units}set mediation(e){e!==this._mediation&&(this._mediation=e,this._needsUpdate=!0)}get mediation(){return this._mediation}output(e){e.cornerTL=this._cornerTL,e.cornerTR=this._cornerTR,e.cornerBR=this._cornerBR,e.cornerBL=this._cornerBL}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0}process(e){this._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,i=e._bounds._offsetHeight;if(this._units===J&&this._valueUV.divideScalar(100),this._units===q&&this._valueUV.divideScalar(Math.min(t,i)),this._mediation)do{this._sideMediators.forEach((e=>e.computeValue())),this._sideMediators.sort(((e,t)=>e.value<t.value?1:-1)),this._sideMediators[0].value>1&&this._sideMediators[0].mediate()}while(this._sideMediators[0].value>1);let n=t>i?i/t:1,s=t<i?t/i:1;this._units===J&&(n=s=1),this._cornerTL.x=this._valueUV.x*n,this._cornerTL.y=1-this._valueUV.x*s,this._cornerTR.x=1-this._valueUV.y*n,this._cornerTR.y=1-this._valueUV.y*s,this._cornerBR.x=1-this._valueUV.z*n,this._cornerBR.y=this._valueUV.z*s,this._cornerBL.x=this._valueUV.w*n,this._cornerBL.y=this._valueUV.w*s}dispose(){for(const e of this._sideMediators)e.dispose();this._sideMediators=null,this._cornerTL=null,this._cornerTR=null,this._cornerBR=null,this._cornerBL=null,super.dispose()}set topLeft(e){this._input.x!==e&&(this._input.x=e,this._needsUpdate=!0)}get topLeft(){return this._input.x}set topRight(e){this._input.y!==e&&(this._input.y=e,this._needsUpdate=!0)}get topRight(){return this._input.y}set bottomRight(e){this._input.z!==e&&(this._input.z=e,this._needsUpdate=!0)}get bottomRight(){return this._input.z}set bottomLeft(e){this._input.w!==e&&(this._input.w=e,this._needsUpdate=!0)}get bottomLeft(){return this._input.w}set top(e){this._input.x===e&&this._input.y===e||(this._input.x=this._input.y=e,this._needsUpdate=!0)}get top(){return(this._input.x+this._input.y)/2}set right(e){this._input.y===e&&this._input.z===e||(this._input.y=this._input.z=e,this._needsUpdate=!0)}get right(){return(this._input.y+this._input.z)/2}set bottom(e){this._input.z===e&&this._input.w===e||(this._input.z=this._input.w=e,this._needsUpdate=!0)}get bottom(){return(this._input.z+this._input.w)/2}set left(e){this._input.w===e&&this._input.x===e||(this._input.w=this._input.x=e,this._needsUpdate=!0)}get left(){return(this._input.w+this._input.x)/2}}class te{constructor(e,t){this._borderRadiuses=e,this._sideProperties=t,this._complementaryMediation=null,this._value=0}get value(){return this._value}set complementaryMediation(e){this._complementaryMediation=e}computeValue(){let e=0;for(const t of this._sideProperties)e+=this._borderRadiuses[t];this._value=e}mediate(e=!0){if(!(this._value<1)){for(const e of this._sideProperties)this._borderRadiuses[e]/=this._value;e&&this._complementaryMediation.mediate(!1)}}dispose(){this._complementaryMediation=null,this._borderRadiuses=null}}class ie extends d{constructor(e){super("borderWidth",e,!1),this._valueUV=this._value.clone(),this.output=this._outputValue,this._units=q}set units(e){this._units=Z(e),this._needsUpdate=!0}get units(){return this._units}computeOutputValue(e){this._vector4ValueSetter(this._value,this._input),this._needsProcess=!0,e._bounds._needsUpdate=!0,e._layouter._needsUpdate=!0}_outputValue(e){e[this._id]=this._valueUV}process(e){this._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._valueUV.copy(this._value);const t=e._bounds._offsetWidth,i=e._bounds._offsetHeight;if(this._units===J&&this._valueUV,this._units===q)0!==t&&(this._valueUV.w/=t,this._valueUV.y/=t),0!==i&&(this._valueUV.x/=i,this._valueUV.z/=i);else if("em"===this._units){if(0!==t){const e=t>i?i/t:1;this._valueUV.y*=e,this._valueUV.w*=e}if(0!==i){const e=t<i?t/i:1;this._valueUV.x*=e,this._valueUV.z*=e}}}}class ne extends i{constructor(e,t=!0){super("visible",t,!0),this._needsUpdate=!1}update(e,t){e.visible=this._value,e._parent._value&&(e._parent._value._children._needsUpdate=!0)}set value(e){this.isValid(e)&&this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return this._value}}class se extends D{constructor(e){super("backgroundColor",e,!1),this._input="transparent",this._allowsInherit=!1}computeOutputValue(e){e._backgroundMesh.visible=!("none"===this._input||"transparent"===this._input),"inherit"===this._input?this._value.set(this.getInheritedInput(e)):"transparent"!==this._input&&"none"!==this._input&&this._value.set(this._input)}}class re extends i{constructor(e="untitled"){super(e,void 0,!1)}update(e,t){}output(e){}}class oe extends i{constructor(){super("inlineJustificator",null,!1),this._value=null}update(e,t){}process(e){const t=e._bounds._innerHeight,i=e._layouter._value,n=Math.abs(i.height);let s=(()=>{switch(e._alignItems._value){case"inherit":case"start":return t/2;case"end":return n-t/2;case"stretch":case"center":return n/2}})();const r=e._padding._value,o=e._borderWidth._value;s+=(-r.x+r.z)/2+(-o.x+o.z)/2,i.forEach((e=>{e.y+=s,e.forEach((e=>{e.offsetY+=s}))}))}}const ae=["start","center","end","stretch"],he=function(e){return-1!==ae.indexOf(e)||(console.warn(`(.style) alignItems value '${e}' is not valid. Aborted`),!1)};class le extends u{constructor(){super("alignItems","inherit",!0),this.isValidValue=he}}class ue extends u{constructor(){super("textAlign","inherit",!0),this.isValidValue=ce}}const de=["left","right","center","justify","justify-left","justify-right","justify-center"],ce=function(e){return-1!==de.indexOf(e)||(console.warn(`(.style) textAlign value '${e}' is not valid. Aborted`),!1)};class _e extends u{constructor(){super("flexDirection","inherit",!0),this.isValid=pe}}const fe=["row","row-reverse","column","column-reverse"];function pe(e){return-1!==fe.indexOf(e)||(console.warn(`(.style) flexDirection value '${e}' is not valid. Aborted`),!1)}class ge extends u{constructor(){super("justifyContent","inherit",!0),this.isValidValue=ve}}const me=["start","center","end","space-between","space-around","space-evenly"];function ve(e){return-1!==me.indexOf(e)||(console.warn(`(.style) justifyContent value '${e}' is not valid. Aborted`),!1)}class be extends u{constructor(){super("order",0,!0),this._value=0,this._input=0,this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._parent._value&&(e._parent._value._children._needsProcess=!0)}}class ye extends u{constructor(){super("position","static",!0),this._allowsInherit=!1,this._value="static",this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=we}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}}const xe=["static","absolute"];function we(e){return-1!==xe.indexOf(e)||(console.warn(`(.style) position value '${e}' is not valid. Aborted`),!1)}class Se extends u{constructor(e,t=null){super(e,t,!0),this._input="auto",this._auto=!0,this._relative=!1,this._updateRequired=!0}set inline(e){this.isValidValue(e)&&e!==this._inline&&(this._inline=e,this._input!==this._inline&&this._parseInput())}get inline(){return this._inline}_parseInput(){let e=!0;if(void 0!==this._inline&&"unset"!==this._inline?this._input=this._inline:void 0!==this._computed?(this._computed===this._input&&(e=!1),this._input=this._computed):e="inherit"===this._input,e){if(this._auto=!this._input||"auto"===this._input,this._auto)this._relative=!1;else if(("string"==typeof this._input||this._input instanceof String)&&this._input.endsWith("%")){this._relative=!0,this._value=0;const e=parseFloat(this._input.replace("%","").trim());isNaN(e)||(this._value=e/100)}else this._relative=!1,this._value=this._input;this._needsUpdate=this._updateRequired=e}}update(e,t){if(this._updateRequired){this._updateRequired=!1,this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(const t of e._children._uis)t[`_${this._id}`]._needsUpdate=!0;this.output(t),e._parent._value&&(e._parent._value._layouter._needsProcess=!0)}}computeOutputValue(e){e._bounds._needsUpdate=!0,e._renderer._needsRender=!0}getInheritedInput(e){if("inherit"!==this._input&&!this._auto)return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return 0}get value(){return this._value}}class Ve extends Se{constructor(){super("width")}}class ke extends Se{constructor(){super("height")}computeOutputValue(e){super.computeOutputValue(e)}}class Re extends re{constructor(){super("textContent"),this._needsUpdate=!1}set value(e){}process(e){let t="";for(let i=0;i<e.children.length;i++){const n=e.children[i];n.isUI&&(t+=n.textContent)}this._value=t}}class Ue extends u{constructor(e){super("fontStyle",e,!0),this.isValidValue=Me}}const Ce=["normal","italic"];function Me(e){return-1!==Ce.indexOf(e)||(console.warn(`(.style) fontStyle value '${e}' is not valid. Aborted`),!1)}class Ie extends u{constructor(){super("fontWeight","inherit",!0),this.isValid=Pe}}const Be=["100","200","300","400","500","600","700","800","900","light","normal","bold","bolder"];function Pe(e){return-1!==Be.indexOf(e.toString())||(console.warn(`(.style) fontWeight value '${e}' is not valid. Aborted`),!1)}class Te{constructor(){this._size=42,this._lineHeight=42,this._lineBase=38,this._name="-",this._charset=""}get size(){return this._size}get lineHeight(){return this._lineHeight}get lineBase(){return this._lineBase}get name(){return this._name}get charset(){return this._charset}}class Fe extends Te{constructor(e){super(),this._size=e.info.size,this._lineHeight=e.common.lineHeight,this._lineBase=e.common.base,this._name=e.info.face,this._textureWidth=e.common.scaleW,this._textureHeight=e.common.scaleH,this._charset=e.chars.map((e=>e.char)).join("")}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}}class ze extends k{constructor(e){super(e)}get uv(){return this.typographic.uv}}class Oe extends V{constructor(e,t){super(e),this._char=t.char,this._width=t.width,this._heigth=t.height,this._xadvance=t.xadvance?t.xadvance:this._width,this._xoffset=t.xoffset?t.xoffset:0,this._yoffset=t.yoffset?t.yoffset:0,this._uv=t.uv?t.uv:null,isNaN(t.x)||(this._uv={left:t.x/e.textureWidth,right:(t.x+t.width)/e.textureWidth,top:1-(t.y+t.height)/e.textureHeight,bottom:1-t.y/e.textureHeight})}get uv(){return this._uv}clone(e){return new Oe(this._font,{char:e,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new ze(this)}}class Ae extends l.PlaneGeometry{constructor(e,t){let i=1,n=1;const s=e.typographic.font.size,r=t._segments.value;i=Math.ceil(e.typographic.width/s*r),n=Math.ceil(e.typographic.height/s*r),super(e.width,e.height,i,n),e.uv?(this._mapUVs(e),this._transformGeometry(e)):(this._nullifyUVs(),this.scale(0,0,1),this.translate(0,e.fontSize/2,0)),this.name="GlyphGeometry"}_mapUVs(e){const t=e.uv.right-e.uv.left,i=e.uv.bottom-e.uv.top,n=this.getAttribute("uv").array.slice(),s=[];for(let r=0;r<n.length;r+=2){const o=n[r],a=n[r+1];s.push(e.uv.left+t*o),s.push(e.uv.top+i*a)}this.setAttribute("uvG",new l.BufferAttribute(new Float32Array(s),2))}_nullifyUVs(){const e=[],t=this.getAttribute("uv").array.length;for(let i=0;i<t;i++)e.push(0);this.setAttribute("uvG",new l.BufferAttribute(new Float32Array(e),2))}_transformGeometry(e){this.translate(e.width/2,-e.height/2,0)}}const We="\nattribute vec2 uvG;\nvarying vec2 vUvG;\n",De="\nvUvG = uvG;\n",Ee="\ngl_Position.z -= 0.00001;\n",Le="\nvarying vec2 vUvG;\nuniform sampler2D glyphMap;\nuniform vec2 unitRange;\n// functions from the original msdf repo:\n// https://github.com/Chlumsky/msdfgen#using-a-multi-channel-distance-field\nfloat median(float r, float g, float b) {\n\treturn max(min(r, g), min(max(r, g), b));\n}\nfloat screenPxRange() {\n\n\t// precomputed unitRange as recommended by Chlumsky\n\t// vec2 unitRange = vec2(pxRange)/vec2(textureSize(glyphMap, 0));\n\tvec2 screenTexSize = vec2(1.0)/fwidth(vUvG);\n\treturn max(0.5*dot(unitRange, screenTexSize), 1.0);\n}\nfloat tap(vec2 offsetUV) {\n\tvec3 msd = texture( glyphMap, offsetUV ).rgb;\n\tfloat sd = median(msd.r, msd.g, msd.b);\n\tfloat screenPxDistance = screenPxRange() * (sd - 0.5);\n\tfloat alpha = clamp(screenPxDistance + 0.5, 0.0, 1.0);\n\treturn alpha;\n}\n",He="\n\tfloat alpha;\n#ifdef NO_RGSS\n\n\talpha = tap( vUvG );\n\n#else\n\n\t// shader-based supersampling based on https://bgolus.medium.com/sharper-mipmapping-using-shader-based-supersampling-ed7aadb47bec\n\t// per pixel partial derivatives\n\tvec2 dx = dFdx(vUvG);\n\tvec2 dy = dFdy(vUvG);\n\t// rotated grid uv offsets\n\tvec2 uvOffsets = vec2(0.125, 0.375);\n\tvec2 offsetUV = vec2(0.0, 0.0);\n\t// supersampled using 2x2 rotated grid\n\talpha = 0.0;\n\toffsetUV.xy = vUvG + uvOffsets.x * dx + uvOffsets.y * dy;\n\talpha += tap(offsetUV);\n\toffsetUV.xy = vUvG - uvOffsets.x * dx - uvOffsets.y * dy;\n\talpha += tap(offsetUV);\n\toffsetUV.xy = vUvG + uvOffsets.y * dx - uvOffsets.x * dy;\n\talpha += tap(offsetUV);\n\toffsetUV.xy = vUvG - uvOffsets.y * dx + uvOffsets.x * dy;\n\talpha += tap(offsetUV);\n\talpha *= 0.25;\n\n#endif\n\n\talpha = clamp( alpha, 0.0, 1.0 );\n\n#ifdef INVERT_ALPHA\n\n\talpha = 1.0 - alpha;\n\n#endif\n\n\tdiffuseColor.a *= alpha;\n",Ge=function(e,t,i){e.alphaTest=i,$e(e,"USE_ALPHATEST",i>0)},$e=function(e,t,i){e.defines&&(i?void 0===e.defines[t]&&(e.defines[t]="",e.needsUpdate=!0):void 0!==e.defines[t]&&(delete e.defines[t],e.needsUpdate=!0))},je=function(e,t,i){e.userData[t]?e.userData[t].value=i:e.uniforms[t].value=i};class Xe{static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||(e.defines={})}static ensureUserData(e,t){e.userData.glyphMap={value:t.glyphMap},e.userData.unitRange={value:new l.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(e){Xe.injectVertexShaderChunks(e),Xe.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>","#include <uv_pars_vertex>\n"+We),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>","#include <uv_vertex>\n"+De),e.vertexShader=e.vertexShader.replace("#include <project_vertex>","#include <project_vertex>\n"+Ee)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <uv_pars_fragment>","#include <uv_pars_fragment>\n"+Le),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>","#include <alphamap_fragment>\n"+He)}static from(e){return class extends e{static get fontMaterialProperties(){return Xe.mediation}constructor(e={}){Xe.ensureMaterialOptions(e),super(e),Xe.ensureDefines(this),Xe.ensureUserData(this,e),this._userDefinedOnBeforeCompile=e=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(e){this._userDefinedOnBeforeCompile=e}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=e=>{Xe.bindUniformsWithUserData(e,this),Xe.injectShaderChunks(e),this._userDefinedOnBeforeCompile(e)}}}static get mediation(){return Ne}}const Ne={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:Ge},fontSide:{m:"side"},font:{m:"glyphMap",t:function(e,t,i){const n=i?i.texture:null,s=i?i.unitRange:new l.Vector2;if(void 0!==e[t])return e.glyphMap=n,void(e.unitRange=s);e.userData&&e.userData.glyphMap&&(e.userData.glyphMap.value=n,e.userData.unitRange.value=s)}},color:{m:"color"},fontOpacity:{m:"opacity"},fontSmooth:{m:"NO_RGSS",t:function(e,t,i){i&&"antialiased"!==i?e.defines.NO_RGSS="":delete e.defines.NO_RGSS,e.needsUpdate=!0}},invertAlpha:{m:"INVERT_ALPHA",t:$e}},Ye=`\n${We}\n#include <clipping_planes_pars_vertex>\nvoid main() {\n\t${De}\n\t#include <begin_vertex>\n\t#include <project_vertex>\n\t${Ee}\n\t#include <clipping_planes_vertex>\n}\n`,Ke=`\nuniform vec3 diffuse;\nuniform float opacity;\n${Le}\n#include <alphatest_pars_fragment>\n#include <clipping_planes_pars_fragment>\nvoid main() {\n\t// instead of <color_fragment> : vec4 diffuseColor\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\t${He}\n\t#include <alphatest_fragment>\n\t// instead of <output_fragment>\n\tgl_FragColor = diffuseColor;\n\t#include <clipping_planes_fragment>\n}\n`;class qe extends l.ShaderMaterial{static get mediation(){return Xe.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new l.Vector2(0,0)},alphaTest:{value:.02}},transparent:!0,clipping:!0,vertexShader:Ye,fragmentShader:Ke,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST="",this.needsUpdate=!0,this.noRGSS=e.noRGSS||!1}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get opacity(){return this.uniforms.opacity.value}get unitRange(){return this.uniforms.unitRange.value}set unitRange(e){this.uniforms.unitRange.value.copy(e)}get glyphMap(){return this.uniforms.glyphMap.value}set glyphMap(e){this.uniforms.glyphMap.value=e}get isDefault(){return this.constructor===qe}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}}class Je extends I{constructor(e,t,i,n){var s,r;if(super(e,t),this._unitRange=new l.Vector2(1,1),i.pages?this._buildData(i):(s=this,r=i,(new l.FileLoader).setResponseType("json").load(r,(e=>{s._buildData(e),s._checkReadiness()}))),n instanceof l.Texture)this._texture=n,this._buildTexture(n);else{if(!("string"==typeof n||n instanceof String))throw new Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof n}'. Only Texture and String allowed.`);!function(e,t){e._texture=(new l.TextureLoader).load(t,(t=>{e._buildTexture(t),e._checkReadiness()}))}(this,n)}this._defaultMaterialClass=qe,this._checkReadiness()}get texture(){return this._texture}get unitRange(){return this._unitRange}set fontMaterial(e){this._defaultMaterialClass=e}get fontMaterial(){return this._defaultMaterialClass}_buildData(e){this._font=new Fe(e),this._kernings=this._buildKerningPairs(e),this._chars=this._buildCharacters(e),this._chars[" "]=this._buildCharacterWhite(e),this._chars["\n"]=this._buildCharacterWhite(e,"\n",.001,1),this._chars["\t"]=this._buildCharacterWhite(e,"\t",4,1),this._size=e.info.size,this._lineHeight=e.common.lineHeight,this._lineBase=e.common.base,this._distanceRange=e.distanceField.distanceRange,this._unitRange=new l.Vector2(this._distanceRange,this._distanceRange).divide(new l.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=l.LinearFilter,e.magFilter=l.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return it.missingCharacter(this,e)}getGeometricGlyph(e,t){return new Ae(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){const t={};for(let i=0;i<e.kernings.length;i++){const n=e.kernings[i];if(0===n.amount)continue;t[String.fromCharCode(n.first,n.second)]=n.amount}return t}_buildCharacters(e){const t={};for(let i=0;i<e.chars.length;i++){const n=e.chars[i];t[n.char]=new Oe(this._font,n)}return t}_buildCharacterWhite(e,t=" ",i=1,n=1){return new Oe(this._font,{char:t,width:e.info.size/3*i,height:.7*e.info.size*n})}_alterElementProperties(e){}}class Qe extends l.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,i,n,s=!1){if(s||!this.getVariant(e,t)){this._isReady=!1;const s=new Je(e,t,i,n);this._variants.push(s),s.isReady?this._checkReadiness():s.addEventListener("ready",this._checkReadiness)}else console.warn(`FontFamily('${this._name}')::addVariant() - Variant(${e}, ${t}) already exists.`);return this}addCustomImplementationVariant(e,t=!1){return t||!this.getVariant(e.weight,e.style)?(this._isReady=!1,this._variants.push(e),e.isReady?this._checkReadiness():e.addEventListener("ready",this._checkReadiness)):console.warn(`FontFamily('${this._name}')::addCustomImplementationVariant() - Variant(${e.weight}, ${e.style}) already exists.`),this}getVariant(e,t){return e=U(e),this._variants.find((i=>i.weight===e&&i.style===t))}get name(){return this._name}_checkReadiness=()=>{var e;this._variants.every((e=>e.isReady))&&((e=this)._isReady=!0,e.dispatchEvent(Ze))}}const Ze={type:"ready"};const et={};let tt=function(e,t){return console.error(`The character '${t}' is not included in the font characters set.`)," "};const it={addFontFamily:function(e){return et[e]&&console.error(`FontLibrary::addFontFamily - Font('${e}') is already registered`),et[e]=new Qe(e),et[e]},getFontFamily:function(e){return et[e]},prepare:function(e){const t=[...arguments];t.forEach((e=>{if(!(e instanceof Qe))throw new Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof e} given.`)}));const i=function(){return t.every((e=>e.isReady))};return new Promise(((e,n)=>{if(i())e();else for(let n=0;n<t.length;n++){const s=t[n];s.isReady||s.addEventListener("ready",(()=>{i()&&e()}))}}))},setMissingCharacterHandler:function(e){tt=e},missingCharacter:function(e,t){return tt(e,t)}};class nt extends u{constructor(){super("fontFamily","inherit",!0)}computeOutputValue(e){if(this._input instanceof Qe)this._value=this._input;else if("inherit"===this._input);else if("string"==typeof this._input){const e=it.getFontFamily(this._input);e?this._value=e:console.warn(`(.style) fontFamily, the font '${this._input}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}getInheritedInput(e){if("inherit"!==this._input)return this._input;const t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}}class st extends u{constructor(){super("lineHeight","inherit",!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}}class rt extends u{constructor(){super("whiteSpace","inherit"),this.isValidValue=at}}const ot=["normal","nowrap","pre","pre-line","pre-wrap"];function at(e){return-1!==ot.indexOf(e)||(console.warn(`(.style) whiteSpace value '${e}' is not valid. Aborted`),!1)}class ht extends u{constructor(){super("letterSpacing","inherit",!0)}}class lt extends u{constructor(){super("fontSize","inherit",!0)}}class ut extends i{constructor(){super("segments",1,!1)}}class dt extends s{constructor(){super("invertAlpha","inherit")}}class ct extends u{constructor(){super("fontKerning","inherit"),this.isValidValue=ft}}const _t=["normal","none","inherit"];function ft(e){return-1!==_t.indexOf(e)||(console.warn(`(.style) fontKerning value '${e}' is not valid. Aborted`),!1)}class pt extends s{constructor(e){super(e,"inherit",!0)}}class gt extends s{constructor(e){super(e,"inherit",!1),this._mediation={},this._defaultMaterial=null}update(e,t){this._notInheritedValue=this._value,"inherit"===this._notInheritedValue?this._notInheritedValue=this.getInheritedInput(e):this.propagate(e),this._notInheritedValue?this._notInheritedValue.constructor.mediation?this._mediation={...this._notInheritedValue.constructor.mediation}:this._mediation={clippingPlanes:{m:"clippingPlanes"},fontAlphaTest:{m:"alphaTest",t:Ge},fontSide:{m:"side"},color:{m:"color"},fontOpacity:{m:"opacity"}}:this._mediation={},e._transferToFontMaterial(),this._outputValue(t)}getInheritedInput(e){if("inherit"!==this._value)return this._value;let t=e,i=null;for(;t._parent._value;)if(t=t._parent._value,"inherit"!==t[`_${this._id}`]._value){i=t[`_${this._id}`]._value;break}return null!==i?i:this.getDefaultValue()}getDefaultValue(){return this._defaultMaterial}}const mt=function(e,t,i){e.traverse((e=>{e.renderOrder=i}))};class vt extends l.Object3D{constructor(e,t){super(),Object.defineProperties(this,{isUI:{configurable:!1,enumerable:!0,value:!0}}),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundCustomDepthMaterial=null,this._backgroundMaterialMediation={},this._backgroundMeshMediation={backgroundCastShadow:{m:"castShadow"},backgroundReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder",t:mt}},this._fontMesh=null,this._fontMaterial=new gt("fontMaterial"),this._fontCustomDepthMaterial=new gt("fontCustomDepthMaterial"),this._fontMeshMediation={fontMaterial:{m:"material"},fontCustomDepthMaterial:{m:"customDepthMaterial",t:p},fontCastShadow:{m:"castShadow"},fontReceiveShadow:{m:"receiveShadow"},renderOrder:{m:"renderOrder"}},this._children=e.children?new e.children:new re("children"),this._parent=new m,this.addEventListener("added",this._rebuildParentUI),this.addEventListener("removed",this._rebuildParentUI),this._backgroundSide=new y("backgroundSide"),this._fontSide=new y("fontSide"),this._backgroundAlphaTest=new b("backgroundAlphaTest",.02),this._fontAlphaTest=new b("fontAlphaTest",.02),this._visible=new ne("visible",!0),this._backgroundCastShadow=new pt("backgroundCastShadow"),this._fontCastShadow=new pt("fontCastShadow"),this._backgroundReceiveShadow=new pt("backgroundReceiveShadow"),this._fontReceiveShadow=new pt("fontReceiveShadow"),this._renderOrder=new n,this._segments=e.segments?new e.segments:new ut,this._bounds=e.bounds?new e.bounds:new re("bounds"),this._order=new be,this._padding=new c,this._margin=new _,this._position=new ye,this._flexDirection=e.flexDirection?new e.flexDirection:new _e,this._justifyContent=e.justifyContent?new e.justifyContent:new ge,this._alignItems=e.alignItems?new e.alignItems:new le,this._display=new T("flex"),this._boxSizing=new O("border-box"),this._width=new Ve,this._height=new ke,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new se,this._backgroundOpacity=new E("backgroundOpacity",.5),this._backgroundImage=new H,this._backgroundSize=new $("cover"),this._color=e.color?new e.color:new D("color","inherit"),this._fontOpacity=new E("fontOpacity","inherit"),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new rt,this._fontFamily=e.fontFamily?new e.fontFamily:new nt,this._fontStyle=e.fontStyle?new e.fontStyle:new Ue("normal"),this._fontWeight=e.fontWeight?new e.fontWeight:new Ie,this._fontSize=e.fontSize?new e.fontSize:new lt,this._lineHeight=e.lineHeight?new e.lineHeight:new st,this._fontKerning=e.fontKerning?new e.fontKerning:new ct,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new ht,this._overflow=new N("visible"),this._borderRadius=new ee(0),this._borderWidth=new ie(0),this._borderColor=new D("borderColor",16711935),this._borderOpacity=new E("borderOpacity",1),this._font=new B,this._lineBreak=e.lineBreak?new e.lineBreak:new re("lineBreak"),this._textContent=e.textContent?new e.textContent:new Re,this._glyphs=e.glyphs?new e.glyphs:new re("glyphs"),this._inlines=e.inlines?new e.inlines:new re("inlines"),this._layouter=e.layouter?new e.layouter:new re("layouter"),this._inlineJustificator=new oe,this._textAlign=e.textAlign?new e.textAlign:new ue,this._autoSize=e.autoSize?new e.autoSize:new re("autoSize"),this._renderer=e.renderer?new e.renderer:new re("renderer"),this._offset=new r,this._invertAlpha=new dt,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new o,this._components=[this._textContent,this._children,this._parent,this._autoSize,this._fontFamily,this._fontStyle,this._fontWeight,this._font,this._whiteSpace,this._glyphs,this._inlines,this._visible,this._backgroundSide,this._fontSide,this._backgroundAlphaTest,this._fontAlphaTest,this._backgroundCastShadow,this._fontCastShadow,this._backgroundReceiveShadow,this._fontReceiveShadow,this._renderOrder,this._segments,this._padding,this._margin,this._width,this._height,this._borderWidth,this._boxSizing,this._bounds,this._position,this._flexDirection,this._justifyContent,this._alignItems,this._order,this._display,this._backgroundColor,this._backgroundOpacity,this._backgroundImage,this._backgroundSize,this._fontOpacity,this._color,this._fontSize,this._lineHeight,this._fontKerning,this._letterSpacing,this._borderRadius,this._borderColor,this._borderOpacity,this._lineBreak,this._offset,this._layouter,this._inlineJustificator,this._textAlign,this._invertAlpha,this._fontSmooth,this._fontMaterial,this._fontCustomDepthMaterial,this._overflow,this._renderer],this._onAfterUpdates=[],t.backgroundSide||(t.backgroundSide=0),t&&this.set(t)}update(){const e={};for(const t of this._components)t._needsUpdate&&(t.update(this,e),t._needsUpdate=!1);this._transferToBackgroundMesh(e),this._transferToFontMesh(e),this._transferToBackgroundMaterial(e),this._transferToFontMaterial(e);for(const e of this._children._uis)e.update()}process(){for(const e of this._children._uis)e.process();for(const e of this._components)e._needsProcess&&(e.process(this),e._needsProcess=!1)}render(){for(let e=0;e<this._components.length;e++){const t=this._components[e];t._needsRender&&(t.render(this),t._needsRender=!1)}for(const e of this._children._uis)e.render()}set(e){if(e.fontTexture&&(console.warn("ThreeMeshUI::set( {fontTexture} ) is deprecated. Please use fontLibrary to register font families and variants."),e.fontFamily)){const t=e.fontFamily.pages?e.fontFamily.info.face:e.fontFamily;let i=it.getFontFamily(t);if(!i){const n=e.fontStyle?e.fontStyle:"normal",s=e.fontWeight?e.fontWeight:"400";i=it.addFontFamily(t).addVariant(s,n,e.fontFamily,e.fontTexture)}e.fontFamily=i,delete e.fontTexture}for(let t of Object.keys(e)){const i=e[t];switch(t){case"contentDirection":console.warn("ThreeMeshUI v7xx: property `contentDirection` is deprecated and has been renamed as `flexDirection`"),t="flexDirection";break;case"interLine":console.warn("ThreeMeshUI v7xx: property `interLine` is deprecated and has been renamed as `lineHeight`"),t="lineHeight";break;case"content":console.warn("ThreeMeshUI v7xx: property `content` is deprecated and has been renamed as `textContent`"),t="textContent";break;case"fontColor":console.warn("ThreeMeshUI v7xx: property `fontColor` is deprecated and has been renamed as `color`"),t="color";break;case"hiddenOverflow":console.warn("ThreeMeshUI v7xx: property `hiddenOverflow` is deprecated and has been renamed as `overflow`"),t="overflow";break;case"backgroundTexture":console.warn("ThreeMeshUI v7xx: property `backgroundTexture` is deprecated and has been renamed as `backgroundImage`"),t="backgroundImage";break;case"alignContent":console.warn("ThreeMeshUI v7xx: property `alignContent` is deprecated and has been renamed as `alignItems`"),t="alignItems";break;case"borderTopColor":case"borderBottomColor":case"borderLeftColor":case"borderRightColor":t="borderColor"}switch(t){case"fontSmooth":case"renderOrder":case"segments":case"visible":case"offset":case"fontSide":case"backgroundSide":case"fontCastShadow":case"backgroundCastShadow":case"fontReceiveShadow":case"backgroundReceiveShadow":case"fontMaterial":case"fontCustomDepthMaterial":this[`_${t}`].value=i;break;case"flexDirection":case"justifyContent":case"alignItems":case"color":case"fontFamily":case"fontOpacity":case"fontKerning":case"fontSize":case"fontStyle":case"fontWeight":case"textAlign":case"letterSpacing":case"lineHeight":case"whiteSpace":case"breakOn":case"width":case"height":case"padding":case"margin":case"backgroundColor":case"backgroundOpacity":case"backgroundImage":case"backgroundSize":case"borderColor":case"borderOpacity":case"borderRadius":case"borderWidth":case"overflow":case"order":case"boxSizing":this[`_${t}`]&&(this[`_${t}`].inline=i);break;case"paddingTop":this._padding.top=i;break;case"paddingRight":this._padding.right=i;break;case"paddingBottom":this._padding.bottom=i;break;case"paddingLeft":this._padding.left=i;break;case"marginTop":this._margin.top=i;break;case"marginRight":this._margin.right=i;break;case"marginBottom":this._margin.bottom=i;break;case"marginLeft":this._margin.left=i;break;case"borderTopWidth":this._borderWidth.top=i;break;case"borderRightWidth":this._borderWidth.right=i;break;case"borderBottomWidth":this._borderWidth.bottom=i;break;case"borderLeftWidth":this._borderWidth.left=i;break;case"borderTopLeftRadius":this._borderRadius.topLeft=i;break;case"borderTopRightRadius":this._borderRadius.topRight=i;break;case"borderBottomRightRadius":this._borderRadius.bottomRight=i;break;case"borderBottomLeftRadius":this._borderRadius.bottomLeft=i;break;case"side":case"castShadow":case"receiveShadow":const e=t.charAt(0).toUpperCase()+t.substr(1);this[`_background${e}`].value=i,this[`_font${e}`].value=i;break;default:void 0!==this[`_${t}`]?this[`_${t}`].value=i:this[t]=i}}}get(e){switch(e){case"overflow":case"width":case"height":return this[`_${e}`].inline}}_rebuildChildrenLists(){this._children._needsUpdate=!0}_rebuildParentUI=()=>{this._parent._needsUpdate=!0,this.parent&&!this.parent.isUI?(bt.register(this),this.activatePseudoState("root")):(bt.remove(this),this.deactivatePseudoState("root"))};add(e){let t=!1;for(let e=0;e<arguments.length;e++)super.add(arguments[e]),arguments[e].isUI&&(t=!0);return t&&this._rebuildChildrenLists(),this}remove(e){for(const e of Object.keys(arguments))arguments[e].isInline&&this.update(null,!0);return super.remove(...arguments),this._rebuildChildrenLists(),this}clear(){return this.removeFromParent(),this.traverse((e=>{e.material&&e.material.dispose(),e.geometry&&e.geometry.dispose()})),super.clear(),this._backgroundMesh=null,this._backgroundMaterial=null,this._backgroundMaterialMediation=null,this._backgroundMeshMediation=null,this._children.dispose(),this._children=null,this._parent.dispose(),this._parent=null,this._backgroundSide=null,this._backgroundAlphaTest=null,this._visible=null,this._backgroundCastShadow=null,this._backgroundReceiveShadow=null,this._renderOrder=null,this._segments=null,this._bounds=null,this._boxSizing=null,this._padding=null,this._margin=null,this._position=null,this._flexDirection=null,this._justifyContent=null,this._alignItems=null,this._display=null,this._backgroundColor=null,this._backgroundOpacity=null,this._backgroundSize=null,this._fontOpacity=null,this._color=null,this._whiteSpace=null,this._fontFamily=null,this._fontStyle=null,this._fontWeight=null,this._lineHeight=null,this._fontKerning=null,this._letterSpacing=null,this._overflow=null,this._textAlign=null,this._font=null,this._lineBreak=null,this._layouter=null,this}get textContent(){return this._textContent.process(this),this._textContent._value}get backgroundMaterial(){return this._backgroundMaterial}set backgroundMaterial(e){this._backgroundMaterial=e,this._backgroundMaterialMediation={...e.constructor.mediation},this._transferToBackgroundMaterial(),this._backgroundMesh&&(this._backgroundMesh.material=this._backgroundMaterial,je(e,"frameSize",this._backgroundMesh.scale))}set backgroundCustomDepthMaterial(e){this._backgroundCustomDepthMaterial=e,this._transferToBackgroundMaterial(),this._backgroundMesh&&(this._backgroundMesh.customDepthMaterial=this._backgroundCustomDepthMaterial)}get backgroundCustomDepthMaterial(){return this._backgroundCustomDepthMaterial}_transferToBackgroundMaterial(e=null){if(!e){e={};for(const t of this._components)t.output(e)}g.mediate(this,this._backgroundMaterial,e,this._backgroundMaterialMediation,this._backgroundCustomDepthMaterial)}set backgroundSide(e){this._backgroundSide.value=e,this._backgroundMaterial&&(this._backgroundMaterial.side=e)}get backgroundSide(){return this._backgroundSide.value}set backgroundAlphaTest(e){this._backgroundAlphaTest.value=e,this._backgroundMaterial&&(this._backgroundMaterial.alphaTest=e)}get backgroundAlphaTest(){return this._backgroundAlphaTest.value}get fontMaterial(){return this._fontMaterial.value}set fontMaterial(e){this._fontMaterial.value=e}set fontCustomDepthMaterial(e){this._fontCustomDepthMaterial.value=e}get fontCustomDepthMaterial(){return this._fontCustomDepthMaterial.value}_transferToFontMaterial(e=null){const t=this._fontMaterial.value;if(t){if(!e){e={};for(const t of this._components)t.output(e)}g.mediate(this,t,e,this._fontMaterial._mediation,this._fontCustomDepthMaterial.value)}}set fontSide(e){this._fontSide.value=e}get fontSide(){return this._fontSide.value}set fontAlphaTest(e){this._fontAlphaTest.value=e}get fontAlphaTest(){return this._fontAlphaTest.value}_transferToBackgroundMesh(e=null){if(!e){e={};for(const t of this._components)t.output(e)}g.mediate(this,this._backgroundMesh,e,this._backgroundMeshMediation)}setBackgroundMesh(e){this._backgroundMesh&&(this.remove(this._backgroundMesh),this.unbindBackgroundMeshProperties()),this._backgroundMesh=e,this._backgroundMesh&&(this.bindBackgroundMeshProperties(),this._backgroundCustomDepthMaterial&&(this._backgroundMesh.customDepthMaterial=this._backgroundCustomDepthMaterial),this._backgroundMaterial&&je(this._backgroundMaterial,"frameSize",this._backgroundMesh.scale),this._transferToBackgroundMesh(),this.add(this._backgroundMesh))}bindBackgroundMeshProperties(){}unbindBackgroundMeshProperties(){}activatePseudoState(e){}deactivatePseudoState(e){}togglePseudoState(e){}hasPseudoState(e){return!1}set borderRadiusMediation(e){this._borderRadius.mediation=e}set backgroundCastShadow(e){this._backgroundCastShadow&&(this._backgroundCastShadow.value=e)}get backgroundCastShadow(){return this._backgroundCastShadow}set backgroundReceiveShadow(e){this._backgroundReceiveShadow&&(this._backgroundReceiveShadow.value=e)}get backgroundReceiveShadow(){return this._backgroundReceiveShadow}set renderOrder(e){this._renderOrder&&(this._renderOrder.value=e)}get renderOrder(){return this._renderOrder.value}_transferToFontMesh(e=null){if(this._fontMesh){if(!e){e={};for(const t of this._components)t.output(e)}g.mediate(this,this._fontMesh,e,this._fontMeshMediation)}}setFontMesh(e){this._fontMesh&&(this.remove(this._fontMesh),this._fontMesh.material&&this._fontMesh.material.dispose(),this._fontMesh.geometry&&this._fontMesh.geometry.dispose(),this._fontMesh=null,this.unbindFontMeshProperties()),this._fontMesh=e,this._fontMesh&&(this._fontMesh.raycast=()=>{},this.bindFontMeshProperties(),this._transferToFontMaterial(),this._transferToFontMesh(),this.add(this._fontMesh))}bindFontMeshProperties(){}unbindFontMeshProperties(){}set fontCastShadow(e){this._fontCastShadow&&(this._fontCastShadow.value=e)}get fontCastShadow(){return this._fontCastShadow}set fontReceiveShadow(e){this._fontReceiveShadow&&(this._fontReceiveShadow.value=e)}get fontReceiveShadow(){return this._fontReceiveShadow}set segments(e){this._segments.value=e}get segments(){return this._segments.value}set onAfterUpdate(e){console.warn("ThreeMeshUI v7xx : `onAfterUpdate()` property has been deprecated, please rely on `addAfterUpdate` instead."),this.addAfterUpdate(e)}addAfterUpdate(e){this._onAfterUpdates.push(e)}removeAfterUpdate(e){const t=this._onAfterUpdates.indexOf(e);-1!==t&&this._onAfterUpdates.splice(t,1)}performAfterUpdate(){for(let e=0;e<this._onAfterUpdates.length;e++)this._onAfterUpdates[e]()}getProperty(e){return this[`_${e}`]?this[`_${e}`]:null}appendProperty(e,t){this[`_${e}`]=t,this._components.push(t)}replaceProperty(e,t){const i=this[`_${e}`],n=this._components.indexOf(i);return this._components[n]=this[`_${e}`]=t,t.needsUpdate=!0,i}}class bt{static register(e){this.elements.includes(e)||this.elements.push(e)}static remove(e){const t=this.elements.indexOf(e);-1!==t&&this.elements.splice(t,1)}static update(){for(const e of this.elements)e.update(),e.process(),e.process(),e.render()}}bt.elements=[];const yt="\n\n// FrameBorder vertex pars\nattribute vec2 uvB;\nvarying vec2 vUvB;\n\n",xt="\n\n\t// FrameBorder vertex shader\n\tvUvB = uvB;\n\n",wt="\n\n// borders sequences are : x:TOP, y:RIGHT, z:BOTTOM, w:LEFT\nuniform vec4 borderWidth;\nuniform vec3 borderColor;\nuniform float borderOpacity;\nuniform vec4 borderRadius;\n\nuniform vec2 cornerTL;\nuniform vec2 cornerTR;\nuniform vec2 cornerBR;\nuniform vec2 cornerBL;\n\nvarying vec2 vUvB;\n\nfloat getEllipticFactor( vec2 uv, vec2 center, float radiusX, float radiusY )\n{\n\n\t\tfloat edx = uv.x - center.x;\n\t\tfloat edy = uv.y - center.y;\n\n\t\tfloat ddx = (edx * edx) / (radiusX * radiusX);\n\t\tfloat ddy = (edy * edy) / (radiusY * radiusY);\n\n\t\treturn ddx + ddy;\n\n}\n\n",St="\n\nvec4 borderColor = vec4( borderColor, borderOpacity );\n\n// This could be tweak to produce more smoothing\nfloat mult = 1.0;\n\n// Step 1 ----------------------------------------------\n// Draw the four borders ( top - right - bottom - left )\n// Without worrying about radiuses ( Straight boorders )\n\n// Top\nfloat topBorderUVy = 1.0 - borderWidth.x;\nif( borderWidth.x > 0.0 && vUvB.y > topBorderUVy )\n{\n\n\tfloat w = fwidth( 1.0 - vUvB.y ) * mult;\n\tfloat step = smoothstep( topBorderUVy , topBorderUVy + w , vUvB.y );\n\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n}\n\n// Left\nfloat leftBorderUVx = borderWidth.w;\nif( borderWidth.w > 0.0 && vUvB.x < leftBorderUVx )\n{\n\n\tfloat w = fwidth( vUvB.x ) * mult ;\n\tfloat step = smoothstep( leftBorderUVx , leftBorderUVx - w , vUvB.x );\n\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n}\n\n// Bottom\nfloat bottomBorderUVy = borderWidth.z;\nif( borderWidth.z > 0.0 && vUvB.y < bottomBorderUVy )\n{\n\tfloat w = fwidth( vUvB.y ) * mult;\n\tfloat step = smoothstep( bottomBorderUVy , bottomBorderUVy - w , vUvB.y );\n\tdiffuseColor = mix( diffuseColor, borderColor, step );\n}\n\n// Right\nfloat rightBorderUVx = 1.0 - borderWidth.y;\nif( borderWidth.y > 0.0 && vUvB.x > rightBorderUVx )\n{\n\tfloat w = fwidth( 1.0 - vUvB.x ) * mult;\n\tfloat step = smoothstep( rightBorderUVx , rightBorderUVx + w , vUvB.x );\n\tdiffuseColor = mix( diffuseColor, borderColor, step );\n}\n\n\n// Step 2 ----------------------------------------------\n// Process each corners ( topLeft, topRight, bottomRight, bottomLeft )\n// To transparentize outside radiuses\n// To draw ellipse border on the corner\n\n\n// Top Left corner\nif( vUvB.x < cornerTL.x && vUvB.y > cornerTL.y ) {\n\n\t\t// Only draw border if width is set\n\t\tif( borderWidth.w + borderWidth.x > 0.0 ){\n\n\t\t\tfloat borderFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x - borderWidth.w, ( 1.0 - cornerTL.y ) - borderWidth.x );\n\t\t\tfloat step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );\n\t\t\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n\t\t}\n\n\t\t// Then then radius\n\t\tfloat radiusFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x, 1.0 - cornerTL.y );\n\t\tfloat alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );\n\t\tdiffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );\n\n}\n// Bottom Left\nif( vUvB.x < cornerBL.x && vUvB.y < cornerBL.y ) {\n\n\t\tif( borderWidth.w + borderWidth.z > 0.0 ){\n\n\t\t\tfloat borderFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x - borderWidth.w, cornerBL.y - borderWidth.z );\n\t\t\tfloat step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );\n\t\t\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n\t\t}\n\n\n\t\tfloat radiusFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x, cornerBL.y );\n\t\tfloat alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );\n\t\tdiffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );\n\n}\n// Top Right\nif( vUvB.x > cornerTR.x && vUvB.y > cornerTR.y ) {\n\n\t\tif( borderWidth.y + borderWidth.x > 0.0 ){\n\n\t\t\tfloat borderFactor = getEllipticFactor( vUvB, cornerTR, ( 1.0 - cornerTR.x ) - borderWidth.y, ( 1.0 - cornerTR.y ) - borderWidth.x );\n\t\t\tfloat step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );\n\t\t\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n\t\t}\n\n\t\tfloat radiusFactor = getEllipticFactor( vUvB, cornerTR, 1.0 - cornerTR.x, 1.0 - cornerTR.y );\n\t\tfloat alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );\n\t\tdiffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );\n\n}\n// Bottom Right\nif( vUvB.x > cornerBR.x && vUvB.y < cornerBR.y ) {\n\n\t\tif( borderWidth.y + borderWidth.z > 0.0 ){\n\n\t\t\tfloat borderFactor = getEllipticFactor( vUvB, cornerBR, ( 1.0 - cornerBR.x ) - borderWidth.y, cornerBR.y - borderWidth.z );\n\t\t\tfloat step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor );\n\t\t\tdiffuseColor = mix( diffuseColor, borderColor, step );\n\n\t\t}\n\n\t\tfloat radiusFactor = getEllipticFactor( vUvB, cornerBR, 1.0 - cornerBR.x, cornerBR.y );\n\t\tfloat alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor );\n\t\tdiffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep );\n\n}\n\n",Vt="\n\n// To be removed - required for both border and background\nuniform vec3 frameSize;\nuniform vec2 textureSize;\n\n",kt="\n\n#ifdef USE_MAP\n\nvec4 sampleTexture() {\n\n\tvec2 uv = vUv;\n\n\t// default stretch\n\t#if BACKGROUND_MAPPING != 0\n\n\tfloat textureRatio = textureSize.x / textureSize.y;\n\tfloat panelRatio = frameSize.x / frameSize.y;\n\tfloat ratio = panelRatio / textureRatio;\n\tfloat ratio2 = textureRatio / panelRatio;\n\n\t\t// contain\n\t\t#if BACKGROUND_MAPPING == 1\n\t\tif ( textureRatio < panelRatio ) { // repeat on X\n\t\t\tfloat newX = uv.x * ratio;\n\t\t\tnewX += 0.5 - 0.5 * ratio;\n\t\t\tuv.x = newX;\n\t\t} else { // repeat on Y\n\t\t\tfloat newY = uv.y * ratio2;\n\t\t\tnewY += 0.5 - 0.5 * ratio2;\n\t\t\tuv.y = newY;\n\t\t}\n\t\t#else\n\t\t// cover\n\t\tif ( textureRatio < panelRatio ) { // stretch on Y\n\t\t\tfloat newY = uv.y * ratio2;\n\t\t\tnewY += 0.5 - 0.5 * ratio2;\n\t\t\tuv.y = newY;\n\t\t} else { // stretch on X\n\t\t\tfloat newX = uv.x * ratio;\n\t\t\tnewX += 0.5 - 0.5 * ratio;\n\t\t\tuv.x = newX;\n\t\t}\n\n\t\t#endif\n\n\t#endif\n\n\treturn texture2D( map, uv );\n\n}\n#endif\n",Rt="\n#ifdef USE_MAP\n\n\tvec4 textureSample = sampleTexture();\n\tdiffuseColor *= textureSample;\n\n#endif\n",Ut={msdfAlphaglyphParsVertexGlsl:We,msdfAlphaglyphVertexGlsl:De,msdfOffsetglyphVertexGlsl:Ee,msdfAlphaglyphParsFragmentGlsl:Le,msdfAlphaglyphFragmentGlsl:He,frameBorderParsVertexGlsl:yt,frameBorderVertexGlsl:xt,frameCommonParsFragmentGlsl:Vt,frameBorderParsFragmentGlsl:wt,frameBorderFragmentGlsl:St,frameBackgroundParsFragmentGlsl:kt,frameBackgroundFragmentGlsl:Rt},Ct=`\n// Would be automatic on three materials and from USE_UV\n#ifdef USE_MAP\nvarying vec2 vUv;\n#endif\n\n${yt}\n\n#include <clipping_planes_pars_vertex>\n\nvoid main() {\n\n\t#ifdef USE_MAP\n\tvUv = uv;\n\t#endif\n\n\t${xt}\n\n\tvec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );\n\tgl_Position = projectionMatrix * mvPosition;\n\n\t#include <clipping_planes_vertex>\n\n}\n`,Mt=`\n\n// Basic\nuniform vec3 diffuse;\nuniform float opacity;\n\n#ifdef USE_ALPHATEST\n\tuniform float alphaTest;\n#endif\n\n${Vt}\n\n${wt}\n\n\n#ifdef USE_MAP\nvarying vec2 vUv;\nuniform sampler2D map;\n#endif\n\n${kt}\n\n#include <clipping_planes_pars_fragment>\n\nvoid main() {\n\n\tvec4 diffuseColor = vec4( diffuse, opacity );\n\n\t// map\n\t${Rt}\n\n\t${St}\n\n\t#ifdef USE_ALPHATEST\n\n\tif ( diffuseColor.a < alphaTest ) discard;\n\n\t#endif\n\n\t// output\n\tgl_FragColor = diffuseColor;\n\n\n\t#include <clipping_planes_fragment>\n}\n`;class It{static get mediation(){return Bt}static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||(e.defines={})}static ensureUserData(e,t){e.userData.borderColor={value:null},e.userData.borderRadius={value:new l.Vector4(0,0,0,0)},e.userData.cornerTL={value:new l.Vector2(0,1)},e.userData.cornerTR={value:new l.Vector2(1,1)},e.userData.cornerBR={value:new l.Vector2(1,0)},e.userData.cornerBL={value:new l.Vector2(0,0)},e.userData.borderWidth={value:new l.Vector4(0,0,0,0)},e.userData.borderOpacity={value:null},e.userData.frameSize={value:new l.Vector3(1,1,1)},e.userData.textureSize={value:new l.Vector2(1,1)}}static bindUniformsWithUserData(e,t){e.uniforms.borderColor=t.userData.borderColor,e.uniforms.borderRadius=t.userData.borderRadius,e.uniforms.cornerTL=t.userData.cornerTL,e.uniforms.cornerTR=t.userData.cornerTR,e.uniforms.cornerBR=t.userData.cornerBR,e.uniforms.cornerBL=t.userData.cornerBL,e.uniforms.borderWidth=t.userData.borderWidth,e.uniforms.borderOpacity=t.userData.borderOpacity,e.uniforms.frameSize=t.userData.frameSize,e.uniforms.textureSize=t.userData.textureSize}static injectShaderChunks(e){It.injectVertexShaderChunks(e),It.injectFragmentShaderChunks(e)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace("#include <uv_pars_vertex>","#include <uv_pars_vertex>\n"+yt),e.vertexShader=e.vertexShader.replace("#include <uv_vertex>","#include <uv_vertex>\n"+xt)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>","#include <map_pars_fragment>\n"+kt),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>","#include <map_pars_fragment>\n"+wt),e.fragmentShader=e.fragmentShader.replace("#include <map_pars_fragment>","#include <map_pars_fragment>\n"+Vt),e.fragmentShader=e.fragmentShader.replace("#include <map_fragment>",Rt),e.fragmentShader=e.fragmentShader.replace("#include <alphamap_fragment>",St+"\n#include <alphamap_fragment>")}}const Bt={clippingPlanes:{m:"clippingPlanes"},backgroundAlphaTest:{m:"alphaTest",t:Ge},backgroundSide:{m:"side"},backgroundImage:{m:"map"},backgroundColor:{m:"color"},backgroundOpacity:{m:"opacity"},backgroundSize:{m:"computedBackgroundSize",t:function(e,t,i){!function(e,t,i){e.defines[t]&&e.defines[t]===i||(e.defines[t]=i,e.needsUpdate=!0)}(e,"BACKGROUND_MAPPING",i=["stretch","contain","cover"].indexOf(i))}},borderWidth:{m:"borderWidth",t:je},borderColor:{m:"borderColor",t:je},cornerTL:{m:"cornerTL",t:je},cornerTR:{m:"cornerTR",t:je},cornerBR:{m:"cornerBR",t:je},cornerBL:{m:"cornerBL",t:je},borderOpacity:{m:"borderOpacity",t:je},size:{m:"frameSize",t:je},tSize:{m:"textureSize",t:je}};class Pt extends l.ShaderMaterial{static get mediation(){return It.mediation}constructor(){super({uniforms:{alphaTest:{value:.02},map:{value:null},diffuse:{value:new l.Color(16777215)},opacity:{value:1},borderColor:{value:new l.Color(0)},borderOpacity:{value:0},borderRadius:{value:new l.Vector4(0,0,0,0)},cornerTL:{value:new l.Vector2(0,1)},cornerTR:{value:new l.Vector2(1,1)},cornerBR:{value:new l.Vector2(1,0)},cornerBL:{value:new l.Vector2(0,0)},borderWidth:{value:new l.Vector4(0,0,0,0)},frameSize:{value:new l.Vector3(1,1,1)},textureSize:{value:new l.Vector2(1,1)}},side:l.FrontSide,transparent:!0,clipping:!0,vertexShader:Ct,fragmentShader:Mt,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST="",this.needsUpdate=!0}set map(e){this.uniforms.map.value=e,e?void 0===this.defines.USE_UV&&(this.defines.USE_UV="",this.needsUpdate=!0):void 0!==this.defines.USE_UV&&(delete this.defines.USE_UV,this.needsUpdate=!0),this.needsUpdate=!0}get map(){return this.uniforms.map.value}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}set opacity(e){this.uniforms&&(this.uniforms.opacity.value=e)}get opacity(){return this.uniforms.opacity.value}get color(){return this.uniforms.diffuse.value}set color(e){this.uniforms.diffuse.value=e}}class Tt extends i{constructor(){super("children",null,!1),this._uis=[],this._boxes=[]}update(e,t){this._compute(e),e._layouter._needsUpdate=!0,e._renderOrder._needsUpdate=!0}process(e){this._compute(e),e._flexDirection._needsProcess=!0,e._layouter._needsProcess=!0,e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter((e=>e.visible&&e.isUI)),this._boxes=this._uis.filter((e=>e.isBox)).sort(this._sortOrder)}dispose(){this._uis=null,this._boxes=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class Ft extends i{constructor(){super("bounds",null,!1),this._size=new l.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0,this._centerX=.5,this._centerY=.5,this._needsProcess=!0}setReferenceWidth(e,t){const i=e._width,n=e._padding._value,s=e._borderWidth._value,r=e._margin._value,o=t*(i._auto?1:i._value)-(r.y+r.w);v(o,this._offsetWidth)||(this._offsetWidth=o,this._innerWidth=this._offsetWidth-(n.y+n.w+s.y+s.w),this._centerX=zt(e),this._propagateWidth(e),this._triggerCascadingDependencies(e))}setReferenceHeight(e,t){const i=e._height,n=e._padding._value,s=e._borderWidth._value,r=e._margin._value,o=t*(i._auto?1:i._value)-(r.x+r.z);v(o,this._offsetHeight)||(this._offsetHeight=o,this._innerHeight=this._offsetHeight-(n.x+n.z+s.x+s.z),this._centerY=Ot(e),this._propagateHeight(e),this._triggerCascadingDependencies(e))}setChildrenWidth(e,t){const i=e._padding._value,n=e._borderWidth._value;this._innerWidth=t,this._offsetWidth=this._innerWidth+(i.y+i.w+n.y+n.w),this._centerX=zt(e),this._propagateWidth(e),this._triggerCascadingDependencies(e)}setChildrenHeight(e,t){const i=e._padding._value,n=e._borderWidth._value;this._innerHeight=t,this._offsetHeight=this._innerHeight+(i.x+i.z+n.x+n.z),this._centerY=Ot(e),this._propagateHeight(e),this._triggerCascadingDependencies(e)}update(e,t){const i=e._padding._value,n=e._borderWidth._value,s=e._width;s._auto||s._relative||("content-box"===e._boxSizing._value?(this._innerWidth=s._value,this._offsetWidth=this._innerWidth+i.y+i.w+n.y+n.w):(this._offsetWidth=s._value,this._innerWidth=this._offsetWidth-(i.y+i.w+n.y+n.w)),this._centerX=zt(e),this._needsProcess=!0,this._propagateWidth(e),this._triggerCascadingDependencies(e));const r=e._height;r._auto||r._relative||("content-box"===e._boxSizing._value?(this._innerHeight=r._value,this._offsetHeight=this._innerHeight+i.x+i.z+n.x+n.z):(this._offsetHeight=r._value,this._innerHeight=this._offsetHeight-(i.x+i.z+n.x+n.z)),this._centerY=Ot(e),this._needsProcess=!0,this._propagateHeight(e),this._triggerCascadingDependencies(e))}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight,e._backgroundMesh&&e._backgroundMesh.updateScale(),e._renderer._needsRender=!0}output(e){e.size=this._size}process(e){e._overflow._needsRender=!0}_computeChildrenSideWidth(e){return function(e){return e._children._boxes.reduce(((e,t)=>{const i=t._margin._value;return e+(t._bounds._offsetWidth+i.y+i.w)}),0)}(e)}_computeChildrenSideHeight(e){return function(e){return e._children._boxes.reduce(((e,t)=>{const i=t._margin._value;return e+(t._bounds._offsetHeight+i.x+i.z)}),0)}(e)}_propagateWidth(e){for(let t=0;t<e._children._boxes.length;t++){const i=e._children._boxes[t];i._width._relative&&i._bounds.setReferenceWidth(i,this._innerWidth)}}_propagateHeight(e){for(let t=0;t<e._children._boxes.length;t++){const i=e._children._boxes[t];i._height._relative&&i._bounds.setReferenceHeight(i,this._innerHeight)}}_triggerCascadingDependencies(e){e._parent._value&&(e._parent._value._autoSize._needsProcess=!0),e._flexDirection._needsProcess=!0,e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0,e._overflow._needsRender=!0}}function zt(e){const t=e._padding._value,i=e._borderWidth._value;return(t.w+i.w-(t.y+i.y))/2}function Ot(e){const t=e._padding._value,i=e._borderWidth._value,n=t.x+i.x;return(t.z+i.z-n)/2}class At extends le{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0,this._process=this.emptyStrategyLogic,this._childAlign=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,e._flexDirection._value){case"row":case"row-reverse":switch(this._process=$t,this._value){case"start":this._childAlign=Et;break;case"end":this._childAlign=Dt;break;default:this._childAlign=Wt}break;case"column":case"column-reverse":switch(this._process=Gt,this._value){case"start":this._childAlign=Ht;break;case"end":this._childAlign=Lt;break;default:this._childAlign=Wt}}this._needsProcess=!0,e._autoSize._needsProcess=!0,e._flexDirection._needsProcess=!0,e._justifyContent._needsProcess=!0,this._needsProcess=!0,e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}process(e){this._process(e,this._childAlign);let t="center",i="center",n="center";const s=e._padding._value,r=e._borderWidth._value;t=-1!==e._flexDirection._value.indexOf("column")?"start"===this._value?i="left":"end"===this._value?i="right":"centerX":"start"===this._value?n="top":"end"===this._value?n="bottom":"centerY";let o=-(s.x-s.z)/2-(r.x-r.z)/2,a=-(s.y-s.w)/2-(r.y-r.w)/2;"left"===i?a=(s.w-s.y)/2+(r.w-r.y)/2:"right"===i&&(a=-(s.y-s.w)/2-(r.y-r.w)/2),"top"===n?o=-(s.x-s.z)/2-(r.x-r.z)/2:"bottom"===n&&(o=(s.z-s.x)/2+(r.z-r.x)/2),e._children._boxes.forEach((i=>{let n=0,s=0;"top"===t?s=-i._margin._value.x:"bottom"===t?s=i._margin._value.z:"left"===t?n=i._margin._value.w:"right"===t?n=-i._margin._value.y:"centerX"===t?n=(i._margin._value.w-i._margin._value.y)/2:"centerY"===t&&(s=(-i._margin._value.x+i._margin._value.z)/2),e._layouter._childrenPos[i.id].x+=a+n,e._layouter._childrenPos[i.id].y+=o+s}))}}function Wt(){return 0}function Dt(e,t){return-t+e._bounds._offsetHeight/2}function Et(e,t){return t-e._bounds._offsetHeight/2}function Lt(e,t){return t-e._bounds._offsetWidth/2}function Ht(e,t){return-t+e._bounds._offsetWidth/2}function Gt(e,t){const i=e._bounds._innerWidth/2;e._children._boxes.forEach((n=>{e._layouter._childrenPos[n.id].x=t(n,i)}))}function $t(e,t){const i=e._bounds._innerHeight/2;e._children._boxes.forEach((n=>{e._layouter._childrenPos[n.id].y=t(n,i)}))}class jt extends _e{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0,this._offset=0,this._reverse=1,this._process=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,this._value){case"row":this._process=Xt;break;case"row-reverse":this._process=Nt;break;case"column":this._process=Yt;break;case"column-reverse":this._process=Kt}e._justifyContent._needsUpdate||e._justifyContent.computeOutputValue(e),e._alignItems._needsUpdate||e._alignItems.computeOutputValue(e),this._needsProcess=!0}process(e){switch(this._value){case"row":this._offset=-e._bounds._innerWidth/2;break;case"row-reverse":this._offset=e._bounds._innerWidth/2;break;case"column":this._offset=e._bounds._innerHeight/2;break;case"column-reverse":this._offset=-e._bounds._innerHeight/2}this._reverse=-Math.sign(this._offset),0===this._reverse&&(this._reverse=1),this._process(e),e._justifyContent._needsProcess=!0,e._layouter._needsProcess=!0}}function Xt(e){let t=e._flexDirection._offset;const i=e._flexDirection._reverse,n=e._children._boxes;for(let s=0;s<n.length;s++){const r=n[s],o=r.id,a=r._bounds._offsetWidth;t+=r._margin._value.w*i;const h=e._layouter._childrenPos[o];h.x=t+a/2*i,h.y=0,t+=i*(a+r._margin._value.y)}}function Nt(e){let t=e._flexDirection._offset;const i=e._flexDirection._reverse,n=e._children._boxes;for(let s=0;s<n.length;s++){const r=n[s],o=r.id,a=r._bounds._offsetWidth;t+=r._margin._value.y*i;const h=e._layouter._childrenPos[o];h.x=t+a/2*i,h.y=0,t+=(a+r._margin._value.w)*i}}function Yt(e){let t=e._flexDirection._offset;const i=e._flexDirection._reverse,n=e._children._boxes;for(let s=0;s<n.length;s++){const r=n[s],o=r.id,a=r._bounds._offsetHeight;t+=r._margin._value.x*i;const h=e._layouter._childrenPos[o];h.x=0,h.y=t+a/2*i,t+=(a+r._margin._value.z)*i}}function Kt(e){let t=e._flexDirection._offset;const i=e._flexDirection._reverse,n=e._children._boxes;for(let s=0;s<n.length;s++){const r=n[s],o=r.id,a=r._bounds._offsetHeight;t+=r._margin._value.z*i;const h=e._layouter._childrenPos[o];h.x=0,h.y=t+a/2*i,t+=(a+r._margin._value.x)*i}}class qt extends ge{constructor(e){super("justifyContent",e,!0),this._allowsInherit=!1,this._needsUpdate=!0,this._computeOffset=this.emptyStrategyLogic,this._computeMargin=this.emptyStrategyLogic,this._process=this.emptyStrategyLogic}computeOutputValue(e){switch(this._value=this._inheritedInput,e._flexDirection._value){case"column-reverse":case"column":this._process=Qt.bind(this);break;case"row-reverse":case"row":this._process=Jt.bind(this)}switch(this._value){case"end":this._computeOffset=ei,this._computeMargin=ii;break;case"center":this._computeOffset=ti,this._computeMargin=ii;break;case"start":this._computeOffset=Zt,this._computeMargin=ii;break;case"space-between":this._computeOffset=Zt,this._computeMargin=ni;break;case"space-around":this._computeOffset=Zt,this._computeMargin=ri;break;case"space-evenly":this._computeOffset=Zt,this._computeMargin=si}e._flexDirection._needsProcess=!0}process(e){this._process(e),e._alignItems._needsProcess=!0}}function Jt(e){const t=e._flexDirection._offset,{usedDirectionSpace:i,remainingSpace:n}=function(e){const t=e._bounds._computeChildrenSideWidth(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerWidth-t}}(e),s=2*t-i*Math.sign(t),r=this._computeOffset(s),o=this._computeMargin(e,n,e._flexDirection._reverse);e._children._boxes.forEach(((t,i)=>{e._layouter._childrenPos[t.id].x-=r-o[i]}))}function Qt(e){const t=e._flexDirection._offset,{usedDirectionSpace:i,remainingSpace:n}=function(e){const t=e._bounds._computeChildrenSideHeight(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerHeight-t}}(e),s=2*t-i*Math.sign(t),r=this._computeOffset(s),o=this._computeMargin(e,n,e._flexDirection._reverse);e._children._boxes.forEach(((t,i)=>{e._layouter._childrenPos[t.id].y-=r-o[i]}))}function Zt(e){return 0}function ei(e){return e}function ti(e){return e/2}function ii(e,t=0,i=1){return Array(e._children._boxes.length).fill(0)}function ni(e,t=0,i=1){const n=e._children._boxes.length,s=Array(n).fill(0);if(t>0&&n>1){const e=t/(n-1)*i;s[0]=0;for(let t=1;t<n;t++)s[t]=e*t}return s}function si(e,t=0,i=1){const n=e._children._boxes.length,s=Array(n).fill(0);if(t>0){const e=t/(n+1)*i;for(let t=0;t<n;t++)s[t]=e*(t+1)}return s}function ri(e,t=0,i=1){const n=e._children._boxes.length,s=Array(n).fill(0);if(t>0){const e=t/n*i,r=e/2;s[0]=r;for(let t=1;t<n;t++)s[t]=r+e*t}return s}let oi;class ai extends l.Mesh{constructor(e){const t=e.slice,i={};let n=1,s=1;if(t){const e=1;if(n=t.width?t.width:1,s=t.height?t.height:1,t.top){if(t.left){const r=new l.PlaneGeometry(t.left*n,t.top*s,e,e);ui(r,0,t.left,1-t.top,1),r.translate(t.left*n/2,-t.top*s/2,0),i.topLeft=r}const r=new l.PlaneGeometry(1,t.top*s,e,e);if(ui(r,t.left,1-t.right,1-t.top,1),r.translate(0,-t.top*s/2,0),i.top=r,t.right){const r=new l.PlaneGeometry(t.right*n,t.top*s,e,e);ui(r,1-t.right,1,1-t.top,1),r.translate(-t.right*n/2,-t.top*s/2,0),i.topRight=r}}if(t.left){const s=new l.PlaneGeometry(t.left*n,1,e,e);ui(s,0,t.left,t.bottom,1-t.top),s.translate(t.left*n/2,0,0),i.left=s}const r=new l.PlaneGeometry(1,1,e,e);if(ui(r,t.left,1-t.right,t.bottom,1-t.top),i.middle=r,t.right){const s=new l.PlaneGeometry(t.right*n,1,e,e);ui(s,1-t.right,1,t.bottom,1-t.top),s.translate(-t.right*n/2,0,0),i.right=s}if(t.bottom){if(t.left){const r=new l.PlaneGeometry(t.left*n,t.bottom*s,e,e);ui(r,0,t.left,0,t.bottom),r.translate(t.left*n/2,t.bottom*s/2,0),i.bottomLeft=r}const r=new l.PlaneGeometry(1,t.bottom*s,e,e);if(ui(r,t.left,1-t.right,0,t.bottom),r.translate(0,t.bottom*s/2,0),i.bottom=r,t.right){const r=new l.PlaneGeometry(t.right*n,t.bottom*s,e,e);ui(r,1-t.right,1,0,t.bottom),r.translate(-t.right*n/2,t.bottom*s/2,0),i.bottomRight=r}}}let r=e.backgroundMaterial;t&&(oi||(oi=new l.MeshBasicMaterial({alphaTest:1.1})),r=oi);const o=new l.PlaneGeometry(1,1,e._segments.value,e._segments.value),a=new l.BufferAttribute(new Float32Array(o.getAttribute("uv").array),2);if(o.setAttribute("uvB",a).name="uvB",super(o,r),this.name="UIBackgroundBox",t){this.slice=t,this.sliceSize=new l.Vector3(1-(t.left+t.right),1-(t.bottom+t.top),1),this.sliceScale=new l.Vector3(n,s,1);for(const t in i){const n=new l.Mesh(i[t],e.backgroundMaterial);this.add(n),i[t]=n}this.updateScale=this.updateScaleSlice,this.slices=i}}updateScale(){}updateScaleSlice(){const e=new l.Vector3(1,1,1);this.scale.x<(this.slice.left+this.slice.right)*this.sliceScale.x&&(e.x=this.scale.x/((this.slice.left+this.slice.right)*this.sliceScale.x)),this.scale.y<(this.slice.bottom+this.slice.top)*this.sliceScale.y&&(e.y=this.scale.y/((this.slice.bottom+this.slice.top)*this.sliceScale.y));for(const e in this.slices){const t=this.slices[e];t.scale.set(1/this.scale.x,1/this.scale.y,this.scale.y);const i=hi[e];for(const e in i)t.position[e]=this.scale[e]*i[e]*t.scale[e];const n=li[e];if(n){n.x&&(t.position.x=.5*this.sliceScale.x*(this.slice.left-this.slice.right)*(1/this.scale.x)),n.y&&(t.position.y=.5*this.sliceScale.y*(this.slice.bottom-this.slice.top)*(1/this.scale.y));for(const e in n){const i=this.scale[e]-(1-this.sliceSize[e])*this.sliceScale[e];t.scale[e]=Math.max(0,i*(1/this.scale[e]))}}}1!==e.x&&(this.slices.left.scale.x*=e.x,this.slices.topLeft.scale.x*=e.x,this.slices.bottomLeft.scale.x*=e.x,this.slices.right.scale.x*=e.x,this.slices.topRight.scale.x*=e.x,this.slices.bottomRight.scale.x*=e.x),1!==e.y&&(this.slices.top.scale.y*=e.y,this.slices.topLeft.scale.y*=e.y,this.slices.topRight.scale.y*=e.y,this.slices.bottom.scale.y*=e.y,this.slices.bottomLeft.scale.y*=e.y,this.slices.bottomRight.scale.y*=e.y)}}const hi={topLeft:{x:-.5,y:.5},top:{y:.5},topRight:{x:.5,y:.5},left:{x:-.5},right:{x:.5},bottomLeft:{x:-.5,y:-.5},bottom:{y:-.5},bottomRight:{x:.5,y:-.5}},li={top:{x:1},left:{y:1},right:{y:1},bottom:{x:1},middle:{x:1,y:1}};function ui(e,t,i,n,s){const r=i-t,o=s-n,a=e.attributes.uv;for(let e=0;e<a.count;e++){const i=a.getX(e),s=a.getY(e);a.setXY(e,t+i*r,n+s*o)}const h=new l.BufferAttribute(new Float32Array(e.getAttribute("uv").array),2);e.setAttribute("uvB",h).name="uvB"}class di extends i{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new ai(e)),e.performAfterUpdate()}}class ci extends ye{constructor(){super("position")}update(e,t){super.update(e,t),this._needsProcess=!0}}class _i extends i{constructor(){super("autosize"),this._needsProcess=!0}process(e){e._width._auto&&function(e){e._bounds.setChildrenWidth(e,function(e){switch(e._flexDirection._value){case"row":case"row-reverse":return function(e){let t=0;for(const i of e._children._boxes){if("static"!==i._position._value)continue;const e=i._margin._value;t+=i._bounds._offsetWidth+e.y+e.w}return t}(e);case"column":case"column-reverse":return function(e){let t=0;for(const i of e._children._boxes){if("static"!==i._position._value)continue;const e=i._margin._value,n=i._bounds._offsetWidth+e.y+e.w;n>t&&(t=n)}return t}(e)}}(e))}(e),e._height._auto&&function(e){e._bounds.setChildrenHeight(e,function(e){switch(e._flexDirection._value){case"row":case"row-reverse":return function(e){let t=0;for(const i of e._children._boxes){if("static"!==i._position._value)continue;const e=i._margin._value,n=i._bounds._offsetHeight+e.x+e.z;n>t&&(t=n)}return t}(e);case"column":case"column-reverse":return function(e){let t=0;for(const i of e._children._boxes){if("static"!==i._position._value)continue;const e=i._margin._value;t+=i._bounds._offsetHeight+e.x+e.z}return t}(e)}}(e))}(e);const t="stretch"===e._alignItems._value,i=t&&-1!==e._flexDirection._value.indexOf("column"),n=t&&!i;for(const t of e._children._boxes)(t._width._auto&&i||t._width._relative)&&t._bounds.setReferenceWidth(t,e._bounds._innerWidth),(t._height._auto&&n||t._height._relative)&&t._bounds.setReferenceHeight(t,e._bounds._innerHeight)}}class fi extends vt{constructor(e,t){fi.definePropertiesValues(e,t),super(e,t),fi.init(this)}bindBackgroundMeshProperties(){this._bounds._size=this._backgroundMesh.scale,this._bounds._needsProcess=!0}unbindBackgroundMeshProperties(){this._bounds._size=new l.Vector3(1,1,1),this._bounds._needsProcess=!0}static definePropertiesValues(e,t){e.children||(e.children=Tt),e.bounds||(e.bounds=Ft),e.flexDirection||(e.flexDirection=jt),e.justifyContent||(e.justifyContent=qt),e.alignItems||(e.alignItems=At),e.position||(e.position=ci),e.autoSize||(e.autoSize=_i),e.renderer||(e.renderer=di),t.fontSide||(t.fontSide=0),t.invertAlpha||(t.invertAlpha=!1),t.fontCastShadow||(t.fontCastShadow=!1),t.fontReceiveShadow||(t.fontReceiveShadow=!1),t.backgroundCastShadow||(t.backgroundCastShadow=!1),t.backgroundReceiveShadow||(t.backgroundReceiveShadow=!1)}static init(e){Object.defineProperties(e,{isBox:{configurable:!1,enumerable:!0,value:!0}}),e.backgroundMaterial=new Pt,e._renderer.render(e),e._backgroundMesh.visible=!1}}class pi extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}}class gi extends i{constructor(){super("layouter",null,!1),this._needsUpdate=!0,this._childrenPos={}}update(e,t){this._childrenPos={};for(const t of e._children._boxes)"static"===t._position._value&&(this._childrenPos[t.id]=t.position)}process(e){}}class mi extends fi{constructor(e={}){const t={};mi.definePropertiesValues(t,e),super(t,e),mi.init(this)}add(e){const t=[];for(let e=0;e<arguments.length;e++){const i=arguments[e];!i.isUI||i.isBox?t.push(i):console.warn("Block element can only contain Box elements.",i)}return super.add(...t)}static definePropertiesValues(e,t){e.layouter=gi}static init(e){Object.defineProperties(e,{isBlock:{configurable:!1,enumerable:!0,value:!0}})}}class vi extends i{constructor(){super("textContent",null,!1)}update(e,t){e._glyphs._needsUpdate=!0,e._whiteSpace._needsProcess=!0}}class bi extends i{constructor(){super("inlines",null,!1),this._value=null}process(e){if(this._value=e._glyphs._value.map((e=>e.asInlineGlyph())),this._value.length){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}e._fontSize._needsProcess=!0,e._lineBreak._needsProcess=!0,e._fontKerning._needsProcess=!0,e._layouter._needsProcess=!0}get value(){return this._value}}class yi extends i{constructor(){super("glyphs",null,!1),this._needsUpdate=!1,this._value=null}process(e){e._font._fontVariant&&e._font._fontVariant.isReady&&(this._value=e._whiteSpace._whiteSpacedContent.split("").map((t=>e._font._fontVariant.getTypographicGlyph(t))),this._value&&(e._inlines._needsProcess=!0))}get value(){return this._value}}class xi extends D{constructor(){super("color","inherit",!1),this.output=this._outputValue}computeOutputValue(e){"inherit"===this._input?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}}class wi extends i{constructor(e="- ,.:?!\n"){super("lineBreak",e,!0),this._newLineBreakability=null}update(e,t){this._needsProcess=!0}process(e){const t=e._whiteSpace._newLineBreakability;if(e._inlines._value)for(let i=0;i<e._inlines._value.length;i++){const n=e._inlines._value[i],s=n.char;let r=null;void 0!==s&&("nowrap"!==t&&(this._value.includes(s)||s.match(/\s/g))&&(r="possible"),s.match(/\n/g)&&(r=t)),n.lineBreak=r}}get value(){return this._value}}class Si extends i{constructor(){super("layouter",null,!1),this._value=null}update(e,t){this._value=e._parent.find((e=>e.isUI&&e.isText)),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}}class Vi extends D{constructor(e){super("backgroundColor",e,!1),this._allowsInherit=!1,this._input=0}computeOutputValue(e){"inherit"===this._input?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}}class ki extends Ue{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class Ri extends Ie{constructor(){super()}computeOutputValue(e){this._value=U(this.getInheritedInput(e))}}class Ui extends nt{constructor(){super("fontFamily","inherit",!0),this._input="inherit",this._needsUpdate=!0,this._allowsInherit=!1}computeOutputValue(e){let t=this._inheritedInput;if("inherit"===t&&(t=this.getInheritedInput(e)),t instanceof Qe)this._value=t,e._font._needsUpdate=!0;else if("string"==typeof t){const i=it.getFontFamily(t);i?(this._value=i,e._font._needsUpdate=!0):console.warn(`(.style) fontFamily, the font '${t}' is not registered. Aborted.`)}else console.warn("(.style) fontFamily requires a registered fontFamily instance, or the id of a registered fontFamily."),console.warn("If you want to set a specific font, please use .font property instead.")}get value(){return this._value}}class Ci extends rt{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited,this._whiteSpacedContent="",this._stringCollapser=this.emptyStrategyLogic,this._inlineCollapser=this.emptyStrategyLogic,this._inlineWrapper=this.emptyStrategyLogic}_computeFromInherited(e){switch(super._computeFromInherited(e),this._newLineBreakability=Ii(this._value),this._value){case"nowrap":case"normal":this._stringCollapser=Bi;break;case"pre-line":this._stringCollapser=Pi;break;default:this._stringCollapser=Ti}switch(this._value){case"pre-line":case"nowrap":case"normal":this._inlineCollapser=Wi;break;case"pre-wrap":this._inlineCollapser=Ai;break;default:this._inlineCollapser=Di}switch(this._value){case"pre-line":case"pre-wrap":case"normal":this._inlineWrapper=Fi;break;case"pre":this._inlineWrapper=zi;break;default:this._inlineWrapper=Oi}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}}const Mi={"\t":"\t","\n":"\n","\r":"\r"," ":" "},Ii=function(e){switch(e){case"pre":case"pre-wrap":case"pre-line":return"mandatory"}return null};function Bi(e){return Pi(e.replace(/\n/g," "))}function Pi(e){return e.replace(/[ ]{2,}/g," ")}function Ti(e){return e}function Fi(e,t,i,n){const s=e[t];if("mandatory"===s.lineBreak)return!0;if(i+s.xadvance+s.xoffset+s.kerning>n.INNER_WIDTH)return!0;const r=Hi(e,t,n);return function(e,t,i,n){return!(!e||!e.char)&&(!(t+i<n.INNER_WIDTH)&&n.BREAKON.indexOf(e.char)>-1)}(e[t-1],i,r,n)}function zi(e,t,i,n){return"mandatory"===e[t].lineBreak}function Oi(){return!1}function Ai(e){if(!e[0])return 0;const t=e[0],i=e[e.length-1];return t.char&&"\n"===t.char&&e.length>1&&Li([t],e[1]),i.char&&"\n"===i.char&&e.length>1&&Ei([i],e[e.length-2]),t.offsetX}function Wi(e){if(!e[0])return 0;let t,i=[];for(let n=0;n<e.length;n++){const s=e[n];if(!(s.char&&Mi[s.char]&&e.length>n))break;i.push(s),t=e[n+1]}Li(i,t),i=[],t=null;for(let n=e.length-1;n>0;n--){const s=e[n];if(!(s.char&&Mi[s.char]&&n>0))break;i.push(s),t=e[n-1]}return Ei(i,t),e[0].offsetX}function Di(e){return e[0]?e[0].offsetX:0}function Ei(e,t){if(t)for(let i=0;i<e.length;i++){const n=e[i];n.fontFactor=0,n.offsetX=t.offsetX+t.cumulativeWidth,n.cumulativeWidth=0}}function Li(e,t){if(t)for(let i=0;i<e.length;i++){const n=e[i];n.fontFactor=0,n.offsetX=t.offsetX,n.cumulativeWidth=0}}function Hi(e,t,i,n){if(n=n||0,!e[t])return n;const s=e[t];return s.lineBreak?n+s.xadvance:Hi(e,t+1,i,n+s.xadvance+s.xoffset+s.kerning+i.LETTERSPACING)}class Gi extends ht{constructor(){super(),this._input="inherit",this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._fontSize._needsProcess=!0,e._layouter._needsProcess=!0}}class $i extends u{constructor(){super("fontSize","inherit",!0),this._allowsInherit=!1}computeOutputValue(e){this._value=this._inheritedInput,e._font._fontVariant&&(e._bounds._needsProcess=!0,e._layouter._needsProcess=!0)}process(e){if(!e._font._fontVariant||!e._font._fontVariant.isReady)return;const t=this._value/e._font._fontVariant.typographic.size,i=e._inlines._value;for(let e=0;e<i.length;e++){const n=i[e];n.resetOffsets(),n.fontSize=this._value,n.fontFactor=t}}get value(){return this._value}}class ji extends ut{constructor(){super("segments",1,!1),this._notInheritedValue=void 0}update(e,t){this._notInheritedValue=this._value,"inherit"===this._notInheritedValue&&(this._notInheritedValue=this.getInheritedInput(e)),e._layouter._needsUpdate=!0}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}get value(){return"inherit"===this._value?this._notInheritedValue:this._value}}class Xi extends ji{constructor(){super(),this._value="inherit"}}class Ni extends ct{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value._layouter._needsProcess=!1}process(e){if("none"!==this._value){const t=e._whiteSpace._whiteSpacedContent,i=e._inlines._value;for(let n=1;n<i.length;n++){const s=t[n-1]+t[n];i[n].kerning=e._font._fontVariant.getKerningAmount(s)}}}}class Yi extends i{constructor(){super("children",null,!1),this._uis=[]}update(e,t){}process(e){}_compute(e){}dispose(){}}function Ki(e){let t,i,n,s=-1,r=0;for(let o=0;o<e.length;++o){const a=e[o];if(void 0===t&&(t=a.array.constructor),t!==a.array.constructor)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.array must be of consistent array types across matching attributes."),null;if(void 0===i&&(i=a.itemSize),i!==a.itemSize)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.itemSize must be consistent across matching attributes."),null;if(void 0===n&&(n=a.normalized),n!==a.normalized)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.normalized must be consistent across matching attributes."),null;if(-1===s&&(s=a.gpuType),s!==a.gpuType)return console.error("THREE.BufferGeometryUtils: .mergeAttributes() failed. BufferAttribute.gpuType must be consistent across matching attributes."),null;r+=a.count*i}const o=new t(r),a=new l.BufferAttribute(o,i,n);let h=0;for(let t=0;t<e.length;++t){const n=e[t];if(n.isInterleavedBufferAttribute){const e=h/i;for(let t=0,s=n.count;t<s;t++)for(let s=0;s<i;s++){const i=n.getComponent(t,s);a.setComponent(t+e,s,i)}}else o.set(n.array,h);h+=n.count*i}return void 0!==s&&(a.gpuType=s),a}class qi extends i{constructor(){super("renderer")}render(e){if(!e._inlines._value||!e._inlines._value.length)return;const t=function(e,t=!1){const i=null!==e[0].index,n=new Set(Object.keys(e[0].attributes)),s=new Set(Object.keys(e[0].morphAttributes)),r={},o={},a=e[0].morphTargetsRelative,h=new l.BufferGeometry;let u=0;for(let l=0;l<e.length;++l){const d=e[l];let c=0;if(i!==(null!==d.index))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". All geometries must have compatible attributes; make sure index attribute exists among all geometries, or in none of them."),null;for(const e in d.attributes){if(!n.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+'. All geometries must have compatible attributes; make sure "'+e+'" attribute exists among all geometries, or in none of them.'),null;void 0===r[e]&&(r[e]=[]),r[e].push(d.attributes[e]),c++}if(c!==n.size)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". Make sure all geometries have the same number of attributes."),null;if(a!==d.morphTargetsRelative)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphTargetsRelative must be consistent throughout all geometries."),null;for(const e in d.morphAttributes){if(!s.has(e))return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". .morphAttributes must be consistent throughout all geometries."),null;void 0===o[e]&&(o[e]=[]),o[e].push(d.morphAttributes[e])}if(t){let e;if(i)e=d.index.count;else{if(void 0===d.attributes.position)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed with geometry at index "+l+". The geometry must have either an index or a position attribute"),null;e=d.attributes.position.count}h.addGroup(u,e,l),u+=e}}if(i){let t=0;const i=[];for(let n=0;n<e.length;++n){const s=e[n].index;for(let e=0;e<s.count;++e)i.push(s.getX(e)+t);t+=e[n].attributes.position.count}h.setIndex(i)}for(const e in r){const t=Ki(r[e]);if(!t)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" attribute."),null;h.setAttribute(e,t)}for(const e in o){const t=o[e][0].length;if(0===t)break;h.morphAttributes=h.morphAttributes||{},h.morphAttributes[e]=[];for(let i=0;i<t;++i){const t=[];for(let n=0;n<o[e].length;++n)t.push(o[e][n][i]);const n=Ki(t);if(!n)return console.error("THREE.BufferGeometryUtils: .mergeGeometries() failed while trying to merge the "+e+" morphAttribute."),null;h.morphAttributes[e].push(n)}}return h}(e._inlines._value.map((t=>e._font._fontVariant.getGeometricGlyph(t,e).translate(t.offsetX,t.offsetY,0))));e.setFontMesh(new l.Mesh(t,e.fontMaterial)),e._fontMesh.renderOrder=1/0}}class Ji extends ue{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}}class Qi extends vt{constructor(e={}){const t={};Qi.definePropertiesValues(t,e),super(t,e),Qi.init(this)}add(e){const t=[];for(let e=0;e<arguments.length;e++){const i=arguments[e];!i.isUI||i.isInline?(t.push(i),i.position.z=.005):console.warn("Block element can only contain Box elements.",i)}return super.add(...t)}_rebuildParentUI=()=>{super._rebuildParentUI(),this._layouter._needsUpdate=!0};set textContent(e){this._textContent.value=e}get textContent(){return this._textContent._value}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}static definePropertiesValues(e,t){e.children||(e.children=Yi),e.textContent||(e.textContent=vi),e.glyphs||(e.glyphs=yi),e.inlines||(e.inlines=bi),e.layouter||(e.layouter=Si),e.renderer||(e.renderer=qi),e.fontFamily||(e.fontFamily=Ui),e.fontWeight||(e.fontWeight=Ri),e.fontStyle||(e.fontStyle=ki),e.fontSize||(e.fontSize=$i),e.color||(e.color=xi),e.backgroundColor||(e.backgroundColor=Vi),e.lineBreak||(e.lineBreak=wi),e.letterSpacing||(e.letterSpacing=Gi),e.whiteSpace||(e.whiteSpace=Ci),e.segments||(e.segments=Xi),e.textAlign||(e.textAlign=Ji),e.fontKerning||(e.fontKerning=Ni)}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}}class Zi extends Re{constructor(){super("textContent",null,!1),this._needsUpdate=!1}set value(e){this._value!==e&&(this._value=e,this._needsUpdate=!0)}update(e,t){this._needsUpdate=!1;for(let t=e.children.length-1;t>=0;t--){const i=e.children[t];i.isUI&&(e.remove(i),i.clear())}e._children._uis=[],this._value&&e.add(new Qi({name:"anonymousInline",textContent:this._value}))}}class en extends Array{constructor(...e){super(...e),this.width=0,this.height=0}}class tn extends i{constructor(){super("layouter",null,!1),this._value=null}update(e,t){}process(e){let t=e._width._value;t=e._width._auto?1/0:e._bounds._innerWidth;const i=e._lineHeight._value,n=new en(new pi);let s=0;e._children._inlines.forEach((e=>{if(!e._inlines.value)return;this._resetInlines(e);const i=e._fontSize._value,r=e._letterSpacing._value*i,o=e._whiteSpace._value,a=e._lineBreak._value,h={WHITESPACE:o,LETTERSPACING:r,BREAKON:a,INNER_WIDTH:t},l=e._whiteSpace._inlineWrapper;s+=e._margin._value.w+e._padding._value.w,e._inlines.value.forEach(((e,t,i)=>{const o=n[n.length-1];if(l(i,t,s,h))return n.push(new pi(e)),e.offsetX=e.xoffset,0===e.width?void(s=0):(e.cumulativeWidth=e.xadvance+r,void(s=e.cumulativeWidth));n[n.length-1].push(e),e.offsetX=s+e.xoffset+e.kerning,e.cumulativeWidth=e.xadvance+e.kerning+r,s+=e.cumulativeWidth,o.length-1==1&&0===o[o.length-2].width&&(e.offsetX-=e.xoffset,s-=e.xoffset)})),s+=e._margin._value.y+e._padding._value.y}));const r=e._whiteSpace._inlineCollapser;let o=0,a=0,h=0;n.forEach(((e,t)=>{const s=r(e);let l=0,u=0;if(e.forEach((e=>{l=Math.max(l,e.lineHeight),u=Math.max(u,e.lineBase),e.offsetX-=s})),e.lineHeight=l,e.lineBase=u,0===t?h=.5*-(l*i-l):h-=n[t-1].lineHeight*i,e.y=h,e.x=0,e.forEach((t=>{t.offsetY=h-t.anchor,t.lineHeight<e.lineHeight&&(t.offsetY-=e.lineBase-t.lineBase)})),a+=e.lineHeight*i,e.width=0,e[0]){const t=e[e.length-1];e.width=t.offsetX+t.cumulativeWidth+t.paddingRight+t.marginRight+e[0].offsetX,o=Math.max(o,e.width)}})),n.height=a,n.width=o,this._value=n,t===1/0&&e._bounds.setChildrenWidth(e,n.width),e._height._auto&&e._bounds.setChildrenHeight(e,n.height);const l=e._parent._value;l&&(l._autoSize._needsProcess=!0,l._flexDirection._needsProcess=!0),e._inlineJustificator._needsProcess=!0,e._textAlign._needsProcess=!0,e._overflow._needsUpdate=!0}_resetInlines(e){e._fontSize.process(e)}}class nn extends ue{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput,this._needsProcess=!0}process(e){!function(e){const t=e._layouter._value,i=e._textAlign._value,n=e._bounds._innerWidth;for(let i=0;i<t.length;i++){const n=t[i],s=sn(e,n,i===t.length-1),r=e._padding._value,o=e._borderWidth._value,a=(-r.w+r.y)/2+(-o.w+o.y)/2;n.x+=s;for(let e=0;e<n.length;e++)n[e].offsetX+=s-a}if(0===i.indexOf("justify"))for(let e=0;e<t.length;e++){const s=t[e];if(-1!==i.indexOf("-")&&e===t.length-1)return;const r=n-s.width;if(r<=0)return;let o=0;for(let e=1;e<s.length-1;e++)o+=" "===s[e].char?1:0;const a=r/o;let h=1;"justify-right"===i&&(s.reverse(),h=-1);let l=0;for(let e=1;e<=s.length-1;e++){const t=s[e];t.offsetX+=l*h,l+=" "===t.char?a:0}"justify-right"===i&&s.reverse()}}(e),e._renderer._needsRender=!0}}function sn(e,t,i){switch(e._textAlign._value){case"justify-left":case"justify":case"left":return-e._bounds._innerWidth/2;case"justify-right":case"right":return-t.width+e._bounds._innerWidth/2;case"center":return-t.width/2;case"justify-center":return i?-t.width/2:-e._bounds._innerWidth/2;default:console.warn(`textAlign: '${e._textAlign._value}' is not valid`)}}class rn extends _e{constructor(){super(),this._value=this._input="column",this._allowsInherit=!1,this._needsUpdate=!0}computeOutputValue(e){this._value=this._inheritedInput}}class on extends st{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}}class an extends ct{constructor(){super(),this._value=this._input=this.getDefaultValue(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}_computeFromInherited(e){super._computeFromInherited(e)}}class hn extends Ft{constructor(){super(),this._innerWidth=1/0,this._innerHeight=0}}class ln extends i{constructor(){super("children",null,!1),this._uis=[],this._inlines=[],this._boxes=[]}update(e,t){this._compute(e),this._needsProcess=!0}process(e){this._compute(e),e._overflow._needsRender=!0}_compute(e){this._uis=e.children.filter((e=>e.visible&&e.isUI)),this._inlines=this._uis.filter((e=>e.isInline)).sort(this._sortOrder)}dispose(){this._inlines=null}_sortOrder=(e,t)=>e._order._value<t._order._value?-1:e._order._value>t._order._value?1:this._uis.indexOf(e)<this._uis.indexOf(t)?-1:1}class un extends i{constructor(){super("autosize")}process(e){if(e._layouter._value&&e._layouter._value.length){const t=e._layouter._value,i=e._padding._value,n=e._borderWidth._value;e._width._auto&&e._bounds.setOffsetWidth(e,t.width+i.w+i.y+n.w+n.y),e._height._auto&&e._bounds.setOffsetHeight(e,t.height+i.x+i.z+n.x+n.z)}}}class dn extends di{constructor(){super("renderer"),this._needsUpdate=!1}render(e){super.render(e);for(const t of e._children._inlines)t._renderer.render(t);e.performAfterUpdate()}}class cn extends fi{constructor(e={},t={}){cn.definePropertiesValues(t,e),super(t,e),cn.init(this)}add(e){const t=[];let i=!1;for(let e=0;e<arguments.length;e++){const n=arguments[e];!n.isUI||n.isInline?(n.isInline&&(i=!0),t.push(n)):console.warn("Block element can only contain Box elements.",n)}return t.length>0&&super.add(...t),i&&(this._children._needsUpdate=!0,this._layouter._needsProcess=!0),this}set textContent(e){this._textContent.value=e}get textContent(){return super.textContent}set invertAlpha(e){this._invertAlpha.value=e}get invertAlpha(){return this._invertAlpha._value}get lines(){return this._layouter._value}static definePropertiesValues(e,t){e.flexDirection=rn,e.justifyContent=ge,e.alignItems=le,e.bounds=hn,e.autoSize=un,e.renderer=dn,e.children||(e.children=ln),e.textContent||(e.textContent=Zi),e.layouter||(e.layouter=tn),e.lineHeight||(e.lineHeight=on),e.textAlign||(e.textAlign=nn),e.whiteSpace||(e.whiteSpace=Ci),e.fontKerning||(e.fontKerning=an),e.segments||(e.segments=ji),t.width||(t.width="100%"),t.fontSide||(t.fontSide=0)}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}}class _n extends i{constructor(){super("inlines",null,!1),this._value=[]}process(e){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;const t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}}class fn extends i{constructor(){super("renderer")}render(e){e._backgroundMesh||e.setBackgroundMesh(new ai(e)),e._backgroundMesh.position.x=e._inlines._value[0].offsetX+e._inlines._value[0].width/2,e._backgroundMesh.position.y=e._inlines._value[0].offsetY+e._inlines._value[0].lineBase/2,e._bounds.render(e)}}class pn extends i{constructor(){super("bounds",null,!1),this._size=new l.Vector3(1,1,1),this._offsetWidth=0,this._offsetHeight=0,this._innerWidth=0,this._innerHeight=0}update(e,t){this.output(t),this._needsProcess=!0}process(e){this._offsetWidth=this._innerWidth=e._inlines._value[0].width,this._offsetHeight=this._innerHeight=e._inlines._value[0].height,this._needsRender=!0,e._borderWidth._needsRender=!0,e._borderRadius._needsRender=!0}render(e){this._size.x=this._offsetWidth,this._size.y=this._offsetHeight}output(e){e.size=this._size}}class gn extends vt{constructor(e={}){const t={};gn.definePropertiesValues(t,e),super(t,e),gn.init(this)}clear(){for(const e of this._inlines._value)e.clear();return super.clear()}bindBackgroundMeshProperties(){this._backgroundMesh.raycast=()=>{},this._bounds._size=this._backgroundMesh.scale,this._bounds._needsUpdate=!0}unbindBackgroundMeshProperties(){this._bounds._size=new l.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){const t=[];for(let e=0;e<arguments.length;e++){const i=arguments[e];i.isUI?console.warn("ThreeMeshUI::InlineBlockElement cannot contains UI Elements.",i):(t.push(i),i.position.z=.005)}return super.add(...t)}static definePropertiesValues(e,t){e.children||(e.children=Yi),e.bounds||(e.bounds=pn),e.inlines||(e.inlines=_n),e.layouter||(e.layouter=Si),e.renderer||(e.renderer=fn),e.fontFamily||(e.fontFamily=Ui),e.fontWeight||(e.fontWeight=Ri),e.fontStyle||(e.fontStyle=ki),e.fontSize||(e.fontSize=$i),e.backgroundColor||(e.backgroundColor=se),e.lineBreak||(e.lineBreak=wi),e.letterSpacing||(e.letterSpacing=Gi),e.whiteSpace||(e.whiteSpace=Ci),e.fontKerning||(e.fontKerning=ct),t.backgroundSize||(t.backgroundSize="cover"),t.width||(t.width="100%"),t.height||(t.height="100%"),t.boxSizing||(t.boxSizing="border-box")}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0},isInlineBlock:{configurable:!1,enumerable:!0,value:!0}}),e._inlines._value=[new mn(e)],e.backgroundMaterial=new Pt,e._renderer.render(e)}}class mn extends S{constructor(e){super(),this._uiElement=e}get xadvance(){const e=this._uiElement._padding._value,t=this._uiElement._width;return t._relative?t._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.w+e.y+t.value}get width(){const e=this._uiElement._width;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get height(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get anchor(){return this.height}get lineHeight(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}get lineBase(){const e=this._uiElement._height;return e._relative?e._value*this._uiElement._fontSize.getInheritedInput(this._uiElement):e.value}clear(){this._uiElement=null}}const vn={BaseProperty:i,Block:mi,Text:cn,Inline:Qi,InlineBlock:gn,MeshUIBaseElement:vt,FontLibrary:it,update:()=>bt.update(),MSDFFontMaterialUtils:Xe,ShaderChunkUI:Ut,Behavior:class{constructor(e){this._subject=e}attach(){console.error(`Behavior::attach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}act(){throw new Error(`Behavior::act() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}detach(){console.error(`Behavior::detach() - Is abstract and therefore should be overridden in ${this.constructor.name}`)}clear(){}},FontVariant:I};void 0!==e.g&&(e.g.ThreeMeshUI=vn)})();