import{n as e}from"./rolldown-runtime.CYVBeYYp.js";import{A as t,Ar as n,It as r,Qt as i,S as a,Zt as o,_n as s,_r as c,fn as l,gr as u,it as d,jr as f,kr as ee,nt as te,tr as ne,vn as re,x as ie}from"./three@0.169.19.js";var ae=e({BaseProperty:()=>xi,Behavior:()=>Si,Block:()=>Ci,DefaultValues:()=>wi,FontLibrary:()=>Ti,FontVariant:()=>Ei,InheritableProperty:()=>Di,Inline:()=>Oi,InlineBlock:()=>ki,InlineGlyph:()=>Ai,MSDFFontMaterialUtils:()=>ji,MaterialTransformers:()=>Mi,MeshUIBaseElement:()=>Ni,ShaderChunkUI:()=>Pi,Text:()=>Fi,TypographicFont:()=>Ii,TypographicGlyph:()=>Li,default:()=>Ri,update:()=>zi}),p={};p.d=(e,t)=>{for(var n in t)p.o(t,n)&&!p.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},p.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),p.r=e=>{typeof Symbol<`u`&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:`Module`}),Object.defineProperty(e,`__esModule`,{value:!0})};var m={};p.d(m,{ti:()=>v,nS:()=>_i,eB:()=>mr,Yp:()=>h,VB:()=>W,BC:()=>E,zN:()=>y,cV:()=>Zr,hW:()=>hi,k2:()=>we,K6:()=>V,M7:()=>g,ls:()=>q,Hi:()=>hn,EY:()=>di,MR:()=>Tt,zf:()=>Ce,Ay:()=>bi,yo:()=>vi});var h={};p.r(h),p.d(h,{get:()=>se,set:()=>oe});var g={};p.r(g),p.d(g,{alphaTestTransformer:()=>R,asPreprocessorValueTransformer:()=>Mt,toPreprocessorTriggerTransformer:()=>z,toUserDataTransformer:()=>Nt,uniformOrUserDataTransformer:()=>B});var _={fontFamily:null,fontSize:.05,fontKerning:`auto`,fontStyle:`normal`,fontWeight:`normal`,offset:.005,lineHeight:1.2,lineBreak:`- ,.:?! `,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},oe=function(e){for(let t in e)_[t]=e[t]},se=function(e){return Object.prototype.hasOwnProperty.call(_,e)||console.warn(`ThreeMeshUI::DefaultValues is trying to retrieve non-existing property '${e}'`),_[e]},v=class{constructor(e,t=null,n=!0){this._id=e,this._value=t,this._needsUpdate=!0,this._needsProcess=!1,this._needsRender=!1,this._isPrimitive=n}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(this._value!==`inherit`)return this._value;let t=e._parent._value;return t&&t[`_${this._id}`]?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return se(this._id)}isValid(e){return!0}emptyStrategyLogic(){throw 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}},ce=class extends v{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(this._value!==`auto`)this._actualValue=this._value;else{let t=e._parent._value;t!==null&&(this._actualValue=t._renderOrder._actualValue+(1+t._children._uis.indexOf(e)))}for(let t of e._children._uis)t._renderOrder._value===`auto`&&(t._renderOrder._needsUpdate=!0);this._outputValue(t)}_outputValue(e){e[this._id]=this._actualValue}get value(){return this._value}},y=class extends v{constructor(e,t=null,n=!0){super(e,t,n),this.output=this._outputValue,this._notInheritedValue=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue===`inherit`&&(this._notInheritedValue=this.getInheritedInput(e)),this.propagate(e),this._outputValue(t)}propagate(e){for(let t of e._children._uis){let e=t[`_${this._id}`];e!==void 0&&e._value===`inherit`&&(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 this._value===`inherit`?this._notInheritedValue:this._value}},le=class extends y{constructor(){super(`offset`,`inherit`,!1)}update(e,t){super.update(e,t),e._parent._value!==null&&(e.position.z=this._notInheritedValue)}},ue=class extends y{constructor(){super(`fontSmooth`,`inherit`,!0),this._needsUpdate=!1,this.isValid=fe,this.output=this._outputValue}},de=[`inherit`,`none`,`antialiased`];function fe(e){return de.indexOf(e)===-1?(console.warn(`.fontSmoothing value '${e}' is not valid. Aborted`),!1):!0}var b=(e=>{var t={};return p.d(t,e),t})({BackSide:()=>1,BufferAttribute:()=>ie,BufferGeometry:()=>a,Color:()=>t,DoubleSide:()=>2,EventDispatcher:()=>te,FileLoader:()=>d,FrontSide:()=>0,LinearFilter:()=>r,Mesh:()=>o,MeshBasicMaterial:()=>i,Object3D:()=>l,Plane:()=>s,PlaneGeometry:()=>re,ShaderMaterial:()=>ne,Texture:()=>u,TextureLoader:()=>c,Vector2:()=>ee,Vector3:()=>n,Vector4:()=>f}),x=class extends v{constructor(e,t,n=!0){super(e,`unset`,n),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(let t of e._children._uis){let e=t[`_${this._id}`];(e._input?e._input:e._value)===`inherit`&&(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(this._input!==`inherit`)return this._input;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}},S=class extends x{constructor(e,t){super(e,t,!1),this._input=new b.Vector4(0,0,0,0),this._inline=null,this._value=new b.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 b.Vector4){e.copy(t);return}if((typeof t==`string`||t instanceof String)&&(t=t.split(` `)),Array.isArray(t))switch(t=t.map(e=>parseFloat(e)),t.length){case 1:e.setScalar(t[0]);return;case 2:e.x=e.z=t[0],e.y=e.w=t[1];return;case 3:e.x=t[0],e.y=t[1],e.z=t[2];return;case 4:e.x=t[0],e.y=t[1],e.z=t[2],e.w=t[3];return;default:console.error(`StyleVector4Property::set() Four Dimension property had more than four values`);return}isNaN(t)||e.setScalar(t)}},pe=class extends S{constructor(){super(`padding`,new b.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)}},me=class extends S{constructor(){super(`margin`,new b.Vector4(0,0,0,0))}computeOutputValue(e){super.computeOutputValue(e),e._renderer._needsRender=!0,e._parent._value&&(e._parent._value._flexDirection._needsProcess=!0)}},he=function(e,t,n){e[t]=n},ge=function(e,t,n){n!==null&&(e[t]=n)},C=class{constructor(e){this._definition=e}set definition(e){this._definition=e}mediate(e,t,n,r=null){for(let e in this._definition){let i=this._definition[e];if(n[e]!==void 0){let a=i.t?i.t:he;a(t,i.m,n[e]),r&&a(r,i.m,n[e])}}}static mediate(e,t,n,r,i=null){if(t)for(let e in r){let a=r[e];if(n[e]!==void 0){let r=a.t?a.t:he;r(t,a.m,n[e]),i&&r(i,a.m,n[e])}}}},_e=class extends v{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}},w=function(e,t,n=6){return e.toFixed(n)===t.toFixed(n)},ve=class extends v{constructor(e,t){super(e,t,!0),this.output=this._outputValue}set value(e){this.isValid(e)&&(w(this._value,e)||(this._value=e,this._needsUpdate=!0))}get value(){return this._value}},ye=class extends y{constructor(e){super(e,`inherit`,!0),this.isValid=xe}},be=[b.FrontSide,b.BackSide,b.DoubleSide];function xe(e){return be.indexOf(e)===-1?(console.warn(`SideProperty value '${e}' is not valid. Abort`),!1):!0}var Se=class{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}},Ce=class{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 Error(`Abstract... Need to be implemented`)}asInlineGlyph(){throw Error(`Abstract... Need to be implemented`)}},we=class extends Se{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}},Te={light:`100`,normal:`400`,bold:`700`,bolder:`900`};function T(e){return isNaN(e)?Te[e]||e:e.toString()}var Ee=class extends b.EventDispatcher{constructor(e,t){super(),this._isReady=!1,this._weight=T(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[` `];let n=this._getFallbackCharacter(e);if(n&&(t=this._chars[n],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 Error(`FontVariant(${typeof this})::_getFallbackCharacter() is abstract and should therefore be overridden.`)}getGeometricGlyph(e,t){throw 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(let t in e){let n=this.getTypographicGlyph(t),r=e[t];for(let i in r)n[`_`+i]=e[t][i]}}_checkReadiness(){this._readyCondition()&&Oe(this)}_alterElementProperties(e){throw Error(`FontVariant(${typeof this})::_alterElementProperties() is abstract and should therefore be overridden.`)}_readyCondition(){throw Error(`FontVariant(${typeof this})::_readyCondition() is abstract and should therefore be overridden.`)}},De={type:`ready`};function Oe(e){e._isReady=!0,e.dispatchEvent(De)}var E=Ee,ke=class extends v{constructor(e=null){super(`font`,e,!1),this._needsUpdate=!1,this._fontVariant=null,this._handleFontReadyClosure=null,this.isValid=Ae}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 E)this._fontVariant=this._value;else{let t=e._fontFamily._value;t&&(this._fontVariant=t.getVariant(e._fontWeight._value,e._fontStyle._value))}this._fontVariant&&(this._fontVariant._alterElementProperties(e),this._handleFontReadyClosure=je(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),null),this._value=null,this._fontVariant=null}};function Ae(e){return e instanceof E?!0:(console.warn(`.font value '${e}' is not valid. It requires a FontVariant instance. Aborted`),!1)}function je(e,t){return function(){t._needsUpdate=!0,e._glyphs._needsProcess=!0,t._fontVariant.removeEventListener(`ready`,t._handleFontReadyClosure),t._handleFontReadyClosure=null}}var Me=class extends x{constructor(e){super(`display`,e),this._value=`flex`,this._allowsInherit=!1,this._needsUpdate=!1,this.isValidValue=Pe}computeOutputValue(e){e._visible._value=this._output!==`none`}},Ne=[`none`,`flex`];function Pe(e){return Ne.indexOf(e)===-1?(console.warn(`(.style) display value '${e}' is not valid. Aborted`),!1):!0}var Fe=class extends x{constructor(e){super(`boxSizing`,e),this._allowsInherit=!1,this.isValidValue=Le}computeOutputValue(e){this._value=this._inheritedInput,e._bounds._needsUpdate=!0}},Ie=[`border-box`,`content-box`];function Le(e){return Ie.indexOf(e)===-1?(console.warn(`(.style) boxSizing value '${e}' is not valid. Aborted`),!1):!0}var D=class extends x{constructor(e,t){super(e,t,!1),this._value=new b.Color,this.output=this._outputValue}computeOutputValue(e){this._input!==`inherit`&&this._value.set(this._input)}set inline(e){this._input=this._inline=e,this._needsUpdate=!0}},O=class extends x{constructor(e,t){super(e,t,!0),this.isValidValue=Re,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 Re(e){return e<0&&e>1?(console.warn(`(.style) styleFactorProperty('${this.id}') value '${e}' is not valid)`),!1):!0}var ze=class extends x{constructor(e){super(`backgroundImage`,e,!0),this._input=null,this._allowsInherit=!1,this._textureSize=new b.Vector2(1,1),this.isValidValue=Be}get value(){return this._value}output(e){e[this._id]=this._value,e.tSize=this._textureSize}computeOutputValue(e){if(this._value=this._inheritedInput,this._value instanceof b.Texture&&!this._value.image){console.warn(`ThreeMeshUI - .backgroundImage :: Please provide preloaded texture in order to have accurate sizing.`);return}this._needsProcess=!0}process(e){this._value?this._textureSize.set(this._value.image.width,this._value.image.height):this._textureSize.set(1,1)}};function Be(e){return!0}var Ve=class extends x{constructor(e){super(`backgroundSize`,e,!0),this.isValidValue=Ue,this.output=this._outputValue}},He=[`cover`,`contain`,`stretch`];function Ue(e){return He.indexOf(e)===-1?(console.warn(`(.style) backgroundSize value '${e}' is not valid. Aborted`),!1):!0}var We=class extends x{constructor(e){super(`overflow`,e,!0),this.isValidValue=Ke,this._clippingPlanes=null,this._renderStrategy=this._emptyRender}update(e,t){this._inline!==void 0&&this._inline!==`unset`?this._input=this._inline:this._computed!==void 0&&(this._input=this._computed),this._allowsInherit||(this._inheritedInput=this.getInheritedInput(e)),this.computeOutputValue(e);for(let t of e._children._uis)t._overflow._needsUpdate=!0;this.output(t)}output(e){e.clippingPlanes=this._clippingPlanes}computeOutputValue(e){super.computeOutputValue(e),this._value===`hidden`?this._renderStrategy=this._propagateRender:(this._renderStrategy=this._emptyRender,this._clippingPlanes=null);let t=e._parent._value;if(t!==null){let e=t._overflow;if((e._value===`hidden`||e._clippingPlanes!==null)&&!this._clippingPlanes){this._clippingPlanes=[new b.Plane(new b.Vector3(0,-1,0),1),new b.Plane(new b.Vector3(-1,0,0),1),new b.Plane(new b.Vector3(0,1,0),1),new b.Plane(new b.Vector3(1,0,0),1)];for(let e=0;ee.computeValue()),this._sideMediators.sort((e,t)=>e.value1&&this._sideMediators[0].mediate();while(this._sideMediators[0].value>1);let r=t>n?n/t:1,i=tn?n/t:1;this._valueUV.y*=e,this._valueUV.w*=e}if(n!==0){let e=t{switch(e._alignItems._value){case`inherit`:case`start`:return t/2;case`end`:return r-t/2;case`stretch`:case`center`:return r/2}})(),a=e._padding._value,o=e._borderWidth._value;i+=(-a.x+a.z)/2+(-o.x+o.z)/2,n.forEach(e=>{e.y+=i,e.forEach(e=>{e.offsetY+=i})})}},tt=[`start`,`center`,`end`,`stretch`],nt=function(e){return tt.indexOf(e)===-1?(console.warn(`(.style) alignItems value '${e}' is not valid. Aborted`),!1):!0},N=class extends x{constructor(){super(`alignItems`,`inherit`,!0),this.isValidValue=nt}},P=class extends x{constructor(){super(`textAlign`,`inherit`,!0),this.isValidValue=it}},rt=[`left`,`right`,`center`,`justify`,`justify-left`,`justify-right`,`justify-center`],it=function(e){return rt.indexOf(e)===-1?(console.warn(`(.style) textAlign value '${e}' is not valid. Aborted`),!1):!0},at=class extends x{constructor(){super(`flexDirection`,`inherit`,!0),this.isValid=st}},ot=[`row`,`row-reverse`,`column`,`column-reverse`];function st(e){return ot.indexOf(e)===-1?(console.warn(`(.style) flexDirection value '${e}' is not valid. Aborted`),!1):!0}var ct=class extends x{constructor(){super(`justifyContent`,`inherit`,!0),this.isValidValue=ut}},lt=[`start`,`center`,`end`,`space-between`,`space-around`,`space-evenly`];function ut(e){return lt.indexOf(e)===-1?(console.warn(`(.style) justifyContent value '${e}' is not valid. Aborted`),!1):!0}var dt=class extends x{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)}},ft=class extends x{constructor(){super(`position`,`static`,!0),this._allowsInherit=!1,this._value=`static`,this._needsUpdate=!1,this.computeOutputValue=this._computeFromInherited,this.isValidValue=mt}_computeFromInherited(e){super._computeFromInherited(e),e._parent._value&&(e._parent._value._children._needsProcess=!0)}},pt=[`static`,`absolute`];function mt(e){return pt.indexOf(e)===-1?(console.warn(`(.style) position value '${e}' is not valid. Aborted`),!1):!0}var ht=class extends x{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(this._inline!==void 0&&this._inline!==`unset`?this._input=this._inline:this._computed===void 0?e=this._input===`inherit`:(this._computed===this._input&&(e=!1),this._input=this._computed),e){if(this._auto=!this._input||this._input===`auto`,this._auto)this._relative=!1;else if((typeof this._input==`string`||this._input instanceof String)&&this._input.endsWith(`%`)){this._relative=!0,this._value=0;let 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(let 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(this._input!==`inherit`&&!this._auto)return this._input;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}getDefaultValue(){return 0}get value(){return this._value}},gt=class extends ht{constructor(){super(`width`)}},_t=class extends ht{constructor(){super(`height`)}computeOutputValue(e){super.computeOutputValue(e)}},vt=class extends M{constructor(){super(`textContent`),this._needsUpdate=!1}set value(e){}process(e){let t=``;for(let n=0;ne.char).join(``)}get textureWidth(){return this._textureWidth}get textureHeight(){return this._textureHeight}},Dt=class extends we{constructor(e){super(e)}get uv(){return this.typographic.uv}},Ot=class e extends Ce{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(t){return new e(this._font,{char:t,width:this._width,height:this._heigth,xadvance:this._xadvance,xoffset:this._xoffset,yoffset:this._yoffset,uv:null})}asInlineGlyph(){return new Dt(this)}},kt=class extends b.PlaneGeometry{constructor(e,t){let n=1,r=1,i=e.typographic.font.size,a=t._segments.value;n=Math.ceil(e.typographic.width/i*a),r=Math.ceil(e.typographic.height/i*a),super(e.width,e.height,n,r),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){let t=e.uv.right-e.uv.left,n=e.uv.bottom-e.uv.top,r=this.getAttribute(`uv`).array.slice(),i=[];for(let a=0;a0)},z=function(e,t,n){e.defines&&(n?e.defines[t]===void 0&&(e.defines[t]=``,e.needsUpdate=!0):e.defines[t]!==void 0&&(delete e.defines[t],e.needsUpdate=!0))},Mt=function(e,t,n){e.defines[t]&&e.defines[t]===n||(e.defines[t]=n,e.needsUpdate=!0)},B=function(e,t,n){e.userData[t]?e.userData[t].value=n:e.uniforms[t].value=n},Nt=function(e,t,n){e.userData[t].value=n},V=class e{static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||={}}static ensureUserData(e,t){e.userData.glyphMap={value:t.glyphMap},e.userData.unitRange={value:new b.Vector2}}static bindUniformsWithUserData(e,t){e.uniforms.glyphMap=t.userData.glyphMap,e.uniforms.unitRange=t.userData.unitRange}static injectShaderChunks(t){e.injectVertexShaderChunks(t),e.injectFragmentShaderChunks(t)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace(`#include `,`#include `+At),e.vertexShader=e.vertexShader.replace(`#include `,`#include `+jt),e.vertexShader=e.vertexShader.replace(`#include `,`#include `+F)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace(`#include `,`#include `+I),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include `+L)}static from(t){return class extends t{static get fontMaterialProperties(){return e.mediation}constructor(t={}){e.ensureMaterialOptions(t),super(t),e.ensureDefines(this),e.ensureUserData(this,t),this._userDefinedOnBeforeCompile=e=>{},this._onBeforeCompile=this._cumulativeOnBeforeCompile}set onBeforeCompile(e){this._userDefinedOnBeforeCompile=e}get onBeforeCompile(){return this._onBeforeCompile}_cumulativeOnBeforeCompile=t=>{e.bindUniformsWithUserData(t,this),e.injectShaderChunks(t),this._userDefinedOnBeforeCompile(t)}}}static get mediation(){return Pt}},Pt={clippingPlanes:{m:`clippingPlanes`},fontAlphaTest:{m:`alphaTest`,t:R},fontSide:{m:`side`},font:{m:`glyphMap`,t:function(e,t,n){let r=n?n.texture:null,i=n?n.unitRange:new b.Vector2;if(e[t]!==void 0){e.glyphMap=r,e.unitRange=i;return}e.userData&&e.userData.glyphMap&&(e.userData.glyphMap.value=r,e.userData.unitRange.value=i)}},color:{m:`color`},fontOpacity:{m:`opacity`},fontSmooth:{m:`NO_RGSS`,t:function(e,t,n){n&&n!==`antialiased`?e.defines.NO_RGSS=``:delete e.defines.NO_RGSS,e.needsUpdate=!0}},invertAlpha:{m:`INVERT_ALPHA`,t:z}},Ft=` ${At} #include void main() { ${jt} #include #include ${F} #include } `,It=` uniform vec3 diffuse; uniform float opacity; ${I} #include #include void main() { // instead of : vec4 diffuseColor vec4 diffuseColor = vec4( diffuse, opacity ); ${L} #include // instead of gl_FragColor = diffuseColor; #include } `,Lt=.02,Rt=class e extends b.ShaderMaterial{static get mediation(){return V.mediation}constructor(e={}){super({uniforms:{glyphMap:{value:null},diffuse:{value:null},opacity:{value:1},unitRange:{value:new b.Vector2(0,0)},alphaTest:{value:Lt}},transparent:!0,clipping:!0,vertexShader:Ft,fragmentShader:It,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===e}get alphaTest(){return this.uniforms.alphaTest.value}set alphaTest(e){this.uniforms.alphaTest.value=e}},zt=class extends E{constructor(e,t,n,r){if(super(e,t),this._unitRange=new b.Vector2(1,1),n.pages?this._buildData(n):Bt(this,n),r instanceof b.Texture)this._texture=r,this._buildTexture(r);else if(typeof r==`string`||r instanceof String)Vt(this,r);else throw Error(`ThreeMeshUI::MSDFVariant provided 'texture' parameter is '${typeof r}'. Only Texture and String allowed.`);this._defaultMaterialClass=Rt,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 Et(e),this._kernings=this._buildKerningPairs(e),this._chars=this._buildCharacters(e),this._chars[` `]=this._buildCharacterWhite(e),this._chars[` `]=this._buildCharacterWhite(e,` `,.001,1),this._chars[` `]=this._buildCharacterWhite(e,` `,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 b.Vector2(this._distanceRange,this._distanceRange).divide(new b.Vector2(e.common.scaleW,e.common.scaleH))}_buildTexture(e){e.generateMipmaps=!1,e.minFilter=b.LinearFilter,e.magFilter=b.LinearFilter,e.needsUpdate=!0}_getFallbackCharacter(e){return W.missingCharacter(this,e)}getGeometricGlyph(e,t){return new kt(e,t)}_readyCondition(){return this._chars&&this._texture&&this._texture.image}_buildKerningPairs(e){let t={};for(let n=0;n{e._buildData(t),e._checkReadiness()})}function Vt(e,t){e._texture=new b.TextureLoader().load(t,t=>{e._buildTexture(t),e._checkReadiness()})}var H=class extends b.EventDispatcher{constructor(e){super(),this._name=e,this._variants=[],this._isReady=!1}get isReady(){return this._isReady}addVariant(e,t,n,r,i=!1){if(i||!this.getVariant(e,t)){this._isReady=!1;let i=new zt(e,t,n,r);this._variants.push(i),i.isReady?this._checkReadiness():i.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=T(e),this._variants.find(n=>n.weight===e&&n.style===t)}get name(){return this._name}_checkReadiness=()=>{this._variants.every(e=>e.isReady)&&Ut(this)}},Ht={type:`ready`};function Ut(e){e._isReady=!0,e.dispatchEvent(Ht)}var U={},Wt=function(e){let t=[...arguments];t.forEach(e=>{if(!(e instanceof H))throw Error(`FontLibrary::prepare() - One of the provided parameter is not a FontFamily. Instead ${typeof e} given.`)});let n=function(){return t.every(e=>e.isReady)};return new Promise((e,r)=>{if(n())e();else for(let r=0;r{n()&&e()})}})},Gt=function(e){return U[e]&&console.error(`FontLibrary::addFontFamily - Font('${e}') is already registered`),U[e]=new H(e),U[e]},Kt=function(e){return U[e]},qt=function(e){Jt=e},Jt=function(e,t){return console.error(`The character '${t}' is not included in the font characters set.`),` `};function Yt(e,t){return Jt(e,t)}var W={addFontFamily:Gt,getFontFamily:Kt,prepare:Wt,setMissingCharacterHandler:qt,missingCharacter:Yt},Xt=class extends x{constructor(){super(`fontFamily`,`inherit`,!0)}computeOutputValue(e){if(this._input instanceof H)this._value=this._input;else if(this._input!==`inherit`)if(typeof this._input==`string`){let e=W.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(this._input!==`inherit`)return this._input;let t=e._parent._value;return t?t[`_${this._id}`].getInheritedInput(t):this.getDefaultValue()}},Zt=class extends x{constructor(){super(`lineHeight`,`inherit`,!0)}update(e,t){super.update(e,t),e._layouter._needsProcess=!0}},Qt=class extends x{constructor(){super(`whiteSpace`,`inherit`),this.isValidValue=en}},$t=[`normal`,`nowrap`,`pre`,`pre-line`,`pre-wrap`];function en(e){return $t.indexOf(e)===-1?(console.warn(`(.style) whiteSpace value '${e}' is not valid. Aborted`),!1):!0}var tn=class extends x{constructor(){super(`letterSpacing`,`inherit`,!0)}},nn=class extends x{constructor(){super(`fontSize`,`inherit`,!0)}},rn=class extends v{constructor(){super(`segments`,1,!1)}},an=class extends y{constructor(){super(`invertAlpha`,`inherit`)}},G=class extends x{constructor(){super(`fontKerning`,`inherit`),this.isValidValue=sn}},on=[`normal`,`none`,`inherit`];function sn(e){return on.indexOf(e)===-1?(console.warn(`(.style) fontKerning value '${e}' is not valid. Aborted`),!1):!0}var K=class extends y{constructor(e){super(e,`inherit`,!0)}},cn=class extends y{constructor(e){super(e,`inherit`,!1),this._mediation={},this._defaultMaterial=null}update(e,t){this._notInheritedValue=this._value,this._notInheritedValue===`inherit`?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:R},fontSide:{m:`side`},color:{m:`color`},fontOpacity:{m:`opacity`}}:this._mediation={},e._transferToFontMaterial(),this._outputValue(t)}getInheritedInput(e){if(this._value!==`inherit`)return this._value;let t=e,n=null;for(;t._parent._value;)if(t=t._parent._value,t[`_${this._id}`]._value!==`inherit`){n=t[`_${this._id}`]._value;break}return n===null?this.getDefaultValue():n}getDefaultValue(){return this._defaultMaterial}},ln=function(e,t,n){e.traverse(e=>{e.renderOrder=n})},q=class extends b.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:ln}},this._fontMesh=null,this._fontMaterial=new cn(`fontMaterial`),this._fontCustomDepthMaterial=new cn(`fontCustomDepthMaterial`),this._fontMeshMediation={fontMaterial:{m:`material`},fontCustomDepthMaterial:{m:`customDepthMaterial`,t:ge},fontCastShadow:{m:`castShadow`},fontReceiveShadow:{m:`receiveShadow`},renderOrder:{m:`renderOrder`}},this._children=e.children?new e.children:new M(`children`),this._parent=new _e,this.addEventListener(`added`,this._rebuildParentUI),this.addEventListener(`removed`,this._rebuildParentUI),this._backgroundSide=new ye(`backgroundSide`),this._fontSide=new ye(`fontSide`),this._backgroundAlphaTest=new ve(`backgroundAlphaTest`,.02),this._fontAlphaTest=new ve(`fontAlphaTest`,.02),this._visible=new Qe(`visible`,!0),this._backgroundCastShadow=new K(`backgroundCastShadow`),this._fontCastShadow=new K(`fontCastShadow`),this._backgroundReceiveShadow=new K(`backgroundReceiveShadow`),this._fontReceiveShadow=new K(`fontReceiveShadow`),this._renderOrder=new ce,this._segments=e.segments?new e.segments:new rn,this._bounds=e.bounds?new e.bounds:new M(`bounds`),this._order=new dt,this._padding=new pe,this._margin=new me,this._position=new ft,this._flexDirection=e.flexDirection?new e.flexDirection:new at,this._justifyContent=e.justifyContent?new e.justifyContent:new ct,this._alignItems=e.alignItems?new e.alignItems:new N,this._display=new Me(`flex`),this._boxSizing=new Fe(`border-box`),this._width=new gt,this._height=new _t,this._backgroundColor=e.backgroundColor?new e.backgroundColor:new $e,this._backgroundOpacity=new O(`backgroundOpacity`,.5),this._backgroundImage=new ze,this._backgroundSize=new Ve(`cover`),this._color=e.color?new e.color:new D(`color`,`inherit`),this._fontOpacity=new O(`fontOpacity`,`inherit`),this._whiteSpace=e.whiteSpace?new e.whiteSpace:new Qt,this._fontFamily=e.fontFamily?new e.fontFamily:new Xt,this._fontStyle=e.fontStyle?new e.fontStyle:new yt(`normal`),this._fontWeight=e.fontWeight?new e.fontWeight:new St,this._fontSize=e.fontSize?new e.fontSize:new nn,this._lineHeight=e.lineHeight?new e.lineHeight:new Zt,this._fontKerning=e.fontKerning?new e.fontKerning:new G,this._letterSpacing=e.letterSpacing?new e.letterSpacing:new tn,this._overflow=new We(`visible`),this._borderRadius=new Xe(0),this._borderWidth=new Ze(0),this._borderColor=new D(`borderColor`,16711935),this._borderOpacity=new O(`borderOpacity`,1),this._font=new ke,this._lineBreak=e.lineBreak?new e.lineBreak:new M(`lineBreak`),this._textContent=e.textContent?new e.textContent:new vt,this._glyphs=e.glyphs?new e.glyphs:new M(`glyphs`),this._inlines=e.inlines?new e.inlines:new M(`inlines`),this._layouter=e.layouter?new e.layouter:new M(`layouter`),this._inlineJustificator=new et,this._textAlign=e.textAlign?new e.textAlign:new P,this._autoSize=e.autoSize?new e.autoSize:new M(`autoSize`),this._renderer=e.renderer?new e.renderer:new M(`renderer`),this._offset=new le,this._invertAlpha=new an,this._fontSmooth=e.fontSmooth?new e.fontSmooth:new ue,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||=0,t&&this.set(t)}update(){let e={};for(let t of this._components)t._needsUpdate&&=(t.update(this,e),!1);this._transferToBackgroundMesh(e),this._transferToFontMesh(e),this._transferToBackgroundMaterial(e),this._transferToFontMaterial(e);for(let e of this._children._uis)e.update()}process(){for(let e of this._children._uis)e.process();for(let e of this._components)e._needsProcess&&=(e.process(this),!1)}render(){for(let e=0;e{this._parent._needsUpdate=!0,this.parent&&!this.parent.isUI?(J.register(this),this.activatePseudoState(`root`)):(J.remove(this),this.deactivatePseudoState(`root`))};add(e){let t=!1;for(let e=0;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,B(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(let t of this._components)t.output(e)}C.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){let t=this._fontMaterial.value;if(t){if(!e){e={};for(let t of this._components)t.output(e)}C.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(let t of this._components)t.output(e)}C.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&&B(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(let t of this._components)t.output(e)}C.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){let t=this._onAfterUpdates.indexOf(e);t!==-1&&this._onAfterUpdates.splice(t,1)}performAfterUpdate(){for(let e=0;e 0.0 && vUvB.y > topBorderUVy ) { float w = fwidth( 1.0 - vUvB.y ) * mult; float step = smoothstep( topBorderUVy , topBorderUVy + w , vUvB.y ); diffuseColor = mix( diffuseColor, borderColor, step ); } // Left float leftBorderUVx = borderWidth.w; if( borderWidth.w > 0.0 && vUvB.x < leftBorderUVx ) { float w = fwidth( vUvB.x ) * mult ; float step = smoothstep( leftBorderUVx , leftBorderUVx - w , vUvB.x ); diffuseColor = mix( diffuseColor, borderColor, step ); } // Bottom float bottomBorderUVy = borderWidth.z; if( borderWidth.z > 0.0 && vUvB.y < bottomBorderUVy ) { float w = fwidth( vUvB.y ) * mult; float step = smoothstep( bottomBorderUVy , bottomBorderUVy - w , vUvB.y ); diffuseColor = mix( diffuseColor, borderColor, step ); } // Right float rightBorderUVx = 1.0 - borderWidth.y; if( borderWidth.y > 0.0 && vUvB.x > rightBorderUVx ) { float w = fwidth( 1.0 - vUvB.x ) * mult; float step = smoothstep( rightBorderUVx , rightBorderUVx + w , vUvB.x ); diffuseColor = mix( diffuseColor, borderColor, step ); } // Step 2 ---------------------------------------------- // Process each corners ( topLeft, topRight, bottomRight, bottomLeft ) // To transparentize outside radiuses // To draw ellipse border on the corner // Top Left corner if( vUvB.x < cornerTL.x && vUvB.y > cornerTL.y ) { // Only draw border if width is set if( borderWidth.w + borderWidth.x > 0.0 ){ float borderFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x - borderWidth.w, ( 1.0 - cornerTL.y ) - borderWidth.x ); float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor ); diffuseColor = mix( diffuseColor, borderColor, step ); } // Then then radius float radiusFactor = getEllipticFactor( vUvB, cornerTL, cornerTL.x, 1.0 - cornerTL.y ); float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor ); diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep ); } // Bottom Left if( vUvB.x < cornerBL.x && vUvB.y < cornerBL.y ) { if( borderWidth.w + borderWidth.z > 0.0 ){ float borderFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x - borderWidth.w, cornerBL.y - borderWidth.z ); float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor ); diffuseColor = mix( diffuseColor, borderColor, step ); } float radiusFactor = getEllipticFactor( vUvB, cornerBL, cornerBL.x, cornerBL.y ); float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor ); diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep ); } // Top Right if( vUvB.x > cornerTR.x && vUvB.y > cornerTR.y ) { if( borderWidth.y + borderWidth.x > 0.0 ){ float borderFactor = getEllipticFactor( vUvB, cornerTR, ( 1.0 - cornerTR.x ) - borderWidth.y, ( 1.0 - cornerTR.y ) - borderWidth.x ); float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor ); diffuseColor = mix( diffuseColor, borderColor, step ); } float radiusFactor = getEllipticFactor( vUvB, cornerTR, 1.0 - cornerTR.x, 1.0 - cornerTR.y ); float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor ); diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep ); } // Bottom Right if( vUvB.x > cornerBR.x && vUvB.y < cornerBR.y ) { if( borderWidth.y + borderWidth.z > 0.0 ){ float borderFactor = getEllipticFactor( vUvB, cornerBR, ( 1.0 - cornerBR.x ) - borderWidth.y, cornerBR.y - borderWidth.z ); float step = smoothstep( 1.0, 1.0 + fwidth( borderFactor ) * mult, borderFactor ); diffuseColor = mix( diffuseColor, borderColor, step ); } float radiusFactor = getEllipticFactor( vUvB, cornerBR, 1.0 - cornerBR.x, cornerBR.y ); float alphaStep = smoothstep( 1.0 , 1.0 + fwidth(radiusFactor) * mult , radiusFactor ); diffuseColor.a = mix( diffuseColor.a, 0.0, alphaStep ); } `,fn=` // To be removed - required for both border and background uniform vec3 frameSize; uniform vec2 textureSize; `,pn=` #ifdef USE_MAP vec4 sampleTexture() { vec2 uv = vUv; // default stretch #if BACKGROUND_MAPPING != 0 float textureRatio = textureSize.x / textureSize.y; float panelRatio = frameSize.x / frameSize.y; float ratio = panelRatio / textureRatio; float ratio2 = textureRatio / panelRatio; // contain #if BACKGROUND_MAPPING == 1 if ( textureRatio < panelRatio ) { // repeat on X float newX = uv.x * ratio; newX += 0.5 - 0.5 * ratio; uv.x = newX; } else { // repeat on Y float newY = uv.y * ratio2; newY += 0.5 - 0.5 * ratio2; uv.y = newY; } #else // cover if ( textureRatio < panelRatio ) { // stretch on Y float newY = uv.y * ratio2; newY += 0.5 - 0.5 * ratio2; uv.y = newY; } else { // stretch on X float newX = uv.x * ratio; newX += 0.5 - 0.5 * ratio; uv.x = newX; } #endif #endif return texture2D( map, uv ); } #endif `,mn=` #ifdef USE_MAP vec4 textureSample = sampleTexture(); diffuseColor *= textureSample; #endif `,hn={msdfAlphaglyphParsVertexGlsl:At,msdfAlphaglyphVertexGlsl:jt,msdfOffsetglyphVertexGlsl:F,msdfAlphaglyphParsFragmentGlsl:I,msdfAlphaglyphFragmentGlsl:L,frameBorderParsVertexGlsl:Y,frameBorderVertexGlsl:X,frameCommonParsFragmentGlsl:fn,frameBorderParsFragmentGlsl:un,frameBorderFragmentGlsl:dn,frameBackgroundParsFragmentGlsl:pn,frameBackgroundFragmentGlsl:mn},gn=` // Would be automatic on three materials and from USE_UV #ifdef USE_MAP varying vec2 vUv; #endif ${Y} #include void main() { #ifdef USE_MAP vUv = uv; #endif ${X} vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 ); gl_Position = projectionMatrix * mvPosition; #include } `,_n=` // Basic uniform vec3 diffuse; uniform float opacity; #ifdef USE_ALPHATEST uniform float alphaTest; #endif ${fn} ${un} #ifdef USE_MAP varying vec2 vUv; uniform sampler2D map; #endif ${pn} #include void main() { vec4 diffuseColor = vec4( diffuse, opacity ); // map ${mn} ${dn} #ifdef USE_ALPHATEST if ( diffuseColor.a < alphaTest ) discard; #endif // output gl_FragColor = diffuseColor; #include } `,vn=class e{static get mediation(){return yn}static ensureMaterialOptions(e){e.transparent=!0,e.alphaTest=e.alphaTest||.02}static ensureDefines(e){e.defines||={}}static ensureUserData(e,t){e.userData.borderColor={value:null},e.userData.borderRadius={value:new b.Vector4(0,0,0,0)},e.userData.cornerTL={value:new b.Vector2(0,1)},e.userData.cornerTR={value:new b.Vector2(1,1)},e.userData.cornerBR={value:new b.Vector2(1,0)},e.userData.cornerBL={value:new b.Vector2(0,0)},e.userData.borderWidth={value:new b.Vector4(0,0,0,0)},e.userData.borderOpacity={value:null},e.userData.frameSize={value:new b.Vector3(1,1,1)},e.userData.textureSize={value:new b.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(t){e.injectVertexShaderChunks(t),e.injectFragmentShaderChunks(t)}static injectVertexShaderChunks(e){e.vertexShader=e.vertexShader.replace(`#include `,`#include `+Y),e.vertexShader=e.vertexShader.replace(`#include `,`#include `+X)}static injectFragmentShaderChunks(e){e.fragmentShader=e.fragmentShader.replace(`#include `,`#include `+pn),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include `+un),e.fragmentShader=e.fragmentShader.replace(`#include `,`#include `+fn),e.fragmentShader=e.fragmentShader.replace(`#include `,mn),e.fragmentShader=e.fragmentShader.replace(`#include `,dn+` #include `)}},yn={clippingPlanes:{m:`clippingPlanes`},backgroundAlphaTest:{m:`alphaTest`,t:R},backgroundSide:{m:`side`},backgroundImage:{m:`map`},backgroundColor:{m:`color`},backgroundOpacity:{m:`opacity`},backgroundSize:{m:`computedBackgroundSize`,t:function(e,t,n){n=[`stretch`,`contain`,`cover`].indexOf(n),Mt(e,`BACKGROUND_MAPPING`,n)}},borderWidth:{m:`borderWidth`,t:B},borderColor:{m:`borderColor`,t:B},cornerTL:{m:`cornerTL`,t:B},cornerTR:{m:`cornerTR`,t:B},cornerBR:{m:`cornerBR`,t:B},cornerBL:{m:`cornerBL`,t:B},borderOpacity:{m:`borderOpacity`,t:B},size:{m:`frameSize`,t:B},tSize:{m:`textureSize`,t:B}},bn=class extends b.ShaderMaterial{static get mediation(){return vn.mediation}constructor(){super({uniforms:{alphaTest:{value:.02},map:{value:null},diffuse:{value:new b.Color(16777215)},opacity:{value:1},borderColor:{value:new b.Color(0)},borderOpacity:{value:0},borderRadius:{value:new b.Vector4(0,0,0,0)},cornerTL:{value:new b.Vector2(0,1)},cornerTR:{value:new b.Vector2(1,1)},cornerBR:{value:new b.Vector2(1,0)},cornerBL:{value:new b.Vector2(0,0)},borderWidth:{value:new b.Vector4(0,0,0,0)},frameSize:{value:new b.Vector3(1,1,1)},textureSize:{value:new b.Vector2(1,1)}},side:b.FrontSide,transparent:!0,clipping:!0,vertexShader:gn,fragmentShader:_n,extensions:{derivatives:!0}}),this.defines.USE_ALPHATEST=``,this.needsUpdate=!0}set map(e){this.uniforms.map.value=e,e?this.defines.USE_UV===void 0&&(this.defines.USE_UV=``,this.needsUpdate=!0):this.defines.USE_UV!==void 0&&(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}},xn=class extends v{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._valuet._order._value?1:this._uis.indexOf(e){let n=t._margin._value;return e+(t._bounds._offsetWidth+n.y+n.w)},0)}function Tn(e){return e._children._boxes.reduce((e,t)=>{let n=t._margin._value;return e+(t._bounds._offsetHeight+n.x+n.z)},0)}var En=class extends N{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=Nn,this._value){case`start`:this._childAlign=kn;break;case`end`:this._childAlign=On;break;default:this._childAlign=Dn}break;case`column`:case`column-reverse`:switch(this._process=Mn,this._value){case`start`:this._childAlign=jn;break;case`end`:this._childAlign=An;break;default:this._childAlign=Dn}break}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`,n=`center`,r=`center`,i=e._padding._value,a=e._borderWidth._value;t=e._flexDirection._value.indexOf(`column`)===-1?this._value===`start`?r=`top`:this._value===`end`?r=`bottom`:`centerY`:this._value===`start`?n=`left`:this._value===`end`?n=`right`:`centerX`;let o=-(i.x-i.z)/2-(a.x-a.z)/2,s=-(i.y-i.w)/2-(a.y-a.w)/2;n===`left`?s=(i.w-i.y)/2+(a.w-a.y)/2:n===`right`&&(s=-(i.y-i.w)/2-(a.y-a.w)/2),r===`top`?o=-(i.x-i.z)/2-(a.x-a.z)/2:r===`bottom`&&(o=(i.z-i.x)/2+(a.z-a.x)/2),e._children._boxes.forEach(n=>{let r=0,i=0;t===`top`?i=-n._margin._value.x:t===`bottom`?i=n._margin._value.z:t===`left`?r=n._margin._value.w:t===`right`?r=-n._margin._value.y:t===`centerX`?r=(n._margin._value.w-n._margin._value.y)/2:t===`centerY`&&(i=(-n._margin._value.x+n._margin._value.z)/2),e._layouter._childrenPos[n.id].x+=s+r,e._layouter._childrenPos[n.id].y+=o+i})}};function Dn(){return 0}function On(e,t){return-t+e._bounds._offsetHeight/2}function kn(e,t){return t-e._bounds._offsetHeight/2}function An(e,t){return t-e._bounds._offsetWidth/2}function jn(e,t){return-t+e._bounds._offsetWidth/2}function Mn(e,t){let n=e._bounds._innerWidth/2;e._children._boxes.forEach(r=>{e._layouter._childrenPos[r.id].x=t(r,n)})}function Nn(e,t){let n=e._bounds._innerHeight/2;e._children._boxes.forEach(r=>{e._layouter._childrenPos[r.id].y=t(r,n)})}var Pn=class extends at{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=Fn;break;case`row-reverse`:this._process=In;break;case`column`:this._process=Ln;break;case`column-reverse`:this._process=Rn;break}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;break}this._reverse=-Math.sign(this._offset),this._reverse===0&&(this._reverse=1),this._process(e),e._justifyContent._needsProcess=!0,e._layouter._needsProcess=!0}};function Fn(e){let t=e._flexDirection._offset,n=e._flexDirection._reverse,r=e._children._boxes;for(let i=0;i{e._layouter._childrenPos[t.id].x-=a-o[n]})}function Vn(e){let t=e._flexDirection._offset,{usedDirectionSpace:n,remainingSpace:r}=Un(e),i=t*2-n*Math.sign(t),a=this._computeOffset(i),o=this._computeMargin(e,r,e._flexDirection._reverse);e._children._boxes.forEach((t,n)=>{e._layouter._childrenPos[t.id].y-=a-o[n]})}function Hn(e){let t=e._bounds._computeChildrenSideWidth(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerWidth-t}}function Un(e){let t=e._bounds._computeChildrenSideHeight(e);return{usedDirectionSpace:t,remainingSpace:e._bounds._innerHeight-t}}function Q(e){return 0}function Wn(e){return e}function Gn(e){return e/2}function Kn(e,t=0,n=1){return Array(e._children._boxes.length).fill(0)}function qn(e,t=0,n=1){let r=e._children._boxes.length,i=Array(r).fill(0);if(t>0&&r>1){let e=t/(r-1)*n;i[0]=0;for(let t=1;t0){let e=t/(r+1)*n;for(let t=0;t0){let e=t/r*n,a=e/2;i[0]=a;for(let t=1;tt&&(t=r)}return t}function ur(e){let t=0;for(let n of e._children._boxes){if(n._position._value!==`static`)continue;let e=n._margin._value,r=n._bounds._offsetHeight+e.x+e.z;r>t&&(t=r)}return t}var dr=class e extends q{constructor(t,n){e.definePropertiesValues(t,n),super(t,n),e.init(this)}bindBackgroundMeshProperties(){this._bounds._size=this._backgroundMesh.scale,this._bounds._needsProcess=!0}unbindBackgroundMeshProperties(){this._bounds._size=new b.Vector3(1,1,1),this._bounds._needsProcess=!0}static definePropertiesValues(e,t){e.children||=xn,e.bounds||=Sn,e.flexDirection||=Pn,e.justifyContent||=zn,e.alignItems||=En,e.position||=tr,e.autoSize||=nr,e.renderer||=er,t.fontSide||=0,t.invertAlpha||=!1,t.fontCastShadow||=!1,t.fontReceiveShadow||=!1,t.backgroundCastShadow||=!1,t.backgroundReceiveShadow||=!1}static init(e){Object.defineProperties(e,{isBox:{configurable:!1,enumerable:!0,value:!0}}),e.backgroundMaterial=new bn,e._renderer.render(e),e._backgroundMesh.visible=!1}},fr=class extends Array{constructor(...e){super(...e),this.width=0,this.lineBase=0,this.lineHeight=0,this.y=0}},pr=class extends v{constructor(){super(`layouter`,null,!1),this._needsUpdate=!0,this._childrenPos={}}update(e,t){this._childrenPos={};for(let t of e._children._boxes)t._position._value===`static`&&(this._childrenPos[t.id]=t.position)}process(e){}},mr=class e extends dr{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}add(e){let t=[];for(let e=0;ee.asInlineGlyph()),this._value.length){this._value[0].paddingLeft=e._padding._value.w,this._value[0].marginLeft=e._margin._value.w;let 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}},_r=class extends v{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}},vr=class extends D{constructor(){super(`color`,`inherit`,!1),this.output=this._outputValue}computeOutputValue(e){this._input===`inherit`?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}},yr=class extends v{constructor(e=`- ,.:?! `){super(`lineBreak`,e,!0),this._newLineBreakability=null}update(e,t){this._needsProcess=!0}process(e){let t=e._whiteSpace._newLineBreakability;if(e._inlines._value)for(let n=0;ne.isUI&&e.isText),this._needsProcess=!0}process(e){this._value&&(this._value._layouter._needsProcess=!0)}},xr=class extends D{constructor(e){super(`backgroundColor`,e,!1),this._allowsInherit=!1,this._input=0}computeOutputValue(e){this._input===`inherit`?this._value.set(this.getInheritedInput(e)):this._value.set(this._input)}},Sr=class extends yt{constructor(){super(),this._allowsInherit=!1,this.computeOutputValue=this._computeFromInherited}},Cr=class extends St{constructor(){super()}computeOutputValue(e){this._value=T(this.getInheritedInput(e))}},wr=class extends Xt{constructor(){super(`fontFamily`,`inherit`,!0),this._input=`inherit`,this._needsUpdate=!0,this._allowsInherit=!1}computeOutputValue(e){let t=this._inheritedInput;if(t===`inherit`&&(t=this.getInheritedInput(e)),t instanceof H)this._value=t,e._font._needsUpdate=!0;else if(typeof t==`string`){let n=W.getFontFamily(t);n?(this._value=n,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}},Tr=class extends Qt{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=Dr(this._value),this._value){case`nowrap`:case`normal`:this._stringCollapser=Or;break;case`pre-line`:this._stringCollapser=kr;break;default:this._stringCollapser=Ar}switch(this._value){case`pre-line`:case`nowrap`:case`normal`:this._inlineCollapser=Fr;break;case`pre-wrap`:this._inlineCollapser=Pr;break;default:this._inlineCollapser=Ir}switch(this._value){case`pre-line`:case`pre-wrap`:case`normal`:this._inlineWrapper=jr;break;case`pre`:this._inlineWrapper=Mr;break;default:this._inlineWrapper=Nr}this._needsProcess=!0}process(e){e.isInline&&!e.isInlineBlock&&(this._whiteSpacedContent=this._stringCollapser(e._textContent._value),e._glyphs._needsProcess=!0)}},Er={" ":` `,"\n":` `,"\r":`\r`," ":` `},Dr=function(e){switch(e){case`pre`:case`pre-wrap`:case`pre-line`:return`mandatory`}return null};function Or(e){return kr(e.replace(/\n/g,` `))}function kr(e){return e.replace(/[ ]{2,}/g,` `)}function Ar(e){return e}function jr(e,t,n,r){let i=e[t];if(i.lineBreak===`mandatory`||n+i.xadvance+i.xoffset+i.kerning>r.INNER_WIDTH)return!0;let a=zr(e,t,r);return Br(e[t-1],n,a,r)}function Mr(e,t,n,r){return e[t].lineBreak===`mandatory`}function Nr(){return!1}function Pr(e){if(!e[0])return 0;let t=e[0],n=e[e.length-1];return t.char&&t.char===` `&&e.length>1&&Rr([t],e[1]),n.char&&n.char===` `&&e.length>1&&Lr([n],e[e.length-2]),t.offsetX}function Fr(e){if(!e[0])return 0;let t=[],n;for(let r=0;rr){t.push(i),n=e[r+1];continue}break}Rr(t,n),t=[],n=null;for(let r=e.length-1;r>0;r--){let i=e[r];if(i.char&&Er[i.char]&&r>0){t.push(i),n=e[r-1];continue}break}return Lr(t,n),e[0].offsetX}function Ir(e){return e[0]?e[0].offsetX:0}function Lr(e,t){if(t)for(let n=0;n-1}var Vr=class extends tn{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}},Hr=class extends x{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;let t=this._value/e._font._fontVariant.typographic.size,n=e._inlines._value;for(let e=0;ee._font._fontVariant.getGeometricGlyph(t,e).translate(t.offsetX,t.offsetY,0)));e.setFontMesh(new b.Mesh(t,e.fontMaterial)),e._fontMesh.renderOrder=1/0}},Xr=class extends P{constructor(){super(),this._allowsInherit=!1,this._needsUpdate=!1}computeOutputValue(e){this._value=this._inheritedInput,e._layouter._needsProcess=!0}},Zr=class e extends q{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}add(e){let t=[];for(let e=0;e{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||=Kr,e.textContent||=hr,e.glyphs||=_r,e.inlines||=gr,e.layouter||=br,e.renderer||=Yr,e.fontFamily||=wr,e.fontWeight||=Cr,e.fontStyle||=Sr,e.fontSize||=Hr,e.color||=vr,e.backgroundColor||=xr,e.lineBreak||=yr,e.letterSpacing||=Vr,e.whiteSpace||=Tr,e.segments||=Wr,e.textAlign||=Xr,e.fontKerning||=Gr}static init(e){Object.defineProperties(e,{isInline:{configurable:!1,enumerable:!0,value:!0}})}},Qr=class extends vt{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--){let n=e.children[t];n.isUI&&(e.remove(n),n.clear())}e._children._uis=[],this._value&&e.add(new Zr({name:`anonymousInline`,textContent:this._value}))}},$r=class extends Array{constructor(...e){super(...e),this.width=0,this.height=0}},ei=class extends v{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;let n=e._lineHeight._value,r=new $r(new fr),i=0;e._children._inlines.forEach(e=>{if(!e._inlines.value)return;this._resetInlines(e);let n=e._fontSize._value,a=e._letterSpacing._value*n,o={WHITESPACE:e._whiteSpace._value,LETTERSPACING:a,BREAKON:e._lineBreak._value,INNER_WIDTH:t},s=e._whiteSpace._inlineWrapper;i+=e._margin._value.w+e._padding._value.w,e._inlines.value.forEach((e,t,n)=>{let c=r[r.length-1];if(s(n,t,i,o)){if(r.push(new fr(e)),e.offsetX=e.xoffset,e.width===0){i=0;return}e.cumulativeWidth=e.xadvance+a,i=e.cumulativeWidth;return}r[r.length-1].push(e),e.offsetX=i+e.xoffset+e.kerning,e.cumulativeWidth=e.xadvance+e.kerning+a,i+=e.cumulativeWidth,c.length-1==1&&c[c.length-2].width===0&&(e.offsetX-=e.xoffset,i-=e.xoffset)}),i+=e._margin._value.y+e._padding._value.y});let a=e._whiteSpace._inlineCollapser,o=0,s=0,c=0;r.forEach((e,t)=>{let i=a(e),l=0,u=0;if(e.forEach(e=>{l=Math.max(l,e.lineHeight),u=Math.max(u,e.lineBase),e.offsetX-=i}),e.lineHeight=l,e.lineBase=u,t===0?c=-(l*n-l)*.5:c-=r[t-1].lineHeight*n,e.y=c,e.x=0,e.forEach(t=>{t.offsetY=c-t.anchor,t.lineHeighte.visible&&e.isUI),this._inlines=this._uis.filter(e=>e.isInline).sort(this._sortOrder)}dispose(){this._inlines=null}_sortOrder=(e,t)=>e._order._valuet._order._value?1:this._uis.indexOf(e)0&&super.add(...t),n&&(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=ii,e.justifyContent=ct,e.alignItems=N,e.bounds=si,e.autoSize=li,e.renderer=ui,e.children||=ci,e.textContent||=Qr,e.layouter||=ei,e.lineHeight||=ai,e.textAlign||=ti,e.whiteSpace||=Tr,e.fontKerning||=oi,e.segments||=Ur,t.width||=`100%`,t.fontSide||=0}static init(e){Object.defineProperties(e,{isText:{configurable:!1,enumerable:!0,value:!0}})}},fi=class extends v{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;let t=this._value.length-1;this._value[t].paddingRight=e._padding._value.y,this._value[t].marginRight=e._margin._value.y}},pi=class extends v{constructor(){super(`renderer`)}render(e){e._backgroundMesh||e.setBackgroundMesh(new Zn(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)}},mi=class extends v{constructor(){super(`bounds`,null,!1),this._size=new b.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}},hi=class e extends q{constructor(t={}){let n={};e.definePropertiesValues(n,t),super(n,t),e.init(this)}clear(){for(let 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 b.Vector3(1,1,1),this._bounds._needsUpdate=!0}add(e){let t=[];for(let e=0;eJ.update(),yi={BaseProperty:v,Block:mr,Text:di,Inline:Zr,InlineBlock:hi,MeshUIBaseElement:q,FontLibrary:W,update:vi,MSDFFontMaterialUtils:V,ShaderChunkUI:hn,Behavior:_i,FontVariant:E};typeof global<`u`&&(global.ThreeMeshUI=yi);var bi=yi,xi=m.ti,Si=m.nS,Ci=m.eB,wi=m.Yp,Ti=m.VB,Ei=m.BC,Di=m.zN,Oi=m.cV,ki=m.hW,Ai=m.k2,ji=m.K6,Mi=m.M7,Ni=m.ls,Pi=m.Hi,Fi=m.EY,Ii=m.MR,Li=m.zf,Ri=m.Ay,zi=m.yo,Bi=class extends Si{constructor(e,t={}){super(e),e._simpleState__activeStates=[],e._simpleState__normalStyles={},e._simpleState__states=t,e._simpleState__statesProperties={};for(let n in t)for(let r in t[n])e._simpleState__statesProperties[r]||(e._simpleState__statesProperties[r]=[]),e._simpleState__statesProperties[r].push(n);for(let t of e._components)e._simpleState__statesProperties[t.id]&&(e._simpleState__normalStyles[t.id]=t.inline?t.inline:t._value);e.__overridedSet=e.set,e.set=this.storeSet.bind(e),e.renderStates=this.renderStates.bind(e),e.setupState=this.setupState.bind(e),e.setState=this.setState.bind(e),e.activatePseudoState=this.activatePseudoState.bind(e),e.deactivatePseudoState=this.deactivatePseudoState.bind(e),e.togglePseudoState=this.togglePseudoState.bind(e)}act(){}attach(){}detach(){}setupState(e,t){this._simpleState__states[e]=t;let n=[];for(let r in t)this._simpleState__statesProperties[r]||(this._simpleState__statesProperties[r]=[],n.push(r)),this._simpleState__statesProperties[r].push(e);for(let e of this._components)n.indexOf(e.id)>-1&&(this._simpleState__normalStyles[e.id]=e.inline?e.inline:e._value)}renderStates(){let e={...this._simpleState__normalStyles};for(let t in this._simpleState__states)this._simpleState__activeStates.indexOf(t)>-1&&(e={...e,...this._simpleState__states[t]});this.set(e,!1)}storeSet(e,t=!0){if(t)for(let t in e)this._simpleState__statesProperties[t]&&(this._simpleState__normalStyles[t]=e[t]);this.__overridedSet(e)}activatePseudoState(e){this._simpleState__activeStates.indexOf(e)===-1&&(this._simpleState__activeStates.push(e),this.renderStates())}deactivatePseudoState(e){let t=this._simpleState__activeStates.indexOf(e);t>-1&&(this._simpleState__activeStates.splice(t,1),this.renderStates())}togglePseudoState(e){let t=this._simpleState__activeStates.indexOf(e);t>-1?this._simpleState__activeStates.splice(t,1):this._simpleState__activeStates.push(e),this.renderStates()}setState(e){Array.isArray(e)?this._simpleState__activeStates=e:this._simpleState__activeStates=[e],this.renderStates()}};export{Fi as a,ae as c,Oi as i,Ci as n,Ri as o,Ti as r,zi as s,Bi as t};