babylonjs-node-editor 5.0.0-beta.6 → 5.0.0-beta.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -21,7 +21,7 @@ PERFORMANCE OF THIS SOFTWARE.
21
21
  /*!
22
22
  * Font Awesome Free 5.15.4 by @fontawesome - https://fontawesome.com
23
23
  * License - https://fontawesome.com/license/free (Icons: CC BY 4.0, Fonts: SIL OFL 1.1, Code: MIT License)
24
- */n(144);var J=function(e){function t(t){var n=e.call(this,t)||this;return n.props.color instanceof l.Color4?n.state={color:new l.Color3(n.props.color.r,n.props.color.g,n.props.color.b),alpha:n.props.color.a}:n.state={color:n.props.color.clone(),alpha:1},n._saturationRef=o.createRef(),n._hueRef=o.createRef(),n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return e.color.toHexString()!==this.props.color.toHexString()||t.color.toHexString()!==this.props.color.toHexString()},t.prototype.onSaturationPointerDown=function(e){this._evaluateSaturation(e),this._isSaturationPointerDown=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onSaturationPointerUp=function(e){this._isSaturationPointerDown=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.onSaturationPointerMove=function(e){this._isSaturationPointerDown&&this._evaluateSaturation(e)},t.prototype.onHuePointerDown=function(e){this._evaluateHue(e),this._isHuePointerDown=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onHuePointerUp=function(e){this._isHuePointerDown=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.onHuePointerMove=function(e){this._isHuePointerDown&&this._evaluateHue(e)},t.prototype._evaluateSaturation=function(e){var t=e.nativeEvent.offsetX,n=e.nativeEvent.offsetY,r=Math.min(1,Math.max(1e-4,t/this._saturationRef.current.clientWidth)),o=Math.min(1,Math.max(1e-4,1-n/this._saturationRef.current.clientHeight));this.props.debugMode&&(console.log("Saturation: "+r),console.log("Value: "+o));var a=this.state.color.toHSV();l.Color3.HSVtoRGBToRef(a.r,r,o,this.state.color),this.setState({color:this.state.color})},t.prototype._evaluateHue=function(e){var t=e.nativeEvent.offsetX,n=360*Math.min(.9999,Math.max(1e-4,t/this._hueRef.current.clientWidth));this.props.debugMode&&console.log("Hue: "+n);var r=this.state.color.toHSV();l.Color3.HSVtoRGBToRef(n,Math.max(r.g,.01),Math.max(r.b,.01),this.state.color),this.setState({color:this.state.color})},t.prototype.componentDidUpdate=function(){this.raiseOnColorChanged()},t.prototype.raiseOnColorChanged=function(){if(this.props.onColorChanged)if(this.props.color instanceof l.Color4){var e=l.Color4.FromColor3(this.state.color,this.state.alpha);this.props.onColorChanged(e)}else this.props.onColorChanged(this.state.color.clone())},t.prototype.render=function(){var e=this,t=this.state.color.toHexString(),n=this.state.color.toHSV(),r=new l.Color3;l.Color3.HSVtoRGBToRef(n.r,1,1,r);var a=r.toHexString(),i=this.props.color instanceof l.Color4;return o.createElement("div",{className:"color-picker-container"+(this.props.linearhint?" with-hints":"")},o.createElement("div",{className:"color-picker-saturation",onPointerMove:function(t){return e.onSaturationPointerMove(t)},onPointerDown:function(t){return e.onSaturationPointerDown(t)},onPointerUp:function(t){return e.onSaturationPointerUp(t)},ref:this._saturationRef,style:{background:a}},o.createElement("div",{className:"color-picker-saturation-white"}),o.createElement("div",{className:"color-picker-saturation-black"}),o.createElement("div",{className:"color-picker-saturation-cursor",style:{top:"".concat(-100*n.b+100,"%"),left:"".concat(100*n.g,"%")}})),o.createElement("div",{className:"color-picker-hue"},o.createElement("div",{className:"color-picker-hue-color",style:{background:t}}),o.createElement("div",{className:"color-picker-hue-slider",ref:this._hueRef,onPointerMove:function(t){return e.onHuePointerMove(t)},onPointerDown:function(t){return e.onHuePointerDown(t)},onPointerUp:function(t){return e.onHuePointerUp(t)}},o.createElement("div",{className:"color-picker-hue-cursor",style:{left:"".concat(n.r/360*100,"%"),border:"1px solid "+a}}))),o.createElement("div",{className:"color-picker-rgb"},o.createElement("div",{className:"red"},o.createElement(K,{label:"R",min:0,max:255,value:Math.round(255*this.state.color.r),onChange:function(t){e.state.color.r=t/255,e.forceUpdate()}})),o.createElement("div",{className:"green"},o.createElement(K,{label:"G",min:0,max:255,value:Math.round(255*this.state.color.g),onChange:function(t){e.state.color.g=t/255,e.forceUpdate()}})),o.createElement("div",{className:"blue"},o.createElement(K,{label:"B",min:0,max:255,value:Math.round(255*this.state.color.b),onChange:function(t){e.state.color.b=t/255,e.forceUpdate()}})),o.createElement("div",{className:"alpha"+(i?"":" grayed")},o.createElement(K,{label:"A",min:0,max:255,value:Math.round(255*this.state.alpha),onChange:function(t){e.setState({alpha:t/255}),e.forceUpdate()}}))),o.createElement("div",{className:"color-picker-hex"},o.createElement("div",{className:"color-picker-hex-label"},"Hex"),o.createElement("div",{className:"color-picker-hex-value"},o.createElement($,{expectedLength:6,value:t,onChange:function(t){e.setState({color:l.Color3.FromHexString(t)})}}))),this.props.linearhint&&o.createElement("div",{className:"color-picker-warning"},"(Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))"))},t}(o.Component),ee=function(e){function t(t){var n=e.call(this,t)||this;return n.state={pickerEnabled:!1,color:n.props.value,hex:n.props.value.toHexString()},n._floatRef=o.createRef(),n._floatHostRef=o.createRef(),n}return u(t,e),t.prototype.syncPositions=function(){var e=this._floatRef.current,t=this._floatHostRef.current;if(e&&t){var n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().height;n+r+10>window.innerHeight&&(n=window.innerHeight-r-10),e.style.top=n+"px",e.style.left=t.getBoundingClientRect().left-e.getBoundingClientRect().width+"px"}},t.prototype.shouldComponentUpdate=function(e,t){var n=e.value.toHexString()!==this.props.value.toHexString()||t.hex!==this.state.hex||t.pickerEnabled!==this.state.pickerEnabled;return e.value.toHexString()!==this.props.value.toHexString()&&(t.color=e.value,t.hex=e.value.toHexString()),n},t.prototype.componentDidUpdate=function(){this.syncPositions()},t.prototype.componentDidMount=function(){this.syncPositions()},t.prototype.setPickerState=function(e){this.setState({pickerEnabled:e}),this.props.globalState.blockKeyboardEvents=e},t.prototype.render=function(){var e=this,t=this.state.color;return this.props.globalState.blockKeyboardEvents=this.state.pickerEnabled,o.createElement("div",{className:"color-picker"},o.createElement("div",{className:"color-rect",ref:this._floatHostRef,style:{background:this.state.hex},onClick:function(){return e.setPickerState(!0)}}),this.state.pickerEnabled&&o.createElement(o.Fragment,null,o.createElement("div",{className:"color-picker-cover",onClick:function(){return e.setPickerState(!1)}}),o.createElement("div",{className:"color-picker-float",ref:this._floatRef},o.createElement(J,{color:t,onColorChanged:function(t){var n=t.toHexString();e.setState({hex:n,color:t}),e.props.onColorChanged(n)}}))))},t}(o.Component),te=n(52),ne=n(74),re=n(75),oe=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,color:n.props.target[n.props.propertyName].clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!(n.equals(t.color)&&!this._localChange)&&(t.color=n.clone(),this._localChange=!1,!0)},t.prototype.onChange=function(e){this._localChange=!0;var t="Color4"===this.props.target[this.props.propertyName].getClassName()?l.Color4.FromHexString(e):l.Color3.FromHexString(e);this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:t,initialValue:this.state.color}),this.props.target[this.props.propertyName]=t,this.setState({color:t}),this.props.onChange&&this.props.onChange()},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.color,initialValue:e})},t.prototype.updateStateR=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].x=e,this.state.color.r=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateG=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].g=e,this.state.color.g=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateB=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].b=e,this.state.color.b=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.copyToClipboard=function(){var e=document.createElement("div");if(e.textContent=this.state.color.toHexString(),document.body.appendChild(e),window.getSelection){var t=document.createRange();t.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}document.execCommand("copy"),e.remove()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?re:ne;return o.createElement("div",{className:"color3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"color3"},o.createElement(ee,{value:this.state.color,globalState:this.props.globalState,onColorChanged:function(t){e.onChange(t)}})),o.createElement("div",{className:"copy hoverIcon",onClick:function(){return e.copyToClipboard()},title:"Copy to clipboard"},o.createElement("img",{src:te,alt:""})),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},o.createElement("img",{src:t,alt:""}))),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"r",value:this.state.color.r,onChange:function(t){return e.updateStateR(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"g",value:this.state.color.g,onChange:function(t){return e.updateStateG(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"b",value:this.state.color.b,onChange:function(t){return e.updateStateB(t)}})))},t}(o.Component),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(oe,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),ie=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,value:n.props.target[n.props.propertyName].clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!(n.equals(t.value)&&!this._localChange)&&(t.value=n.clone(),this._localChange=!1,!0)},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateVector3=function(){var e=this.props.target[this.props.propertyName].clone();this.props.target[this.props.propertyName]=this.state.value,this.setState({value:e}),this.raiseOnPropertyChanged(e)},t.prototype.updateStateX=function(e){this._localChange=!0,this.state.value.x=e,this.updateVector3()},t.prototype.updateStateY=function(e){this._localChange=!0,this.state.value.y=e,this.updateVector3()},t.prototype.updateStateZ=function(e){this._localChange=!0,this.state.value.z=e,this.updateVector3()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?o.createElement(q,{icon:X}):o.createElement(q,{icon:G});return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"vector"},"X: ".concat(this.state.value.x.toFixed(2),", Y: ").concat(this.state.value.y.toFixed(2),", Z: ").concat(this.state.value.z.toFixed(2))),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},t)),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"x",step:this.props.step,value:this.state.value.x,onChange:function(t){return e.updateStateX(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"y",step:this.props.step,value:this.state.value.y,onChange:function(t){return e.updateStateY(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"z",step:this.props.step,value:this.state.value.z,onChange:function(t){return e.updateStateZ(t)}})))},t.defaultProps={step:.001},t}(o.Component),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(ie,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),se=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,value:(n.props.value||n.props.target[n.props.propertyName]).clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.value||e.target[e.propertyName];return!(n.equals(t.value)&&!this._localChange)&&(t.value=n.clone(),this._localChange=!1,!0)},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.propertyName&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateVector4=function(){var e=(this.props.value||this.props.target[this.props.propertyName]).clone();this.props.value?this.props.value.copyFrom(this.state.value):this.props.target[this.props.propertyName]=this.state.value,this.forceUpdate(),this.raiseOnPropertyChanged(e)},t.prototype.updateStateX=function(e){this._localChange=!0,this.state.value.x=e,this.updateVector4()},t.prototype.updateStateY=function(e){this._localChange=!0,this.state.value.y=e,this.updateVector4()},t.prototype.updateStateZ=function(e){this._localChange=!0,this.state.value.z=e,this.updateVector4()},t.prototype.updateStateW=function(e){this._localChange=!0,this.state.value.w=e,this.updateVector4()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?o.createElement(q,{icon:X}):o.createElement(q,{icon:G});return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"vector"},"X: ".concat(this.state.value.x.toFixed(2),", Y: ").concat(this.state.value.y.toFixed(2),", Z: ").concat(this.state.value.z.toFixed(2),", W: ").concat(this.state.value.w.toFixed(2))),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},t)),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"x",step:this.props.step,value:this.state.value.x,onChange:function(t){return e.updateStateX(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"y",step:this.props.step,value:this.state.value.y,onChange:function(t){return e.updateStateY(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"z",step:this.props.step,value:this.state.value.z,onChange:function(t){return e.updateStateZ(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"w",step:this.props.step,value:this.state.value.w,onChange:function(t){return e.updateStateW(t)}})))},t.defaultProps={step:.001},t}(o.Component),ce=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(se,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),ue=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={value:n._getValue(t)},n}return u(t,e),t.prototype._getValue=function(e){return e.getSelection?e.getSelection(e.target):e.target&&e.propertyName?e.target[e.propertyName]:e.options[e.defaultIfNull||0]},t.prototype.setValue=function(e){this.setState({value:e})},t.prototype.shouldComponentUpdate=function(e,t){if(this._localChange)return this._localChange=!1,!0;var n=this._getValue(e);return null!=n&&n!==t.value&&(t.value=n,!0)},t.prototype.raiseOnPropertyChanged=function(e,t){this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:e,initialValue:t})},t.prototype.updateValue=function(e){var t=this.props.valuesAreStrings?e:parseInt(e);this._localChange=!0;var n=this.state.value;this.props.noDirectUpdate||(this.props.target[this.props.propertyName]=t),this.setState({value:t}),this.raiseOnPropertyChanged(t,n),this.props.onSelect&&this.props.onSelect(t)},t.prototype.render=function(){var e,t=this;return o.createElement("div",{className:"listLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"options"+(this.props.className?" "+this.props.className:"")},o.createElement("select",{onChange:function(e){return t.updateValue(e.target.value)},value:null!==(e=this.state.value)&&void 0!==e?e:""},this.props.options.map((function(e){return o.createElement("option",{key:e.label,value:e.value,title:e.label},e.label)})))))},t}(o.Component),pe=function(e){function t(t){var n=e.call(this,t)||this;n._localChange=!1;var r=n.props.target[n.props.propertyName].clone(),o=0;if(n.props.mode){var a=new l.Quaternion;r.decompose(void 0,a);var i=a.toEulerAngles();switch(n.props.mode){case 1:o=i.x;break;case 2:o=i.y;break;case 3:o=i.z}}return n.state={value:r,mode:n.props.mode||0,angle:o},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!n.equals(t.value)||this._localChange?(t.value=n.clone(),this._localChange=!1,!0):t.mode!==this.state.mode||t.angle!==this.state.angle},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateMatrix=function(){var e=this.props.target[this.props.propertyName].clone();this.props.target[this.props.propertyName]=this.state.value,this.setState({value:e}),this.raiseOnPropertyChanged(e)},t.prototype.updateRow=function(e,t){this._localChange=!0,this.state.value.setRow(t,e),this.updateMatrix()},t.prototype.updateBasedOnMode=function(e){switch(this.state.mode){case 1:l.Matrix.RotationXToRef(this.state.angle,this.state.value);break;case 2:l.Matrix.RotationYToRef(this.state.angle,this.state.value);break;case 3:l.Matrix.RotationZToRef(this.state.angle,this.state.value)}this.updateMatrix(),this.setState({angle:e})},t.prototype.render=function(){var e=this;return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label)),o.createElement("div",{className:"secondLine"},o.createElement(ue,{label:"Mode",className:"no-right-margin",options:[{label:"User-defined",value:0},{label:"Rotation over X axis",value:1},{label:"Rotation over Y axis",value:2},{label:"Rotation over Z axis",value:3}],target:this,noDirectUpdate:!0,getSelection:function(){return e.state.mode},onSelect:function(t){e.props.target[e.props.propertyName]=l.Matrix.Identity(),l.Matrix.IdentityToRef(e.state.value),e.setState({mode:t,angle:0}),e.updateMatrix(),e.props.onModeChange&&e.props.onModeChange(t)}})),0===this.state.mode&&o.createElement("div",{className:"secondLine"},o.createElement(se,{globalState:this.props.globalState,label:"Row #0",value:this.state.value.getRow(0),onChange:function(t){return e.updateRow(t,0)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #1",value:this.state.value.getRow(1),onChange:function(t){return e.updateRow(t,1)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #2",value:this.state.value.getRow(2),onChange:function(t){return e.updateRow(t,2)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #3",value:this.state.value.getRow(3),onChange:function(t){return e.updateRow(t,3)}})),0!==this.state.mode&&o.createElement("div",{className:"secondLine"},o.createElement(B,{label:"Angle",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,globalState:this.props.globalState,directValue:this.state.angle,onChange:function(t){return e.updateBasedOnMode(t)}})))},t}(o.Component),de=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(pe,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)},mode:this.props.inputBlock.matrixMode,onModeChange:function(t){e.props.inputBlock.matrixMode=t}})},t}(o.Component),he=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n._onFocus=!1,n.state={value:void 0!==n.props.value?n.props.value:n.props.target[n.props.propertyName]||""},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){if(this._localChange)return this._localChange=!1,!0;var n=void 0!==e.value?e.value:e.target[e.propertyName];return n!==t.value&&(t.value=n||"",!0)},t.prototype.componentWillUnmount=function(){this._onFocus&&this.updateValue(this.state.value,!0)},t.prototype.raiseOnPropertyChanged=function(e,t){this.props.onChange?this.props.onChange(e):this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:e,initialValue:t})},t.prototype.updateValue=function(e,t){this._localChange=!0;var n=void 0!==this.props.value?this.props.value:this.props.target[this.props.propertyName];this.props.validator&&t&&0==this.props.validator(e)&&(e=n),this.setState({value:e}),t&&this.raiseOnPropertyChanged(e,n),this.props.propertyName&&(this.props.target[this.props.propertyName]=e)},t.prototype.render=function(){var e=this;return o.createElement("div",{className:this.props.multilines?"textInputArea":"textInputLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"value"},this.props.multilines&&o.createElement(o.Fragment,null,o.createElement("textarea",{value:this.state.value,onFocus:function(){e.props.globalState.blockKeyboardEvents=!0,e._onFocus=!0},onChange:function(t){return e.updateValue(t.target.value,!1)},onKeyDown:function(t){13===t.keyCode&&e.updateValue(e.state.value,!0)},onBlur:function(t){e.updateValue(t.target.value,!0),e.props.globalState.blockKeyboardEvents=!1,e._onFocus=!1}})),!this.props.multilines&&o.createElement(o.Fragment,null,o.createElement("input",{value:this.state.value,onFocus:function(){e.props.globalState.blockKeyboardEvents=!0,e._onFocus=!0},onChange:function(t){return e.updateValue(t.target.value,!1)},onKeyDown:function(t){13===t.keyCode&&e.updateValue(e.state.value,!0)},onBlur:function(t){e.updateValue(t.target.value,!0),e.props.globalState.blockKeyboardEvents=!1,e._onFocus=!1}}))))},t}(o.Component),fe=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.onLink=function(){this.props.onLink&&this.props.onLink()},t.prototype.renderContent=function(){var e=this;return this.props.onLink?o.createElement("div",{className:"link-value",title:this.props.value,onClick:function(){return e.onLink()}},this.props.value||"no name"):o.createElement("div",{className:"value",title:this.props.value,style:{color:this.props.color?this.props.color:""}},this.props.value||"no name")},t.prototype.render=function(){return o.createElement("div",{className:this.props.underline?"textLine underline":"textLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),this.renderContent())},t}(o.Component),me=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){return o.createElement(o.Fragment,null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),ge=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=[{label:"Neutral",value:l.NodeMaterialBlockTargets.Neutral},{label:"Vertex",value:l.NodeMaterialBlockTargets.Vertex},{label:"Fragment",value:l.NodeMaterialBlockTargets.Fragment}];return o.createElement(o.Fragment,null,o.createElement(m,{title:"GENERAL"},(!this.props.block.isInput||!this.props.block.isAttribute)&&o.createElement(he,{globalState:this.props.globalState,label:"Name",propertyName:"name",target:this.props.block,onChange:function(){return e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)},validator:function(t){return!!e.props.block.validateBlockName(t)||(e.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers('"'.concat(t,'" is a reserved name, please choose another')),!1)}}),this.props.block._originalTargetIsNeutral&&o.createElement(ue,{label:"Target",options:t,target:this.props.block,propertyName:"target",onSelect:function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),!this.props.block._originalTargetIsNeutral&&o.createElement(fe,{label:"Target",value:l.NodeMaterialBlockTargets[this.props.block.target]}),o.createElement(fe,{label:"Type",value:this.props.block.getClassName()}),o.createElement(he,{globalState:this.props.globalState,label:"Comments",propertyName:"comments",target:this.props.block,onChange:function(){return e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})))},t}(o.Component),ve=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.forceRebuild=function(e){var t;e&&!e.update||this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),e&&!e.rebuild||this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),(null==e?void 0:e.activatePreviewCommand)&&this.props.globalState.onPreviewCommandActivated.notifyObservers(!0),null===(t=null==e?void 0:e.callback)||void 0===t||t.call(e,this.props.globalState.nodeMaterial.getScene())},t.prototype.render=function(){var e=this,t=this.props.block._propStore;if(!t)return o.createElement(o.Fragment,null);for(var n={},r=[],a=function(t,a,s,c,u){var p=n[c];switch(p||(p=[],n[c]=p,r.push(c)),s){case l.PropertyTypeForEdition.Boolean:p.push(o.createElement(E,{label:a,target:i.props.block,propertyName:t,onValueChanged:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Float:isNaN(u.min)||isNaN(u.max)||u.min===u.max?p.push(o.createElement(P,{globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}})):p.push(o.createElement(B,{label:a,target:i.props.block,globalState:i.props.globalState,propertyName:t,step:Math.abs(u.max-u.min)/100,minimum:Math.min(u.min,u.max),maximum:u.max,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Int:p.push(o.createElement(P,{digits:0,step:"1",isInteger:!0,globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Vector2:p.push(o.createElement(Z,{globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.List:p.push(o.createElement(ue,{label:a,options:u.options,target:i.props.block,propertyName:t,onSelect:function(){return e.forceRebuild(u.notifiers)}}))}},i=this,s=0,c=t;s<c.length;s++){var u=c[s];a(u.propertyName,u.displayName,u.type,u.groupName,u.options)}return o.createElement(o.Fragment,null,r.map((function(e){return o.createElement(m,{title:e},n[e])})))},t}(o.Component),be=n(52),ye=n(74),xe=n(75),we=function(e){function t(t){var n=e.call(this,t)||this;n._localChange=!1;var r=n.props.target[n.props.propertyName],o="Color4"===r.getClassName()?r.clone():new l.Color4(r.r,r.g,r.b,1);return n.state={isExpanded:!1,color:o},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName],r="Color4"===n.getClassName()?n:new l.Color4(n.r,n.g,n.b,1);return!(r.equals(t.color)&&!this._localChange)&&(t.color=r.clone(),this._localChange=!1,!0)},t.prototype.onChange=function(e){this._localChange=!0;var t=l.Color4.FromHexString(e);this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:t,initialValue:this.state.color}),this.props.target[this.props.propertyName]=t,this.setState({color:this.props.target[this.props.propertyName]}),this.props.onChange&&this.props.onChange()},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.color,initialValue:e})},t.prototype.updateStateR=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].x=e,this.state.color.r=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateG=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].g=e,this.state.color.g=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateB=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].b=e,this.state.color.b=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateA=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].a=e,this.state.color.a=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.copyToClipboard=function(){var e=document.createElement("div");if(e.textContent=this.state.color.toHexString(),document.body.appendChild(e),window.getSelection){var t=document.createRange();t.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}document.execCommand("copy"),e.remove()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?xe:ye;return o.createElement("div",{className:"color3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"color3"},o.createElement(ee,{globalState:this.props.globalState,value:this.state.color,onColorChanged:function(t){e.onChange(t)}})),o.createElement("div",{className:"copy hoverIcon",onClick:function(){return e.copyToClipboard()},title:"Copy to clipboard"},o.createElement("img",{src:be,alt:""})),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},o.createElement("img",{src:t,alt:""}))),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"r",value:this.state.color.r,onChange:function(t){return e.updateStateR(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"g",value:this.state.color.g,onChange:function(t){return e.updateStateG(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"b",value:this.state.color.b,onChange:function(t){return e.updateStateB(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"a",value:this.state.color.a,onChange:function(t){return e.updateStateA(t)}})))},t}(o.Component),ke=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(we,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),_e=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this,t=this.props.block;this.onValueChangedObserver=t.onValueChangedObservable.add((function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}))},t.prototype.componentWillUnmount=function(){var e=this.props.block;this.onValueChangedObserver&&(e.onValueChangedObservable.remove(this.onValueChangedObserver),this.onValueChangedObserver=null)},t.prototype.renderValue=function(e){var t=this,n=this.props.block;switch(n.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var r=isNaN(n.min)||isNaN(n.max)||n.min===n.max;return o.createElement(o.Fragment,null,o.createElement(E,{label:"Is boolean",target:n,propertyName:"isBoolean"}),n.isBoolean&&o.createElement(E,{label:"Value",isSelected:function(){return 1===n.value},onSelect:function(e){n.value=e?1:0,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),!n.isBoolean&&o.createElement(P,{globalState:this.props.globalState,label:"Min",target:n,propertyName:"min",onChange:function(){n.value<n.min&&(n.value=n.min,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)),t.forceUpdate()}}),!n.isBoolean&&o.createElement(P,{globalState:this.props.globalState,label:"Max",target:n,propertyName:"max",onChange:function(){n.value>n.max&&(n.value=n.max,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)),t.forceUpdate()}}),!n.isBoolean&&r&&o.createElement(T,{globalState:e,inputBlock:n}),!n.isBoolean&&!r&&o.createElement(B,{label:"Value",globalState:this.props.globalState,target:n,propertyName:"value",step:Math.abs(n.max-n.min)/100,minimum:Math.min(n.min,n.max),maximum:n.max,onChange:function(){n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Q,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(o.Fragment,null,o.createElement(ae,{globalState:e,inputBlock:n}),o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(o.Fragment,null,o.createElement(ke,{globalState:e,inputBlock:n}),o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(le,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(ce,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Matrix:return o.createElement(de,{globalState:e,inputBlock:n})}return null},t.prototype.setDefaultValue=function(){this.props.block.setDefaultValue()},t.prototype.render=function(){var e=this,t=this.props.block,n=[],r=[],a=[];switch(t.type){case l.NodeMaterialBlockConnectionPointTypes.Float:a=[{label:"None",value:l.AnimatedInputBlockTypes.None},{label:"Time",value:l.AnimatedInputBlockTypes.Time}],n=[{label:"Delta time",value:l.NodeMaterialSystemValues.DeltaTime},{label:"Material alpha",value:l.NodeMaterialSystemValues.MaterialAlpha}];break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:n=[{label:"World",value:l.NodeMaterialSystemValues.World},{label:"World x View",value:l.NodeMaterialSystemValues.WorldView},{label:"World x View x Projection",value:l.NodeMaterialSystemValues.WorldViewProjection},{label:"View",value:l.NodeMaterialSystemValues.View},{label:"View x Projection",value:l.NodeMaterialSystemValues.ViewProjection},{label:"Projection",value:l.NodeMaterialSystemValues.Projection}];break;case l.NodeMaterialBlockConnectionPointTypes.Color3:n=[{label:"Fog color",value:l.NodeMaterialSystemValues.FogColor}];break;case l.NodeMaterialBlockConnectionPointTypes.Color4:r=[{label:"color",value:"color"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:r=[{label:"uv",value:"uv"},{label:"uv2",value:"uv2"},{label:"uv3",value:"uv3"},{label:"uv4",value:"uv4"},{label:"uv5",value:"uv5"},{label:"uv6",value:"uv6"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:n=[{label:"Camera position",value:l.NodeMaterialSystemValues.CameraPosition}],r=[{label:"position",value:"position"},{label:"normal",value:"normal"},{label:"tangent",value:"tangent"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:r=[{label:"matricesIndices",value:"matricesIndices"},{label:"matricesWeights",value:"matricesWeights"}],n=[{label:"Camera parameters",value:l.NodeMaterialSystemValues.CameraParameters}]}var i=[{label:"User-defined",value:0}];r.length>0&&i.push({label:"Mesh attribute",value:1}),n.length>0&&i.push({label:"System value",value:2});return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&o.createElement(ue,{label:"Type",options:[{label:"None",value:0},{label:"Visible in the inspector",value:1},{label:"Constant",value:2}],target:t,noDirectUpdate:!0,getSelection:function(e){return e.visibleInInspector?1:e.isConstant?2:0},onSelect:function(n){switch(n){case 0:t.visibleInInspector=!1,t.isConstant=!1;break;case 1:t.visibleInInspector=!0,t.isConstant=!1;break;case 2:t.visibleInInspector=!1,t.isConstant=!0}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.visibleInInspector&&o.createElement(he,{globalState:this.props.globalState,label:"Group",propertyName:"groupInInspector",target:this.props.block,onChange:function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),o.createElement(ue,{label:"Mode",options:i,target:t,noDirectUpdate:!0,getSelection:function(e){return e.isAttribute?1:e.isSystemValue?2:0},onSelect:function(o){switch(o){case 0:t.isUniform=!0,t.setAsSystemValue(null),e.setDefaultValue();break;case 1:t.setAsAttribute(r[0].value);break;case 2:t.setAsSystemValue(n[0].value)}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isAttribute&&o.createElement(ue,{label:"Attribute",valuesAreStrings:!0,options:r,target:t,propertyName:"name",onSelect:function(n){t.setAsAttribute(n),e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&a.length>0&&o.createElement(ue,{label:"Animation type",options:a,target:t,propertyName:"animationType",onSelect:function(t){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&this.renderValue(this.props.globalState),t.isUniform&&t.isSystemValue&&o.createElement(ue,{label:"System value",options:n,target:t,propertyName:"systemValue",onSelect:function(n){t.setAsSystemValue(n),e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&o.createElement(E,{label:"Visible on frame",target:this.props.block,propertyName:"visibleOnFrame"})))},t}(o.Component),Ce=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(o.Fragment,null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(E,{label:"Transform as direction",onSelect:function(t){var n=e.props.block;n.complementW=t?0:1,e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},isSelected:function(){return 0===e.props.block.complementW}})))},t}(o.Component),Se=n(73),Ee=n(52),Pe=function(e){function t(t){var n=e.call(this,t)||this;return n.state={gradient:t.step.step},n}return u(t,e),t.prototype.updateColor=function(e){this.props.step.color=l.Color3.FromHexString(e),this.props.onUpdateStep(),this.forceUpdate()},t.prototype.updateStep=function(e){this.props.step.step=e,this.setState({gradient:e}),this.props.onUpdateStep()},t.prototype.onPointerUp=function(){this.props.onCheckForReOrder()},t.prototype.render=function(){var e=this,t=this.props.step;return o.createElement("div",{className:"gradient-step"},o.createElement("div",{className:"step"},"#".concat(this.props.lineIndex)),o.createElement("div",{className:"color"},o.createElement(ee,{value:t.color,globalState:this.props.globalState,onColorChanged:function(t){e.updateColor(t)}})),o.createElement("div",{className:"step-value"},o.createElement(P,{globalState:this.props.globalState,smallUI:!0,label:"",target:t,propertyName:"step",min:0,max:1,onEnter:function(){e.props.onUpdateStep(),e.props.onCheckForReOrder(),e.forceUpdate()}})),o.createElement("div",{className:"step-slider"},o.createElement("input",{className:"range",type:"range",step:.01,min:0,max:1,value:t.step,onPointerUp:function(t){return e.onPointerUp()},onChange:function(t){return e.updateStep(parseFloat(t.target.value))}})),o.createElement("div",{className:"gradient-copy",onClick:function(){e.props.onCopy&&e.props.onCopy()},title:"Copy Step"},o.createElement("img",{className:"img",src:Ee})),o.createElement("div",{className:"gradient-delete",onClick:function(){return e.props.onDelete()},title:"Delete Step"},o.createElement("img",{className:"img",src:Se})))},t}(o.Component),Te=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this,t=this.props.block;this.onValueChangedObserver=t.onValueChangedObservable.add((function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}))},t.prototype.componentWillUnmount=function(){var e=this.props.block;this.onValueChangedObserver&&(e.onValueChangedObservable.remove(this.onValueChangedObserver),this.onValueChangedObserver=null)},t.prototype.forceRebuild=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.deleteStep=function(e){var t=this.props.block,n=t.colorSteps.indexOf(e);n>-1&&(t.colorSteps.splice(n,1),t.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate())},t.prototype.copyStep=function(e){var t=this.props.block,n=new l.GradientBlockColorStep(1,e.color);t.colorSteps.push(n),t.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate()},t.prototype.addNewStep=function(){var e=this.props.block,t=new l.GradientBlockColorStep(1,l.Color3.White());e.colorSteps.push(t),e.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate()},t.prototype.checkForReOrder=function(){var e=this.props.block;e.colorSteps.sort((function(e,t){return e.step===t.step?0:e.step>t.step?1:-1})),e.colorStepsUpdated(),this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.forceUpdate()},t.prototype.render=function(){var e=this,t=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Type",options:[{label:"None",value:0},{label:"Visible in the inspector",value:1}],target:this.props.block,noDirectUpdate:!0,getSelection:function(e){return e.visibleInInspector?1:e.isConstant?2:0},onSelect:function(t){switch(t){case 0:e.props.block.visibleInInspector=!1;break;case 1:e.props.block.visibleInInspector=!0}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})),o.createElement(m,{title:"STEPS"},o.createElement(k,{label:"Add new step",onClick:function(){return e.addNewStep()}}),t.colorSteps.map((function(t,n){return o.createElement(Pe,{globalState:e.props.globalState,onCheckForReOrder:function(){return e.checkForReOrder()},onUpdateStep:function(){return e.forceRebuild()},key:"step-"+n,lineIndex:n,step:t,onCopy:function(){return e.copyStep(t)},onDelete:function(){return e.deleteStep(t)}})}))))},t}(o.Component),Be=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.globalState.nodeMaterial.getScene(),n=t.lights.map((function(e){return{label:e.name,value:e.name}}));n.splice(0,0,{label:"All",value:""});var r=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Light",defaultIfNull:0,noDirectUpdate:!0,valuesAreStrings:!0,options:n,target:r,propertyName:"name",onSelect:function(n){r.light=""===n?null:t.getLightByName(n),e.forceUpdate(),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})))},t}(o.Component),Ne=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.globalState.nodeMaterial.getScene(),n=t.lights.map((function(e){return{label:e.name,value:e.name}})),r=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Light",noDirectUpdate:!0,valuesAreStrings:!0,options:n,target:r,propertyName:"name",onSelect:function(n){r.light=t.getLightByName(n),e.forceUpdate(),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})))},t}(o.Component),Oe=function(e){function t(t){var n=e.call(this,t)||this,r=n.textureBlock.texture;return n.state={isEmbedded:!r||"data"===r.name.substring(0,4),loadAsCubeTexture:r&&r.isCube,textureIsPrefiltered:!0},n}return u(t,e),Object.defineProperty(t.prototype,"textureBlock",{get:function(){return this.props.block},enumerable:!1,configurable:!0}),t.prototype.UNSAFE_componentWillUpdate=function(e,t){if(e.block!==this.props.block){var n=e.block.texture;t.isEmbedded=!n||"data"===n.name.substring(0,4),t.loadAsCubeTexture=n&&n.isCube}},t.prototype._generateRandomForCache=function(){return"xxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,(function(e){return(10*Math.random()|0).toString()}))},t.prototype.updateAfterTextureLoad=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),this.forceUpdate()},t.prototype.removeTexture=function(){var e=this.textureBlock.texture;e&&(e.dispose(),e=null,this.textureBlock.texture=null),this.updateAfterTextureLoad()},t.prototype._prepareTexture=function(){var e=this.textureBlock.texture;e&&e.isCube!==this.state.loadAsCubeTexture&&(e.dispose(),e=null),e||(this.state.loadAsCubeTexture?(this.textureBlock.texture=new l.CubeTexture("",this.props.globalState.nodeMaterial.getScene()),(e=this.textureBlock.texture).coordinatesMode=l.Texture.CUBIC_MODE):(this.textureBlock.texture=new l.Texture(null,this.props.globalState.nodeMaterial.getScene(),!1,this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock||this.props.globalState.mode===l.NodeMaterialModes.PostProcess),(e=this.textureBlock.texture).coordinatesMode=l.Texture.EQUIRECTANGULAR_MODE))},t.prototype.replaceTexture=function(e){var t=this;this._prepareTexture();var n=this.textureBlock.texture;l.Tools.ReadFile(e,(function(r){var o=new Blob([r],{type:"octet/stream"}),a=new FileReader;a.readAsDataURL(o),a.onloadend=function(){var r=a.result,o=void 0;e.name.toLowerCase().indexOf(".dds")>0?o=".dds":e.name.toLowerCase().indexOf(".env")>0&&(o=".env"),n.isCube?n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}),t.state.textureIsPrefiltered):n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}))}}),void 0,!0)},t.prototype.replaceTextureWithUrl=function(e){var t=this;this._prepareTexture();var n=this.textureBlock.texture;if(n.isCube||this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock){var r=void 0;e.toLowerCase().indexOf(".dds")>0?r=".dds":e.toLowerCase().indexOf(".env")>0&&(r=".env"),n.updateURL(e,r,(function(){return t.updateAfterTextureLoad()}),this.state.textureIsPrefiltered)}else n.updateURL(e,null,(function(){return t.updateAfterTextureLoad()}))},t.prototype.render=function(){var e=this,t="",n=this.textureBlock.hasImageSource?null:this.textureBlock.texture;n&&n.name&&"data"!==n.name.substring(0,4)&&(t=n.name),t=t.replace(/\?nocache=\d+/,"");var r=this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock,a=this.textureBlock instanceof l.CurrentScreenBlock||this.textureBlock instanceof l.ParticleTextureBlock,i=this.textureBlock instanceof l.ReflectionBlock,s=[{label:"Cubic",value:l.Texture.CUBIC_MODE},{label:"Equirectangular",value:l.Texture.EQUIRECTANGULAR_MODE},{label:"Explicit",value:l.Texture.EXPLICIT_MODE},{label:"Fixed equirectangular",value:l.Texture.FIXED_EQUIRECTANGULAR_MODE},{label:"Fixed mirrored equirectangular",value:l.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE},{label:"Planar",value:l.Texture.PLANAR_MODE},{label:"Projection",value:l.Texture.PROJECTION_MODE},{label:"Skybox",value:l.Texture.SKYBOX_MODE},{label:"Spherical",value:l.Texture.SPHERICAL_MODE}],c=[{label:"Nearest",value:l.Texture.NEAREST_NEAREST},{label:"Linear",value:l.Texture.LINEAR_LINEAR},{label:"Linear & linear mip",value:l.Texture.LINEAR_LINEAR_MIPLINEAR},{label:"Linear & nearest mip",value:l.Texture.LINEAR_LINEAR_MIPNEAREST},{label:"Nearest & linear mip",value:l.Texture.NEAREST_NEAREST_MIPLINEAR},{label:"Nearest & nearest mip",value:l.Texture.NEAREST_NEAREST_MIPNEAREST},{label:"Nearest/Linear",value:l.Texture.NEAREST_LINEAR},{label:"Nearest/Linear & linear mip",value:l.Texture.NEAREST_LINEAR_MIPLINEAR},{label:"Nearest/Linear & nearest mip",value:l.Texture.NEAREST_LINEAR_MIPNEAREST},{label:"Linear/Nearest",value:l.Texture.LINEAR_NEAREST},{label:"Linear/Nearest & linear mip",value:l.Texture.LINEAR_NEAREST_MIPLINEAR},{label:"Linear/Nearest & nearest mip",value:l.Texture.LINEAR_NEAREST_MIPNEAREST}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(E,{label:"Auto select UV",propertyName:"autoSelectUV",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),!r&&o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),!r&&o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&i&&o.createElement(E,{label:"Is in gamma space",propertyName:"gammaSpace",target:n,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),o.createElement(E,{label:"Disable multiplying by level",propertyName:"disableLevelMultiplication",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),n&&n.updateSamplingMode&&o.createElement(ue,{label:"Sampling",options:c,target:n,noDirectUpdate:!0,propertyName:"samplingMode",onSelect:function(t){n.updateSamplingMode(t),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&r&&o.createElement(ue,{label:"Reflection mode",options:s,target:n,propertyName:"coordinatesMode",onSelect:function(t){n.coordinatesMode=t,e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(E,{label:"Clamp U",isSelected:function(){return n.wrapU===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapU=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(E,{label:"Clamp V",isSelected:function(){return n.wrapV===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapV=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Offset U",target:n,propertyName:"uOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Offset V",target:n,propertyName:"vOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Scale U",target:n,propertyName:"uScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Scale V",target:n,propertyName:"vScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation U",target:n,globalState:this.props.globalState,propertyName:"uAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation V",target:n,globalState:this.props.globalState,propertyName:"vAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation W",target:n,globalState:this.props.globalState,propertyName:"wAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})),!this.textureBlock.hasImageSource&&o.createElement(m,{title:"SOURCE"},o.createElement(E,{label:"Embed static texture",isSelected:function(){return e.state.isEmbedded},onSelect:function(t){e.setState({isEmbedded:t}),e.textureBlock.texture=null,e.updateAfterTextureLoad()}}),r&&o.createElement(E,{label:"Load as cube texture",isSelected:function(){return e.state.loadAsCubeTexture},onSelect:function(t){return e.setState({loadAsCubeTexture:t})}}),r&&this.state.loadAsCubeTexture&&o.createElement(E,{label:"      Texture is prefiltered",isSelected:function(){return e.state.textureIsPrefiltered},onSelect:function(t){return e.setState({textureIsPrefiltered:t})}}),this.state.isEmbedded&&o.createElement(C,{label:"Upload",onClick:function(t){return e.replaceTexture(t)},accept:".jpg, .png, .tga, .dds, .env"}),!this.state.isEmbedded&&o.createElement(he,{label:"Link",globalState:this.props.globalState,value:t,onChange:function(t){return e.replaceTextureWithUrl(t)}}),!this.state.isEmbedded&&t&&o.createElement(k,{label:"Refresh",onClick:function(){return e.replaceTextureWithUrl(t+"?nocache="+e._generateRandomForCache())}}),n&&o.createElement(k,{label:"Remove",onClick:function(){return e.removeTexture()}})),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),Le=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"Cos",value:l.TrigonometryBlockOperations.Cos},{label:"Sin",value:l.TrigonometryBlockOperations.Sin},{label:"Abs",value:l.TrigonometryBlockOperations.Abs},{label:"Exp",value:l.TrigonometryBlockOperations.Exp},{label:"Exp2",value:l.TrigonometryBlockOperations.Exp2},{label:"Round",value:l.TrigonometryBlockOperations.Round},{label:"Ceiling",value:l.TrigonometryBlockOperations.Ceiling},{label:"Floor",value:l.TrigonometryBlockOperations.Floor},{label:"Sqrt",value:l.TrigonometryBlockOperations.Sqrt},{label:"ArcCos",value:l.TrigonometryBlockOperations.ArcCos},{label:"ArcSin",value:l.TrigonometryBlockOperations.ArcSin},{label:"ArcTan",value:l.TrigonometryBlockOperations.ArcTan},{label:"Tan",value:l.TrigonometryBlockOperations.Tan},{label:"Log",value:l.TrigonometryBlockOperations.Log},{label:"Fract",value:l.TrigonometryBlockOperations.Fract},{label:"Sign",value:l.TrigonometryBlockOperations.Sign},{label:"Radians to degrees",value:l.TrigonometryBlockOperations.Degrees},{label:"Degrees to radians",value:l.TrigonometryBlockOperations.Radians}];return n.sort((function(e,t){return e.label.localeCompare(t.label)})),o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Operation",options:n,target:t,propertyName:"operation",onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Me=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"Equal",value:l.ConditionalBlockConditions.Equal},{label:"NotEqual",value:l.ConditionalBlockConditions.NotEqual},{label:"LessThan",value:l.ConditionalBlockConditions.LessThan},{label:"GreaterThan",value:l.ConditionalBlockConditions.GreaterThan},{label:"LessOrEqual",value:l.ConditionalBlockConditions.LessOrEqual},{label:"GreaterOrEqual",value:l.ConditionalBlockConditions.GreaterOrEqual},{label:"Xor",value:l.ConditionalBlockConditions.Xor},{label:"Or",value:l.ConditionalBlockConditions.Or},{label:"And",value:l.ConditionalBlockConditions.And}];return n.sort((function(e,t){return e.label.localeCompare(t.label)})),o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Condition",options:n,target:t,propertyName:"condition",onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Re=function(e){function t(t){var n=e.call(this,t)||this,r=n.imageSourceBlock.texture;return n.state={isEmbedded:!r||"data"===r.name.substring(0,4)},n}return u(t,e),Object.defineProperty(t.prototype,"imageSourceBlock",{get:function(){return this.props.block},enumerable:!1,configurable:!0}),t.prototype.UNSAFE_componentWillUpdate=function(e,t){if(e.block!==this.props.block){var n=e.block.texture;t.isEmbedded=!n||"data"===n.name.substring(0,4),t.loadAsCubeTexture=n&&n.isCube}},t.prototype._generateRandomForCache=function(){return"xxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,(function(e){return(10*Math.random()|0).toString()}))},t.prototype.updateAfterTextureLoad=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),this.forceUpdate()},t.prototype.removeTexture=function(){var e=this.imageSourceBlock.texture;e&&(e.dispose(),e=null,this.imageSourceBlock.texture=null),this.updateAfterTextureLoad()},t.prototype._prepareTexture=function(){var e=this.imageSourceBlock.texture;e&&(e.dispose(),e=null),e||(this.imageSourceBlock.texture=new l.Texture(null,this.props.globalState.nodeMaterial.getScene(),!1,!1),(e=this.imageSourceBlock.texture).coordinatesMode=l.Texture.EQUIRECTANGULAR_MODE)},t.prototype.replaceTexture=function(e){var t=this;this._prepareTexture();var n=this.imageSourceBlock.texture;l.Tools.ReadFile(e,(function(r){var o=new Blob([r],{type:"octet/stream"}),a=new FileReader;a.readAsDataURL(o),a.onloadend=function(){var r=a.result,o=void 0;e.name.toLowerCase().indexOf(".dds")>0?o=".dds":e.name.toLowerCase().indexOf(".env")>0&&(o=".env"),n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}))}}),void 0,!0)},t.prototype.replaceTextureWithUrl=function(e){var t=this;this._prepareTexture(),this.imageSourceBlock.texture.updateURL(e,null,(function(){return t.updateAfterTextureLoad()}))},t.prototype.render=function(){var e=this,t="",n=this.imageSourceBlock.texture;n&&n.name&&"data"!==n.name.substring(0,4)&&(t=n.name),t=t.replace(/\?nocache=\d+/,"");var r=[{label:"Nearest",value:l.Texture.NEAREST_NEAREST},{label:"Linear",value:l.Texture.LINEAR_LINEAR},{label:"Linear & linear mip",value:l.Texture.LINEAR_LINEAR_MIPLINEAR},{label:"Linear & nearest mip",value:l.Texture.LINEAR_LINEAR_MIPNEAREST},{label:"Nearest & linear mip",value:l.Texture.NEAREST_NEAREST_MIPLINEAR},{label:"Nearest & nearest mip",value:l.Texture.NEAREST_NEAREST_MIPNEAREST},{label:"Nearest/Linear",value:l.Texture.NEAREST_LINEAR},{label:"Nearest/Linear & linear mip",value:l.Texture.NEAREST_LINEAR_MIPLINEAR},{label:"Nearest/Linear & nearest mip",value:l.Texture.NEAREST_LINEAR_MIPNEAREST},{label:"Linear/Nearest",value:l.Texture.LINEAR_NEAREST},{label:"Linear/Nearest & linear mip",value:l.Texture.LINEAR_NEAREST_MIPLINEAR},{label:"Linear/Nearest & nearest mip",value:l.Texture.LINEAR_NEAREST_MIPNEAREST}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},n&&n.updateSamplingMode&&o.createElement(ue,{label:"Sampling",options:r,target:n,noDirectUpdate:!0,propertyName:"samplingMode",onSelect:function(t){n.updateSamplingMode(t),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(E,{label:"Clamp U",isSelected:function(){return n.wrapU===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapU=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(E,{label:"Clamp V",isSelected:function(){return n.wrapV===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapV=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Offset U",target:n,propertyName:"uOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Offset V",target:n,propertyName:"vOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Scale U",target:n,propertyName:"uScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Scale V",target:n,propertyName:"vScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation U",target:n,globalState:this.props.globalState,propertyName:"uAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation V",target:n,globalState:this.props.globalState,propertyName:"vAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation W",target:n,globalState:this.props.globalState,propertyName:"wAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})),o.createElement(m,{title:"SOURCE"},o.createElement(E,{label:"Embed static texture",isSelected:function(){return e.state.isEmbedded},onSelect:function(t){e.setState({isEmbedded:t}),e.imageSourceBlock.texture=null,e.updateAfterTextureLoad()}}),this.state.isEmbedded&&o.createElement(C,{label:"Upload",onClick:function(t){return e.replaceTexture(t)},accept:".jpg, .png, .tga, .dds, .env"}),!this.state.isEmbedded&&o.createElement(he,{label:"Link",globalState:this.props.globalState,value:t,onChange:function(t){return e.replaceTextureWithUrl(t)}}),!this.state.isEmbedded&&t&&o.createElement(k,{label:"Refresh",onClick:function(){return e.replaceTextureWithUrl(t+"?nocache="+e._generateRandomForCache())}}),n&&o.createElement(k,{label:"Remove",onClick:function(){return e.removeTexture()}})),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),Ie=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"X",value:"x"},{label:"Y",value:"y"},{label:"Z",value:"z"},{label:"W",value:"w"}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"SWIZZLES"},o.createElement(ue,{label:"X",options:n,target:t,propertyName:"xSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"Y",options:n,target:t,propertyName:"ySwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"Z",options:n,target:t,propertyName:"zSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"W",options:n,target:t,propertyName:"wSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Ae=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"R",value:"r"},{label:"G",value:"g"},{label:"B",value:"b"},{label:"A",value:"a"}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"SWIZZLES"},o.createElement(ue,{label:"R",options:n,target:t,propertyName:"rSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"G",options:n,target:t,propertyName:"gSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"B",options:n,target:t,propertyName:"bSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"A",options:n,target:t,propertyName:"aSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),De=function(){function e(){}return e.RegisteredControls={},e}();De.RegisteredControls.TransformBlock=Ce,De.RegisteredControls.InputBlock=_e,De.RegisteredControls.GradientBlock=Te,De.RegisteredControls.LightBlock=Be,De.RegisteredControls.LightInformationBlock=Ne,De.RegisteredControls.TextureBlock=Oe,De.RegisteredControls.ReflectionTextureBlock=Oe,De.RegisteredControls.ReflectionBlock=Oe,De.RegisteredControls.RefractionBlock=Oe,De.RegisteredControls.CurrentScreenBlock=Oe,De.RegisteredControls.ParticleTextureBlock=Oe,De.RegisteredControls.TrigonometryBlock=Le,De.RegisteredControls.ConditionalBlock=Me,De.RegisteredControls.ImageSourceBlock=Re,De.RegisteredControls.VectorMergerBlock=Ie,De.RegisteredControls.ColorMergerBlock=Ae;var Fe=function(){function e(){}return e.GetBlockFromString=function(e,t,n){switch(e){case"ElbowBlock":return new l.ElbowBlock("");case"TwirlBlock":return new l.TwirlBlock("Twirl");case"VoronoiNoiseBlock":return new l.VoronoiNoiseBlock("VoronoiNoise");case"ScreenSpaceBlock":return new l.ScreenSpaceBlock("ScreenSpace");case"CloudBlock":return new l.CloudBlock("Cloud");case"MatrixBuilderBlock":return new l.MatrixBuilderBlock("MatrixBuilder");case"DesaturateBlock":return new l.DesaturateBlock("Desaturate");case"RefractBlock":return new l.RefractBlock("Refract");case"ReflectBlock":return new l.ReflectBlock("Reflect");case"DerivativeBlock":return new l.DerivativeBlock("Derivative");case"Rotate2dBlock":return new l.Rotate2dBlock("Rotate2d");case"NormalBlendBlock":return new l.NormalBlendBlock("NormalBlend");case"WorleyNoise3DBlock":return new l.WorleyNoise3DBlock("WorleyNoise3D");case"SimplexPerlin3DBlock":return new l.SimplexPerlin3DBlock("SimplexPerlin3D");case"BonesBlock":return new l.BonesBlock("Bones");case"InstancesBlock":return new l.InstancesBlock("Instances");case"MorphTargetsBlock":return new l.MorphTargetsBlock("MorphTargets");case"DiscardBlock":return new l.DiscardBlock("Discard");case"ImageProcessingBlock":return new l.ImageProcessingBlock("ImageProcessing");case"ColorMergerBlock":return new l.ColorMergerBlock("ColorMerger");case"VectorMergerBlock":return new l.VectorMergerBlock("VectorMerger");case"ColorSplitterBlock":return new l.ColorSplitterBlock("ColorSplitter");case"VectorSplitterBlock":return new l.VectorSplitterBlock("VectorSplitter");case"TextureBlock":return new l.TextureBlock("Texture",n.mode===l.NodeMaterialModes.Particle);case"ReflectionTextureBlock":return new l.ReflectionTextureBlock("Reflection texture");case"LightBlock":return new l.LightBlock("Lights");case"FogBlock":return new l.FogBlock("Fog");case"VertexOutputBlock":return new l.VertexOutputBlock("VertexOutput");case"FragmentOutputBlock":return new l.FragmentOutputBlock("FragmentOutput");case"AddBlock":return new l.AddBlock("Add");case"ClampBlock":return new l.ClampBlock("Clamp");case"ScaleBlock":return new l.ScaleBlock("Scale");case"CrossBlock":return new l.CrossBlock("Cross");case"DotBlock":return new l.DotBlock("Dot");case"PowBlock":return new l.PowBlock("Pow");case"MultiplyBlock":return new l.MultiplyBlock("Multiply");case"TransformBlock":return new l.TransformBlock("Transform");case"TrigonometryBlock":return new l.TrigonometryBlock("Trigonometry");case"RemapBlock":return new l.RemapBlock("Remap");case"NormalizeBlock":return new l.NormalizeBlock("Normalize");case"FresnelBlock":return new l.FresnelBlock("Fresnel");case"LerpBlock":return new l.LerpBlock("Lerp");case"NLerpBlock":return new l.NLerpBlock("NLerp");case"DivideBlock":return new l.DivideBlock("Divide");case"SubtractBlock":return new l.SubtractBlock("Subtract");case"ModBlock":return new l.ModBlock("Mod");case"StepBlock":return new l.StepBlock("Step");case"SmoothStepBlock":return new l.SmoothStepBlock("Smooth step");case"OneMinusBlock":return new l.OneMinusBlock("One minus");case"ReciprocalBlock":return new l.ReciprocalBlock("Reciprocal");case"ViewDirectionBlock":return new l.ViewDirectionBlock("View direction");case"LightInformationBlock":var r=new l.LightInformationBlock("Light information");return r.light=t.lights.length?t.lights[0]:null,r;case"MaxBlock":return new l.MaxBlock("Max");case"MinBlock":return new l.MinBlock("Min");case"LengthBlock":return new l.LengthBlock("Length");case"DistanceBlock":return new l.DistanceBlock("Distance");case"NegateBlock":return new l.NegateBlock("Negate");case"PerturbNormalBlock":return new l.PerturbNormalBlock("Perturb normal");case"RandomNumberBlock":return new l.RandomNumberBlock("Random number");case"ReplaceColorBlock":return new l.ReplaceColorBlock("Replace color");case"PosterizeBlock":return new l.PosterizeBlock("Posterize");case"ArcTan2Block":return new l.ArcTan2Block("ArcTan2");case"GradientBlock":return new l.GradientBlock("Gradient");case"FrontFacingBlock":return new l.FrontFacingBlock("Front facing");case"CosBlock":var o=new l.TrigonometryBlock("Cos");return o.operation=l.TrigonometryBlockOperations.Cos,o;case"SinBlock":var a=new l.TrigonometryBlock("Sin");return a.operation=l.TrigonometryBlockOperations.Sin,a;case"AbsBlock":var i=new l.TrigonometryBlock("Abs");return i.operation=l.TrigonometryBlockOperations.Abs,i;case"SqrtBlock":var s=new l.TrigonometryBlock("Sqrt");return s.operation=l.TrigonometryBlockOperations.Sqrt,s;case"ArcCosBlock":var c=new l.TrigonometryBlock("ArcCos");return c.operation=l.TrigonometryBlockOperations.ArcCos,c;case"ArcSinBlock":var u=new l.TrigonometryBlock("ArcSin");return u.operation=l.TrigonometryBlockOperations.ArcSin,u;case"TanBlock":var p=new l.TrigonometryBlock("Tan");return p.operation=l.TrigonometryBlockOperations.Tan,p;case"ArcTanBlock":var d=new l.TrigonometryBlock("ArcTan");return d.operation=l.TrigonometryBlockOperations.ArcTan,d;case"FractBlock":var h=new l.TrigonometryBlock("Fract");return h.operation=l.TrigonometryBlockOperations.Fract,h;case"SignBlock":var f=new l.TrigonometryBlock("Sign");return f.operation=l.TrigonometryBlockOperations.Sign,f;case"LogBlock":var m=new l.TrigonometryBlock("Log");return m.operation=l.TrigonometryBlockOperations.Log,m;case"ExpBlock":var g=new l.TrigonometryBlock("Exp");return g.operation=l.TrigonometryBlockOperations.Exp,g;case"Exp2Block":var v=new l.TrigonometryBlock("Exp2");return v.operation=l.TrigonometryBlockOperations.Exp2,v;case"DegreesToRadiansBlock":var b=new l.TrigonometryBlock("Degrees to radians");return b.operation=l.TrigonometryBlockOperations.Radians,b;case"RadiansToDegreesBlock":var y=new l.TrigonometryBlock("Radians to degrees");return y.operation=l.TrigonometryBlockOperations.Degrees,y;case"RoundBlock":var x=new l.TrigonometryBlock("Round");return x.operation=l.TrigonometryBlockOperations.Round,x;case"CeilingBlock":var w=new l.TrigonometryBlock("Ceiling");return w.operation=l.TrigonometryBlockOperations.Ceiling,w;case"FloorBlock":var k=new l.TrigonometryBlock("Floor");return k.operation=l.TrigonometryBlockOperations.Floor,k;case"SawToothWaveBlock":var _=new l.WaveBlock("SawTooth wave");return _.kind=l.WaveBlockKind.SawTooth,_;case"SquareWaveBlock":var C=new l.WaveBlock("Square wave");return C.kind=l.WaveBlockKind.Square,C;case"TriangleWaveBlock":var S=new l.WaveBlock("Triangle wave");return S.kind=l.WaveBlockKind.Triangle,S;case"WorldMatrixBlock":return(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World),X;case"WorldViewMatrixBlock":var E=new l.InputBlock("World x View");return E.setAsSystemValue(l.NodeMaterialSystemValues.WorldView),E;case"WorldViewProjectionMatrixBlock":var P=new l.InputBlock("World x View x Projection");return P.setAsSystemValue(l.NodeMaterialSystemValues.WorldViewProjection),P;case"ViewMatrixBlock":var T=new l.InputBlock("View");return T.setAsSystemValue(l.NodeMaterialSystemValues.View),T;case"ViewProjectionMatrixBlock":var B=new l.InputBlock("View x Projection");return B.setAsSystemValue(l.NodeMaterialSystemValues.ViewProjection),B;case"ProjectionMatrixBlock":var N=new l.InputBlock("Projection");return N.setAsSystemValue(l.NodeMaterialSystemValues.Projection),N;case"CameraPositionBlock":var O=new l.InputBlock("Camera position");return O.setAsSystemValue(l.NodeMaterialSystemValues.CameraPosition),O;case"CameraParametersBlock":var L=new l.InputBlock("Camera parameters");L.setAsSystemValue(l.NodeMaterialSystemValues.CameraParameters);var M=new l.VectorSplitterBlock("Vector splitter");return L.connectTo(M),M;case"FogColorBlock":var R=new l.InputBlock("Fog color");return R.setAsSystemValue(l.NodeMaterialSystemValues.FogColor),R;case"PositionBlock":return(I=new l.InputBlock("position")).setAsAttribute("position"),I;case"ScreenPositionBlock":var I;return(I=new l.InputBlock("position")).setAsAttribute("position2d"),I;case"UVBlock":var A=new l.InputBlock("uv");return A.setAsAttribute("uv"),A;case"ColorBlock":var D=new l.InputBlock("color");return D.setAsAttribute("color"),D;case"NormalBlock":var F=new l.InputBlock("normal");return F.setAsAttribute("normal"),F;case"TangentBlock":var z=new l.InputBlock("tangent");return z.setAsAttribute("tangent"),z;case"MatrixIndicesBlock":var j=new l.InputBlock("matricesIndices");return j.setAsAttribute("matricesIndices"),j;case"MatrixWeightsBlock":var U=new l.InputBlock("matricesWeights");return U.setAsAttribute("matricesWeights"),U;case"TimeBlock":var V=new l.InputBlock("Time",void 0,l.NodeMaterialBlockConnectionPointTypes.Float);return V.animationType=l.AnimatedInputBlockTypes.Time,V;case"DeltaTimeBlock":return(W=new l.InputBlock("Delta time")).setAsSystemValue(l.NodeMaterialSystemValues.DeltaTime),W;case"MaterialAlphaBlock":var W;return(W=new l.InputBlock("Material alpha")).setAsSystemValue(l.NodeMaterialSystemValues.MaterialAlpha),W;case"WorldPositionBlock":var H=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"position"===e.name}));H||(H=new l.InputBlock("position")).setAsAttribute("position"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);var q=new l.TransformBlock("World position");return H.connectTo(q),X.connectTo(q),q;case"WorldNormalBlock":var Y=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"normal"===e.name}));Y||(Y=new l.InputBlock("normal")).setAsAttribute("normal"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);q=new l.TransformBlock("World normal");return Y.connectTo(q),X.connectTo(q),q;case"WorldTangentBlock":var X,G=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"tangent"===e.name}));G||(G=new l.InputBlock("tangent")).setAsAttribute("tangent"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);q=new l.TransformBlock("World tangent");return G.connectTo(q),X.connectTo(q),q;case"PBRMetallicRoughnessBlock":return new l.PBRMetallicRoughnessBlock("PBRMetallicRoughness");case"SheenBlock":return new l.SheenBlock("Sheen");case"AnisotropyBlock":return new l.AnisotropyBlock("Anisotropy");case"ReflectionBlock":return new l.ReflectionBlock("Reflection");case"ClearCoatBlock":return new l.ClearCoatBlock("ClearCoat");case"RefractionBlock":return new l.RefractionBlock("Refraction");case"SubSurfaceBlock":return new l.SubSurfaceBlock("SubSurface");case"CurrentScreenBlock":return new l.CurrentScreenBlock("CurrentScreen");case"ParticleUVBlock":var Z=new l.InputBlock("uv");return Z.setAsAttribute("particle_uv"),Z;case"ParticleTextureBlock":return new l.ParticleTextureBlock("ParticleTexture");case"ParticleColorBlock":var Q=new l.InputBlock("Color");return Q.setAsAttribute("particle_color"),Q;case"ParticleTextureMaskBlock":var K=new l.InputBlock("TextureMask");return K.setAsAttribute("particle_texturemask"),K;case"ParticlePositionWorldBlock":var $=new l.InputBlock("PositionWorld");return $.setAsAttribute("particle_positionw"),$;case"ParticleRampGradientBlock":return new l.ParticleRampGradientBlock("ParticleRampGradient");case"ParticleBlendMultiplyBlock":return new l.ParticleBlendMultiplyBlock("ParticleBlendMultiply");case"FragCoordBlock":return new l.FragCoordBlock("FragCoord");case"ScreenSizeBlock":return new l.ScreenSizeBlock("ScreenSize");case"SceneDepthBlock":return new l.SceneDepthBlock("SceneDepth");case"EqualBlock":var J=new l.ConditionalBlock("Equal");return J.condition=l.ConditionalBlockConditions.Equal,J;case"NotEqualBlock":var ee=new l.ConditionalBlock("NotEqual");return ee.condition=l.ConditionalBlockConditions.NotEqual,ee;case"LessThanBlock":var te=new l.ConditionalBlock("LessThan");return te.condition=l.ConditionalBlockConditions.LessThan,te;case"LessOrEqualBlock":var ne=new l.ConditionalBlock("LessOrEqual");return ne.condition=l.ConditionalBlockConditions.LessOrEqual,ne;case"GreaterThanBlock":var re=new l.ConditionalBlock("GreaterThan");return re.condition=l.ConditionalBlockConditions.GreaterThan,re;case"GreaterOrEqualBlock":var oe=new l.ConditionalBlock("GreaterOrEqual");return oe.condition=l.ConditionalBlockConditions.GreaterOrEqual,oe;case"XorBlock":var ae=new l.ConditionalBlock("Xor");return ae.condition=l.ConditionalBlockConditions.Xor,ae;case"OrBlock":var ie=new l.ConditionalBlock("Or");return ie.condition=l.ConditionalBlockConditions.Or,ie;case"AndBlock":var le=new l.ConditionalBlock("And");return le.condition=l.ConditionalBlockConditions.And,le;case"ImageSourceBlock":return new l.ImageSourceBlock("ImageSource");case"ClipPlanesBlock":return new l.ClipPlanesBlock("ClipPlanes")}return null},e.GetColorFromConnectionNodeType=function(e){var t="#880000";switch(e){case l.NodeMaterialBlockConnectionPointTypes.Float:t="#cb9e27";break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:t="#16bcb1";break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:case l.NodeMaterialBlockConnectionPointTypes.Color3:t="#b786cb";break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:case l.NodeMaterialBlockConnectionPointTypes.Color4:t="#be5126";break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:t="#591990";break;case l.NodeMaterialBlockConnectionPointTypes.Object:t="#6174FA"}return t},e.GetConnectionNodeTypeFromString=function(e){switch(e){case"Float":return l.NodeMaterialBlockConnectionPointTypes.Float;case"Vector2":return l.NodeMaterialBlockConnectionPointTypes.Vector2;case"Vector3":return l.NodeMaterialBlockConnectionPointTypes.Vector3;case"Vector4":return l.NodeMaterialBlockConnectionPointTypes.Vector4;case"Matrix":return l.NodeMaterialBlockConnectionPointTypes.Matrix;case"Color3":return l.NodeMaterialBlockConnectionPointTypes.Color3;case"Color4":return l.NodeMaterialBlockConnectionPointTypes.Color4}return l.NodeMaterialBlockConnectionPointTypes.AutoDetect},e.GetStringFromConnectionNodeType=function(e){switch(e){case l.NodeMaterialBlockConnectionPointTypes.Float:return"Float";case l.NodeMaterialBlockConnectionPointTypes.Vector2:return"Vector2";case l.NodeMaterialBlockConnectionPointTypes.Vector3:return"Vector3";case l.NodeMaterialBlockConnectionPointTypes.Vector4:return"Vector4";case l.NodeMaterialBlockConnectionPointTypes.Color3:return"Color3";case l.NodeMaterialBlockConnectionPointTypes.Color4:return"Color4";case l.NodeMaterialBlockConnectionPointTypes.Matrix:return"Matrix"}return""},e}(),ze={position2d:"position",particle_uv:"uv",particle_color:"color",particle_texturemask:"textureMask",particle_positionw:"positionW"},je={position2d:"screen",particle_uv:"particle",particle_color:"particle",particle_texturemask:"particle",particle_positionw:"particle"},Ue=function(){function e(){}return e.prototype.getHeaderClass=function(e){var t=e;return t.isConstant?"constant":t.visibleInInspector?"inspector":""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(t){var n=t,r="".concat(n.name," (").concat(e.GetBaseType(n.output.type),")");return n.isAttribute&&(r=e.GetBaseType(n.output.type)),r},e.GetBaseType=function(e){return l.NodeMaterialBlockConnectionPointTypes[e]},e.prototype.getBackgroundColor=function(e){var t="",n=e;switch(n.type){case l.NodeMaterialBlockConnectionPointTypes.Color3:case l.NodeMaterialBlockConnectionPointTypes.Color4:if(n.value){t=n.value.toHexString();break}default:t=Fe.GetColorFromConnectionNodeType(n.type)}return t},e.prototype.updatePreviewContent=function(e,t){var n,r,o="",a=e;if(a.isAttribute){var i=null!==(n=ze[a.name])&&void 0!==n?n:a.name;o=(null!==(r=je[a.name])&&void 0!==r?r:"mesh")+"."+i}else if(a.isSystemValue)switch(a.systemValue){case l.NodeMaterialSystemValues.World:o="World";break;case l.NodeMaterialSystemValues.WorldView:o="World x View";break;case l.NodeMaterialSystemValues.WorldViewProjection:o="World x View x Projection";break;case l.NodeMaterialSystemValues.View:o="View";break;case l.NodeMaterialSystemValues.ViewProjection:o="View x Projection";break;case l.NodeMaterialSystemValues.Projection:o="Projection";break;case l.NodeMaterialSystemValues.CameraPosition:o="Camera position";break;case l.NodeMaterialSystemValues.FogColor:o="Fog color";break;case l.NodeMaterialSystemValues.DeltaTime:o="Delta time";break;case l.NodeMaterialSystemValues.CameraParameters:o="Camera parameters";break;case l.NodeMaterialSystemValues.MaterialAlpha:o="Material alpha"}else switch(a.type){case l.NodeMaterialBlockConnectionPointTypes.Float:o=a.animationType!==l.AnimatedInputBlockTypes.None?l.AnimatedInputBlockTypes[a.animationType]:a.value.toFixed(4);break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:var s=a.value;o="(".concat(s.x.toFixed(2),", ").concat(s.y.toFixed(2),")");break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:var c=a.value;o="(".concat(c.x.toFixed(2),", ").concat(c.y.toFixed(2),", ").concat(c.z.toFixed(2),")");break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:var u=a.value;o="(".concat(u.x.toFixed(2),", ").concat(u.y.toFixed(2),", ").concat(u.z.toFixed(2),", ").concat(u.w.toFixed(2),")")}t.innerHTML=o,t.classList.add("input-block")},e}(),Ve=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"rgb(106, 44, 131)"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("output-block")},e}(),We=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#4086BB"},e.prototype.updatePreviewContent=function(e,t){var n=e;t.classList.add("clamp-block"),t.innerHTML="[".concat(n.minimum,", ").concat(n.maximum,"]")},e}(),He=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){var t=e.colorSteps.map((function(e){return"rgb(".concat(255*e.color.r,", ").concat(255*e.color.g,", ").concat(255*e.color.b,") ").concat(100*e.step,"%")}));return t.length?"linear-gradient(90deg, ".concat(t.join(", "),")"):"black"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("gradient-block")},e}(),qe=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#4086BB"},e.prototype._extractInputValue=function(e){var t=e.connectedPoint.ownerBlock;if(t.isInput){var n=t;if(n.isUniform&&!n.isSystemValue)return n.value}return"?"},e.prototype.updatePreviewContent=function(e,t){var n=e,r=n.sourceMin.isConnected?this._extractInputValue(n.sourceMin):n.sourceRange.x,o=n.sourceMax.isConnected?this._extractInputValue(n.sourceMax):n.sourceRange.y,a=n.targetMin.isConnected?this._extractInputValue(n.targetMin):n.targetRange.x,i=n.targetMax.isConnected?this._extractInputValue(n.targetMax):n.targetRange.y;t.classList.add("remap-block"),t.innerHTML="[".concat(r,", ").concat(o,"] -> [").concat(a,", ").concat(i,"]")},e}(),Ye=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#405C86"},e.prototype.updatePreviewContent=function(e,t){var n=e;t.classList.add("trigonometry-block"),t.innerHTML=l.TrigonometryBlockOperations[n.operation]},e}(),Xe=function(e){function t(t){var n=e.call(this,t)||this;return n.state={displayRed:!0,displayGreen:!0,displayBlue:!0,displayAlpha:!0,face:0},n.canvasRef=o.createRef(),n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!0},t.prototype.componentDidMount=function(){this.updatePreview()},t.prototype.componentDidUpdate=function(){this.updatePreview()},t.prototype.updatePreview=function(){t.UpdatePreview(this.canvasRef.current,this.props.texture,this.props.width,this.state,void 0,this.props.globalState)},t.UpdatePreview=function(e,n,r,o,a,i){return d(this,void 0,void 0,(function(){var s,c,u,p,d,f,m,g,v,b,y,x,w,k,_,C,S,E,P,T,B;return h(this,(function(h){switch(h.label){case 0:return!n.isReady()&&n._texture&&n._texture.onLoadedObservable.addOnce((function(){t.UpdatePreview(e,n,r,o,a,i)})),s=n.getScene(),c=s.getEngine(),u=n.getSize(),p=u.width/u.height,d=r/p|1,n.isCube?((m=new l.PassCubePostProcess("pass",1,null,l.Texture.NEAREST_SAMPLINGMODE,c,!1,l.Constants.TEXTURETYPE_UNSIGNED_INT)).face=o.face,f=m):f=new l.PassPostProcess("pass",1,null,l.Texture.NEAREST_SAMPLINGMODE,c,!1,l.Constants.TEXTURETYPE_UNSIGNED_INT),f.getEffect().isReady()?(i&&(i.blockMutationUpdates=!0),g=new l.RenderTargetTexture("temp",{width:r,height:d},s,!1),f.externalTextureSamplerBinding=!0,f.onApply=function(e){e.setTexture("textureSampler",n)},(v=g.renderTarget)?(s.postProcessManager.directRender([f],v,!0),b=4*r,y=d/2,[4,c.readPixels(0,0,r,d)]):[3,2]):(f.dispose(),setTimeout((function(){return t.UpdatePreview(e,n,r,o,a,i)}),250),[2]);case 1:if(x=h.sent(),w=new Uint8Array(x.buffer,0,x.byteLength),!(n.isCube||o.displayRed&&o.displayGreen&&o.displayBlue))for(_=0;_<r*d*4;_+=4)o.displayRed||(w[_]=0),o.displayGreen||(w[_+1]=0),o.displayBlue||(w[_+2]=0),o.displayAlpha&&(k=w[_+2],w[_]=k,w[_+1]=k,w[_+2]=k,w[_+2]=0);if(n.invertY||n.isCube)for(_=0;_<y;_++)for(C=0;C<b;C++)E=C+(d-_-1)*b,P=w[S=C+_*b],w[S]=w[E],w[E]=P;e.width=r,e.height=d,(T=e.getContext("2d"))&&(B=T.createImageData(r,d),B.data.set(w),T.putImageData(B,0,0),a&&a()),c.unBindFramebuffer(v),h.label=2;case 2:return g.dispose(),f.dispose(),e.style.height=d+"px",i&&(i.blockMutationUpdates=!1),[2]}}))}))},t.prototype.render=function(){var e=this,t=this.props.texture;return o.createElement("div",{className:"textureLine"},!this.props.hideChannelSelect&&t.isCube&&o.createElement("div",{className:"control3D"},o.createElement("button",{className:0===this.state.face?"px command selected":"px command",onClick:function(){return e.setState({face:0})}},"PX"),o.createElement("button",{className:1===this.state.face?"nx command selected":"nx command",onClick:function(){return e.setState({face:1})}},"NX"),o.createElement("button",{className:2===this.state.face?"py command selected":"py command",onClick:function(){return e.setState({face:2})}},"PY"),o.createElement("button",{className:3===this.state.face?"ny command selected":"ny command",onClick:function(){return e.setState({face:3})}},"NY"),o.createElement("button",{className:4===this.state.face?"pz command selected":"pz command",onClick:function(){return e.setState({face:4})}},"PZ"),o.createElement("button",{className:5===this.state.face?"nz command selected":"nz command",onClick:function(){return e.setState({face:5})}},"NZ")),!this.props.hideChannelSelect&&!t.isCube&&o.createElement("div",{className:"control"},o.createElement("button",{className:this.state.displayRed&&!this.state.displayGreen?"red command selected":"red command",onClick:function(){return e.setState({displayRed:!0,displayGreen:!1,displayBlue:!1,displayAlpha:!1})}},"R"),o.createElement("button",{className:this.state.displayGreen&&!this.state.displayBlue?"green command selected":"green command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!0,displayBlue:!1,displayAlpha:!1})}},"G"),o.createElement("button",{className:this.state.displayBlue&&!this.state.displayAlpha?"blue command selected":"blue command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!1,displayBlue:!0,displayAlpha:!1})}},"B"),o.createElement("button",{className:this.state.displayAlpha&&!this.state.displayRed?"alpha command selected":"alpha command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!1,displayBlue:!1,displayAlpha:!0})}},"A"),o.createElement("button",{className:this.state.displayRed&&this.state.displayGreen?"all command selected":"all command",onClick:function(){return e.setState({displayRed:!0,displayGreen:!0,displayBlue:!0,displayAlpha:!0})}},"ALL")),o.createElement("canvas",{ref:this.canvasRef,className:"preview"}))},t}(o.Component),Ge=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"RefractionBlock"===e.getClassName()||"ReflectionBlock"===e.getClassName()?"#6174FA":"#323232"},e.prototype.updatePreviewContent=function(e,t){var n=this,r=e;this._previewCanvas||(t.classList.add("texture-block"),e instanceof l.TextureBlock&&t.classList.add("regular-texture-block"),e instanceof l.ReflectionBlock&&t.classList.add("reflection-block"),(e instanceof l.CurrentScreenBlock||e instanceof l.ParticleTextureBlock)&&t.classList.add("reduced-texture-block"),this._previewCanvas=t.ownerDocument.createElement("canvas"),this._previewImage=t.ownerDocument.createElement("img"),t.appendChild(this._previewImage),this._previewImage.classList.add("empty")),r.texture?Xe.UpdatePreview(this._previewCanvas,r.texture,140,{face:0,displayRed:!0,displayAlpha:!0,displayBlue:!0,displayGreen:!0},(function(){n._previewImage.src=n._previewCanvas.toDataURL("image/png"),n._previewImage.classList.remove("empty")})):this._previewImage.classList.add("empty")},e}(),Ze=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#540b0b"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("discard-block")},e}(),Qe=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#6174FA"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("pbr-block")},e}(),Ke=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){var t="";switch(e.condition){case l.ConditionalBlockConditions.Equal:t="=";break;case l.ConditionalBlockConditions.NotEqual:t="!=";break;case l.ConditionalBlockConditions.LessThan:t="<";break;case l.ConditionalBlockConditions.LessOrEqual:t="<=";break;case l.ConditionalBlockConditions.GreaterThan:t=">";break;case l.ConditionalBlockConditions.GreaterOrEqual:t=">=";break;case l.ConditionalBlockConditions.Xor:t="xor";break;case l.ConditionalBlockConditions.Or:t="|";break;case l.ConditionalBlockConditions.And:t="&"}return e.name+" ("+t+")"},e.prototype.getBackgroundColor=function(e){return"#00A080"},e.prototype.updatePreviewContent=function(e,t){},e}(),$e=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#323232"},e.prototype.updatePreviewContent=function(e,t){var n=this,r=e;this._previewCanvas||(t.classList.add("texture-block"),t.classList.add("image-source-block"),this._previewCanvas=t.ownerDocument.createElement("canvas"),this._previewImage=t.ownerDocument.createElement("img"),t.appendChild(this._previewImage),this._previewImage.classList.add("empty")),r.texture?Xe.UpdatePreview(this._previewCanvas,r.texture,140,{face:0,displayRed:!0,displayAlpha:!0,displayBlue:!0,displayGreen:!0},(function(){n._previewImage.src=n._previewCanvas.toDataURL("image/png"),n._previewImage.classList.remove("empty")})):this._previewImage.classList.add("empty")},e}(),Je=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){var t=e;return Fe.GetColorFromConnectionNodeType(t.input.type)},e.prototype.updatePreviewContent=function(e,t){t.parentElement.classList.add("elbow-block")},e}(),et=function(){function e(){}return e.RegisteredControls={},e}();et.RegisteredControls.InputBlock=Ue,et.RegisteredControls.VertexOutputBlock=Ve,et.RegisteredControls.FragmentOutputBlock=Ve,et.RegisteredControls.ClampBlock=We,et.RegisteredControls.GradientBlock=He,et.RegisteredControls.RemapBlock=qe,et.RegisteredControls.TrigonometryBlock=Ye,et.RegisteredControls.ConditionalBlock=Ke,et.RegisteredControls.TextureBlock=Ge,et.RegisteredControls.ReflectionTextureBlock=Ge,et.RegisteredControls.ReflectionBlock=Ge,et.RegisteredControls.RefractionBlock=Ge,et.RegisteredControls.CurrentScreenBlock=Ge,et.RegisteredControls.ParticleTextureBlock=Ge,et.RegisteredControls.DiscardBlock=Ze,et.RegisteredControls.PBRMetallicRoughnessBlock=Qe,et.RegisteredControls.AnisotropyBlock=Qe,et.RegisteredControls.ClearCoatBlock=Qe,et.RegisteredControls.SheenBlock=Qe,et.RegisteredControls.SubSurfaceBlock=Qe,et.RegisteredControls.ImageSourceBlock=$e,et.RegisteredControls.ElbowBlock=Je;var tt=function(){function e(e,t,n,r){var o=this;this.connectionPoint=t,this.node=n,this.delegatedPort=null,this._element=e.ownerDocument.createElement("div"),this._element.classList.add("port"),e.appendChild(this._element),this._globalState=r,this._img=e.ownerDocument.createElement("img"),this._element.appendChild(this._img),"port-label"===e.children[0].className&&(this._portLabelElement=e.children[0]),this._element.port=this,this._element.ondragstart=function(){return!1},this._onCandidateLinkMovedObserver=r.onCandidateLinkMoved.add((function(e){var t=o._element.getBoundingClientRect();!e||t.left>e.x||t.right<e.x||t.top>e.y||t.bottom<e.y?o._element.classList.remove("selected"):(o._element.classList.add("selected"),o._globalState.onCandidatePortSelectedObservable.notifyObservers(o))})),this._onSelectionChangedObserver=this._globalState.onSelectionChangedObservable.add((function(e){e===o?o._img.classList.add("selected"):o._img.classList.remove("selected")})),this.refresh()}return Object.defineProperty(e.prototype,"element",{get:function(){return this.delegatedPort?this.delegatedPort.element:this._element},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portName",{get:function(){var e=this.connectionPoint.displayName||this.connectionPoint.name;return this.connectionPoint.ownerBlock.isInput&&(e=this.node.name),e},set:function(e){this._portLabelElement&&(this.connectionPoint.displayName=e,this._portLabelElement.innerHTML=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){if(!this.connectionPoint.isConnected)return!1;if(this._isConnectedToNodeOutsideOfFrame())return!0;var e=this.node.getLinksForConnectionPoint(this.connectionPoint);return!(!e.length||e[0].nodeB!==this.node)},enumerable:!1,configurable:!0}),e.prototype.hasLabel=function(){return!!this._portLabelElement},Object.defineProperty(e.prototype,"exposedOnFrame",{get:function(){return!(!this.connectionPoint.isExposedOnFrame&&!this._isConnectedToNodeOutsideOfFrame())},set:function(e){this.disabled||(this.connectionPoint.isExposedOnFrame=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exposedPortPosition",{get:function(){return this.connectionPoint.exposedPortPosition},set:function(e){this.connectionPoint.exposedPortPosition=e},enumerable:!1,configurable:!0}),e.prototype._isConnectedToNodeOutsideOfFrame=function(){var e=this.node.getLinksForConnectionPoint(this.connectionPoint);if(e.length)for(var t=0;t<e.length;t++)if(e[t].nodeA.enclosingFrameId!==e[t].nodeB.enclosingFrameId)return!0;return!1},e.prototype.refresh=function(){switch(this._element.style.background=Fe.GetColorFromConnectionNodeType(this.connectionPoint.type),this.connectionPoint.type){case l.NodeMaterialBlockConnectionPointTypes.Float:case l.NodeMaterialBlockConnectionPointTypes.Int:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IxPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48Y2lyY2xlIGNsYXNzPSJjbHMtMSIgY3g9IjEwLjUiIGN5PSIxMC41IiByPSI3LjUiLz48L2c+PC9zdmc+";break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IyPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0zLDEwLjVhNy41Miw3LjUyLDAsMCwwLDYuNSw3LjQzVjMuMDdBNy41Miw3LjUyLDAsMCwwLDMsMTAuNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMS41LDMuMDdWMTcuOTNhNy41LDcuNSwwLDAsMCwwLTE0Ljg2WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:case l.NodeMaterialBlockConnectionPointTypes.Color3:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IzPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0zLjU3LDEzLjMxLDkuNSw5Ljg5VjNBNy41MSw3LjUxLDAsMCwwLDMsMTAuNDYsNy4zMiw3LjMyLDAsMCwwLDMuNTcsMTMuMzFaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTYuNDMsMTUsMTAuNSwxMS42Miw0LjU3LDE1YTcuNDgsNy40OCwwLDAsMCwxMS44NiwwWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTE4LDEwLjQ2QTcuNTEsNy41MSwwLDAsMCwxMS41LDNWOS44OWw1LjkzLDMuNDJBNy4zMiw3LjMyLDAsMCwwLDE4LDEwLjQ2WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:case l.NodeMaterialBlockConnectionPointTypes.Color4:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3I0PC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMS41LDExLjV2Ni40M2E3LjUxLDcuNTEsMCwwLDAsNi40My02LjQzWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMy4wN1Y5LjVoNi40M0E3LjUxLDcuNTEsMCwwLDAsMTEuNSwzLjA3WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTkuNSwxNy45M1YxMS41SDMuMDdBNy41MSw3LjUxLDAsMCwwLDkuNSwxNy45M1oiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05LjUsMy4wN0E3LjUxLDcuNTEsMCwwLDAsMy4wNyw5LjVIOS41WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5NYXRyaXg8L3RpdGxlPjxnIGlkPSJMYXllcl81IiBkYXRhLW5hbWU9IkxheWVyIDUiPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsNi4xMVY5LjVoMy4zOUE0LjUxLDQuNTEsMCwwLDAsMTEuNSw2LjExWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMTQuODlhNC41MSw0LjUxLDAsMCwwLDMuMzktMy4zOUgxMS41WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMy4wN3YyQTUuNTQsNS41NCwwLDAsMSwxNS45Miw5LjVoMkE3LjUxLDcuNTEsMCwwLDAsMTEuNSwzLjA3WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTE1LjkyLDExLjVhNS41NCw1LjU0LDAsMCwxLTQuNDIsNC40MnYyYTcuNTEsNy41MSwwLDAsMCw2LjQzLTYuNDNaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNS4wOCwxMS41aC0yQTcuNTEsNy41MSwwLDAsMCw5LjUsMTcuOTN2LTJBNS41NCw1LjU0LDAsMCwxLDUuMDgsMTEuNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05LjUsMy4wN0E3LjUxLDcuNTEsMCwwLDAsMy4wNyw5LjVoMkE1LjU0LDUuNTQsMCwwLDEsOS41LDUuMDhaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNOS41LDExLjVINi4xMUE0LjUxLDQuNTEsMCwwLDAsOS41LDE0Ljg5WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTkuNSw2LjExQTQuNTEsNC41MSwwLDAsMCw2LjExLDkuNUg5LjVaIi8+PC9nPjwvc3ZnPg==";break;case l.NodeMaterialBlockConnectionPointTypes.Object:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMSIgaGVpZ2h0PSIyMSIgdmlld0JveD0iMCAwIDIxIDIxIj48Y2lyY2xlIGN4PSI3LjEiIGN5PSIxMy4wOCIgcj0iMy4yNSIgc3R5bGU9ImZpbGw6I2ZmZiIvPjxwYXRoIGQ9Ik0xMC40OSwzQTcuNTIsNy41MiwwLDAsMCwzLDEwYTUuMTMsNS4xMywwLDEsMSw2LDcuODUsNy42MSw3LjYxLDAsMCwwLDEuNTIuMTYsNy41Miw3LjUyLDAsMCwwLDAtMTVaIiBzdHlsZT0iZmlsbDojZmZmIi8+PC9zdmc+",this._img.style.width="100%",this._img.style.height="100%"}},e.prototype.dispose=function(){this._globalState.onCandidateLinkMoved.remove(this._onCandidateLinkMovedObserver),this._onSelectionChangedObserver&&this._globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},e.CreatePortElement=function(t,n,r,o,a){var i=r.ownerDocument.createElement("div"),l=t.ownerBlock;if(i.classList.add("portLine"),r.appendChild(i),!o||o.shouldDisplayPortLabels(l)){var s=r.ownerDocument.createElement("div");s.classList.add("port-label"),s.innerHTML=t.displayName||t.name,i.appendChild(s)}return new e(i,t,n,a)},e}(),nt=n(146),rt=function(){function e(e,t){var n=this;this.block=e,this._inputPorts=[],this._outputPorts=[],this._links=[],this._x=0,this._y=0,this._gridAlignedX=0,this._gridAlignedY=0,this._mouseStartPointX=null,this._mouseStartPointY=null,this._displayManager=null,this._isVisible=!0,this._enclosingFrameId=-1,this._globalState=t,this._onSelectionChangedObserver=this._globalState.onSelectionChangedObservable.add((function(e){e===n?n._visual.classList.add("selected"):setTimeout((function(){-1===n._ownerCanvas.selectedNodes.indexOf(n)&&n._visual.classList.remove("selected")}))})),this._onUpdateRequiredObserver=this._globalState.onUpdateRequiredObservable.add((function(e){e===n.block&&n.refresh()})),this._onSelectionBoxMovedObserver=this._globalState.onSelectionBoxMoved.add((function(e){var t=n._visual.getBoundingClientRect(),r=!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom);n.isSelected=r})),this._onFrameCreatedObserver=this._globalState.onFrameCreatedObservable.add((function(e){n._ownerCanvas.frames.some((function(e){return-1!==e.nodes.indexOf(n)}))||n.isOverlappingFrame(e)&&e.nodes.push(n)}))}return Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible=e,e?(this._visual.classList.remove("hidden"),this._upateNodePortNames()):this._visual.classList.add("hidden");for(var t=0,n=this._links;t<n.length;t++){n[t].isVisible=e}this._refreshLinks()},enumerable:!1,configurable:!0}),e.prototype._upateNodePortNames=function(){for(var e=0,t=this._inputPorts.concat(this._outputPorts);e<t.length;e++){var n=t[e];n.hasLabel()&&(n.portName=n.connectionPoint.displayName||n.connectionPoint.name)}},Object.defineProperty(e.prototype,"outputPorts",{get:function(){return this._outputPorts},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputPorts",{get:function(){return this._inputPorts},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"links",{get:function(){return this._links},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gridAlignedX",{get:function(){return this._gridAlignedX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gridAlignedY",{get:function(){return this._gridAlignedY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this._gridAlignedX=this._ownerCanvas.getGridPosition(e),this._visual.style.left="".concat(this._gridAlignedX,"px"),this._refreshLinks(),this._refreshFrames())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this._gridAlignedY=this._ownerCanvas.getGridPosition(e),this._visual.style.top="".concat(this._gridAlignedY,"px"),this._refreshLinks(),this._refreshFrames())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._visual.clientWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._visual.clientHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.block.uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.block.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSelected",{get:function(){return this._isSelected},set:function(e){if(this._isSelected!==e)if(this._isSelected=e,e)this._globalState.onSelectionChangedObservable.notifyObservers(this);else{this._visual.classList.remove("selected");var t=this._ownerCanvas.selectedNodes.indexOf(this);t>-1&&this._ownerCanvas.selectedNodes.splice(t,1)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enclosingFrameId",{get:function(){return this._enclosingFrameId},set:function(e){this._enclosingFrameId=e},enumerable:!1,configurable:!0}),e.prototype.isOverlappingFrame=function(e){var t=this._visual.getBoundingClientRect(),n=e.element.getBoundingClientRect();n.width-=5,n.height-=5;var r=!(n.right<t.left||n.left>t.right||n.bottom<t.top||n.top>t.bottom);return r&&(this.enclosingFrameId=e.id),r},e.prototype.getPortForConnectionPoint=function(e){for(var t=0,n=this._inputPorts;t<n.length;t++){if((a=n[t]).connectionPoint===e)return a}for(var r=0,o=this._outputPorts;r<o.length;r++){var a;if((a=o[r]).connectionPoint===e)return a}return null},e.prototype.getLinksForConnectionPoint=function(e){return this._links.filter((function(t){return t.portA.connectionPoint===e||t.portB.connectionPoint===e}))},e.prototype._refreshFrames=function(){if(!this._ownerCanvas._frameIsMoving&&!this._ownerCanvas._isLoading)for(var e=0,t=this._ownerCanvas.frames;e<t.length;e++){t[e].syncNode(this)}},e.prototype._refreshLinks=function(){if(!this._ownerCanvas._isLoading)for(var e=0,t=this._links;e<t.length;e++){t[e].update()}},e.prototype.refresh=function(){var e=this;if(this._displayManager){this._header.innerHTML=this._displayManager.getHeaderText(this.block),this._displayManager.updatePreviewContent(this.block,this._content),this._visual.style.background=this._displayManager.getBackgroundColor(this.block);var t=this._displayManager.getHeaderClass(this.block);this._header.classList.value="header",this._headerContainer.classList.value="header-container",t&&this._headerContainer.classList.add(t)}else this._header.innerHTML=this.block.name;for(var n=0,r=this._inputPorts;n<r.length;n++){r[n].refresh()}for(var o=0,a=this._outputPorts;o<a.length;o++){a[o].refresh()}if(-1!==this.enclosingFrameId){var i=this._ownerCanvas.frames.findIndex((function(t){return t.id===e.enclosingFrameId}));i>=0&&this._ownerCanvas.frames[i].isCollapsed&&this._ownerCanvas.frames[i].redrawFramePorts()}this._comments.innerHTML=this.block.comments||"",this._comments.title=this.block.comments||"",this.block.willBeGeneratedIntoVertexShaderFromFragmentShader?this._promotionWarning.classList.add("visible"):this._promotionWarning.classList.remove("visible")},e.prototype._onDown=function(e){if(!e.srcElement||"IMG"!==e.srcElement.nodeName){-1===this._ownerCanvas.selectedNodes.indexOf(this)?this._globalState.onSelectionChangedObservable.notifyObservers(this):e.ctrlKey&&(this.isSelected=!1),e.stopPropagation();for(var t=0,n=this._ownerCanvas.selectedNodes;t<n.length;t++){n[t].cleanAccumulation()}this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,this._visual.setPointerCapture(e.pointerId)}},e.prototype.cleanAccumulation=function(e){void 0===e&&(e=!1),this.x=this._ownerCanvas.getGridPosition(this.x,e),this.y=this._ownerCanvas.getGridPosition(this.y,e)},e.prototype._onUp=function(e){e.stopPropagation();for(var t=0,n=this._ownerCanvas.selectedNodes;t<n.length;t++){n[t].cleanAccumulation()}this._mouseStartPointX=null,this._mouseStartPointY=null,this._visual.releasePointerCapture(e.pointerId)},e.prototype._onMove=function(e){if(null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&!e.ctrlKey){for(var t=(e.clientX-this._mouseStartPointX)/this._ownerCanvas.zoom,n=(e.clientY-this._mouseStartPointY)/this._ownerCanvas.zoom,r=0,o=this._ownerCanvas.selectedNodes;r<o.length;r++){var a=o[r];a.x+=t,a.y+=n}this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,e.stopPropagation()}},e.prototype.renderProperties=function(){var e=De.RegisteredControls[this.block.getClassName()];return e||(e=me),o.createElement(e,{globalState:this._globalState,block:this.block})},e.prototype.appendVisual=function(e,t){var n=this;this._ownerCanvas=t;var r=et.RegisteredControls[this.block.getClassName()];r&&(this._displayManager=new r),this._visual=e.ownerDocument.createElement("div"),this._visual.classList.add("visual"),this._visual.addEventListener("pointerdown",(function(e){return n._onDown(e)})),this._visual.addEventListener("pointerup",(function(e){return n._onUp(e)})),this._visual.addEventListener("pointermove",(function(e){return n._onMove(e)})),this._headerContainer=e.ownerDocument.createElement("div"),this._headerContainer.classList.add("header-container"),this._visual.appendChild(this._headerContainer),this._header=e.ownerDocument.createElement("div"),this._header.classList.add("header"),this._headerContainer.appendChild(this._header),this._promotionWarning=e.ownerDocument.createElement("div"),this._promotionWarning.classList.add("promotion-warning"),this._promotionWarning.title="For optimization reasons, this block will be promoted to the vertex shader. You can force it to render in the fragment shader by setting its target to Fragment";var o=e.ownerDocument.createElement("img");o.src=nt,this._promotionWarning.appendChild(o),this._visual.appendChild(this._promotionWarning);var a=e.ownerDocument.createElement("div");a.classList.add("selection-border"),this._visual.appendChild(a),this._connections=e.ownerDocument.createElement("div"),this._connections.classList.add("connections"),this._visual.appendChild(this._connections),this._inputsContainer=e.ownerDocument.createElement("div"),this._inputsContainer.classList.add("inputsContainer"),this._connections.appendChild(this._inputsContainer),this._outputsContainer=e.ownerDocument.createElement("div"),this._outputsContainer.classList.add("outputsContainer"),this._connections.appendChild(this._outputsContainer),this._content=e.ownerDocument.createElement("div"),this._content.classList.add("content"),this._visual.appendChild(this._content),e.appendChild(this._visual),this._comments=e.ownerDocument.createElement("div"),this._comments.classList.add("comments"),this._visual.appendChild(this._comments);for(var i=0,l=this.block.inputs;i<l.length;i++){var s=l[i];this._inputPorts.push(tt.CreatePortElement(s,this,this._inputsContainer,this._displayManager,this._globalState))}for(var c=0,u=this.block.outputs;c<u.length;c++){var p=u[c];this._outputPorts.push(tt.CreatePortElement(p,this,this._outputsContainer,this._displayManager,this._globalState))}this.refresh()},e.prototype.dispose=function(){this._globalState.onGraphNodeRemovalObservable.notifyObservers(this),this._onSelectionChangedObserver&&this._globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._onUpdateRequiredObserver&&this._globalState.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver),this._onSelectionBoxMovedObserver&&this._globalState.onSelectionBoxMoved.remove(this._onSelectionBoxMovedObserver),this._visual.parentElement&&this._visual.parentElement.removeChild(this._visual),this._onFrameCreatedObserver&&this._globalState.onFrameCreatedObservable.remove(this._onFrameCreatedObserver);for(var e=0,t=this._inputPorts;e<t.length;e++){t[e].dispose()}for(var n=0,r=this._outputPorts;n<r.length;n++){r[n].dispose()}for(var o=0,a=this._links.slice(0);o<a.length;o++){a[o].dispose()}this.block.dispose()},e}(),ot=n(71),at=function(){function e(e,t,n,r,o){var a=this;this._isVisible=!0,this.onDisposedObservable=new l.Observable,this._portA=t,this._portB=r,this._nodeA=n,this._nodeB=o,this._graphCanvas=e;var i=t.element.ownerDocument,s=e.svgCanvas;this._path=i.createElementNS("http://www.w3.org/2000/svg","path"),this._path.setAttribute("fill","none"),this._path.classList.add("link"),s.appendChild(this._path),this._selectionPath=i.createElementNS("http://www.w3.org/2000/svg","path"),this._selectionPath.setAttribute("fill","none"),this._selectionPath.classList.add("selection-link"),s.appendChild(this._selectionPath),this._selectionPath.onmousedown=function(){return a.onClick()},this._portB&&this.update(),this._onSelectionChangedObserver=this._graphCanvas.globalState.onSelectionChangedObservable.add((function(e){e===a?(a._path.classList.add("selected"),a._selectionPath.classList.add("selected")):(a._path.classList.remove("selected"),a._selectionPath.classList.remove("selected"))}))}return Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible=e,e?(this._path.classList.remove("hidden"),this._selectionPath.classList.remove("hidden")):(this._path.classList.add("hidden"),this._selectionPath.classList.add("hidden")),this.update()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portA",{get:function(){return this._portA},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portB",{get:function(){return this._portB},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeA",{get:function(){return this._nodeA},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeB",{get:function(){return this._nodeB},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=!1);var r=this._portA.element.getBoundingClientRect(),o=this._graphCanvas.canvasContainer.getBoundingClientRect(),a=this._graphCanvas.zoom,i=o.left,l=o.top,s=(r.left-i+.5*r.width)/a,c=(r.top-l+.5*r.height)/a;if(this._portB){var u=this._portB.element.getBoundingClientRect();e=(u.left-i+.5*u.width)/a,t=(u.top-l+.5*u.height)/a}if(n)this._path.setAttribute("d","M".concat(s,",").concat(c," L").concat(e,",").concat(t)),this._path.setAttribute("stroke-dasharray","10, 10"),this._path.setAttribute("stroke-linecap","round");else{var p=e-s,d=t-c,h=Math.min(.5*Math.sqrt(p*p+d*d),300);this._path.setAttribute("d","M".concat(s,",").concat(c," C").concat(s+h,",").concat(c," ").concat(e-h,",").concat(t," ").concat(e,",").concat(t)),this._selectionPath.setAttribute("d","M".concat(s,",").concat(c," C").concat(s+h,",").concat(c," ").concat(e-h,",").concat(t," ").concat(e,",").concat(t))}this._path.setAttribute("stroke",this._portA.element.style.backgroundColor)},e.prototype.onClick=function(){this._graphCanvas.globalState.onSelectionChangedObservable.notifyObservers(this)},e.prototype.dispose=function(e){void 0===e&&(e=!0),this._graphCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._path.parentElement&&this._path.parentElement.removeChild(this._path),this._selectionPath.parentElement&&this._selectionPath.parentElement.removeChild(this._selectionPath),this._nodeB&&(this._nodeA.links.splice(this._nodeA.links.indexOf(this),1),this._nodeB.links.splice(this._nodeB.links.indexOf(this),1),this._graphCanvas.links.splice(this._graphCanvas.links.indexOf(this),1),this._portA.connectionPoint.disconnectFrom(this._portB.connectionPoint),ct._RefreshNode(this._nodeB)),e&&(this.onDisposedObservable.notifyObservers(this),this.onDisposedObservable.clear())},e}();n(323);var it,lt,st=function(e){return!!e&&void 0!==e.port},ct=function(e){function t(t){var n=e.call(this,t)||this;return n.MinZoom=.1,n.MaxZoom=4,n._nodes=[],n._links=[],n._mouseStartPointX=null,n._mouseStartPointY=null,n._dropPointX=0,n._dropPointY=0,n._selectionStartX=0,n._selectionStartY=0,n._candidateLinkedHasMoved=!1,n._x=0,n._y=0,n._zoom=1,n._selectedNodes=[],n._selectedLink=null,n._selectedPort=null,n._candidateLink=null,n._candidatePort=null,n._gridSize=20,n._selectionBox=null,n._selectedFrame=null,n._frameCandidate=null,n._frames=[],n._altKeyIsPressed=!1,n._ctrlKeyIsPressed=!1,n._oldY=-1,n._frameIsMoving=!1,n._isLoading=!1,t.globalState.onSelectionChangedObservable.add((function(e){e?e instanceof at?(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=e,n._selectedPort=null):e instanceof pt?(n._selectedNodes=[],n._selectedFrame=e,n._selectedLink=null,n._selectedPort=null):e instanceof rt?n._ctrlKeyIsPressed?-1===n._selectedNodes.indexOf(e)&&n._selectedNodes.push(e):n._selectedNodes=[e]:e instanceof tt?(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=null,n._selectedPort=e):(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=null,n._selectedPort=e.port):(n._selectedNodes=[],n._selectedLink=null,n._selectedFrame=null,n._selectedPort=null)})),t.globalState.onCandidatePortSelectedObservable.add((function(e){n._candidatePort=e})),t.globalState.onGridSizeChanged.add((function(){n.gridSize=l.DataStorage.ReadNumber("GridSize",20)})),n.props.globalState.hostDocument.addEventListener("keyup",(function(){return n.onKeyUp()}),!1),n.props.globalState.hostDocument.addEventListener("keydown",(function(e){n._altKeyIsPressed=e.altKey,n._ctrlKeyIsPressed=e.ctrlKey}),!1),n.props.globalState.hostDocument.defaultView.addEventListener("blur",(function(){n._altKeyIsPressed=!1,n._ctrlKeyIsPressed=!1}),!1),n.props.globalState.storeEditorData=function(e,t){if(e.frames=[],t)e.frames.push(t.serialize(!1));else{e.x=n.x,e.y=n.y,e.zoom=n.zoom;for(var r=0,o=n._frames;r<o.length;r++){var a=o[r];e.frames.push(a.serialize(!0))}}},n}var n;return u(t,e),Object.defineProperty(t.prototype,"gridSize",{get:function(){return this._gridSize},set:function(e){this._gridSize=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"globalState",{get:function(){return this.props.globalState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"links",{get:function(){return this._links},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frames",{get:function(){return this._frames},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoom",{get:function(){return this._zoom},set:function(e){this._zoom!==e&&(this._zoom=e,this.updateTransform())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedNodes",{get:function(){return this._selectedNodes},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedLink",{get:function(){return this._selectedLink},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedFrame",{get:function(){return this._selectedFrame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedPort",{get:function(){return this._selectedPort},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasContainer",{get:function(){return this._graphCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hostCanvas",{get:function(){return this._hostCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"svgCanvas",{get:function(){return this._svgCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectionContainer",{get:function(){return this._selectionContainer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameContainer",{get:function(){return this._frameContainer},enumerable:!1,configurable:!0}),t.prototype.getGridPosition=function(e,t){void 0===t&&(t=!1);var n=this.gridSize;return 0===n?e:t?n*Math.ceil(e/n):n*Math.floor(e/n)},t.prototype.getGridPositionCeil=function(e){var t=this.gridSize;return 0===t?e:t*Math.ceil(e/t)},t.prototype.updateTransform=function(){this._rootContainer.style.transform="translate(".concat(this._x,"px, ").concat(this._y,"px) scale(").concat(this._zoom,")"),l.DataStorage.ReadBoolean("ShowGrid",!0)?(this._hostCanvas.style.backgroundSize="".concat(this._gridSize*this._zoom,"px ").concat(this._gridSize*this._zoom,"px"),this._hostCanvas.style.backgroundPosition="".concat(this._x,"px ").concat(this._y,"px")):this._hostCanvas.style.backgroundSize="0"},t.prototype.onKeyUp=function(){this._altKeyIsPressed=!1,this._ctrlKeyIsPressed=!1,this._oldY=-1},t.prototype.findNodeFromBlock=function(e){return this.nodes.filter((function(t){return t.block===e}))[0]},t.prototype.reset=function(){for(var e=0,t=this._nodes;e<t.length;e++){t[e].dispose()}for(var n=0,r=this._frames.splice(0);n<r.length;n++){r[n].dispose()}this._nodes=[],this._frames=[],this._links=[],this._graphCanvas.innerHTML="",this._svgCanvas.innerHTML=""},t.prototype.connectPorts=function(e,t){var n=e.ownerBlock,r=t.ownerBlock,o=this.findNodeFromBlock(n),a=this.findNodeFromBlock(r);if(o&&a){var i=o.getPortForConnectionPoint(e),l=a.getPortForConnectionPoint(t);if(i&&l){for(var s=0,c=this._links;s<c.length;s++){var u=c[s];if(u.portA===i&&u.portB===l)return;if(u.portA===l&&u.portB===i)return}var p=new at(this,i,o,l,a);this._links.push(p),o.links.push(p),a.links.push(p)}}},t.prototype.removeLink=function(e){var t=this._links.indexOf(e);t>-1&&this._links.splice(t,1),e.dispose()},t.prototype.appendBlock=function(e){var t=new rt(e,this.props.globalState);return t.appendVisual(this._graphCanvas,this),this._nodes.push(t),t},t.prototype.distributeGraph=function(){var e=this;this.x=0,this.y=0,this.zoom=1;var t=new ot.graphlib.Graph;t.setGraph({}),t.setDefaultEdgeLabel((function(){return{}})),t.graph().rankdir="LR",this._nodes.forEach((function(n){e._frames.some((function(e){return-1!==e.nodes.indexOf(n)}))||t.setNode(n.id.toString(),{id:n.id,type:"node",width:n.width,height:n.height})})),this._frames.forEach((function(e){t.setNode(e.id.toString(),{id:e.id,type:"frame",width:e.element.clientWidth,height:e.element.clientHeight})})),this._nodes.forEach((function(n){n.block.outputs.forEach((function(r){r.hasEndpoints&&r.endpoints.forEach((function(r){var o=e._frames.filter((function(e){return-1!==e.nodes.indexOf(n)})),a=e._frames.filter((function(e){return e.nodes.some((function(e){return e.block===r.ownerBlock}))})),i=o.length>0?o[0].id:n.id,l=a.length>0?a[0].id:r.ownerBlock.uniqueId;t.setEdge(i.toString(),l.toString())}))}))})),ot.layout(t),t.nodes().map((function(e){return t.node(e)})).forEach((function(t){if(t)if("node"!==t.type)for(var n=0,r=e._frames;n<r.length;n++){var o=r[n];if(o.id===t.id)return e._frameIsMoving=!0,o.move(t.x-t.width/2,t.y-t.height/2,!1),o.cleanAccumulation(),void(e._frameIsMoving=!1)}else for(var a=0,i=e._nodes;a<i.length;a++){var l=i[a];if(l.id===t.id)return l.x=t.x-t.width/2,l.y=t.y-t.height/2,void l.cleanAccumulation()}}))},t.prototype.componentDidMount=function(){this._hostCanvas=this.props.globalState.hostDocument.getElementById("graph-canvas"),this._rootContainer=this.props.globalState.hostDocument.getElementById("graph-container"),this._graphCanvas=this.props.globalState.hostDocument.getElementById("graph-canvas-container"),this._svgCanvas=this.props.globalState.hostDocument.getElementById("graph-svg-container"),this._selectionContainer=this.props.globalState.hostDocument.getElementById("selection-container"),this._frameContainer=this.props.globalState.hostDocument.getElementById("frame-container"),this.gridSize=l.DataStorage.ReadNumber("GridSize",20),this.updateTransform()},t.prototype.onMove=function(e){if(this._selectionBox){var t=this.canvasContainer.getBoundingClientRect(),n=e.pageX-t.left,r=e.pageY-t.top;return n>this._selectionStartX?(this._selectionBox.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._selectionBox.style.width="".concat((n-this._selectionStartX)/this.zoom,"px")):(this._selectionBox.style.left="".concat(n/this.zoom,"px"),this._selectionBox.style.width="".concat((this._selectionStartX-n)/this.zoom,"px")),r>this._selectionStartY?(this._selectionBox.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._selectionBox.style.height="".concat((r-this._selectionStartY)/this.zoom,"px")):(this._selectionBox.style.top="".concat(r/this.zoom,"px"),this._selectionBox.style.height="".concat((this._selectionStartY-r)/this.zoom,"px")),void this.props.globalState.onSelectionBoxMoved.notifyObservers(this._selectionBox.getBoundingClientRect())}if(this._frameCandidate){t=this.canvasContainer.getBoundingClientRect(),n=e.pageX-t.left,r=e.pageY-t.top;return n>this._selectionStartX?(this._frameCandidate.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._frameCandidate.style.width="".concat((n-this._selectionStartX)/this.zoom,"px")):(this._frameCandidate.style.left="".concat(n/this.zoom,"px"),this._frameCandidate.style.width="".concat((this._selectionStartX-n)/this.zoom,"px")),void(r>this._selectionStartY?(this._frameCandidate.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._frameCandidate.style.height="".concat((r-this._selectionStartY)/this.zoom,"px")):(this._frameCandidate.style.top="".concat(r/this.zoom,"px"),this._frameCandidate.style.height="".concat((this._selectionStartY-r)/this.zoom,"px")))}if(this._candidateLink){t=this.canvasContainer.getBoundingClientRect();return this._candidatePort=null,this.props.globalState.onCandidateLinkMoved.notifyObservers(new l.Vector2(e.pageX,e.pageY)),this._dropPointX=(e.pageX-t.left)/this.zoom,this._dropPointY=(e.pageY-t.top)/this.zoom,this._candidateLink.update(this._dropPointX,this._dropPointY,!0),void(this._candidateLinkedHasMoved=!0)}if(this._altKeyIsPressed&&1===e.buttons){this._oldY<0&&(this._oldY=e.pageY);var o=(e.pageY-this._oldY)/10;if(Math.abs(o)>5){var a=this.zoom;this.zoom=Math.max(Math.min(this.MaxZoom,this.zoom+o/100),this.MinZoom);var i=e.currentTarget.getBoundingClientRect(),s=i.width,c=s*this.zoom-s*a,u=(e.clientX-i.left-this.x)/a/s;this.x=this.x-c*u,this._oldY=e.pageY}}else this._rootContainer.style.cursor="move",null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&(this.x+=e.clientX-this._mouseStartPointX,this.y+=e.clientY-this._mouseStartPointY,this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY)},t.prototype.onDown=function(e){if(this._rootContainer.setPointerCapture(e.pointerId),e.currentTarget===this._hostCanvas&&e.ctrlKey){this._selectionBox=this.props.globalState.hostDocument.createElement("div"),this._selectionBox.classList.add("selection-box"),this._selectionContainer.appendChild(this._selectionBox);var t=this.canvasContainer.getBoundingClientRect();return this._selectionStartX=e.pageX-t.left,this._selectionStartY=e.pageY-t.top,this._selectionBox.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._selectionBox.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._selectionBox.style.width="0px",void(this._selectionBox.style.height="0px")}if(e.currentTarget===this._hostCanvas&&e.shiftKey){this._frameCandidate=this.props.globalState.hostDocument.createElement("div"),this._frameCandidate.classList.add("frame-box"),this._frameContainer.appendChild(this._frameCandidate);t=this.canvasContainer.getBoundingClientRect();return this._selectionStartX=e.pageX-t.left,this._selectionStartY=e.pageY-t.top,this._frameCandidate.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._frameCandidate.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._frameCandidate.style.width="0px",void(this._frameCandidate.style.height="0px")}if(e.nativeEvent.srcElement&&"IMG"===e.nativeEvent.srcElement.nodeName){if(!this._candidateLink){var n=e.nativeEvent.srcElement.parentElement.port;this._candidateLink=new at(this,n,n.node),this._candidateLinkedHasMoved=!1}}else this.props.globalState.onSelectionChangedObservable.notifyObservers(null),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY},t.prototype.onUp=function(e){if(this._mouseStartPointX=null,this._mouseStartPointY=null,this._rootContainer.releasePointerCapture(e.pointerId),this._oldY=-1,this._candidateLink){if(this._candidateLinkedHasMoved)this.processCandidatePort(),this.props.globalState.onCandidateLinkMoved.notifyObservers(null);else if(this._candidateLink.portA instanceof ut){var t=this._candidateLink.portA,n=this.frames.find((function(e){return e.id===t.parentFrameId}));if(n){var r={frame:n,port:t};this.props.globalState.onSelectionChangedObservable.notifyObservers(r)}}else this._candidateLink.portA instanceof tt&&this.props.globalState.onSelectionChangedObservable.notifyObservers(this._candidateLink.portA);this._candidateLink.dispose(),this._candidateLink=null,this._candidatePort=null}if(this._selectionBox&&(this._selectionBox.parentElement.removeChild(this._selectionBox),this._selectionBox=null),this._frameCandidate){var o=new pt(this._frameCandidate,this);this._frames.push(o),this._frameCandidate.parentElement.removeChild(this._frameCandidate),this._frameCandidate=null,this.props.globalState.onSelectionChangedObservable.notifyObservers(o)}},t.prototype.onWheel=function(e){var t=e.deltaY<0?.1:-.1,n=this.zoom;this.zoom=Math.min(Math.max(this.MinZoom,this.zoom+t*this.zoom),this.MaxZoom);var r=e.currentTarget.getBoundingClientRect(),o=r.width,a=r.height,i=o*this.zoom-o*n,l=a*this.zoom-a*n,s=e.clientX-r.left,c=e.clientY-r.top,u=(s-this.x)/n/o,p=(c-this.y)/n/a;this.x=this.x-i*u,this.y=this.y-l*p,e.stopPropagation()},t.prototype.zoomToFit=function(){var e=this,t=0,n=0;this._nodes.forEach((function(r){e._frames.some((function(e){return-1!==e.nodes.indexOf(r)}))||(r.x<t&&(t=r.x),r.y<n&&(n=r.y))})),this._frames.forEach((function(e){e.x<t&&(t=e.x),e.y<n&&(n=e.y)})),this._frames.forEach((function(e){e.x+=-t,e.y+=-n,e.cleanAccumulation()})),this._nodes.forEach((function(e){e.x+=-t,e.y+=-n,e.cleanAccumulation()}));var r=this._rootContainer.clientWidth/this._rootContainer.scrollWidth,o=this._rootContainer.clientHeight/this._rootContainer.scrollHeight,a=r<o?r:o;this.zoom=a,this.x=0,this.y=0},t.prototype.processCandidatePort=function(){var e,n,r=this,o=this._candidateLink.portA.connectionPoint,a=this._candidateLink.portA.node;if(this._candidatePort)e=this._candidatePort.connectionPoint,n=this._candidatePort.node;else{if(o.direction===l.NodeMaterialConnectionPointDirection.Output)return;var i="output",s=void 0,c=this._candidateLink.portA.connectionPoint.createCustomInputBlock();c?(s=c[0],i=c[1]):s=new l.InputBlock(l.NodeMaterialBlockConnectionPointTypes[this._candidateLink.portA.connectionPoint.type],void 0,this._candidateLink.portA.connectionPoint.type),this.props.globalState.nodeMaterial.attachedBlocks.push(s),e=s[i],s.isInput?n=this.appendBlock(s):(s.autoConfigure(this.props.globalState.nodeMaterial),n=this.props.onEmitNewBlock(s)),n.x=this._dropPointX-200,n.y=this._dropPointY-50;var u=n.x-250,p=n.y;s.inputs.forEach((function(e){if(e.connectedPoint){var t=r.nodes.filter((function(t){return t.block===e.connectedPoint.ownerBlock}))[0];0===t.x&&0===t.y&&(t.x=u,t.y=p,t.cleanAccumulation(),p+=80)}}))}if(e.direction===l.NodeMaterialConnectionPointDirection.Input){var d=o;o=e,e=d;var h=n;n=a,a=h}if(o.connectedPoint!==e&&o!==e&&o.direction!==e.direction&&o.ownerBlock!==e.ownerBlock){var f="FragmentOutputBlock"===o.ownerBlock.getClassName(),m=e.checkCompatibilityState(o);if(!e.needDualDirectionValidation&&!o.needDualDirectionValidation||m!==l.NodeMaterialConnectionPointCompatibilityStates.Compatible||e instanceof l.InputBlock||(m=o.checkCompatibilityState(e)),m===l.NodeMaterialConnectionPointCompatibilityStates.Compatible){if(f){var g=o.ownerBlock;"rgb"===o.name&&g.rgba.isConnected?a.getLinksForConnectionPoint(g.rgba)[0].dispose():"rgba"===o.name&&g.rgb.isConnected&&a.getLinksForConnectionPoint(g.rgb)[0].dispose()}var v=null;if(o.isConnected){var b=a.getLinksForConnectionPoint(o);v=b.slice(),b.forEach((function(e){e.dispose(!1)}))}o.ownerBlock.inputsAreExclusive&&o.ownerBlock.inputs.forEach((function(e){var t=a.getLinksForConnectionPoint(e);v?v.push.apply(v,t.slice()):v=t.slice(),t.forEach((function(e){e.dispose(!1)}))})),e.connectTo(o),this.connectPorts(e,o);var y=new Set([n]),x=new Set([a.links[a.links.length-1]]);t._RefreshNode(a,y,x),null==v||v.forEach((function(e){e.onDisposedObservable.notifyObservers(e),e.onDisposedObservable.clear()})),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}else{var w="";switch(m){case l.NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible:w="Cannot connect two different connection types";break;case l.NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible:w="Source block can only work in fragment shader whereas destination block is currently aimed for the vertex shader";break;case l.NodeMaterialConnectionPointCompatibilityStates.HierarchyIssue:w="Source block cannot be connected with one of its ancestors"}this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers(w)}}},t.prototype.processEditorData=function(e){for(var t=0,n=this._frames.splice(0);t<n.length;t++){(i=n[t]).dispose()}if(this._frames=[],this.x=e.x||0,this.y=e.y||0,this.zoom=e.zoom||1,e.frames)for(var r=0,o=e.frames;r<o.length;r++){var a=o[r],i=pt.Parse(a,this,e.map);this._frames.push(i)}},t.prototype.addFrame=function(e){var t=pt.Parse(e,this,this.props.globalState.nodeMaterial.editorData.map);this._frames.push(t),this.globalState.onSelectionChangedObservable.notifyObservers(t)},t.prototype.render=function(){var e=this;return o.createElement("div",{id:"graph-canvas",onWheel:function(t){return e.onWheel(t)},onPointerMove:function(t){return e.onMove(t)},onPointerDown:function(t){return e.onDown(t)},onPointerUp:function(t){return e.onUp(t)}},o.createElement("div",{id:"graph-container"},o.createElement("div",{id:"graph-canvas-container"}),o.createElement("div",{id:"frame-container"}),o.createElement("svg",{id:"graph-svg-container"}),o.createElement("div",{id:"selection-container"})))},n=t,t._RefreshNode=function(e,t,r){e.refresh();var o=e.links;t&&o.forEach((function(e){var o=e.nodeA,a=e.nodeB;t.has(o)||(t.add(o),n._RefreshNode(o,t,r)),a&&!t.has(a)&&(t.add(a),n._RefreshNode(a,t,r))})),r&&o.forEach((function(e){r.has(e)||(r.add(e),e.update())}))},t}(o.Component),ut=function(e){function t(t,n,r,o,a,i,s){var c=e.call(this,t,n,r,o)||this;return c.connectionPoint=n,c.node=r,c._onFramePortPositionChangedObservable=new l.Observable,c._parentFrameId=s,c._isInput=a,c._framePortId=i,c._onSelectionChangedObserver=c._globalState.onSelectionChangedObservable.add((function(e){st(e)&&e.port===c?c._img.classList.add("selected"):c._img.classList.remove("selected")})),c.refresh(),c}return u(t,e),Object.defineProperty(t.prototype,"parentFrameId",{get:function(){return this._parentFrameId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onFramePortPositionChangedObservable",{get:function(){return this._onFramePortPositionChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framePortId",{get:function(){return this._framePortId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framePortPosition",{get:function(){return this._framePortPosition},set:function(e){this._framePortPosition=e,this.onFramePortPositionChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),t.CreateFrameNodePortElement=function(e,n,r,o,a,i,l,s){var c=r.ownerDocument.createElement("div"),u=e.ownerBlock;if(c.classList.add("portLine"),null!==l&&(c.dataset.framePortId="".concat(l)),r.appendChild(c),!o||o.shouldDisplayPortLabels(u)){var p=r.ownerDocument.createElement("div");p.classList.add("port-label");var d=e.displayName||e.name;e.ownerBlock.isInput&&(d=n.name),p.innerHTML=d,c.appendChild(p)}return new t(c,e,n,a,i,l,s)},t}(tt);!function(e){e[e.Right=0]="Right",e[e.Left=1]="Left",e[e.Top=2]="Top",e[e.Bottom=3]="Bottom",e[e.TopRight=4]="TopRight",e[e.TopLeft=5]="TopLeft",e[e.BottomRight=6]="BottomRight",e[e.BottomLeft=7]="BottomLeft"}(it||(it={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(lt||(lt={}));var pt=function(){function e(t,n,r){var o=this;void 0===r&&(r=!1),this.CollapsedWidth=200,this._x=0,this._y=0,this._gridAlignedX=0,this._gridAlignedY=0,this._nodes=[],this._mouseStartPointX=null,this._mouseStartPointY=null,this._onNodeLinkDisposedObservers=[],this._isCollapsed=!1,this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._exposedInPorts=[],this._exposedOutPorts=[],this._minFrameHeight=40,this._minFrameWidth=220,this.onExpandStateChanged=new l.Observable,this.CloseSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M16,15l5.85,5.84-1,1L15,15.93,9.15,21.78l-1-1L14,15,8.19,9.12l1-1L15,14l5.84-5.84,1,1Z"/></g></svg>',this.ExpandSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-6.75,6.75H11.06V14.44h3.38V11.06h1.12v3.38h3.38v1.12H15.56v3.38H14.44Z"/></g></svg>',this.CollapseSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-2.25,6.75H11.06V14.44h7.88Z"/></g></svg>',this.initResizing=function(e){e.stopPropagation(),o._mouseStartPointX=e.clientX,o._mouseStartPointY=e.clientY,o._frameIsResizing=!0},this.cleanUpResizing=function(e){e.stopPropagation(),o._frameIsResizing=!1,o._resizingDirection=null,o._mouseStartPointX=null,o._mouseStartPointY=null,o.mouseXLimit=null,o.refresh()},this.updateMinHeightWithComments=function(){if(o.comments&&o.comments.length>0){var e=o._commentsElement.offsetHeight+40;o._minFrameHeight=e}},this._onRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(o.initResizing(e),t._resizingDirection=it.Right,t.mouseXLimit=e.clientX-(t.width-t._minFrameWidth),t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onRightHandlePointerMove))},this._onRightHandlePointerMove=function(e){var t=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,n=o._mouseStartPointX-t;o._moveRightHandle(e,n)},this._moveRightHandle=function(e,t){var n=o;if(n.mouseXLimit){if(!n._isResizingRight()||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientX<t)return;if(n._isResizingRight()){e.stopPropagation();var r=(e.clientX-n._mouseStartPointX)/n._ownerCanvas.zoom;n._expandRight(r,e.clientX),n._mouseStartPointX=e.clientX}}},this._onRightHandlePointerUp=function(e){var t=o;t._isResizingRight()&&(t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Bottom,t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomHandlePointerMove),t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomHandlePointerUp))},this._onBottomHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t;o._moveBottomHandle(e,n)},this._moveBottomHandle=function(e,t){var n=o;if(!(n._resizingDirection!==it.Bottom||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientY<t)&&n._resizingDirection===it.Bottom){e.stopPropagation();var r=(e.clientY-n._mouseStartPointY)/n._ownerCanvas.zoom;n._expandBottom(r),n._mouseStartPointY=e.clientY}},this._onBottomHandlePointerUp=function(e){var t=o;t._resizingDirection===it.Bottom&&(t.height=parseFloat(t.element.style.height.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomHandlePointerMove),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomHandlePointerUp),t.cleanUpResizing(e))},this._onLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Left,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onLeftHandlePointerMove))},this._onLeftHandlePointerMove=function(e){var t=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,n=o._mouseStartPointX+t;o._moveLeftHandle(e,n)},this._moveLeftHandle=function(e,t){var n=o;if(n.mouseXLimit){if(n._resizingDirection!==it.Left||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientX>t)return;if(n._resizingDirection===it.Left){e.stopPropagation();var r=(e.clientX-n._mouseStartPointX)/n._ownerCanvas.zoom;n._expandLeft(r),n._mouseStartPointX=e.clientX}}},this._onLeftHandlePointerUp=function(e){var t=o;t._resizingDirection===it.Left&&(t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onLeftHandlePointerMove),t.cleanUpResizing(e))},this._onTopHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Top,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopHandlePointerMove))},this._onTopHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t;o._moveTopHandle(e,n)},this._moveTopHandle=function(e,t){var n=o;if(n._isResizingTop()&&null!==n._mouseStartPointX&&null!==n._mouseStartPointY&&!(e.clientY>t)&&n._isResizingTop()){e.stopPropagation();var r=(e.clientY-n._mouseStartPointY)/n._ownerCanvas.zoom;n._expandTop(r),n._mouseStartPointY=e.clientY}},this._onTopHandlePointerUp=function(e){var t=o;t._isResizingTop()&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopHandlePointerMove),t.cleanUpResizing(e))},this._onTopRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.TopRight,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopRightHandlePointerMove))},this._onTopRightHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX-r;o._moveTopRightHandle(e,a,n)},this._moveTopRightHandle=function(e,t,n){var r=o;if(r._isResizingTop()&&r._isResizingRight()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingRight()&&r._isResizingTop())if(e.stopPropagation(),e.clientY<n&&e.clientX>t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}else if(e.clientY>n&&e.clientX>t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX}else if(e.clientY<n&&e.clientX<t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}},this._onTopRightHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.TopRight&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.BottomRight,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomRightHandlePointerMove))},this._onBottomRightHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX-r;o._moveBottomRightHandle(e,a,n)},this._moveBottomRightHandle=function(e,t,n){var r=o;if(r._isResizingBottom()&&r._isResizingRight()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingRight()&&r._isResizingBottom())if(e.stopPropagation(),e.clientY>n&&e.clientX>t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}else if(e.clientY<n&&e.clientX>t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX}else if(e.clientY>n&&e.clientX<t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}},this._onBottomRightHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.BottomRight&&(t.height=parseFloat(t.element.style.height.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.BottomLeft,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomLeftHandlePointerMove))},this._onBottomLeftHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX+r;o._moveBottomLeftHandle(e,a,n)},this._moveBottomLeftHandle=function(e,t,n){var r=o;if(r._isResizingBottom()&&r._isResizingLeft()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingLeft()&&r._isResizingBottom())if(e.stopPropagation(),e.clientY>n&&e.clientX<t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}else if(e.clientY<n&&e.clientX<t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX}else if(e.clientY>n&&e.clientX>t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}},this._onBottomLeftHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.BottomLeft&&(t.height=parseFloat(t.element.style.height.replace("px","")),t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomLeftHandlePointerMove),t.cleanUpResizing(e))},this._onTopLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.TopLeft,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopLeftHandlePointerMove))},this._onTopLeftHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX+r;o._moveTopLeftHandle(e,a,n)},this._moveTopLeftHandle=function(e,t,n){var r=o;if(r._isResizingTop()&&r._isResizingLeft()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingLeft()&&r._isResizingTop())if(e.stopPropagation(),e.clientY<n&&e.clientX<t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}else if(e.clientY>n&&e.clientX<t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX}else if(e.clientY<n&&e.clientX>t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}},this._onTopLeftHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.TopLeft&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopLeftHandlePointerMove),t.cleanUpResizing(e))},this._id=e._FrameCounter++,this._ownerCanvas=n;var a=n.frameContainer;this.element=a.ownerDocument.createElement("div"),this.element.classList.add("frame-box"),a.appendChild(this.element),this._headerElement=a.ownerDocument.createElement("div"),this._headerElement.classList.add("frame-box-header"),this._headerElement.addEventListener("dblclick",(function(){o.isCollapsed=!o.isCollapsed})),this.element.appendChild(this._headerElement),this._borderElement=a.ownerDocument.createElement("div"),this._borderElement.classList.add("frame-box-border"),this.element.appendChild(this._borderElement);var i=a.ownerDocument.createElement("div");i.className="handle right-handle",this.element.appendChild(i),i.addEventListener("pointerdown",this._onRightHandlePointerDown);var s=a.ownerDocument.createElement("div");s.className="handle left-handle",this.element.appendChild(s),s.addEventListener("pointerdown",this._onLeftHandlePointerDown);var c=a.ownerDocument.createElement("div");c.className="handle bottom-handle",this.element.appendChild(c),c.addEventListener("pointerdown",this._onBottomHandlePointerDown);var u=a.ownerDocument.createElement("div");u.className="handle top-handle",this.element.appendChild(u),u.addEventListener("pointerdown",this._onTopHandlePointerDown);var p=a.ownerDocument.createElement("div");p.className="handle right-handle top-right-corner-handle",this.element.appendChild(p),p.addEventListener("pointerdown",this._onTopRightHandlePointerDown);var d=a.ownerDocument.createElement("div");d.className="handle right-handle bottom-right-corner-handle",this.element.appendChild(d),d.addEventListener("pointerdown",this._onBottomRightHandlePointerDown);var h=a.ownerDocument.createElement("div");h.className="handle left-handle top-left-corner-handle",this.element.appendChild(h),h.addEventListener("pointerdown",this._onTopLeftHandlePointerDown);var f=a.ownerDocument.createElement("div");f.className="handle left-handle bottom-left-corner-handle",this.element.appendChild(f),f.addEventListener("pointerdown",this._onBottomLeftHandlePointerDown),this._headerTextElement=a.ownerDocument.createElement("div"),this._headerTextElement.classList.add("frame-box-header-title"),this._headerElement.appendChild(this._headerTextElement),this._headerCollapseElement=a.ownerDocument.createElement("div"),this._headerCollapseElement.classList.add("frame-box-header-collapse"),this._headerCollapseElement.classList.add("frame-box-header-button"),this._headerCollapseElement.title="Collapse",this._headerCollapseElement.ondragstart=function(){return!1},this._headerCollapseElement.addEventListener("pointerdown",(function(e){o._headerCollapseElement.classList.add("down"),e.stopPropagation()})),this._headerCollapseElement.addEventListener("pointerup",(function(e){e.stopPropagation(),o._headerCollapseElement.classList.remove("down"),o.isCollapsed=!o.isCollapsed})),this._headerCollapseElement.innerHTML=this.CollapseSVG,this._headerElement.appendChild(this._headerCollapseElement),this._headerCloseElement=a.ownerDocument.createElement("div"),this._headerCloseElement.classList.add("frame-box-header-close"),this._headerCloseElement.classList.add("frame-box-header-button"),this._headerCloseElement.title="Close",this._headerCloseElement.ondragstart=function(){return!1},this._headerCloseElement.addEventListener("pointerdown",(function(e){e.stopPropagation()})),this._headerCloseElement.addEventListener("pointerup",(function(e){e.stopPropagation(),o.dispose()})),this._headerCloseElement.innerHTML=this.CloseSVG,this._headerElement.appendChild(this._headerCloseElement),this._portContainer=a.ownerDocument.createElement("div"),this._portContainer.classList.add("port-container"),this.element.appendChild(this._portContainer),this._outputPortContainer=a.ownerDocument.createElement("div"),this._outputPortContainer.classList.add("outputsContainer"),this._portContainer.appendChild(this._outputPortContainer),this._inputPortContainer=a.ownerDocument.createElement("div"),this._inputPortContainer.classList.add("inputsContainer"),this._portContainer.appendChild(this._inputPortContainer),this.name="Frame",this.color=l.Color3.FromInts(72,72,72),t&&(this.x=parseFloat(t.style.left.replace("px","")),this.y=parseFloat(t.style.top.replace("px","")),this.width=parseFloat(t.style.width.replace("px","")),this.height=parseFloat(t.style.height.replace("px","")),this.cleanAccumulation()),this._headerTextElement.addEventListener("pointerdown",(function(e){return o._onDown(e)})),this._headerTextElement.addEventListener("pointerup",(function(e){return o._onUp(e)})),this._headerTextElement.addEventListener("pointermove",(function(e){return o._onMove(e)})),this._onSelectionChangedObserver=n.globalState.onSelectionChangedObservable.add((function(e){e===o?o.element.classList.add("selected"):o.element.classList.remove("selected")})),this._onGraphNodeRemovalObserver=n.globalState.onGraphNodeRemovalObservable.add((function(e){var t=o._nodes.indexOf(e);-1!==t&&(e.enclosingFrameId=-1,o._nodes.splice(t,1))})),this._onExposePortOnFrameObserver=n.globalState.onExposePortOnFrameObservable.add((function(e){-1!==o.nodes.indexOf(e)&&o.redrawFramePorts()})),this._commentsElement=document.createElement("div"),this._commentsElement.className="frame-comments",this._commentsElement.style.color="white",this._commentsElement.style.fontSize="16px";var m=document.createElement("span");m.className="frame-comment-span",this._commentsElement.appendChild(m),this.element.appendChild(this._commentsElement),r||this.refresh()}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCollapsed",{get:function(){return this._isCollapsed},set:function(e){if(this._isCollapsed!==e){if(this._isCollapsed=e,this._ownerCanvas._frameIsMoving=!0,e)this.element.classList.add("collapsed"),this._moveFrame((this.width-this.CollapsedWidth)/2,0),this._createFramePorts(),this._markFramePortPositions();else{this.element.classList.remove("collapsed"),this._outputPortContainer.innerHTML="",this._inputPortContainer.innerHTML="",this._frameInPorts.forEach((function(e){e.dispose()})),this._frameOutPorts.forEach((function(e){e.dispose()})),this._controlledPorts.forEach((function(e){e.delegatedPort=null,e.refresh()})),this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._onNodeLinkDisposedObservers=[];for(var t=0,n=this._nodes;t<n.length;t++){n[t].isVisible=!0}this._moveFrame(-(this.width-this.CollapsedWidth)/2,0)}this.cleanAccumulation(),this._ownerCanvas._frameIsMoving=!1,this._isCollapsed?(this._headerCollapseElement.innerHTML=this.ExpandSVG,this._headerCollapseElement.title="Expand"):(this._headerCollapseElement.innerHTML=this.CollapseSVG,this._headerCollapseElement.title="Collapse"),this.onExpandStateChanged.notifyObservers(this)}},enumerable:!1,configurable:!0}),e.prototype._createInputPort=function(t,n){var r=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._inputPortContainer,null,this._ownerCanvas.globalState,!0,e._FramePortCounter++,this.id);this._frameInPorts.push(r),t.delegatedPort=r,this._controlledPorts.push(t),t.exposedPortPosition=this._exposedInPorts.findIndex((function(e){return e===t})),t.exposedPortPosition<0&&(this._exposedInPorts.push(t),t.exposedPortPosition=this._exposedInPorts.length-1)},e.prototype._markFramePortPositions=function(){if(2==this._frameInPorts.length)this._frameInPorts[0].framePortPosition=lt.Top,this._frameInPorts[1].framePortPosition=lt.Bottom;else for(var e=0;e<this._frameInPorts.length;e++){var t=this._frameInPorts[e];0===e?t.framePortPosition=lt.Top:e===this._frameInPorts.length-1?t.framePortPosition=lt.Bottom:t.framePortPosition=lt.Middle}if(2==this._frameOutPorts.length)this._frameOutPorts[0].framePortPosition=lt.Top,this._frameOutPorts[1].framePortPosition=lt.Bottom;else for(e=0;e<this._frameOutPorts.length;e++){t=this._frameOutPorts[e];0===e?t.framePortPosition=lt.Top:e===this._frameInPorts.length-1?t.framePortPosition=lt.Bottom:t.framePortPosition=lt.Middle}},e.prototype._createFramePorts=function(){for(var e=0,t=this._nodes;e<t.length;e++){(a=t[e]).isVisible=!1}for(var n=0;n<this._exposedOutPorts.length;){if(null===(d=this._exposedOutPorts[n]).node||d.node.enclosingFrameId!=this.id){if(this.removePortFromExposedWithNode(d,this._exposedOutPorts))continue}else if(!this.createOutputPorts(d,d.node)&&this.removePortFromExposedWithNode(d,this._exposedOutPorts))continue;++n}for(n=0;n<this._exposedInPorts.length;){if((d=this._exposedInPorts[n])&&null!==d.node&&d.node.enclosingFrameId==this.id){if(!this.createInputPorts(d,d.node)&&this.removePortFromExposedWithNode(d,this._exposedInPorts))continue}else if(this.removePortFromExposedWithNode(d,this._exposedInPorts))continue;++n}for(var r=0,o=this._nodes;r<o.length;r++){for(var a=o[r],i=function(e){e.exposedPortPosition=l._exposedOutPorts.findIndex((function(t){return t===e})),e.exposedPortPosition<0&&l.createOutputPorts(e,a)&&(e.node.enclosingFrameId=l.id,l._exposedOutPorts.push(e),e.exposedPortPosition=l._exposedOutPorts.length-1)},l=this,s=0,c=a.outputPorts;s<c.length;s++){i(c[s])}for(var u=0,p=a.inputPorts;u<p.length;u++){var d;(d=p[u]).exposedPortPosition=this._exposedInPorts.findIndex((function(e){return e===d})),d.exposedPortPosition<0&&this.createInputPorts(d,a)}}},e.prototype.removePortFromExposedWithNode=function(e,t){var n=t.findIndex((function(t){return t===e}));return n>=0&&(t.splice(n,1),e&&(e.exposedPortPosition=-1),!0)},e.prototype.removePortFromExposedWithLink=function(e,t){var n=t.findIndex((function(t){return t===e.portA})),r=t.findIndex((function(t){return t===e.portB}));if(n>=0){if(!e.portA.exposedOnFrame)return t.splice(n,1),e.portA.exposedPortPosition=-1,!0}else if(r>=0&&e.portB&&!e.portB.exposedOnFrame)return t.splice(r,1),e.portB.exposedPortPosition=-1,!0;return!1},e.prototype.createInputPorts=function(e,t){var n=this;if(e.connectionPoint.isConnected){for(var r=!1,o=0,a=t.links;o<a.length;o++){var i=a[o];if(i.portB===e&&-1===this.nodes.indexOf(i.nodeA)){this._createInputPort(e,t),i.isVisible=!0,r=!0;var l=i.onDisposedObservable.add((function(e){n.removePortFromExposedWithLink(e,n._exposedInPorts)&&n.redrawFramePorts()}));this._onNodeLinkDisposedObservers.push(l)}}if(r)return!0}else if(e.exposedOnFrame)return this._createInputPort(e,t),!0;return!1},e.prototype.createOutputPorts=function(t,n){var r=this;if(t.connectionPoint.hasEndpoints){for(var o=!1,a=0,i=n.links;a<i.length;a++){var l=i[a];if(l.portA===t&&-1===this.nodes.indexOf(l.nodeB)){var s=void 0;if(o)-1===this.nodes.indexOf(l.nodeB)?(l.isVisible=!0,s=this.ports.filter((function(e){return e.connectionPoint===t.connectionPoint}))[0]):s=this.ports.filter((function(e){return e.connectionPoint===t.connectionPoint}))[0];else{o=!0,s=ut.CreateFrameNodePortElement(t.connectionPoint,l.nodeA,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id),this._frameOutPorts.push(s),l.isVisible=!0;var c=l.onDisposedObservable.add((function(e){r.removePortFromExposedWithLink(e,r._exposedOutPorts)&&r.redrawFramePorts()}));this._onNodeLinkDisposedObservers.push(c)}t.delegatedPort=s,this._controlledPorts.push(t)}else if(t.exposedPortPosition>=0&&!o){s=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id);this._frameOutPorts.push(s),t.delegatedPort=s,this._controlledPorts.push(t),o=!0}}if(o)return!0}else if(t.exposedOnFrame){s=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id);return this._frameOutPorts.push(s),t.delegatedPort=s,this._controlledPorts.push(t),!0}return!1},e.prototype.redrawFramePorts=function(){this.isCollapsed&&(this._outputPortContainer.innerHTML="",this._inputPortContainer.innerHTML="",this.ports.forEach((function(e){e.dispose()})),this._controlledPorts.forEach((function(e){e.delegatedPort=null,e.refresh()})),this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._createFramePorts(),this._markFramePortPositions(),this.ports.forEach((function(e){return e.node._refreshLinks()})))},Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ports",{get:function(){return this._frameInPorts.concat(this._frameOutPorts)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e,this._headerTextElement.innerHTML=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){this._color=e,this._headerElement.style.background="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 1)"),this._headerElement.style.borderColor="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 1)"),this.element.style.background="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 0.7)")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this._gridAlignedX=this._ownerCanvas.getGridPosition(e),this.element.style.left="".concat(this._gridAlignedX,"px"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this._gridAlignedY=this._ownerCanvas.getGridPosition(e),this.element.style.top="".concat(this._gridAlignedY,"px"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(e){if(this._width!==e){var t=e>this._minFrameWidth?e:this._minFrameWidth;this._width=t;var n=this._ownerCanvas.getGridPositionCeil(t+this._gridAlignedX);this.element.style.width="".concat(n-this._gridAlignedX,"px")}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(e){if(this._height!==e){this._height=e;var t=this._ownerCanvas.getGridPositionCeil(e+this._gridAlignedY);this.element.style.height="".concat(t-this._gridAlignedY,"px")}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},set:function(e){e&&!this._comments&&e.length>0?(this.element.style.gridTemplateRows="40px min-content 1fr",this._borderElement.style.gridRow="1 / span 3",this._portContainer.style.gridRow="3",this._commentsElement.classList.add("has-comments")):e||(this.element.style.gridTemplateRows="40px calc(100% - 40px)",this._borderElement.style.gridRow="1 / span 2",this._portContainer.style.gridRow="2",this._commentsElement.classList.remove("has-comments")),(""===e||e&&e.length>=0)&&(this._commentsElement.children[0].innerText=e),this.height=this._borderElement.offsetHeight,this._comments=e,this.updateMinHeightWithComments()},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){this._nodes=[],this._ownerCanvas.globalState.onFrameCreatedObservable.notifyObservers(this)},e.prototype.addNode=function(e){-1===this.nodes.indexOf(e)&&this.nodes.push(e)},e.prototype.removeNode=function(e){var t=this.nodes.indexOf(e);t>-1&&(e.enclosingFrameId=-1,this.nodes.splice(t,1))},e.prototype.syncNode=function(e){this.isCollapsed||(e.isOverlappingFrame(this)?this.addNode(e):this.removeNode(e))},e.prototype.cleanAccumulation=function(){for(var e=0,t=this._nodes;e<t.length;e++){t[e].cleanAccumulation()}this.x=this._ownerCanvas.getGridPosition(this.x),this.y=this._ownerCanvas.getGridPosition(this.y)},e.prototype._onDown=function(e){e.stopPropagation(),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,this._headerTextElement.setPointerCapture(e.pointerId),this._ownerCanvas.globalState.onSelectionChangedObservable.notifyObservers(this),this._ownerCanvas._frameIsMoving=!0,this.move(this._ownerCanvas.getGridPosition(this.x),this._ownerCanvas.getGridPosition(this.y))},e.prototype.move=function(e,t,n){void 0===n&&(n=!0);var r=this.x,o=this.y;this.x=e,this.y=t;for(var a=0,i=this._nodes;a<i.length;a++){var l=i[a];l.x+=this.x-r,l.y+=this.y-o,n&&l.cleanAccumulation(!0)}},e.prototype._onUp=function(e){e.stopPropagation(),this.cleanAccumulation(),this._mouseStartPointX=null,this._mouseStartPointY=null,this._headerTextElement.releasePointerCapture(e.pointerId),this._ownerCanvas._frameIsMoving=!1},e.prototype._moveFrame=function(e,t){this.x+=e,this.y+=t;for(var n=0,r=this._nodes;n<r.length;n++){var o=r[n];o.x+=e,o.y+=t}},e.prototype._onMove=function(e){if(null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&!e.ctrlKey&&!this._frameIsResizing){var t=(e.clientX-this._mouseStartPointX)/this._ownerCanvas.zoom,n=(e.clientY-this._mouseStartPointY)/this._ownerCanvas.zoom;this._moveFrame(t,n),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,e.stopPropagation()}},e.prototype.moveFramePortUp=function(e){var t,n,r;if(e.isInput){if(this._inputPortContainer.children.length<2)return;r=Array.from(this._inputPortContainer.childNodes);var o=this._frameInPorts.findIndex((function(t){return t===e}));t=[this._exposedInPorts[o],this._exposedInPorts[o-1]],this._exposedInPorts[o-1]=t[0],this._exposedInPorts[o]=t[1],this._movePortUp(r,e,this._frameInPorts)}else{if(this._outputPortContainer.children.length<2)return;r=Array.from(this._outputPortContainer.childNodes);o=this._frameOutPorts.findIndex((function(t){return t===e}));n=[this._exposedOutPorts[o],this._exposedOutPorts[o-1]],this._exposedOutPorts[o-1]=n[0],this._exposedOutPorts[o]=n[1],this._movePortUp(r,e,this._frameOutPorts)}this.ports.forEach((function(e){return e.node._refreshLinks()}))},e.prototype._movePortUp=function(e,t,n){var r,o,a=e.findIndex((function(e){return e.dataset.framePortId==="".concat(t.framePortId)}));if(0!==a){var i=e[a],l=e[a-1];null===(o=l.parentElement)||void 0===o||o.insertBefore(i,l);var s=n.findIndex((function(e){return e===t}));r=[n[s],n[s-1]],n[s-1]=r[0],n[s]=r[1],2==n.length?(n[1].framePortPosition=lt.Bottom,n[0].framePortPosition=lt.Top):1===a?(n[1].framePortPosition=lt.Middle,n[0].framePortPosition=lt.Top):s===e.length-1?(n[n.length-1].framePortPosition=lt.Bottom,n[n.length-2].framePortPosition=lt.Middle):t.framePortPosition=lt.Middle}},e.prototype.moveFramePortDown=function(e){var t,n,r;if(e.isInput){if(this._inputPortContainer.children.length<2)return;r=Array.from(this._inputPortContainer.childNodes);var o=this._frameInPorts.findIndex((function(t){return t===e}));t=[this._exposedInPorts[o+1],this._exposedInPorts[o]],this._exposedInPorts[o]=t[0],this._exposedInPorts[o+1]=t[1],this._movePortDown(r,e,this._frameInPorts)}else{if(this._outputPortContainer.children.length<2)return;r=Array.from(this._outputPortContainer.childNodes);o=this._frameOutPorts.findIndex((function(t){return t===e}));n=[this._exposedOutPorts[o+1],this._exposedOutPorts[o]],this._exposedOutPorts[o]=n[0],this._exposedOutPorts[o+1]=n[1],this._movePortDown(r,e,this._frameOutPorts)}this.ports.forEach((function(e){return e.node._refreshLinks()}))},e.prototype._movePortDown=function(e,t,n){var r,o,a=e.findIndex((function(e){return e.dataset.framePortId==="".concat(t.framePortId)}));if(a!==e.length-1){var i=e[a],l=e[a+1];null===(o=i.parentElement)||void 0===o||o.insertBefore(l,i);var s=n.findIndex((function(e){return e===t}));r=[n[s+1],n[s]],n[s]=r[0],n[s+1]=r[1],2==n.length?(n[0].framePortPosition=lt.Top,n[1].framePortPosition=lt.Bottom):s===e.length-2?(n[e.length-2].framePortPosition=lt.Middle,n[e.length-1].framePortPosition=lt.Bottom):0===s?(n[0].framePortPosition=lt.Top,n[1].framePortPosition=lt.Middle):t.framePortPosition=lt.Middle}},e.prototype._isResizingTop=function(){return this._resizingDirection===it.Top||this._resizingDirection===it.TopRight||this._resizingDirection===it.TopLeft},e.prototype._isResizingRight=function(){return this._resizingDirection===it.Right||this._resizingDirection===it.TopRight||this._resizingDirection===it.BottomRight},e.prototype._isResizingBottom=function(){return this._resizingDirection===it.Bottom||this._resizingDirection===it.BottomLeft||this._resizingDirection===it.BottomRight},e.prototype._isResizingLeft=function(){return this._resizingDirection===it.Left||this._resizingDirection===it.TopLeft||this._resizingDirection===it.BottomLeft},e.prototype._expandLeft=function(e){var t=parseFloat(this.element.style.width.replace("px","")),n=parseFloat(this.element.style.left.replace("px",""));this.element.style.width="".concat(t-e,"px"),this.element.style.left="".concat(n+e,"px"),this.updateMinHeightWithComments()},e.prototype._expandTop=function(e){var t=parseFloat(this.element.style.height.replace("px","")),n=parseFloat(this.element.style.top.replace("px",""));this.element.style.height="".concat(t-e,"px"),this.element.style.top="".concat(n+e,"px")},e.prototype._expandRight=function(e,t){var n=parseFloat(this.element.style.width.replace("px",""));n+e>20&&(this._mouseStartPointX=t,this.element.style.width="".concat(n+e,"px")),this.updateMinHeightWithComments()},e.prototype._expandBottom=function(e){var t=parseFloat(this.element.style.height.replace("px",""));this.element.style.height="".concat(t+e,"px")},e.prototype.dispose=function(){var e;this._onSelectionChangedObserver&&this._ownerCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._onGraphNodeRemovalObserver&&this._ownerCanvas.globalState.onGraphNodeRemovalObservable.remove(this._onGraphNodeRemovalObserver),this._onExposePortOnFrameObserver&&this._ownerCanvas.globalState.onExposePortOnFrameObservable.remove(this._onExposePortOnFrameObserver),null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element),this._ownerCanvas.frames.splice(this._ownerCanvas.frames.indexOf(this),1),this.onExpandStateChanged.clear()},e.prototype.serializePortData=function(e){if(e.length>0)for(var t=0;t<e.length;++t)e[t]&&(e[t].exposedPortPosition=t)},e.prototype.serialize=function(e){return this.serializePortData(this._exposedInPorts),this.serializePortData(this._exposedOutPorts),{x:this._x,y:this._y,width:this._width,height:this._height,color:this._color.asArray(),name:this.name,isCollapsed:!e||this.isCollapsed,blocks:this.nodes.map((function(e){return e.block.uniqueId})),comments:this._comments}},e.prototype.export=function(){var e=this._ownerCanvas.globalState,t=S.Serialize(e.nodeMaterial,e,this);_.DownloadAsFile(e.hostDocument,t,this._name+".json")},e.prototype.adjustPorts=function(){for(var e=0,t=this.nodes;e<t.length;e++){for(var n=t[e],r=0,o=n.outputPorts;r<o.length;r++){(l=o[r]).exposedOnFrame&&-1!==l.exposedPortPosition&&(this._exposedOutPorts[l.exposedPortPosition]=l)}for(var a=0,i=n.inputPorts;a<i.length;a++){var l;(l=i[a]).exposedOnFrame&&-1!==l.exposedPortPosition&&(this._exposedInPorts[l.exposedPortPosition]=l)}}},e.Parse=function(t,n,r){var o=new e(null,n,!0),a=!!t.isCollapsed;if(o.x=t.x,o.y=t.y,o.width=t.width,o.height=t.height,o.name=t.name,o.color=l.Color3.FromArray(t.color),o.comments=t.comments,t.blocks&&r)for(var i=function(){var e=r[u],t=n.nodes.filter((function(t){return t.block.uniqueId===e}));t.length&&(o.nodes.push(t[0]),t[0].enclosingFrameId=o.id)},s=0,c=t.blocks;s<c.length;s++){var u=c[s];i()}else o.refresh();if(o.adjustPorts(),o.isCollapsed=a,a){n._frameIsMoving=!0,o._moveFrame(-(o.width-o.CollapsedWidth)/2,0);var p=t.x-o.x;o._moveFrame(p,0),o.cleanAccumulation();for(var d=0,h=o.nodes;d<h.length;d++){h[d].refresh()}n._frameIsMoving=!1}return o},e._FrameCounter=0,e._FramePortCounter=0,e}();n(129);var dt=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.processInputBlockUpdate=function(e){this.props.globalState.onUpdateRequiredObservable.notifyObservers(e),e.isConstant&&this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.renderInputBlock=function(e){var t=this;switch(e.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var n=isNaN(e.min)||isNaN(e.max)||e.min===e.max;return o.createElement("div",{key:e.uniqueId},e.isBoolean&&o.createElement(E,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",onValueChanged:function(){t.processInputBlockUpdate(e)}}),!e.isBoolean&&n&&o.createElement(P,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}}),!e.isBoolean&&!n&&o.createElement(B,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",step:(e.max-e.min)/100,minimum:e.min,maximum:e.max,globalState:this.props.globalState,onChange:function(){return t.processInputBlockUpdate(e)}}));case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(oe,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(we,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Z,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(ie,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(se,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}})}return null},t.prototype.render=function(){var e=this;return o.createElement(m,{title:"INPUTS"},this.props.inputs.map((function(t){return t.isUniform&&!t.isSystemValue&&t.name?e.renderInputBlock(t):null})))},t}(o.Component),ht=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.onFrameExpandStateChangedObserver=this.props.frame.onExpandStateChanged.add((function(){return e.forceUpdate()}))},t.prototype.componentWillUnmount=function(){this.onFrameExpandStateChangedObserver&&(this.props.frame.onExpandStateChanged.remove(this.onFrameExpandStateChangedObserver),this.onFrameExpandStateChangedObserver=null)},t.prototype.render=function(){var e=this,t=[];return this.props.frame.nodes.forEach((function(e){e.block.isInput&&e.block.visibleOnFrame&&t.push(e.block)})),t=t.sort((function(e,t){return e.name.localeCompare(t.name)})),o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(he,{globalState:this.props.globalState,label:"Name",propertyName:"name",target:this.props.frame}),o.createElement(oe,{globalState:this.props.globalState,label:"Color",target:this.props.frame,propertyName:"color"}),o.createElement(he,{globalState:this.props.globalState,label:"Comments",propertyName:"comments",target:this.props.frame}),!this.props.frame.isCollapsed&&o.createElement(k,{label:"Collapse",onClick:function(){e.props.frame.isCollapsed=!0}}),this.props.frame.isCollapsed&&o.createElement(k,{label:"Expand",onClick:function(){e.props.frame.isCollapsed=!1}}),o.createElement(k,{label:"Export",onClick:function(){e.props.frame.export()}})),o.createElement(dt,{globalState:this.props.globalState,inputs:t})))},t}(o.Component),ft=function(e){function t(t){var n=e.call(this,t)||this;n.state={port:n.props.frameNodePort};var r=n;return n._onSelectionChangedObserver=n.props.globalState.onSelectionChangedObservable.add((function(e){st(e)&&(e.port.onFramePortPositionChangedObservable.clear(),r._onFramePortPositionChangedObserver=e.port.onFramePortPositionChangedObservable.add((function(e){r.setState({port:e})})),r.setState({port:e.port}))})),n._onFramePortPositionChangedObserver=n.props.frameNodePort.onFramePortPositionChangedObservable.add((function(e){r.setState({port:e})})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.frameNodePort.onFramePortPositionChangedObservable.remove(this._onFramePortPositionChangedObserver),this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},t.prototype.render=function(){var e=this;return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(he,{globalState:this.props.globalState,label:"Port Name",propertyName:"portName",target:this.props.frameNodePort}),this.props.frameNodePort.framePortPosition!==lt.Top&&o.createElement(k,{label:"Move Port Up",onClick:function(){e.props.frame.moveFramePortUp(e.props.frameNodePort)}}),this.props.frameNodePort.framePortPosition!==lt.Bottom&&o.createElement(k,{label:"Move Port Down",onClick:function(){e.props.frame.moveFramePortDown(e.props.frameNodePort)}}))))},t}(o.Component),mt=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},t.prototype.toggleExposeOnFrame=function(e){this.props.nodePort.exposedOnFrame=e,this.props.globalState.onExposePortOnFrameObservable.notifyObservers(this.props.nodePort.node)},t.prototype.render=function(){var e=this,t=this.props.nodePort.hasLabel()?o.createElement(o.Fragment,null,this.props.nodePort.hasLabel()&&o.createElement(he,{globalState:this.props.globalState,label:"Port Label",propertyName:"portName",target:this.props.nodePort}),-1!==this.props.nodePort.node.enclosingFrameId&&o.createElement(E,{label:"Expose Port on Frame",target:this.props.nodePort,isSelected:function(){return e.props.nodePort.exposedOnFrame},onSelect:function(t){return e.toggleExposeOnFrame(t)},propertyName:"exposedOnFrame",disabled:this.props.nodePort.disabled})):o.createElement(fe,{label:"This node is a constant input node and cannot be exposed to the frame.",value:" "});return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},t)))},t}(o.Component);n(129);var gt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:null,uploadInProgress:!1},n._modeSelect=o.createRef(),n}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.props.globalState.onSelectionChangedObservable.add((function(t){t instanceof rt?e.setState({currentNode:t,currentFrame:null,currentFrameNodePort:null,currentNodePort:null}):t instanceof pt?e.setState({currentNode:null,currentFrame:t,currentFrameNodePort:null,currentNodePort:null}):st(t)?e.setState({currentNode:null,currentFrame:t.frame,currentFrameNodePort:t.port,currentNodePort:null}):t instanceof tt?e.setState({currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:t}):e.setState({currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:null})})),this._onBuiltObserver=this.props.globalState.onBuiltObservable.add((function(){e.forceUpdate()}))},t.prototype.componentWillUnmount=function(){this.props.globalState.onBuiltObservable.remove(this._onBuiltObserver)},t.prototype.processInputBlockUpdate=function(e){this.props.globalState.onUpdateRequiredObservable.notifyObservers(e),e.isConstant&&this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.renderInputBlock=function(e){var t=this;switch(e.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var n=isNaN(e.min)||isNaN(e.max)||e.min===e.max;return o.createElement("div",{key:e.uniqueId},e.isBoolean&&o.createElement(E,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",onValueChanged:function(){t.processInputBlockUpdate(e)}}),!e.isBoolean&&n&&o.createElement(P,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}}),!e.isBoolean&&!n&&o.createElement(B,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",step:(e.max-e.min)/100,minimum:e.min,maximum:e.max,globalState:this.props.globalState,onChange:function(){return t.processInputBlockUpdate(e)}}));case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(oe,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(we,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Z,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(ie,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(se,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}})}return null},t.prototype.load=function(e){var t=this;l.Tools.ReadFile(e,(function(e){var n=new TextDecoder("utf-8");S.Deserialize(JSON.parse(n.decode(e)),t.props.globalState),t.changeMode(t.props.globalState.nodeMaterial.mode,!0,!1)||t.props.globalState.onResetRequiredObservable.notifyObservers(),t.props.globalState.onSelectionChangedObservable.notifyObservers(null)}),void 0,!0)},t.prototype.loadFrame=function(e){var t=this;l.Tools.ReadFile(e,(function(e){var n=new TextDecoder("utf-8"),r=JSON.parse(n.decode(e));S.AddFrameToMaterial(r,t.props.globalState,t.props.globalState.nodeMaterial)}),void 0,!0)},t.prototype.save=function(){var e=S.Serialize(this.props.globalState.nodeMaterial,this.props.globalState);_.DownloadAsFile(this.props.globalState.hostDocument,e,"nodeMaterial.json")},t.prototype.customSave=function(){var e=this;this.setState({uploadInProgress:!0}),this.props.globalState.onLogRequiredObservable.notifyObservers({message:"Saving your material to Babylon.js snippet server...",isError:!1}),this.props.globalState.customSave.action(S.Serialize(this.props.globalState.nodeMaterial,this.props.globalState)).then((function(){e.props.globalState.onLogRequiredObservable.notifyObservers({message:"Material saved successfully",isError:!1}),e.setState({uploadInProgress:!1})})).catch((function(t){e.props.globalState.onLogRequiredObservable.notifyObservers({message:t,isError:!0}),e.setState({uploadInProgress:!1})}))},t.prototype.saveToSnippetServer=function(){var e=this,t=this.props.globalState.nodeMaterial,n=new XMLHttpRequest,r=S.Serialize(t,this.props.globalState);n.onreadystatechange=function(){if(4==n.readyState)if(200==n.status){var r=JSON.parse(n.responseText),a=t.snippetId;t.snippetId=r.id,r.version&&"0"!=r.version&&(t.snippetId+="#"+r.version),e.forceUpdate(),navigator.clipboard&&navigator.clipboard.writeText(t.snippetId);var i=window;i.Playground&&a&&i.Playground.onRequestCodeChangeObservable.notifyObservers({regex:new RegExp(a,"g"),replace:t.snippetId}),e.props.globalState.hostDocument.defaultView.alert("NodeMaterial saved with ID: "+t.snippetId+" (please note that the id was also saved to your clipboard)")}else e.props.globalState.hostDocument.defaultView.alert("Unable to save your node material. It may be too large (".concat((o.payload.length/1024).toFixed(2)," KB) because of embedded textures. Please reduce texture sizes or point to a specific url instead of embedding them and try again."))},n.open("POST",l.NodeMaterial.SnippetUrl+(t.snippetId?"/"+t.snippetId:""),!0),n.setRequestHeader("Content-Type","application/json");var o={payload:JSON.stringify({nodeMaterial:r}),name:"",description:"",tags:""};n.send(JSON.stringify(o))},t.prototype.loadFromSnippet=function(){var e=this,t=this.props.globalState.nodeMaterial,n=t.getScene(),r=window.prompt("Please enter the snippet ID to use");r&&(this.props.globalState.onSelectionChangedObservable.notifyObservers(null),l.NodeMaterial.ParseFromSnippetAsync(r,n,"",t).then((function(){t.build(),e.changeMode(e.props.globalState.nodeMaterial.mode,!0,!1)||e.props.globalState.onResetRequiredObservable.notifyObservers()})).catch((function(t){e.props.globalState.hostDocument.defaultView.alert("Unable to load your node material: "+t)})))},t.prototype.changeMode=function(e,t,n){var o,a;if(void 0===t&&(t=!1),void 0===n&&(n=!0),this.props.globalState.mode===e)return!1;if(!t&&!this.props.globalState.hostDocument.defaultView.confirm("Are your sure? You will lose your current changes (if any) if they are not saved!"))return null===(o=this._modeSelect.current)||void 0===o||o.setValue(this.props.globalState.mode),!1;if(t&&(null===(a=this._modeSelect.current)||void 0===a||a.setValue(e)),n)switch(e){case l.NodeMaterialModes.Material:this.props.globalState.nodeMaterial.setToDefault();break;case l.NodeMaterialModes.PostProcess:this.props.globalState.nodeMaterial.setToDefaultPostProcess();break;case l.NodeMaterialModes.Particle:this.props.globalState.nodeMaterial.setToDefaultParticle();break;case l.NodeMaterialModes.ProceduralTexture:this.props.globalState.nodeMaterial.setToDefaultProceduralTexture()}switch(e){case l.NodeMaterialModes.Material:this.props.globalState.previewType=r.Sphere;break;case l.NodeMaterialModes.Particle:this.props.globalState.previewType=r.Bubbles}return this.props.globalState.listOfCustomPreviewFiles=[],this.props.globalState.previewFile=void 0,l.DataStorage.WriteNumber("PreviewType",this.props.globalState.previewType),this.props.globalState.mode=e,this.props.globalState.onResetRequiredObservable.notifyObservers(),!0},t.prototype.render=function(){var e,t,n=this;if(this.state.currentNode)return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),(null===(e=this.state.currentNode)||void 0===e?void 0:e.renderProperties())||(null===(t=this.state.currentNodePort)||void 0===t?void 0:t.node.renderProperties()));if(this.state.currentFrameNodePort&&this.state.currentFrame)return o.createElement(ft,{globalState:this.props.globalState,frame:this.state.currentFrame,frameNodePort:this.state.currentFrameNodePort});if(this.state.currentNodePort)return o.createElement(mt,{globalState:this.props.globalState,nodePort:this.state.currentNodePort});if(this.state.currentFrame)return o.createElement(ht,{globalState:this.props.globalState,frame:this.state.currentFrame});var r=l.DataStorage.ReadNumber("GridSize",20),a=[{label:"Material",value:l.NodeMaterialModes.Material},{label:"Post Process",value:l.NodeMaterialModes.PostProcess},{label:"Particle",value:l.NodeMaterialModes.Particle},{label:"Procedural",value:l.NodeMaterialModes.ProceduralTexture}],i=[{label:"Combine",value:l.Constants.ALPHA_COMBINE},{label:"One one",value:l.Constants.ALPHA_ONEONE},{label:"Add",value:l.Constants.ALPHA_ADD},{label:"Subtract",value:l.Constants.ALPHA_SUBTRACT},{label:"Multiply",value:l.Constants.ALPHA_MULTIPLY},{label:"Maximized",value:l.Constants.ALPHA_MAXIMIZED},{label:"Pre-multiplied",value:l.Constants.ALPHA_PREMULTIPLIED}];return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(ue,{ref:this._modeSelect,label:"Mode",target:this,getSelection:function(e){return n.props.globalState.mode},options:a,onSelect:function(e){return n.changeMode(e)}}),o.createElement(fe,{label:"Version",value:l.Engine.Version}),o.createElement(fe,{label:"Help",value:"doc.babylonjs.com",underline:!0,onLink:function(){return window.open("https://doc.babylonjs.com/how_to/node_material","_blank")}}),o.createElement(he,{label:"Comment",multilines:!0,value:this.props.globalState.nodeMaterial.comment,target:this.props.globalState.nodeMaterial,propertyName:"comment",globalState:this.props.globalState}),o.createElement(k,{label:"Reset to default",onClick:function(){switch(n.props.globalState.mode){case l.NodeMaterialModes.Material:n.props.globalState.nodeMaterial.setToDefault();break;case l.NodeMaterialModes.PostProcess:n.props.globalState.nodeMaterial.setToDefaultPostProcess();break;case l.NodeMaterialModes.Particle:n.props.globalState.nodeMaterial.setToDefaultParticle();break;case l.NodeMaterialModes.ProceduralTexture:n.props.globalState.nodeMaterial.setToDefaultProceduralTexture()}n.props.globalState.onResetRequiredObservable.notifyObservers()}})),o.createElement(m,{title:"UI"},o.createElement(k,{label:"Zoom to fit",onClick:function(){n.props.globalState.onZoomToFitRequiredObservable.notifyObservers()}}),o.createElement(k,{label:"Reorganize",onClick:function(){n.props.globalState.onReOrganizedRequiredObservable.notifyObservers()}})),o.createElement(m,{title:"OPTIONS"},o.createElement(E,{label:"Embed textures when saving",isSelected:function(){return l.DataStorage.ReadBoolean("EmbedTextures",!0)},onSelect:function(e){l.DataStorage.WriteBoolean("EmbedTextures",e)}}),o.createElement(B,{label:"Grid size",minimum:0,maximum:100,step:5,decimalCount:0,globalState:this.props.globalState,directValue:r,onChange:function(e){l.DataStorage.WriteNumber("GridSize",e),n.props.globalState.onGridSizeChanged.notifyObservers(),n.forceUpdate()}}),o.createElement(E,{label:"Show grid",isSelected:function(){return l.DataStorage.ReadBoolean("ShowGrid",!0)},onSelect:function(e){l.DataStorage.WriteBoolean("ShowGrid",e),n.props.globalState.onGridSizeChanged.notifyObservers()}})),o.createElement(m,{title:"FILE"},o.createElement(C,{label:"Load",onClick:function(e){return n.load(e)},accept:".json"}),o.createElement(k,{label:"Save",onClick:function(){n.save()}}),o.createElement(k,{label:"Generate code",onClick:function(){_.DownloadAsFile(n.props.globalState.hostDocument,n.props.globalState.nodeMaterial.generateCode(),"code.txt")}}),o.createElement(k,{label:"Export shaders",onClick:function(){n.props.globalState.nodeMaterial.build(),_.DownloadAsFile(n.props.globalState.hostDocument,n.props.globalState.nodeMaterial.compiledShaders,"shaders.txt")}}),this.props.globalState.customSave&&o.createElement(k,{label:this.props.globalState.customSave.label,isDisabled:this.state.uploadInProgress,onClick:function(){n.customSave()}}),o.createElement(C,{label:"Load Frame",uploadName:"frame-upload",onClick:function(e){return n.loadFrame(e)},accept:".json"})),!this.props.globalState.customSave&&o.createElement(m,{title:"SNIPPET"},this.props.globalState.nodeMaterial.snippetId&&o.createElement(fe,{label:"Snippet ID",value:this.props.globalState.nodeMaterial.snippetId}),o.createElement(k,{label:"Load from snippet server",onClick:function(){return n.loadFromSnippet()}}),o.createElement(k,{label:"Save to snippet server",onClick:function(){n.saveToSnippetServer()}})),o.createElement(m,{title:"TRANSPARENCY"},o.createElement(E,{label:"Force alpha blending",target:this.props.globalState.nodeMaterial,propertyName:"forceAlphaBlending",onValueChanged:function(){return n.props.globalState.onUpdateRequiredObservable.notifyObservers(null)}}),o.createElement(ue,{label:"Alpha mode",options:i,target:this.props.globalState.nodeMaterial,propertyName:"alphaMode",onSelect:function(){return n.props.globalState.onUpdateRequiredObservable.notifyObservers(null)}})),o.createElement(dt,{globalState:this.props.globalState,inputs:this.props.globalState.nodeMaterial.getInputBlocks()})))},t}(o.Component),vt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){return i.createPortal(this.props.children,this.props.globalState.hostElement)},t}(o.Component);n(326);var bt=function(e,t){this.message=e,this.isError=t},yt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={logs:[]},n}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.props.globalState.onLogRequiredObservable.add((function(t){var n=e.state.logs;n.push(t),e.setState({logs:n})}))},t.prototype.componentDidUpdate=function(){var e=i.findDOMNode(this.refs["nme-log-console"]);e&&(e.scrollTop=e.scrollHeight)},t.prototype.render=function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),r=e.getSeconds();return o.createElement("div",{id:"nme-log-console",ref:"log-console"},this.state.logs.map((function(e,a){return o.createElement("div",{key:a,className:"log"+(e.isError?" error":"")},t+":"+n+":"+r+": "+e.message)})))},t}(o.Component),xt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={message:"",isError:!1},n.props.globalState.onErrorMessageDialogRequiredObservable.add((function(e){n.setState({message:e,isError:!0})})),n}return u(t,e),t.prototype.render=function(){var e=this;return this.state.message?o.createElement("div",{className:"dialog-container"},o.createElement("div",{className:"dialog"},o.createElement("div",{className:"dialog-message"},this.state.message),o.createElement("div",{className:"dialog-buttons"},o.createElement("div",{className:"dialog-button-ok"+(this.state.isError?" error":""),onClick:function(){return e.setState({message:""})}},"OK")))):null},t}(o.Component),wt=function(){function e(e,t){var n=this;this._nodeMaterial=t.nodeMaterial,this._globalState=t,this._onBuildObserver=this._nodeMaterial.onBuildObservable.add((function(e){var t=e.serialize();n._updatePreview(t)})),this._onPreviewCommandActivatedObserver=t.onPreviewCommandActivated.add((function(e){e&&(n._currentType=-1,n._scene.disableDepthRenderer()),n._refreshPreviewMesh()})),this._onLightUpdatedObserver=t.onLightUpdated.add((function(){n._prepareLights()})),this._onUpdateRequiredObserver=t.onUpdateRequiredObservable.add((function(){var e=n._nodeMaterial.serialize();n._updatePreview(e)})),this._onPreviewBackgroundChangedObserver=t.onPreviewBackgroundChanged.add((function(){n._scene.clearColor=n._globalState.backgroundColor})),this._onAnimationCommandActivatedObserver=t.onAnimationCommandActivated.add((function(){n._handleAnimations()})),this._onBackFaceCullingChangedObserver=t.onBackFaceCullingChanged.add((function(){n._material.backFaceCulling=n._globalState.backFaceCulling})),this._onDepthPrePassChangedObserver=t.onDepthPrePassChanged.add((function(){n._material.needDepthPrePass=n._globalState.depthPrePass})),this._engine=new l.Engine(e,!0),this._scene=new l.Scene(this._engine),this._scene.clearColor=this._globalState.backgroundColor,this._scene.ambientColor=new l.Color3(1,1,1),this._camera=new l.ArcRotateCamera("Camera",0,.8,4,l.Vector3.Zero(),this._scene),this._camera.lowerRadiusLimit=3,this._camera.upperRadiusLimit=10,this._camera.wheelPrecision=20,this._camera.minZ=.1,this._camera.attachControl(!1),this._lightParent=new l.TransformNode("LightParent",this._scene),this._refreshPreviewMesh(),this._engine.runRenderLoop((function(){n._engine.resize(),n._scene.render()}));var r=void 0;this._scene.onPointerObservable.add((function(e){if(!n._globalState.controlCamera)if(e.type!==l.PointerEventTypes.POINTERUP){if(1===e.event.buttons){void 0===r&&(r=e.event.offsetX);var t=.01*(r-e.event.offsetX);n._lightParent.rotation.y+=t,r=e.event.offsetX}}else r=void 0}))}return e.prototype._handleAnimations=function(){if(this._scene.stopAllAnimations(),this._globalState.rotatePreview)for(var e=0,t=this._scene.rootNodes;e<t.length;e++){var n=t[e],r=n;"TransformNode"!==r.getClassName()&&"Mesh"!==r.getClassName()&&"GroundMesh"!==r.getClassName()||(r.rotationQuaternion&&(r.rotation=r.rotationQuaternion.toEulerAngles(),r.rotationQuaternion=null),l.Animation.CreateAndStartAnimation("turnTable",n,"rotation.y",60,1200,r.rotation.y,r.rotation.y+2*Math.PI,1))}},e.prototype._prepareLights=function(){for(var e=0,t=this._scene.lights.slice(0);e<t.length;e++){t[e].dispose()}if(this._globalState.hemisphericLight&&new l.HemisphericLight("Hemispheric light",new l.Vector3(0,1,0),this._scene),this._globalState.directionalLight0){var n=new l.DirectionalLight("Directional light #0",new l.Vector3(.841626576496605,-.2193391004130599,-.49351298337996535),this._scene);n.intensity=.9,n.diffuse=new l.Color3(.9294117647058824,.9725490196078431,.996078431372549),n.specular=new l.Color3(.9294117647058824,.9725490196078431,.996078431372549),n.parent=this._lightParent}if(this._globalState.directionalLight1){var r=new l.DirectionalLight("Directional light #1",new l.Vector3(-.9519937437504213,-.24389315636999764,-.1849974057546125),this._scene);r.intensity=1.2,r.specular=new l.Color3(.9803921568627451,.9529411764705882,.7725490196078432),r.diffuse=new l.Color3(.9803921568627451,.9529411764705882,.7725490196078432),r.parent=this._lightParent}},e.prototype._prepareScene=function(){var e,t,n=this;switch(this._camera.useFramingBehavior=this._globalState.mode===l.NodeMaterialModes.Material,this._globalState.mode){case l.NodeMaterialModes.Material:this._prepareLights();var o=this._camera.getBehaviorByName("Framing");setTimeout((function(){if(o.framingTime=0,o.elevationReturnTime=-1,n._scene.meshes.length){var e=n._scene.getWorldExtends();n._camera.lowerRadiusLimit=null,n._camera.upperRadiusLimit=null,o.zoomOnBoundingInfo(e.min,e.max)}n._camera.pinchPrecision=200/n._camera.radius,n._camera.upperRadiusLimit=5*n._camera.radius})),this._camera.wheelDeltaPercentage=.01,this._camera.pinchDeltaPercentage=.01,this._handleAnimations();break;case l.NodeMaterialModes.PostProcess:case l.NodeMaterialModes.ProceduralTexture:this._camera.radius=4,this._camera.upperRadiusLimit=10;break;case l.NodeMaterialModes.Particle:this._camera.radius=this._globalState.previewType===r.Explosion?50:this._globalState.previewType===r.DefaultParticleSystem?6:20,this._camera.upperRadiusLimit=5e3,this._globalState.particleSystemBlendMode=null!==(t=null===(e=this._particleSystem)||void 0===e?void 0:e.blendMode)&&void 0!==t?t:l.ParticleSystem.BLENDMODE_STANDARD}var a=this._nodeMaterial.serialize();this._updatePreview(a)},e.prototype._refreshPreviewMesh=function(){var e=this;if(this._currentType!==this._globalState.previewType||this._currentType===r.Custom){if(this._currentType=this._globalState.previewType,this._meshes&&this._meshes.length)for(var t=0,n=this._meshes;t<n.length;t++){n[t].dispose()}this._meshes=[],this._layer&&(this._layer.dispose(),this._layer=null);for(var o=0,a=this._scene.lights.slice(0);o<a.length;o++){a[o].dispose()}if(this._engine.releaseEffects(),this._particleSystem&&(this._particleSystem.onBeforeDrawParticlesObservable.clear(),this._particleSystem.onDisposeObservable.clear(),this._particleSystem.stop(),this._particleSystem.dispose(),this._particleSystem=null),l.SceneLoader.ShowLoadingScreen=!1,this._globalState.onIsLoadingChanged.notifyObservers(!0),this._globalState.mode===l.NodeMaterialModes.Material)switch(this._globalState.previewType){case r.Box:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","roundedCube.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Sphere:this._meshes.push(Object(l.CreateSphere)("dummy-sphere",{segments:32,diameter:2},this._scene));break;case r.Torus:this._meshes.push(Object(l.CreateTorus)("dummy-torus",{diameter:2,thickness:.5,tessellation:32},this._scene));break;case r.Cylinder:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","roundedCylinder.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Plane:var i=Object(l.CreateGround)("dummy-plane",{width:2,height:2,subdivisions:128},this._scene);i.scaling.y=-1,i.rotation.x=Math.PI,this._meshes.push(i);break;case r.ShaderBall:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","shaderBall.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Custom:return void l.SceneLoader.AppendAsync("file:",this._globalState.previewFile,this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}))}else if(this._globalState.mode===l.NodeMaterialModes.ProceduralTexture)this._layer=new l.Layer("proceduralLayer",null,this._scene);else if(this._globalState.mode===l.NodeMaterialModes.Particle)switch(this._globalState.previewType){case r.DefaultParticleSystem:this._particleSystem=l.ParticleHelper.CreateDefault(new l.Vector3(0,0,0),500,this._scene),this._particleSystem.blendMode=l.DataStorage.ReadNumber("DefaultParticleSystemBlendMode",l.ParticleSystem.BLENDMODE_ONEONE),this._particleSystem.start();break;case r.Bubbles:this._particleSystem=new l.ParticleSystem("particles",4e3,this._scene),this._particleSystem.particleTexture=new l.Texture("https://assets.babylonjs.com/particles/textures/explosion/Flare.png",this._scene),this._particleSystem.minSize=.1,this._particleSystem.maxSize=1,this._particleSystem.minLifeTime=.5,this._particleSystem.maxLifeTime=5,this._particleSystem.minEmitPower=.5,this._particleSystem.maxEmitPower=3,this._particleSystem.createBoxEmitter(new l.Vector3(-1,1,-1),new l.Vector3(1,1,1),new l.Vector3(-.1,-.1,-.1),new l.Vector3(.1,.1,.1)),this._particleSystem.emitRate=100,this._particleSystem.blendMode=l.DataStorage.ReadNumber("DefaultParticleSystemBlendMode",l.ParticleSystem.BLENDMODE_ONEONE),this._particleSystem.color1=new l.Color4(1,1,0,1),this._particleSystem.color2=new l.Color4(1,.5,0,1),this._particleSystem.gravity=new l.Vector3(0,-1,0),this._particleSystem.start();break;case r.Explosion:return void this._loadParticleSystem(this._globalState.previewType,1);case r.Fire:case r.Rain:case r.Smoke:return void this._loadParticleSystem(this._globalState.previewType);case r.Custom:return void Object(l.ReadFile)(this._globalState.previewFile,(function(t){e._particleSystem=l.ParticleSystem.Parse(JSON.parse(t),e._scene,""),e._particleSystem.start(),e._prepareScene()}),void 0,!1,(function(e){console.log(e)}))}this._prepareScene()}},e.prototype._loadParticleSystem=function(e,t,n){var o=this;void 0===t&&(t=0),void 0===n&&(n=!0);var a="";switch(e){case r.Explosion:a="explosion";break;case r.Fire:a="fire";break;case r.Rain:a="rain";break;case r.Smoke:a="smoke"}l.ParticleHelper.CreateAsync(a,this._scene).then((function(r){for(var a=0;a<r.systems.length;++a)a==t?(o._particleSystem=r.systems[a],o._particleSystem.disposeOnStop=!0,o._particleSystem.onDisposeObservable.add((function(){o._loadParticleSystem(e,t,!1)})),o._particleSystem.start()):r.systems[a].dispose();if(n)o._prepareScene();else{var i=o._nodeMaterial.serialize();o._updatePreview(i)}}))},e.prototype._forceCompilationAsync=function(e,t){return e.forceCompilationAsync(t)},e.prototype._updatePreview=function(e){var t=this;try{var n=l.NodeMaterial.IgnoreTexturesAtLoadTime;l.NodeMaterial.IgnoreTexturesAtLoadTime=!1;var r=l.NodeMaterial.Parse(e,this._scene);switch(l.NodeMaterial.IgnoreTexturesAtLoadTime=n,r.backFaceCulling=this._globalState.backFaceCulling,r.needDepthPrePass=this._globalState.depthPrePass,this._postprocess&&(this._postprocess.dispose(this._camera),this._postprocess=null),this._proceduralTexture&&(this._proceduralTexture.dispose(),this._proceduralTexture=null),this._globalState.mode){case l.NodeMaterialModes.PostProcess:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._postprocess=r.createPostProcess(this._camera,1,l.Constants.TEXTURE_NEAREST_SAMPLINGMODE,this._engine);var o=r.getBlockByPredicate((function(e){return e instanceof l.CurrentScreenBlock}));o&&this._postprocess&&(this._postprocess.externalTextureSamplerBinding=!0,this._postprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",o.texture)}))),this._material&&this._material.dispose(!1,!0),this._material=r;break;case l.NodeMaterialModes.ProceduralTexture:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._proceduralTexture=r.createProceduralTexture(512,this._scene),this._material&&this._material.dispose(!1,!0),this._layer&&(this._layer.texture=this._proceduralTexture);break;case l.NodeMaterialModes.Particle:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._particleSystem.onBeforeDrawParticlesObservable.clear(),this._particleSystem.onBeforeDrawParticlesObservable.add((function(e){var t=r.getBlockByPredicate((function(e){return e instanceof l.ParticleTextureBlock}));t&&t.texture&&e&&e.setTexture("diffuseSampler",t.texture)})),r.createEffectForParticles(this._particleSystem),this._particleSystem.blendMode=this._globalState.particleSystemBlendMode,this._material&&this._material.dispose(!1,!0),this._material=r;break;default:if(this._meshes.length){var a=this._meshes.map((function(e){return t._forceCompilationAsync(r,e)}));Promise.all(a).then((function(){for(var e=0,n=t._meshes;e<n.length;e++){n[e].material=r}t._material&&t._material.dispose(!1,!0),t._material=r,t._globalState.onIsLoadingChanged.notifyObservers(!1)})).catch((function(e){t._globalState.onLogRequiredObservable.notifyObservers(new bt("Shader compilation error:\r\n"+e,!0)),t._globalState.onIsLoadingChanged.notifyObservers(!1)}))}else this._material=r}}catch(e){this._globalState.onIsLoadingChanged.notifyObservers(!1)}},e.prototype.dispose=function(){this._nodeMaterial.onBuildObservable.remove(this._onBuildObserver),this._globalState.onPreviewCommandActivated.remove(this._onPreviewCommandActivatedObserver),this._globalState.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver),this._globalState.onAnimationCommandActivated.remove(this._onAnimationCommandActivatedObserver),this._globalState.onPreviewBackgroundChanged.remove(this._onPreviewBackgroundChangedObserver),this._globalState.onBackFaceCullingChanged.remove(this._onBackFaceCullingChangedObserver),this._globalState.onDepthPrePassChanged.remove(this._onDepthPrePassChangedObserver),this._globalState.onLightUpdated.remove(this._onLightUpdatedObserver),this._material&&this._material.dispose(!1,!0),this._camera.dispose();for(var e=0,t=this._meshes;e<t.length;e++){t[e].dispose()}this._scene.dispose(),this._engine.dispose()},e}(),kt=n(328),_t=n(329),Ct=n(330),St=n(331),Et=function(e){function t(t){var n=e.call(this,t)||this;return n.colorInputRef=o.createRef(),n.filePickerRef=o.createRef(),n._onResetRequiredObserver=n.props.globalState.onResetRequiredObservable.add((function(){n.forceUpdate()})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onResetRequiredObservable.remove(this._onResetRequiredObserver)},t.prototype.changeMeshType=function(e){this.props.globalState.previewType!==e&&(this.props.globalState.previewType=e,this.props.globalState.onPreviewCommandActivated.notifyObservers(!1),l.DataStorage.WriteNumber("PreviewType",e),this.forceUpdate())},t.prototype.useCustomMesh=function(e){var t=e.target.files;if(t&&t.length){var n=t[0];this.props.globalState.previewFile=n,this.props.globalState.previewType=r.Custom,this.props.globalState.onPreviewCommandActivated.notifyObservers(!1),this.props.globalState.listOfCustomPreviewFiles=[n],this.forceUpdate()}this.filePickerRef.current&&(this.filePickerRef.current.value="")},t.prototype.onPopUp=function(){this.props.togglePreviewAreaComponent()},t.prototype.changeAnimation=function(){this.props.globalState.rotatePreview=!this.props.globalState.rotatePreview,this.props.globalState.onAnimationCommandActivated.notifyObservers(),this.forceUpdate()},t.prototype.changeBackground=function(e){var t=l.Color3.FromHexString(e);l.DataStorage.WriteNumber("BackgroundColorR",t.r),l.DataStorage.WriteNumber("BackgroundColorG",t.g),l.DataStorage.WriteNumber("BackgroundColorB",t.b);var n=l.Color4.FromColor3(t,1);this.props.globalState.backgroundColor=n,this.props.globalState.onPreviewBackgroundChanged.notifyObservers()},t.prototype.changeBackgroundClick=function(){var e;null===(e=this.colorInputRef.current)||void 0===e||e.click()},t.prototype.render=function(){var e=this,t=[{label:"Cube",value:r.Box},{label:"Cylinder",value:r.Cylinder},{label:"Plane",value:r.Plane},{label:"Shader ball",value:r.ShaderBall},{label:"Sphere",value:r.Sphere},{label:"Load...",value:r.Custom+1}],n=[{label:"Default",value:r.DefaultParticleSystem},{label:"Bubbles",value:r.Bubbles},{label:"Explosion",value:r.Explosion},{label:"Fire",value:r.Fire},{label:"Rain",value:r.Rain},{label:"Smoke",value:r.Smoke},{label:"Load...",value:r.Custom+1}];this.props.globalState.listOfCustomPreviewFiles.length>0&&(t.splice(0,0,{label:"Custom",value:r.Custom}),n.splice(0,0,{label:"Custom",value:r.Custom}));var a=this.props.globalState.mode===l.NodeMaterialModes.Particle?n:t,i=this.props.globalState.mode===l.NodeMaterialModes.Particle?".json":".gltf, .glb, .babylon, .obj";return o.createElement("div",{id:"preview-mesh-bar"},(this.props.globalState.mode===l.NodeMaterialModes.Material||this.props.globalState.mode===l.NodeMaterialModes.Particle)&&o.createElement(o.Fragment,null,o.createElement(ue,{label:"",options:a,target:this.props.globalState,propertyName:"previewType",noDirectUpdate:!0,onSelect:function(t){var n;t!==r.Custom+1?e.changeMeshType(t):null===(n=e.filePickerRef.current)||void 0===n||n.click()}}),o.createElement("div",{style:{display:"none"},title:"Preview with a custom mesh"},o.createElement("input",{ref:this.filePickerRef,id:"file-picker",type:"file",onChange:function(t){return e.useCustomMesh(t)},accept:i}))),this.props.globalState.mode===l.NodeMaterialModes.Material&&o.createElement(o.Fragment,null,o.createElement("div",{title:"Turn-table animation",onClick:function(){return e.changeAnimation()},className:"button",id:"play-button"},this.props.globalState.rotatePreview?o.createElement("img",{src:Ct,alt:""}):o.createElement("img",{src:St,alt:""})),o.createElement("div",{id:"color-picker-button",title:"Background color",className:"button align",onClick:function(t){return e.changeBackgroundClick()}},o.createElement("img",{src:_t,alt:"",id:"color-picker-image"}),o.createElement("input",{ref:this.colorInputRef,id:"color-picker",type:"color",onChange:function(t){return e.changeBackground(t.target.value)}}))),o.createElement("div",{title:"Open preview in new window",id:"preview-new-window",onClick:function(){return e.onPopUp()},className:"button"},o.createElement("img",{src:kt,alt:""})))},t}(o.Component),Pt=n(332),Tt=n(333),Bt=n(334),Nt=n(335),Ot=n(336),Lt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={isLoading:!0},n._onIsLoadingChangedObserver=n.props.globalState.onIsLoadingChanged.add((function(e){return n.setState({isLoading:e})})),n._onResetRequiredObserver=n.props.globalState.onResetRequiredObservable.add((function(){n.forceUpdate()})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onIsLoadingChanged.remove(this._onIsLoadingChangedObserver),this.props.globalState.onResetRequiredObservable.remove(this._onResetRequiredObserver)},t.prototype.changeBackFaceCulling=function(e){this.props.globalState.backFaceCulling=e,l.DataStorage.WriteBoolean("BackFaceCulling",e),this.props.globalState.onBackFaceCullingChanged.notifyObservers(),this.forceUpdate()},t.prototype.changeDepthPrePass=function(e){this.props.globalState.depthPrePass=e,l.DataStorage.WriteBoolean("DepthPrePass",e),this.props.globalState.onDepthPrePassChanged.notifyObservers(),this.forceUpdate()},t.prototype.changeParticleSystemBlendMode=function(e){this.props.globalState.particleSystemBlendMode!==e&&(this.props.globalState.particleSystemBlendMode=e,this.props.globalState.onUpdateRequiredObservable.notifyObservers(null),l.DataStorage.WriteNumber("DefaultParticleSystemBlendMode",e),this.forceUpdate())},t.prototype.render=function(){var e=this,t=[{label:"Add",value:l.ParticleSystem.BLENDMODE_ADD},{label:"Multiply",value:l.ParticleSystem.BLENDMODE_MULTIPLY},{label:"Multiply Add",value:l.ParticleSystem.BLENDMODE_MULTIPLYADD},{label:"OneOne",value:l.ParticleSystem.BLENDMODE_ONEONE},{label:"Standard",value:l.ParticleSystem.BLENDMODE_STANDARD}];return o.createElement(o.Fragment,null,o.createElement("div",{id:"preview",style:{height:this.props.width+"px"}},o.createElement("canvas",{id:"preview-canvas"}),o.createElement("div",{className:"waitPanel"+(this.state.isLoading?"":" hidden")},"Please wait, loading...")),this.props.globalState.mode===l.NodeMaterialModes.Particle&&o.createElement("div",{id:"preview-config-bar",className:"extended"},o.createElement(ue,{label:"Blend mode",options:t,target:this.props.globalState,propertyName:"particleSystemBlendMode",noDirectUpdate:!0,onSelect:function(t){e.changeParticleSystemBlendMode(t)}})),this.props.globalState.mode===l.NodeMaterialModes.Material&&o.createElement(o.Fragment,null,o.createElement("div",{id:"preview-config-bar"},o.createElement("div",{title:"Render without back face culling",onClick:function(){return e.changeBackFaceCulling(!e.props.globalState.backFaceCulling)},className:"button back-face"+(this.props.globalState.backFaceCulling?"":" selected")},o.createElement("img",{src:Pt,alt:""})),o.createElement("div",{title:"Render with depth pre-pass",onClick:function(){return e.changeDepthPrePass(!e.props.globalState.depthPrePass)},className:"button depth-pass"+(this.props.globalState.depthPrePass?" selected":"")},o.createElement("img",{src:Tt,alt:""})),o.createElement("div",{title:"Turn on/off hemispheric light",onClick:function(){e.props.globalState.hemisphericLight=!e.props.globalState.hemisphericLight,l.DataStorage.WriteBoolean("HemisphericLight",e.props.globalState.hemisphericLight),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button hemispheric-light"+(this.props.globalState.hemisphericLight?" selected":"")},o.createElement("img",{src:Bt,alt:""})),o.createElement("div",{title:"Turn on/off direction light #1",onClick:function(){e.props.globalState.directionalLight1=!e.props.globalState.directionalLight1,l.DataStorage.WriteBoolean("DirectionalLight1",e.props.globalState.directionalLight1),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button direction-light-1"+(this.props.globalState.directionalLight1?" selected":"")},o.createElement("img",{src:Nt,alt:""})),o.createElement("div",{title:"Turn on/off direction light #0",onClick:function(){e.props.globalState.directionalLight0=!e.props.globalState.directionalLight0,l.DataStorage.WriteBoolean("DirectionalLight0",e.props.globalState.directionalLight0),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button direction-light-0"+(this.props.globalState.directionalLight0?" selected":"")},o.createElement("img",{src:Ot,alt:""})))))},t}(o.Component),Mt=function(){function e(){}return e.CreatePopup=function(e,t,n,r){var o=this;void 0===n&&(n=300),void 0===r&&(r=800);var a={width:n,height:r,top:(window.innerHeight-n)/2+window.screenY,left:(window.innerWidth-r)/2+window.screenX},i=Object.keys(a).map((function(e){return e+"="+a[e]})).join(","),l=window.open("",e,i);if(!l)return null;var s=l.document,c=s.createElement("link");c.rel="stylesheet",c.href="https://use.typekit.net/cta4xsb.css",s.head.appendChild(c),s.title=e,s.body.style.width="100%",s.body.style.height="100%",s.body.style.margin="0",s.body.style.padding="0";var u=s.createElement("div");return u.style.width="100%",u.style.height="100%",u.style.margin="0",u.style.padding="0",l.document.body.appendChild(u),this._CopyStyles(window.document,s),setTimeout((function(){o._CopyStyles(window.document,s)}),0),this[t]=l,u},e._CopyStyles=function(e,t){for(var n=0;n<e.styleSheets.length;n++){var r=e.styleSheets[n];try{if(r.cssRules){for(var o=e.createElement("style"),a=0,i=r.cssRules;a<i.length;a++){var l=i[a];o.appendChild(e.createTextNode(l.cssText))}t.head.appendChild(o)}else if(r.href){var s=e.createElement("link");s.rel="stylesheet",s.href=r.href,t.head.appendChild(s)}}catch(e){}}},e}();n(337);var Rt=function(e){function t(t){var n=e.call(this,t)||this;return n.NodeWidth=100,n._leftWidth=l.DataStorage.ReadNumber("LeftWidth",200),n._rightWidth=l.DataStorage.ReadNumber("RightWidth",300),n._blocks=new Array,n._copiedNodes=[],n._copiedFrame=null,n._mouseLocationX=0,n._mouseLocationY=0,n.handlePopUp=function(){n.setState({showPreviewPopUp:!0}),n.createPopUp(),n.props.globalState.hostWindow.addEventListener("beforeunload",n.handleClosingPopUp)},n.handleClosingPopUp=function(){n._previewManager&&n._previewManager.dispose(),n._popUpWindow.close(),n.setState({showPreviewPopUp:!1},(function(){return n.initiatePreviewArea()}))},n.initiatePreviewArea=function(e){void 0===e&&(e=n.props.globalState.hostDocument.getElementById("preview-canvas")),n._previewManager=new wt(e,n.props.globalState)},n.createPopUp=function(){var e=p({embedHostWidth:"100%"},{original:!0,popup:!0,overlay:!1,embedMode:!1,enableClose:!0,handleResize:!0,enablePopup:!0}),t=n.createPopupWindow("PREVIEW AREA","_PreviewHostWindow");if(t){t.addEventListener("beforeunload",n.handleClosingPopUp);var r=t.document.getElementById("node-editor-graph-root");n.createPreviewMeshControlHost(e,r),n.createPreviewHost(e,r),r&&(n.fixPopUpStyles(r.ownerDocument),n.initiatePreviewArea(r.ownerDocument.getElementById("preview-canvas")))}},n.createPopupWindow=function(e,t,r,o){void 0===r&&(r=500),void 0===o&&(o=500);var a={width:r,height:o,top:(n.props.globalState.hostWindow.innerHeight-r)/2+window.screenY,left:(n.props.globalState.hostWindow.innerWidth-o)/2+window.screenX},i=Object.keys(a).map((function(e){return e+"="+a[e]})).join(","),l=n.props.globalState.hostWindow.open("",e,i);if(!l)return null;var s=l.document;s.title=e,s.body.style.width="100%",s.body.style.height="100%",s.body.style.margin="0",s.body.style.padding="0";var c=s.createElement("div");return c.style.width="100%",c.style.height="100%",c.style.margin="0",c.style.padding="0",c.style.display="grid",c.style.gridTemplateRows="40px auto",c.id="node-editor-graph-root",c.className="right-panel popup",l.document.body.appendChild(c),Mt._CopyStyles(n.props.globalState.hostWindow.document,s),n[t]=l,n._popUpWindow=l,l},n.createPreviewMeshControlHost=function(e,t){if(t){var r=t.ownerDocument.createElement("div");r.id="PreviewMeshControl-host",r.style.width=e.embedHostWidth||"auto",t.appendChild(r);var a=o.createElement(Et,{globalState:n.props.globalState,togglePreviewAreaComponent:n.handlePopUp});i.render(a,r)}},n.createPreviewHost=function(e,t){if(t){var r=t.ownerDocument.createElement("div");r.id="PreviewAreaComponent-host",r.style.width=e.embedHostWidth||"auto",r.style.height="100%",r.style.overflow="hidden",r.style.display="grid",r.style.gridRow="2",r.style.gridTemplateRows="auto 40px",r.style.gridTemplateRows="calc(100% - 40px) 40px",t.appendChild(r),n._previewHost=r,e.overlay||(n._previewHost.style.position="relative")}if(n._previewHost){var a=o.createElement(Lt,{globalState:n.props.globalState,width:200});i.render(a,n._previewHost)}},n.fixPopUpStyles=function(e){var t=e.getElementById("preview");t&&(t.style.height="auto",t.style.gridRow="1");var n=e.getElementById("preview-config-bar");n&&(n.style.gridRow="2");var r=e.getElementById("preview-new-window");r&&(r.style.display="none");var o=e.getElementById("preview-mesh-bar");o&&(o.style.gridTemplateColumns="auto 1fr 40px 40px")},n.state={showPreviewPopUp:!1},n.props.globalState.onRebuildRequiredObservable.add((function(e){n.props.globalState.nodeMaterial&&n.buildMaterial(e)})),n.props.globalState.onResetRequiredObservable.add((function(){n.build(),n.props.globalState.nodeMaterial&&n.buildMaterial()})),n.props.globalState.onImportFrameObservable.add((function(e){var t=e.editorData.frames[0];n.props.globalState.nodeMaterial.attachedBlocks.slice(-t.blocks.length).forEach((function(e){n.createNodeFromObject(e)})),n._graphCanvas.addFrame(t),n.reOrganize(n.props.globalState.nodeMaterial.editorData,!0)})),n.props.globalState.onZoomToFitRequiredObservable.add((function(){n.zoomToFit()})),n.props.globalState.onReOrganizedRequiredObservable.add((function(){n.reOrganize()})),n.props.globalState.onGetNodeFromBlock=function(e){return n._graphCanvas.findNodeFromBlock(e)},n.props.globalState.hostDocument.addEventListener("keydown",(function(e){if((46===e.keyCode||8===e.keyCode)&&!n.props.globalState.blockKeyboardEvents){for(var t=0,r=s=n._graphCanvas.selectedNodes;t<r.length;t++){var o=r[t];o.dispose();var a=o.block;n.props.globalState.nodeMaterial.removeBlock(a),(l=n._blocks.indexOf(a))>-1&&n._blocks.splice(l,1)}if(n._graphCanvas.selectedLink&&n._graphCanvas.selectedLink.dispose(),n._graphCanvas.selectedFrame){var i=n._graphCanvas.selectedFrame;if(i.isCollapsed){for(;i.nodes.length>0;){var l;a=i.nodes[0].block;n.props.globalState.nodeMaterial.removeBlock(a),(l=n._blocks.indexOf(a))>-1&&n._blocks.splice(l,1),i.nodes[0].dispose()}i.isCollapsed=!1}else i.nodes.forEach((function(e){e.enclosingFrameId=-1}));n._graphCanvas.selectedFrame.dispose()}return n.props.globalState.onSelectionChangedObservable.notifyObservers(null),void n.props.globalState.onRebuildRequiredObservable.notifyObservers(!1)}if(e.ctrlKey&&!n.props.globalState.blockKeyboardEvents)if("c"===e.key||"C"===e.key){if(n._copiedNodes=[],n._copiedFrame=null,n._graphCanvas.selectedFrame)return n._copiedFrame=n._graphCanvas.selectedFrame,void n._copiedFrame.serialize(!0);var s;if(!(s=n._graphCanvas.selectedNodes).length)return;if(!s[0].block)return;n._copiedNodes=s.slice(0)}else if("v"===e.key||"V"===e.key){var c=n.props.globalState.hostDocument.querySelector(".diagram-container"),u=n._graphCanvas.zoom,p=(n._mouseLocationY-c.offsetTop-n._graphCanvas.y-20)/u;if(n._copiedFrame){var d=new pt(null,n._graphCanvas,!0);n._graphCanvas.frames.push(d),d.width=n._copiedFrame.width,d.height=n._copiedFrame.height,d.width,d.name=n._copiedFrame.name,d.color=n._copiedFrame.color;var h=(n._mouseLocationX-c.offsetLeft-n._graphCanvas.x)/u;if(d.x=h-d.width/2,d.y=p,n._copiedFrame.nodes.length){h=d.x+n._copiedFrame.nodes[0].x-n._copiedFrame.x,p=d.y+n._copiedFrame.nodes[0].y-n._copiedFrame.y,n._graphCanvas._frameIsMoving=!0;var f=n.pasteSelection(n._copiedFrame.nodes,h,p);if(f)for(var m=0,g=f;m<g.length;m++){var v=g[m];d.syncNode(v)}n._graphCanvas._frameIsMoving=!1}return d.adjustPorts(),n._copiedFrame.isCollapsed&&(d.isCollapsed=!0),void n.props.globalState.onSelectionChangedObservable.notifyObservers(d)}if(!n._copiedNodes.length)return;var b=(n._mouseLocationX-c.offsetLeft-n._graphCanvas.x-n.NodeWidth)/u;n.pasteSelection(n._copiedNodes,b,p,!0)}}),!1),n}return u(t,e),t.prototype.createNodeFromObject=function(e,t){if(void 0===t&&(t=!0),-1!==this._blocks.indexOf(e))return this._graphCanvas.nodes.filter((function(t){return t.block===e}))[0];if(this._blocks.push(e),-1===this.props.globalState.nodeMaterial.attachedBlocks.indexOf(e)&&this.props.globalState.nodeMaterial.attachedBlocks.push(e),e.isFinalMerger&&this.props.globalState.nodeMaterial.addOutputNode(e),e.inputs.length)for(var n=0,r=e.inputs;n<r.length;n++){(l=r[n]).isConnected&&t&&this.createNodeFromObject(l.sourceBlock)}var o=this._graphCanvas.appendBlock(e);if(e.inputs.length&&t)for(var a=0,i=e.inputs;a<i.length;a++){var l;(l=i[a]).isConnected&&this._graphCanvas.connectPorts(l.connectedPoint,l)}return o},t.prototype.addValueNode=function(e){var t=Fe.GetConnectionNodeTypeFromString(e),n=new l.InputBlock(e,void 0,t);return this.createNodeFromObject(n)},t.prototype.componentDidMount=function(){var e=this;this.props.globalState.hostDocument&&(this._graphCanvas=this.refs.graphCanvas,this._previewManager=new wt(this.props.globalState.hostDocument.getElementById("preview-canvas"),this.props.globalState),this.props.globalState._previewManager=this._previewManager),-1!==navigator.userAgent.indexOf("Mobile")&&((this.props.globalState.hostDocument||document).querySelector(".blocker").style.visibility="visible"),this.props.globalState.onPopupClosedObservable.addOnce((function(){e.componentWillUnmount()})),this.build()},t.prototype.componentWillUnmount=function(){this.props.globalState.hostDocument&&this.props.globalState.hostDocument.removeEventListener("keyup",this._onWidgetKeyUpPointer,!1),this._previewManager&&(this._previewManager.dispose(),this._previewManager=null)},t.prototype.reconnectNewNodes=function(e,t,n,r){if(!r[e]){for(var o=t[e],a=o.block,i=n[e],l=function(){var e=i.block.inputs[c],o=a.inputs[c];if(!e.isConnected)return"continue";var l=e.connectedPoint.ownerBlock,u=n.filter((function(e){return e.block===l}));if(u.length>0){var p=u[0],d=n.indexOf(p);s.reconnectNewNodes(d,t,n,r);var h=l.outputs.indexOf(e.connectedPoint);t[d].block.outputs[h].connectTo(o)}else e._connectedPoint.connectTo(o);s._graphCanvas.connectPorts(o.connectedPoint,o)},s=this,c=0;c<i.block.inputs.length;c++)l();o.refresh(),r[e]=!0}},t.prototype.pasteSelection=function(e,t,n,r){void 0===r&&(r=!1);var o=null,a=[];e=e.slice(),this.props.globalState.onSelectionChangedObservable.notifyObservers(null);for(var i=0,l=e;i<l.length;i++){var s=l[i],c=s.block;if(c){var u=c.clone(this.props.globalState.nodeMaterial.getScene());if(!u)return;var p=this.createNodeFromObject(u,!1),d=0,h=0;o?(d=t+s.x-o.x,h=n+s.y-o.y):(o=s,d=t,h=n),p.x=d,p.y=h,p.cleanAccumulation(),a.push(p),r&&this.props.globalState.onSelectionChangedObservable.notifyObservers(p)}}for(var f=new Array(a.length),m=0;m<a.length;m++)this.reconnectNewNodes(m,a,e,f);return a},t.prototype.zoomToFit=function(){this._graphCanvas.zoomToFit()},t.prototype.buildMaterial=function(e){if(void 0===e&&(e=!0),this.props.globalState.nodeMaterial){try{this.props.globalState.nodeMaterial.options.emitComments=!0,this.props.globalState.nodeMaterial.build(!0,void 0,e),this.props.globalState.onLogRequiredObservable.notifyObservers(new bt("Node material build successful",!1))}catch(e){this.props.globalState.onLogRequiredObservable.notifyObservers(new bt(e,!0))}S.UpdateLocations(this.props.globalState.nodeMaterial,this.props.globalState),this.props.globalState.onBuiltObservable.notifyObservers()}},t.prototype.build=function(){var e=this.props.globalState.nodeMaterial.editorData;this._graphCanvas._isLoading=!0,e instanceof Array&&(e={locations:e}),this._blocks=[],this._graphCanvas.reset(),this.props.globalState.nodeMaterial&&this.loadGraph(),this.reOrganize(e)},t.prototype.loadGraph=function(){var e=this,t=this.props.globalState.nodeMaterial;t._vertexOutputNodes.forEach((function(t){e.createNodeFromObject(t,!0)})),t._fragmentOutputNodes.forEach((function(t){e.createNodeFromObject(t,!0)})),t.attachedBlocks.forEach((function(t){e.createNodeFromObject(t,!0)})),t.attachedBlocks.forEach((function(t){if(t.inputs.length)for(var n=0,r=t.inputs;n<r.length;n++){var o=r[n];o.isConnected&&e._graphCanvas.connectPorts(o.connectedPoint,o)}}))},t.prototype.showWaitScreen=function(){var e;null===(e=this.props.globalState.hostDocument.querySelector(".wait-screen"))||void 0===e||e.classList.remove("hidden")},t.prototype.hideWaitScreen=function(){var e;null===(e=this.props.globalState.hostDocument.querySelector(".wait-screen"))||void 0===e||e.classList.add("hidden")},t.prototype.reOrganize=function(e,t){var n=this;void 0===e&&(e=null),void 0===t&&(t=!1),this.showWaitScreen(),this._graphCanvas._isLoading=!0,setTimeout((function(){if(e&&e.locations){for(var r=0,o=e.locations;r<o.length;r++)for(var a=o[r],i=0,l=n._graphCanvas.nodes;i<l.length;i++){if((u=l[i]).block&&u.block.uniqueId===a.blockId){u.x=a.x,u.y=a.y,u.cleanAccumulation();break}}t||n._graphCanvas.processEditorData(e)}else n._graphCanvas.distributeGraph();n._graphCanvas._isLoading=!1;for(var s=0,c=n._graphCanvas.nodes;s<c.length;s++){var u;(u=c[s])._refreshLinks()}n.hideWaitScreen()}))},t.prototype.onPointerDown=function(e){this._startX=e.clientX,this._moveInProgress=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onPointerUp=function(e){this._moveInProgress=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.resizeColumns=function(e,t){if(void 0===t&&(t=!0),this._moveInProgress){var n=e.clientX-this._startX,r=e.currentTarget.ownerDocument.getElementById("node-editor-graph-root");t?(this._leftWidth+=n,this._leftWidth=Math.max(150,Math.min(400,this._leftWidth)),l.DataStorage.WriteNumber("LeftWidth",this._leftWidth)):(this._rightWidth-=n,this._rightWidth=Math.max(250,Math.min(500,this._rightWidth)),l.DataStorage.WriteNumber("RightWidth",this._rightWidth),r.ownerDocument.getElementById("preview").style.height=this._rightWidth+"px"),r.style.gridTemplateColumns=this.buildColumnLayout(),this._startX=e.clientX}},t.prototype.buildColumnLayout=function(){return"".concat(this._leftWidth,"px 4px calc(100% - ").concat(this._leftWidth+8+this._rightWidth,"px) 4px ").concat(this._rightWidth,"px")},t.prototype.emitNewBlock=function(e){var t,n,r=this,o=e.dataTransfer.getData("babylonjs-material-node");if(o.indexOf("CustomBlock")>-1){if(!(a=localStorage.getItem(o)))return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("Error loading custom block");if(!(n=JSON.parse(a)))return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("Error parsing custom block")}else if(o.indexOf("Custom")>-1){var a;if(a=localStorage.getItem(o)){var i=JSON.parse(a),s=(e.clientX-e.currentTarget.offsetLeft-this._graphCanvas.x-this.NodeWidth)/this._graphCanvas.zoom,c=(e.clientY-e.currentTarget.offsetTop-this._graphCanvas.y-20)/this._graphCanvas.zoom,u=i.editorData.frames[0].x,p=i.editorData.frames[0].y;i.editorData.frames[0].x=s,i.editorData.frames[0].y=c;for(var d=0,h=i.editorData.locations;d<h.length;d++){var f=h[d];f.x+=s-u,f.y+=c-p}return S.AddFrameToMaterial(i,this.props.globalState,this.props.globalState.nodeMaterial),this._graphCanvas.frames[this._graphCanvas.frames.length-1].cleanAccumulation(),void this.forceUpdate()}}if(-1===o.indexOf("Block"))t=this.addValueNode(o);else{var m;if(n?(m=new l.CustomBlock("")).options=n:m=Fe.GetBlockFromString(o,this.props.globalState.nodeMaterial.getScene(),this.props.globalState.nodeMaterial),m.isUnique)for(var g=m.getClassName(),v=0,b=this._blocks;v<b.length;v++){var y=b[v];if(y!==m&&y.getClassName()===g)return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("You can only have one ".concat(g," per graph"))}m.autoConfigure(this.props.globalState.nodeMaterial),t=this.createNodeFromObject(m)}var x=e.clientX-e.currentTarget.offsetLeft-this._graphCanvas.x-this.NodeWidth,w=e.clientY-e.currentTarget.offsetTop-this._graphCanvas.y-20;t.x=x/this._graphCanvas.zoom,t.y=w/this._graphCanvas.zoom,t.cleanAccumulation(),this.props.globalState.onSelectionChangedObservable.notifyObservers(null),this.props.globalState.onSelectionChangedObservable.notifyObservers(t);var k=t.block;x-=this.NodeWidth+150,k.inputs.forEach((function(e){if(e.connectedPoint){var t=r._graphCanvas.nodes.filter((function(t){return t.block===e.connectedPoint.ownerBlock}))[0];0===t.x&&0===t.y&&(t.x=x/r._graphCanvas.zoom,t.y=w/r._graphCanvas.zoom,t.cleanAccumulation(),w+=80)}})),this.forceUpdate()},t.prototype.render=function(){var e=this;return o.createElement(vt,{globalState:this.props.globalState},o.createElement("div",{id:"node-editor-graph-root",style:{gridTemplateColumns:this.buildColumnLayout()},onMouseMove:function(t){e._mouseLocationX=t.pageX,e._mouseLocationY=t.pageY},onMouseDown:function(t){"INPUT"!==t.target.nodeName&&(e.props.globalState.blockKeyboardEvents=!1)}},o.createElement(w,{globalState:this.props.globalState}),o.createElement("div",{id:"leftGrab",onPointerDown:function(t){return e.onPointerDown(t)},onPointerUp:function(t){return e.onPointerUp(t)},onPointerMove:function(t){return e.resizeColumns(t)}}),o.createElement("div",{className:"diagram-container",onDrop:function(t){e.emitNewBlock(t)},onDragOver:function(e){e.preventDefault()}},o.createElement(ct,{ref:"graphCanvas",globalState:this.props.globalState,onEmitNewBlock:function(t){return e.createNodeFromObject(t)}})),o.createElement("div",{id:"rightGrab",onPointerDown:function(t){return e.onPointerDown(t)},onPointerUp:function(t){return e.onPointerUp(t)},onPointerMove:function(t){return e.resizeColumns(t,!1)}}),o.createElement("div",{className:"right-panel"},o.createElement(gt,{globalState:this.props.globalState}),this.state.showPreviewPopUp?null:o.createElement(Et,{globalState:this.props.globalState,togglePreviewAreaComponent:this.handlePopUp}),this.state.showPreviewPopUp?null:o.createElement(Lt,{globalState:this.props.globalState,width:this._rightWidth})),o.createElement(yt,{globalState:this.props.globalState})),o.createElement(xt,{globalState:this.props.globalState}),o.createElement("div",{className:"blocker"},"Node Material Editor runs only on desktop"),o.createElement("div",{className:"wait-screen hidden"},"Processing...please wait"))},t}(o.Component),It=function(){function e(){}return e.Show=function(e){this._CurrentState&&((c=Mt["node-editor"])&&c.close());var t=e.hostElement;t||(t=Mt.CreatePopup("BABYLON.JS NODE EDITOR","node-editor",1e3,800));var n=new s;n.nodeMaterial=e.nodeMaterial,n.mode=e.nodeMaterial.mode,n.hostElement=t,n.hostDocument=t.ownerDocument,n.customSave=e.customSave,n.hostWindow=t.ownerDocument.defaultView;var a=o.createElement(Rt,{globalState:n});i.render(a,t),e.customLoadObservable&&e.customLoadObservable.add((function(t){S.Deserialize(t,n),n.mode=e.nodeMaterial.mode,n.onResetRequiredObservable.notifyObservers(),n.onBuiltObservable.notifyObservers()})),this._CurrentState=n,n.hostWindow.addEventListener("beforeunload",(function(){n.onPopupClosedObservable.notifyObservers()}));var c=Mt["node-editor"];n.nodeMaterial&&c&&(n.nodeMaterial.getScene().onDisposeObservable.addOnce((function(){c&&c.close()})),window.onbeforeunload=function(){var e=Mt["node-editor"];e&&e.close()}),window.addEventListener("beforeunload",(function(){l.DataStorage.ReadNumber("PreviewType",r.Box)===r.Custom&&l.DataStorage.WriteNumber("PreviewType",n.mode===l.NodeMaterialModes.Material?r.Box:r.Bubbles)}))},e}()},function(e,t){e.exports="data:image/svg+xml,%3Csvg viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24' height='24'%3E %3C!-- Generator: Sketch 59.1 (86144) - https://sketch.com --%3E %3Ctitle%3Eic_fluent_copy_24_regular%3C/title%3E %3Cdesc%3ECreated with Sketch.%3C/desc%3E %3Cg id='🔍-Product-Icons' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='ic_fluent_copy_24_regular' fill='white' fill-rule='nonzero'%3E %3Cpath d='M5.50280381,4.62704038 L5.5,6.75 L5.5,17.2542087 C5.5,19.0491342 6.95507456,20.5042087 8.75,20.5042087 L17.3662868,20.5044622 C17.057338,21.3782241 16.2239751,22.0042087 15.2444057,22.0042087 L8.75,22.0042087 C6.12664744,22.0042087 4,19.8775613 4,17.2542087 L4,6.75 C4,5.76928848 4.62744523,4.93512464 5.50280381,4.62704038 Z M17.75,2 C18.9926407,2 20,3.00735931 20,4.25 L20,17.25 C20,18.4926407 18.9926407,19.5 17.75,19.5 L8.75,19.5 C7.50735931,19.5 6.5,18.4926407 6.5,17.25 L6.5,4.25 C6.5,3.00735931 7.50735931,2 8.75,2 L17.75,2 Z M17.75,3.5 L8.75,3.5 C8.33578644,3.5 8,3.83578644 8,4.25 L8,17.25 C8,17.6642136 8.33578644,18 8.75,18 L17.75,18 C18.1642136,18 18.5,17.6642136 18.5,17.25 L18.5,4.25 C18.5,3.83578644 18.1642136,3.5 17.75,3.5 Z' id='🎨-Color'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E"},function(e,t,n){"use strict";var r=n(6);e.exports=o;function o(e){this._isDirected=!r.has(e,"directed")||e.directed,this._isMultigraph=!!r.has(e,"multigraph")&&e.multigraph,this._isCompound=!!r.has(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function a(e,t){e[t]?e[t]++:e[t]=1}function i(e,t){--e[t]||delete e[t]}function l(e,t,n,o){var a=""+t,i=""+n;if(!e&&a>i){var l=a;a=i,i=l}return a+""+i+""+(r.isUndefined(o)?"\0":o)}function s(e,t,n,r){var o=""+t,a=""+n;if(!e&&o>a){var i=o;o=a,a=i}var l={v:o,w:a};return r&&(l.name=r),l}function c(e,t){return l(e,t.v,t.w,t.name)}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(e){return this._label=e,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(e){return r.isFunction(e)||(e=r.constant(e)),this._defaultNodeLabelFn=e,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return r.keys(this._nodes)},o.prototype.sources=function(){var e=this;return r.filter(this.nodes(),(function(t){return r.isEmpty(e._in[t])}))},o.prototype.sinks=function(){var e=this;return r.filter(this.nodes(),(function(t){return r.isEmpty(e._out[t])}))},o.prototype.setNodes=function(e,t){var n=arguments,o=this;return r.each(e,(function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this},o.prototype.setNode=function(e,t){return r.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},o.prototype.node=function(e){return this._nodes[e]},o.prototype.hasNode=function(e){return r.has(this._nodes,e)},o.prototype.removeNode=function(e){var t=this;if(r.has(this._nodes,e)){var n=function(e){t.removeEdge(t._edgeObjs[e])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],r.each(this.children(e),(function(e){t.setParent(e)})),delete this._children[e]),r.each(r.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],r.each(r.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},o.prototype.setParent=function(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(t))t="\0";else{for(var n=t+="";!r.isUndefined(n);n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this},o.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},o.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}},o.prototype.children=function(e){if(r.isUndefined(e)&&(e="\0"),this._isCompound){var t=this._children[e];if(t)return r.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}},o.prototype.predecessors=function(e){var t=this._preds[e];if(t)return r.keys(t)},o.prototype.successors=function(e){var t=this._sucs[e];if(t)return r.keys(t)},o.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return r.union(t,this.successors(e))},o.prototype.isLeaf=function(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length},o.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;r.each(this._nodes,(function(n,r){e(r)&&t.setNode(r,n)})),r.each(this._edgeObjs,(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};return this._isCompound&&r.each(t.nodes(),(function(e){t.setParent(e,function e(r){var a=n.parent(r);return void 0===a||t.hasNode(a)?(o[r]=a,a):a in o?o[a]:e(a)}(e))})),t},o.prototype.setDefaultEdgeLabel=function(e){return r.isFunction(e)||(e=r.constant(e)),this._defaultEdgeLabelFn=e,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return r.values(this._edgeObjs)},o.prototype.setPath=function(e,t){var n=this,o=arguments;return r.reduce(e,(function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this},o.prototype.setEdge=function(){var e,t,n,o,i=!1,c=arguments[0];"object"==typeof c&&null!==c&&"v"in c?(e=c.v,t=c.w,n=c.name,2===arguments.length&&(o=arguments[1],i=!0)):(e=c,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],i=!0)),e=""+e,t=""+t,r.isUndefined(n)||(n=""+n);var u=l(this._isDirected,e,t,n);if(r.has(this._edgeLabels,u))return i&&(this._edgeLabels[u]=o),this;if(!r.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[u]=i?o:this._defaultEdgeLabelFn(e,t,n);var p=s(this._isDirected,e,t,n);return e=p.v,t=p.w,Object.freeze(p),this._edgeObjs[u]=p,a(this._preds[t],e),a(this._sucs[e],t),this._in[t][u]=p,this._out[e][u]=p,this._edgeCount++,this},o.prototype.edge=function(e,t,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n);return this._edgeLabels[r]},o.prototype.hasEdge=function(e,t,n){var o=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n);return r.has(this._edgeLabels,o)},o.prototype.removeEdge=function(e,t,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[t],e),i(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this},o.prototype.inEdges=function(e,t){var n=this._in[e];if(n){var o=r.values(n);return t?r.filter(o,(function(e){return e.v===t})):o}},o.prototype.outEdges=function(e,t){var n=this._out[e];if(n){var o=r.values(n);return t?r.filter(o,(function(e){return e.w===t})):o}},o.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},function(e,t,n){var r=n(16)(n(10),"Map");e.exports=r},function(e,t,n){var r=n(166),o=n(173),a=n(175),i=n(176),l=n(177);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=o,s.prototype.get=a,s.prototype.has=i,s.prototype.set=l,e.exports=s},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t,n){(function(e){var r=n(77),o=t&&!t.nodeType&&t,a=o&&"object"==typeof e&&e&&!e.nodeType&&e,i=a&&a.exports===o&&r.process,l=function(){try{var e=a&&a.require&&a.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=l}).call(this,n(57)(e))},function(e,t,n){var r=n(42),o=n(183),a=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))a.call(e,n)&&"constructor"!=n&&t.push(n);return t}},function(e,t,n){var r=n(84),o=n(85),a=Object.prototype.propertyIsEnumerable,i=Object.getOwnPropertySymbols,l=i?function(e){return null==e?[]:(e=Object(e),r(i(e),(function(t){return a.call(e,t)})))}:o;e.exports=l},function(e,t){e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},function(e,t,n){var r=n(90);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t){e.exports=function(e){return function(){return e}}},function(e,t,n){var r=n(66),o=n(15);e.exports=function(e,t){return e&&r(e,t,o)}},function(e,t,n){var r=n(202)();e.exports=r},function(e,t){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}},function(e,t,n){var r=n(4),o=n(25),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||(i.test(e)||!a.test(e)||null!=t&&e in Object(t))}},function(e,t,n){var r=n(62),o=n(236);e.exports=function e(t,n,a,i,l){var s=-1,c=t.length;for(a||(a=o),l||(l=[]);++s<c;){var u=t[s];n>0&&a(u)?n>1?e(u,n-1,a,i,l):r(l,u):i||(l[l.length]=u)}return l}},function(e,t,n){var r=n(25);e.exports=function(e,t,n){for(var o=-1,a=e.length;++o<a;){var i=e[o],l=t(i);if(null!=l&&(void 0===s?l==l&&!r(l):n(l,s)))var s=l,c=i}return c}},function(e,t,n){e.exports={graphlib:n(9),layout:n(260),debug:n(321),util:{time:n(5).time,notime:n(5).notime},version:n(322)}},function(e,t,n){"use strict";
24
+ */n(144);var J=function(e){function t(t){var n=e.call(this,t)||this;return n.props.color instanceof l.Color4?n.state={color:new l.Color3(n.props.color.r,n.props.color.g,n.props.color.b),alpha:n.props.color.a}:n.state={color:n.props.color.clone(),alpha:1},n._saturationRef=o.createRef(),n._hueRef=o.createRef(),n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return e.color.toHexString()!==this.props.color.toHexString()||t.color.toHexString()!==this.props.color.toHexString()},t.prototype.onSaturationPointerDown=function(e){this._evaluateSaturation(e),this._isSaturationPointerDown=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onSaturationPointerUp=function(e){this._isSaturationPointerDown=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.onSaturationPointerMove=function(e){this._isSaturationPointerDown&&this._evaluateSaturation(e)},t.prototype.onHuePointerDown=function(e){this._evaluateHue(e),this._isHuePointerDown=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onHuePointerUp=function(e){this._isHuePointerDown=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.onHuePointerMove=function(e){this._isHuePointerDown&&this._evaluateHue(e)},t.prototype._evaluateSaturation=function(e){var t=e.nativeEvent.offsetX,n=e.nativeEvent.offsetY,r=Math.min(1,Math.max(1e-4,t/this._saturationRef.current.clientWidth)),o=Math.min(1,Math.max(1e-4,1-n/this._saturationRef.current.clientHeight));this.props.debugMode&&(console.log("Saturation: "+r),console.log("Value: "+o));var a=this.state.color.toHSV();l.Color3.HSVtoRGBToRef(a.r,r,o,this.state.color),0===this.state.alpha&&this.setState({alpha:1}),this.setState({color:this.state.color})},t.prototype._evaluateHue=function(e){var t=e.nativeEvent.offsetX,n=360*Math.min(.9999,Math.max(1e-4,t/this._hueRef.current.clientWidth));this.props.debugMode&&console.log("Hue: "+n);var r=this.state.color.toHSV();l.Color3.HSVtoRGBToRef(n,Math.max(r.g,.01),Math.max(r.b,.01),this.state.color),this.setState({color:this.state.color})},t.prototype.componentDidUpdate=function(){this.raiseOnColorChanged()},t.prototype.raiseOnColorChanged=function(){if(this.props.onColorChanged)if(this.props.color instanceof l.Color4){var e=l.Color4.FromColor3(this.state.color,this.state.alpha);this.props.onColorChanged(e)}else this.props.onColorChanged(this.state.color.clone())},t.prototype.render=function(){var e=this,t=this.state.color.toHexString(),n=this.state.color.toHSV(),r=new l.Color3;l.Color3.HSVtoRGBToRef(n.r,1,1,r);var a=r.toHexString(),i=this.props.color instanceof l.Color4;return o.createElement("div",{className:"color-picker-container"+(this.props.linearhint?" with-hints":"")},o.createElement("div",{className:"color-picker-saturation",onPointerMove:function(t){return e.onSaturationPointerMove(t)},onPointerDown:function(t){return e.onSaturationPointerDown(t)},onPointerUp:function(t){return e.onSaturationPointerUp(t)},ref:this._saturationRef,style:{background:a}},o.createElement("div",{className:"color-picker-saturation-white"}),o.createElement("div",{className:"color-picker-saturation-black"}),o.createElement("div",{className:"color-picker-saturation-cursor",style:{top:"".concat(-100*n.b+100,"%"),left:"".concat(100*n.g,"%")}})),o.createElement("div",{className:"color-picker-hue"},o.createElement("div",{className:"color-picker-hue-color",style:{background:t}}),o.createElement("div",{className:"color-picker-hue-slider",ref:this._hueRef,onPointerMove:function(t){return e.onHuePointerMove(t)},onPointerDown:function(t){return e.onHuePointerDown(t)},onPointerUp:function(t){return e.onHuePointerUp(t)}},o.createElement("div",{className:"color-picker-hue-cursor",style:{left:"".concat(n.r/360*100,"%"),border:"1px solid "+a}}))),o.createElement("div",{className:"color-picker-alpha"}),o.createElement("div",{className:"color-picker-rgb"},o.createElement("div",{className:"red"},o.createElement(K,{label:"R",min:0,max:255,value:Math.round(255*this.state.color.r),onChange:function(t){e.state.color.r=t/255,e.forceUpdate()}})),o.createElement("div",{className:"green"},o.createElement(K,{label:"G",min:0,max:255,value:Math.round(255*this.state.color.g),onChange:function(t){e.state.color.g=t/255,e.forceUpdate()}})),o.createElement("div",{className:"blue"},o.createElement(K,{label:"B",min:0,max:255,value:Math.round(255*this.state.color.b),onChange:function(t){e.state.color.b=t/255,e.forceUpdate()}})),o.createElement("div",{className:"alpha"+(i?"":" grayed")},o.createElement(K,{label:"A",min:0,max:255,value:Math.round(255*this.state.alpha),onChange:function(t){e.setState({alpha:t/255}),e.forceUpdate()}}))),o.createElement("div",{className:"color-picker-hex"},o.createElement("div",{className:"color-picker-hex-label"},"Hex"),o.createElement("div",{className:"color-picker-hex-value"},o.createElement($,{expectedLength:6,value:t,onChange:function(t){e.setState({color:l.Color3.FromHexString(t)})}}))),this.props.linearhint&&o.createElement("div",{className:"color-picker-warning"},"(Note: color is stored in linear mode and was converted to gamma to be displayed here (toGammaSpace() / toLinearSpace()))"))},t}(o.Component),ee=function(e){function t(t){var n=e.call(this,t)||this;return n.state={pickerEnabled:!1,color:n.props.value,hex:n.props.value.toHexString()},n._floatRef=o.createRef(),n._floatHostRef=o.createRef(),n}return u(t,e),t.prototype.syncPositions=function(){var e=this._floatRef.current,t=this._floatHostRef.current;if(e&&t){var n=t.getBoundingClientRect().top,r=e.getBoundingClientRect().height;n+r+10>window.innerHeight&&(n=window.innerHeight-r-10),e.style.top=n+"px",e.style.left=t.getBoundingClientRect().left-e.getBoundingClientRect().width+"px"}},t.prototype.shouldComponentUpdate=function(e,t){var n=e.value.toHexString()!==this.props.value.toHexString()||t.hex!==this.state.hex||t.pickerEnabled!==this.state.pickerEnabled;return e.value.toHexString()!==this.props.value.toHexString()&&(t.color=e.value,t.hex=e.value.toHexString()),n},t.prototype.componentDidUpdate=function(){this.syncPositions()},t.prototype.componentDidMount=function(){this.syncPositions()},t.prototype.setPickerState=function(e){this.setState({pickerEnabled:e}),this.props.globalState.blockKeyboardEvents=e},t.prototype.render=function(){var e=this,t=this.state.color;return this.props.globalState.blockKeyboardEvents=this.state.pickerEnabled,o.createElement("div",{className:"color-picker"},o.createElement("div",{className:"color-rect",ref:this._floatHostRef,style:{background:this.state.hex},onClick:function(){return e.setPickerState(!0)}}),this.state.pickerEnabled&&o.createElement(o.Fragment,null,o.createElement("div",{className:"color-picker-cover",onClick:function(){return e.setPickerState(!1)}}),o.createElement("div",{className:"color-picker-float",ref:this._floatRef},o.createElement(J,{color:t,onColorChanged:function(t){var n=t.toHexString();e.setState({hex:n,color:t}),e.props.onColorChanged(n)}}))))},t}(o.Component),te=n(52),ne=n(74),re=n(75),oe=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,color:n.props.target[n.props.propertyName].clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!(n.equals(t.color)&&!this._localChange)&&(t.color=n.clone(),this._localChange=!1,!0)},t.prototype.onChange=function(e){this._localChange=!0;var t="Color4"===this.props.target[this.props.propertyName].getClassName()?l.Color4.FromHexString(e):l.Color3.FromHexString(e);this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:t,initialValue:this.state.color}),this.props.target[this.props.propertyName]=t,this.setState({color:t}),this.props.onChange&&this.props.onChange()},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.color,initialValue:e})},t.prototype.updateStateR=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].x=e,this.state.color.r=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateG=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].g=e,this.state.color.g=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateB=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].b=e,this.state.color.b=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.copyToClipboard=function(){var e=document.createElement("div");if(e.textContent=this.state.color.toHexString(),document.body.appendChild(e),window.getSelection){var t=document.createRange();t.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}document.execCommand("copy"),e.remove()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?re:ne;return o.createElement("div",{className:"color3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"color3"},o.createElement(ee,{value:this.state.color,globalState:this.props.globalState,onColorChanged:function(t){e.onChange(t)}})),o.createElement("div",{className:"copy hoverIcon",onClick:function(){return e.copyToClipboard()},title:"Copy to clipboard"},o.createElement("img",{src:te,alt:""})),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},o.createElement("img",{src:t,alt:""}))),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"r",value:this.state.color.r,onChange:function(t){return e.updateStateR(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"g",value:this.state.color.g,onChange:function(t){return e.updateStateG(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"b",value:this.state.color.b,onChange:function(t){return e.updateStateB(t)}})))},t}(o.Component),ae=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(oe,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),ie=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,value:n.props.target[n.props.propertyName].clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!(n.equals(t.value)&&!this._localChange)&&(t.value=n.clone(),this._localChange=!1,!0)},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateVector3=function(){var e=this.props.target[this.props.propertyName].clone();this.props.target[this.props.propertyName]=this.state.value,this.setState({value:e}),this.raiseOnPropertyChanged(e)},t.prototype.updateStateX=function(e){this._localChange=!0,this.state.value.x=e,this.updateVector3()},t.prototype.updateStateY=function(e){this._localChange=!0,this.state.value.y=e,this.updateVector3()},t.prototype.updateStateZ=function(e){this._localChange=!0,this.state.value.z=e,this.updateVector3()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?o.createElement(q,{icon:X}):o.createElement(q,{icon:G});return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"vector"},"X: ".concat(this.state.value.x.toFixed(2),", Y: ").concat(this.state.value.y.toFixed(2),", Z: ").concat(this.state.value.z.toFixed(2))),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},t)),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"x",step:this.props.step,value:this.state.value.x,onChange:function(t){return e.updateStateX(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"y",step:this.props.step,value:this.state.value.y,onChange:function(t){return e.updateStateY(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"z",step:this.props.step,value:this.state.value.z,onChange:function(t){return e.updateStateZ(t)}})))},t.defaultProps={step:.001},t}(o.Component),le=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(ie,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),se=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={isExpanded:!1,value:(n.props.value||n.props.target[n.props.propertyName]).clone()},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.value||e.target[e.propertyName];return!(n.equals(t.value)&&!this._localChange)&&(t.value=n.clone(),this._localChange=!1,!0)},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.propertyName&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateVector4=function(){var e=(this.props.value||this.props.target[this.props.propertyName]).clone();this.props.value?this.props.value.copyFrom(this.state.value):this.props.target[this.props.propertyName]=this.state.value,this.forceUpdate(),this.raiseOnPropertyChanged(e)},t.prototype.updateStateX=function(e){this._localChange=!0,this.state.value.x=e,this.updateVector4()},t.prototype.updateStateY=function(e){this._localChange=!0,this.state.value.y=e,this.updateVector4()},t.prototype.updateStateZ=function(e){this._localChange=!0,this.state.value.z=e,this.updateVector4()},t.prototype.updateStateW=function(e){this._localChange=!0,this.state.value.w=e,this.updateVector4()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?o.createElement(q,{icon:X}):o.createElement(q,{icon:G});return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"vector"},"X: ".concat(this.state.value.x.toFixed(2),", Y: ").concat(this.state.value.y.toFixed(2),", Z: ").concat(this.state.value.z.toFixed(2),", W: ").concat(this.state.value.w.toFixed(2))),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},t)),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"x",step:this.props.step,value:this.state.value.x,onChange:function(t){return e.updateStateX(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"y",step:this.props.step,value:this.state.value.y,onChange:function(t){return e.updateStateY(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"z",step:this.props.step,value:this.state.value.z,onChange:function(t){return e.updateStateZ(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"w",step:this.props.step,value:this.state.value.w,onChange:function(t){return e.updateStateW(t)}})))},t.defaultProps={step:.001},t}(o.Component),ce=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(se,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),ue=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n.state={value:n._getValue(t)},n}return u(t,e),t.prototype._getValue=function(e){return e.getSelection?e.getSelection(e.target):e.target&&e.propertyName?e.target[e.propertyName]:e.options[e.defaultIfNull||0]},t.prototype.setValue=function(e){this.setState({value:e})},t.prototype.shouldComponentUpdate=function(e,t){if(this._localChange)return this._localChange=!1,!0;var n=this._getValue(e);return null!=n&&n!==t.value&&(t.value=n,!0)},t.prototype.raiseOnPropertyChanged=function(e,t){this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:e,initialValue:t})},t.prototype.updateValue=function(e){var t=this.props.valuesAreStrings?e:parseInt(e);this._localChange=!0;var n=this.state.value;this.props.noDirectUpdate||(this.props.target[this.props.propertyName]=t),this.setState({value:t}),this.raiseOnPropertyChanged(t,n),this.props.onSelect&&this.props.onSelect(t)},t.prototype.render=function(){var e,t=this;return o.createElement("div",{className:"listLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"options"+(this.props.className?" "+this.props.className:"")},o.createElement("select",{onChange:function(e){return t.updateValue(e.target.value)},value:null!==(e=this.state.value)&&void 0!==e?e:""},this.props.options.map((function(e){return o.createElement("option",{key:e.label,value:e.value,title:e.label},e.label)})))))},t}(o.Component),pe=function(e){function t(t){var n=e.call(this,t)||this;n._localChange=!1;var r=n.props.target[n.props.propertyName].clone(),o=0;if(n.props.mode){var a=new l.Quaternion;r.decompose(void 0,a);var i=a.toEulerAngles();switch(n.props.mode){case 1:o=i.x;break;case 2:o=i.y;break;case 3:o=i.z}}return n.state={value:r,mode:n.props.mode||0,angle:o},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName];return!n.equals(t.value)||this._localChange?(t.value=n.clone(),this._localChange=!1,!0):t.mode!==this.state.mode||t.angle!==this.state.angle},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(this.state.value),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.value,initialValue:e})},t.prototype.updateMatrix=function(){var e=this.props.target[this.props.propertyName].clone();this.props.target[this.props.propertyName]=this.state.value,this.setState({value:e}),this.raiseOnPropertyChanged(e)},t.prototype.updateRow=function(e,t){this._localChange=!0,this.state.value.setRow(t,e),this.updateMatrix()},t.prototype.updateBasedOnMode=function(e){switch(this.state.mode){case 1:l.Matrix.RotationXToRef(this.state.angle,this.state.value);break;case 2:l.Matrix.RotationYToRef(this.state.angle,this.state.value);break;case 3:l.Matrix.RotationZToRef(this.state.angle,this.state.value)}this.updateMatrix(),this.setState({angle:e})},t.prototype.render=function(){var e=this;return o.createElement("div",{className:"vector3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label)),o.createElement("div",{className:"secondLine"},o.createElement(ue,{label:"Mode",className:"no-right-margin",options:[{label:"User-defined",value:0},{label:"Rotation over X axis",value:1},{label:"Rotation over Y axis",value:2},{label:"Rotation over Z axis",value:3}],target:this,noDirectUpdate:!0,getSelection:function(){return e.state.mode},onSelect:function(t){e.props.target[e.props.propertyName]=l.Matrix.Identity(),l.Matrix.IdentityToRef(e.state.value),e.setState({mode:t,angle:0}),e.updateMatrix(),e.props.onModeChange&&e.props.onModeChange(t)}})),0===this.state.mode&&o.createElement("div",{className:"secondLine"},o.createElement(se,{globalState:this.props.globalState,label:"Row #0",value:this.state.value.getRow(0),onChange:function(t){return e.updateRow(t,0)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #1",value:this.state.value.getRow(1),onChange:function(t){return e.updateRow(t,1)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #2",value:this.state.value.getRow(2),onChange:function(t){return e.updateRow(t,2)}}),o.createElement(se,{globalState:this.props.globalState,label:"Row #3",value:this.state.value.getRow(3),onChange:function(t){return e.updateRow(t,3)}})),0!==this.state.mode&&o.createElement("div",{className:"secondLine"},o.createElement(B,{label:"Angle",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,globalState:this.props.globalState,directValue:this.state.angle,onChange:function(t){return e.updateBasedOnMode(t)}})))},t}(o.Component),de=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(pe,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)},mode:this.props.inputBlock.matrixMode,onModeChange:function(t){e.props.inputBlock.matrixMode=t}})},t}(o.Component),he=function(e){function t(t){var n=e.call(this,t)||this;return n._localChange=!1,n._onFocus=!1,n.state={value:void 0!==n.props.value?n.props.value:n.props.target[n.props.propertyName]||""},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){if(this._localChange)return this._localChange=!1,!0;var n=void 0!==e.value?e.value:e.target[e.propertyName];return n!==t.value&&(t.value=n||"",!0)},t.prototype.componentWillUnmount=function(){this._onFocus&&this.updateValue(this.state.value,!0)},t.prototype.raiseOnPropertyChanged=function(e,t){this.props.onChange?this.props.onChange(e):this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:e,initialValue:t})},t.prototype.updateValue=function(e,t){this._localChange=!0;var n=void 0!==this.props.value?this.props.value:this.props.target[this.props.propertyName];this.props.validator&&t&&0==this.props.validator(e)&&(e=n),this.setState({value:e}),t&&this.raiseOnPropertyChanged(e,n),this.props.propertyName&&(this.props.target[this.props.propertyName]=e)},t.prototype.render=function(){var e=this;return o.createElement("div",{className:this.props.multilines?"textInputArea":"textInputLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"value"},this.props.multilines&&o.createElement(o.Fragment,null,o.createElement("textarea",{value:this.state.value,onFocus:function(){e.props.globalState.blockKeyboardEvents=!0,e._onFocus=!0},onChange:function(t){return e.updateValue(t.target.value,!1)},onKeyDown:function(t){13===t.keyCode&&e.updateValue(e.state.value,!0)},onBlur:function(t){e.updateValue(t.target.value,!0),e.props.globalState.blockKeyboardEvents=!1,e._onFocus=!1}})),!this.props.multilines&&o.createElement(o.Fragment,null,o.createElement("input",{value:this.state.value,onFocus:function(){e.props.globalState.blockKeyboardEvents=!0,e._onFocus=!0},onChange:function(t){return e.updateValue(t.target.value,!1)},onKeyDown:function(t){13===t.keyCode&&e.updateValue(e.state.value,!0)},onBlur:function(t){e.updateValue(t.target.value,!0),e.props.globalState.blockKeyboardEvents=!1,e._onFocus=!1}}))))},t}(o.Component),fe=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.onLink=function(){this.props.onLink&&this.props.onLink()},t.prototype.renderContent=function(){var e=this;return this.props.onLink?o.createElement("div",{className:"link-value",title:this.props.value,onClick:function(){return e.onLink()}},this.props.value||"no name"):o.createElement("div",{className:"value",title:this.props.value,style:{color:this.props.color?this.props.color:""}},this.props.value||"no name")},t.prototype.render=function(){return o.createElement("div",{className:this.props.underline?"textLine underline":"textLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),this.renderContent())},t}(o.Component),me=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){return o.createElement(o.Fragment,null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),ge=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=[{label:"Neutral",value:l.NodeMaterialBlockTargets.Neutral},{label:"Vertex",value:l.NodeMaterialBlockTargets.Vertex},{label:"Fragment",value:l.NodeMaterialBlockTargets.Fragment}];return o.createElement(o.Fragment,null,o.createElement(m,{title:"GENERAL"},(!this.props.block.isInput||!this.props.block.isAttribute)&&o.createElement(he,{globalState:this.props.globalState,label:"Name",propertyName:"name",target:this.props.block,onChange:function(){return e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)},validator:function(t){return!!e.props.block.validateBlockName(t)||(e.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers('"'.concat(t,'" is a reserved name, please choose another')),!1)}}),this.props.block._originalTargetIsNeutral&&o.createElement(ue,{label:"Target",options:t,target:this.props.block,propertyName:"target",onSelect:function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),!this.props.block._originalTargetIsNeutral&&o.createElement(fe,{label:"Target",value:l.NodeMaterialBlockTargets[this.props.block.target]}),o.createElement(fe,{label:"Type",value:this.props.block.getClassName()}),o.createElement(he,{globalState:this.props.globalState,label:"Comments",propertyName:"comments",target:this.props.block,onChange:function(){return e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})))},t}(o.Component),ve=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.forceRebuild=function(e){var t;e&&!e.update||this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),e&&!e.rebuild||this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),(null==e?void 0:e.activatePreviewCommand)&&this.props.globalState.onPreviewCommandActivated.notifyObservers(!0),null===(t=null==e?void 0:e.callback)||void 0===t||t.call(e,this.props.globalState.nodeMaterial.getScene())},t.prototype.render=function(){var e=this,t=this.props.block._propStore;if(!t)return o.createElement(o.Fragment,null);for(var n={},r=[],a=function(t,a,s,c,u){var p=n[c];switch(p||(p=[],n[c]=p,r.push(c)),s){case l.PropertyTypeForEdition.Boolean:p.push(o.createElement(E,{label:a,target:i.props.block,propertyName:t,onValueChanged:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Float:isNaN(u.min)||isNaN(u.max)||u.min===u.max?p.push(o.createElement(P,{globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}})):p.push(o.createElement(B,{label:a,target:i.props.block,globalState:i.props.globalState,propertyName:t,step:Math.abs(u.max-u.min)/100,minimum:Math.min(u.min,u.max),maximum:u.max,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Int:p.push(o.createElement(P,{digits:0,step:"1",isInteger:!0,globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.Vector2:p.push(o.createElement(Z,{globalState:i.props.globalState,label:a,propertyName:t,target:i.props.block,onChange:function(){return e.forceRebuild(u.notifiers)}}));break;case l.PropertyTypeForEdition.List:p.push(o.createElement(ue,{label:a,options:u.options,target:i.props.block,propertyName:t,onSelect:function(){return e.forceRebuild(u.notifiers)}}))}},i=this,s=0,c=t;s<c.length;s++){var u=c[s];a(u.propertyName,u.displayName,u.type,u.groupName,u.options)}return o.createElement(o.Fragment,null,r.map((function(e){return o.createElement(m,{title:e},n[e])})))},t}(o.Component),be=n(52),ye=n(74),xe=n(75),we=function(e){function t(t){var n=e.call(this,t)||this;n._localChange=!1;var r=n.props.target[n.props.propertyName],o="Color4"===r.getClassName()?r.clone():new l.Color4(r.r,r.g,r.b,1);return n.state={isExpanded:!1,color:o},n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){var n=e.target[e.propertyName],r="Color4"===n.getClassName()?n:new l.Color4(n.r,n.g,n.b,1);return!(r.equals(t.color)&&!this._localChange)&&(t.color=r.clone(),this._localChange=!1,!0)},t.prototype.onChange=function(e){this._localChange=!0;var t=l.Color4.FromHexString(e);this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:t,initialValue:this.state.color}),this.props.target[this.props.propertyName]=t,this.setState({color:this.props.target[this.props.propertyName]}),this.props.onChange&&this.props.onChange()},t.prototype.switchExpandState=function(){this._localChange=!0,this.setState({isExpanded:!this.state.isExpanded})},t.prototype.raiseOnPropertyChanged=function(e){this.props.onChange&&this.props.onChange(),this.props.onPropertyChangedObservable&&this.props.onPropertyChangedObservable.notifyObservers({object:this.props.target,property:this.props.propertyName,value:this.state.color,initialValue:e})},t.prototype.updateStateR=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].x=e,this.state.color.r=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateG=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].g=e,this.state.color.g=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateB=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].b=e,this.state.color.b=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.updateStateA=function(e){this._localChange=!0;var t=this.state.color.clone();this.props.target[this.props.propertyName].a=e,this.state.color.a=e,this.props.target[this.props.propertyName]=this.state.color,this.setState({color:this.state.color}),this.raiseOnPropertyChanged(t)},t.prototype.copyToClipboard=function(){var e=document.createElement("div");if(e.textContent=this.state.color.toHexString(),document.body.appendChild(e),window.getSelection){var t=document.createRange();t.selectNode(e),window.getSelection().removeAllRanges(),window.getSelection().addRange(t)}document.execCommand("copy"),e.remove()},t.prototype.render=function(){var e=this,t=this.state.isExpanded?xe:ye;return o.createElement("div",{className:"color3Line"},o.createElement("div",{className:"firstLine"},o.createElement("div",{className:"label",title:this.props.label},this.props.label),o.createElement("div",{className:"color3"},o.createElement(ee,{globalState:this.props.globalState,value:this.state.color,onColorChanged:function(t){e.onChange(t)}})),o.createElement("div",{className:"copy hoverIcon",onClick:function(){return e.copyToClipboard()},title:"Copy to clipboard"},o.createElement("img",{src:be,alt:""})),o.createElement("div",{className:"expand hoverIcon",onClick:function(){return e.switchExpandState()},title:"Expand"},o.createElement("img",{src:t,alt:""}))),this.state.isExpanded&&o.createElement("div",{className:"secondLine"},o.createElement(N,{globalState:this.props.globalState,label:"r",value:this.state.color.r,onChange:function(t){return e.updateStateR(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"g",value:this.state.color.g,onChange:function(t){return e.updateStateG(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"b",value:this.state.color.b,onChange:function(t){return e.updateStateB(t)}}),o.createElement(N,{globalState:this.props.globalState,label:"a",value:this.state.color.a,onChange:function(t){return e.updateStateA(t)}})))},t}(o.Component),ke=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(we,{globalState:this.props.globalState,label:"Value",target:this.props.inputBlock,propertyName:"value",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.inputBlock)}})},t}(o.Component),_e=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this,t=this.props.block;this.onValueChangedObserver=t.onValueChangedObservable.add((function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}))},t.prototype.componentWillUnmount=function(){var e=this.props.block;this.onValueChangedObserver&&(e.onValueChangedObservable.remove(this.onValueChangedObserver),this.onValueChangedObserver=null)},t.prototype.renderValue=function(e){var t=this,n=this.props.block;switch(n.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var r=isNaN(n.min)||isNaN(n.max)||n.min===n.max;return o.createElement(o.Fragment,null,o.createElement(E,{label:"Is boolean",target:n,propertyName:"isBoolean"}),n.isBoolean&&o.createElement(E,{label:"Value",isSelected:function(){return 1===n.value},onSelect:function(e){n.value=e?1:0,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),!n.isBoolean&&o.createElement(P,{globalState:this.props.globalState,label:"Min",target:n,propertyName:"min",onChange:function(){n.value<n.min&&(n.value=n.min,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)),t.forceUpdate()}}),!n.isBoolean&&o.createElement(P,{globalState:this.props.globalState,label:"Max",target:n,propertyName:"max",onChange:function(){n.value>n.max&&(n.value=n.max,n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)),t.forceUpdate()}}),!n.isBoolean&&r&&o.createElement(T,{globalState:e,inputBlock:n}),!n.isBoolean&&!r&&o.createElement(B,{label:"Value",globalState:this.props.globalState,target:n,propertyName:"value",step:Math.abs(n.max-n.min)/100,minimum:Math.min(n.min,n.max),maximum:n.max,onChange:function(){n.isConstant&&t.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Q,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(o.Fragment,null,o.createElement(ae,{globalState:e,inputBlock:n}),o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(o.Fragment,null,o.createElement(ke,{globalState:e,inputBlock:n}),o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}),o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){t.props.globalState.onUpdateRequiredObservable.notifyObservers(t.props.block)}}));case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(le,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(ce,{globalState:e,inputBlock:n});case l.NodeMaterialBlockConnectionPointTypes.Matrix:return o.createElement(de,{globalState:e,inputBlock:n})}return null},t.prototype.setDefaultValue=function(){this.props.block.setDefaultValue()},t.prototype.render=function(){var e=this,t=this.props.block,n=[],r=[],a=[];switch(t.type){case l.NodeMaterialBlockConnectionPointTypes.Float:a=[{label:"None",value:l.AnimatedInputBlockTypes.None},{label:"Time",value:l.AnimatedInputBlockTypes.Time}],n=[{label:"Delta time",value:l.NodeMaterialSystemValues.DeltaTime},{label:"Material alpha",value:l.NodeMaterialSystemValues.MaterialAlpha}];break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:n=[{label:"World",value:l.NodeMaterialSystemValues.World},{label:"World x View",value:l.NodeMaterialSystemValues.WorldView},{label:"World x View x Projection",value:l.NodeMaterialSystemValues.WorldViewProjection},{label:"View",value:l.NodeMaterialSystemValues.View},{label:"View x Projection",value:l.NodeMaterialSystemValues.ViewProjection},{label:"Projection",value:l.NodeMaterialSystemValues.Projection}];break;case l.NodeMaterialBlockConnectionPointTypes.Color3:n=[{label:"Fog color",value:l.NodeMaterialSystemValues.FogColor}];break;case l.NodeMaterialBlockConnectionPointTypes.Color4:r=[{label:"color",value:"color"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:r=[{label:"uv",value:"uv"},{label:"uv2",value:"uv2"},{label:"uv3",value:"uv3"},{label:"uv4",value:"uv4"},{label:"uv5",value:"uv5"},{label:"uv6",value:"uv6"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:n=[{label:"Camera position",value:l.NodeMaterialSystemValues.CameraPosition}],r=[{label:"position",value:"position"},{label:"normal",value:"normal"},{label:"tangent",value:"tangent"}];break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:r=[{label:"matricesIndices",value:"matricesIndices"},{label:"matricesWeights",value:"matricesWeights"}],n=[{label:"Camera parameters",value:l.NodeMaterialSystemValues.CameraParameters}]}var i=[{label:"User-defined",value:0}];r.length>0&&i.push({label:"Mesh attribute",value:1}),n.length>0&&i.push({label:"System value",value:2});return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&o.createElement(ue,{label:"Type",options:[{label:"None",value:0},{label:"Visible in the inspector",value:1},{label:"Constant",value:2}],target:t,noDirectUpdate:!0,getSelection:function(e){return e.visibleInInspector?1:e.isConstant?2:0},onSelect:function(n){switch(n){case 0:t.visibleInInspector=!1,t.isConstant=!1;break;case 1:t.visibleInInspector=!0,t.isConstant=!1;break;case 2:t.visibleInInspector=!1,t.isConstant=!0}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.visibleInInspector&&o.createElement(he,{globalState:this.props.globalState,label:"Group",propertyName:"groupInInspector",target:this.props.block,onChange:function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),o.createElement(ue,{label:"Mode",options:i,target:t,noDirectUpdate:!0,getSelection:function(e){return e.isAttribute?1:e.isSystemValue?2:0},onSelect:function(o){switch(o){case 0:t.isUniform=!0,t.setAsSystemValue(null),e.setDefaultValue();break;case 1:t.setAsAttribute(r[0].value);break;case 2:t.setAsSystemValue(n[0].value)}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isAttribute&&o.createElement(ue,{label:"Attribute",valuesAreStrings:!0,options:r,target:t,propertyName:"name",onSelect:function(n){t.setAsAttribute(n),e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&a.length>0&&o.createElement(ue,{label:"Animation type",options:a,target:t,propertyName:"animationType",onSelect:function(t){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&this.renderValue(this.props.globalState),t.isUniform&&t.isSystemValue&&o.createElement(ue,{label:"System value",options:n,target:t,propertyName:"systemValue",onSelect:function(n){t.setAsSystemValue(n),e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),t.isUniform&&!t.isSystemValue&&t.animationType===l.AnimatedInputBlockTypes.None&&o.createElement(E,{label:"Visible on frame",target:this.props.block,propertyName:"visibleOnFrame"})))},t}(o.Component),Ce=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this;return o.createElement(o.Fragment,null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(E,{label:"Transform as direction",onSelect:function(t){var n=e.props.block;n.complementW=t?0:1,e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},isSelected:function(){return 0===e.props.block.complementW}})))},t}(o.Component),Se=n(73),Ee=n(52),Pe=function(e){function t(t){var n=e.call(this,t)||this;return n.state={gradient:t.step.step},n}return u(t,e),t.prototype.updateColor=function(e){this.props.step.color=l.Color3.FromHexString(e),this.props.onUpdateStep(),this.forceUpdate()},t.prototype.updateStep=function(e){this.props.step.step=e,this.setState({gradient:e}),this.props.onUpdateStep()},t.prototype.onPointerUp=function(){this.props.onCheckForReOrder()},t.prototype.render=function(){var e=this,t=this.props.step;return o.createElement("div",{className:"gradient-step"},o.createElement("div",{className:"step"},"#".concat(this.props.lineIndex)),o.createElement("div",{className:"color"},o.createElement(ee,{value:t.color,globalState:this.props.globalState,onColorChanged:function(t){e.updateColor(t)}})),o.createElement("div",{className:"step-value"},o.createElement(P,{globalState:this.props.globalState,smallUI:!0,label:"",target:t,propertyName:"step",min:0,max:1,onEnter:function(){e.props.onUpdateStep(),e.props.onCheckForReOrder(),e.forceUpdate()}})),o.createElement("div",{className:"step-slider"},o.createElement("input",{className:"range",type:"range",step:.01,min:0,max:1,value:t.step,onPointerUp:function(t){return e.onPointerUp()},onChange:function(t){return e.updateStep(parseFloat(t.target.value))}})),o.createElement("div",{className:"gradient-copy",onClick:function(){e.props.onCopy&&e.props.onCopy()},title:"Copy Step"},o.createElement("img",{className:"img",src:Ee})),o.createElement("div",{className:"gradient-delete",onClick:function(){return e.props.onDelete()},title:"Delete Step"},o.createElement("img",{className:"img",src:Se})))},t}(o.Component),Te=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this,t=this.props.block;this.onValueChangedObserver=t.onValueChangedObservable.add((function(){e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}))},t.prototype.componentWillUnmount=function(){var e=this.props.block;this.onValueChangedObserver&&(e.onValueChangedObservable.remove(this.onValueChangedObserver),this.onValueChangedObserver=null)},t.prototype.forceRebuild=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.deleteStep=function(e){var t=this.props.block,n=t.colorSteps.indexOf(e);n>-1&&(t.colorSteps.splice(n,1),t.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate())},t.prototype.copyStep=function(e){var t=this.props.block,n=new l.GradientBlockColorStep(1,e.color);t.colorSteps.push(n),t.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate()},t.prototype.addNewStep=function(){var e=this.props.block,t=new l.GradientBlockColorStep(1,l.Color3.White());e.colorSteps.push(t),e.colorStepsUpdated(),this.forceRebuild(),this.forceUpdate()},t.prototype.checkForReOrder=function(){var e=this.props.block;e.colorSteps.sort((function(e,t){return e.step===t.step?0:e.step>t.step?1:-1})),e.colorStepsUpdated(),this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.forceUpdate()},t.prototype.render=function(){var e=this,t=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Type",options:[{label:"None",value:0},{label:"Visible in the inspector",value:1}],target:this.props.block,noDirectUpdate:!0,getSelection:function(e){return e.visibleInInspector?1:e.isConstant?2:0},onSelect:function(t){switch(t){case 0:e.props.block.visibleInInspector=!1;break;case 1:e.props.block.visibleInInspector=!0}e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})),o.createElement(m,{title:"STEPS"},o.createElement(k,{label:"Add new step",onClick:function(){return e.addNewStep()}}),t.colorSteps.map((function(t,n){return o.createElement(Pe,{globalState:e.props.globalState,onCheckForReOrder:function(){return e.checkForReOrder()},onUpdateStep:function(){return e.forceRebuild()},key:"step-"+n,lineIndex:n,step:t,onCopy:function(){return e.copyStep(t)},onDelete:function(){return e.deleteStep(t)}})}))))},t}(o.Component),Be=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.globalState.nodeMaterial.getScene(),n=t.lights.map((function(e){return{label:e.name,value:e.name}}));n.splice(0,0,{label:"All",value:""});var r=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Light",defaultIfNull:0,noDirectUpdate:!0,valuesAreStrings:!0,options:n,target:r,propertyName:"name",onSelect:function(n){r.light=""===n?null:t.getLightByName(n),e.forceUpdate(),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})))},t}(o.Component),Ne=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.globalState.nodeMaterial.getScene(),n=t.lights.map((function(e){return{label:e.name,value:e.name}})),r=this.props.block;return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Light",noDirectUpdate:!0,valuesAreStrings:!0,options:n,target:r,propertyName:"name",onSelect:function(n){r.light=t.getLightByName(n),e.forceUpdate(),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}})))},t}(o.Component),Oe=function(e){function t(t){var n=e.call(this,t)||this,r=n.textureBlock.texture;return n.state={isEmbedded:!r||"data"===r.name.substring(0,4),loadAsCubeTexture:r&&r.isCube,textureIsPrefiltered:!0},n}return u(t,e),Object.defineProperty(t.prototype,"textureBlock",{get:function(){return this.props.block},enumerable:!1,configurable:!0}),t.prototype.UNSAFE_componentWillUpdate=function(e,t){if(e.block!==this.props.block){var n=e.block.texture;t.isEmbedded=!n||"data"===n.name.substring(0,4),t.loadAsCubeTexture=n&&n.isCube}},t.prototype._generateRandomForCache=function(){return"xxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,(function(e){return(10*Math.random()|0).toString()}))},t.prototype.updateAfterTextureLoad=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),this.forceUpdate()},t.prototype.removeTexture=function(){var e=this.textureBlock.texture;e&&(e.dispose(),e=null,this.textureBlock.texture=null),this.updateAfterTextureLoad()},t.prototype._prepareTexture=function(){var e=this.textureBlock.texture;e&&e.isCube!==this.state.loadAsCubeTexture&&(e.dispose(),e=null),e||(this.state.loadAsCubeTexture?(this.textureBlock.texture=new l.CubeTexture("",this.props.globalState.nodeMaterial.getScene()),(e=this.textureBlock.texture).coordinatesMode=l.Texture.CUBIC_MODE):(this.textureBlock.texture=new l.Texture(null,this.props.globalState.nodeMaterial.getScene(),!1,this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock||this.props.globalState.mode===l.NodeMaterialModes.PostProcess),(e=this.textureBlock.texture).coordinatesMode=l.Texture.EQUIRECTANGULAR_MODE))},t.prototype.replaceTexture=function(e){var t=this;this._prepareTexture();var n=this.textureBlock.texture;l.Tools.ReadFile(e,(function(r){var o=new Blob([r],{type:"octet/stream"}),a=new FileReader;a.readAsDataURL(o),a.onloadend=function(){var r=a.result,o=void 0;e.name.toLowerCase().indexOf(".dds")>0?o=".dds":e.name.toLowerCase().indexOf(".env")>0&&(o=".env"),n.isCube?n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}),t.state.textureIsPrefiltered):n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}))}}),void 0,!0)},t.prototype.replaceTextureWithUrl=function(e){var t=this;this._prepareTexture();var n=this.textureBlock.texture;if(n.isCube||this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock){var r=void 0;e.toLowerCase().indexOf(".dds")>0?r=".dds":e.toLowerCase().indexOf(".env")>0&&(r=".env"),n.updateURL(e,r,(function(){return t.updateAfterTextureLoad()}),this.state.textureIsPrefiltered)}else n.updateURL(e,null,(function(){return t.updateAfterTextureLoad()}))},t.prototype.render=function(){var e=this,t="",n=this.textureBlock.hasImageSource?null:this.textureBlock.texture;n&&n.name&&"data"!==n.name.substring(0,4)&&(t=n.name),t=t.replace(/\?nocache=\d+/,"");var r=this.textureBlock instanceof l.ReflectionTextureBlock||this.textureBlock instanceof l.ReflectionBlock||this.textureBlock instanceof l.RefractionBlock,a=this.textureBlock instanceof l.CurrentScreenBlock||this.textureBlock instanceof l.ParticleTextureBlock,i=this.textureBlock instanceof l.ReflectionBlock,s=[{label:"Cubic",value:l.Texture.CUBIC_MODE},{label:"Equirectangular",value:l.Texture.EQUIRECTANGULAR_MODE},{label:"Explicit",value:l.Texture.EXPLICIT_MODE},{label:"Fixed equirectangular",value:l.Texture.FIXED_EQUIRECTANGULAR_MODE},{label:"Fixed mirrored equirectangular",value:l.Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE},{label:"Planar",value:l.Texture.PLANAR_MODE},{label:"Projection",value:l.Texture.PROJECTION_MODE},{label:"Skybox",value:l.Texture.SKYBOX_MODE},{label:"Spherical",value:l.Texture.SPHERICAL_MODE}],c=[{label:"Nearest",value:l.Texture.NEAREST_NEAREST},{label:"Linear",value:l.Texture.LINEAR_LINEAR},{label:"Linear & linear mip",value:l.Texture.LINEAR_LINEAR_MIPLINEAR},{label:"Linear & nearest mip",value:l.Texture.LINEAR_LINEAR_MIPNEAREST},{label:"Nearest & linear mip",value:l.Texture.NEAREST_NEAREST_MIPLINEAR},{label:"Nearest & nearest mip",value:l.Texture.NEAREST_NEAREST_MIPNEAREST},{label:"Nearest/Linear",value:l.Texture.NEAREST_LINEAR},{label:"Nearest/Linear & linear mip",value:l.Texture.NEAREST_LINEAR_MIPLINEAR},{label:"Nearest/Linear & nearest mip",value:l.Texture.NEAREST_LINEAR_MIPNEAREST},{label:"Linear/Nearest",value:l.Texture.LINEAR_NEAREST},{label:"Linear/Nearest & linear mip",value:l.Texture.LINEAR_NEAREST_MIPLINEAR},{label:"Linear/Nearest & nearest mip",value:l.Texture.LINEAR_NEAREST_MIPNEAREST}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(E,{label:"Auto select UV",propertyName:"autoSelectUV",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),!r&&o.createElement(E,{label:"Convert to gamma space",propertyName:"convertToGammaSpace",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),!r&&o.createElement(E,{label:"Convert to linear space",propertyName:"convertToLinearSpace",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&i&&o.createElement(E,{label:"Is in gamma space",propertyName:"gammaSpace",target:n,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),o.createElement(E,{label:"Disable multiplying by level",propertyName:"disableLevelMultiplication",target:this.props.block,onValueChanged:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}}),n&&n.updateSamplingMode&&o.createElement(ue,{label:"Sampling",options:c,target:n,noDirectUpdate:!0,propertyName:"samplingMode",onSelect:function(t){n.updateSamplingMode(t),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&r&&o.createElement(ue,{label:"Reflection mode",options:s,target:n,propertyName:"coordinatesMode",onSelect:function(t){n.coordinatesMode=t,e.forceUpdate(),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(E,{label:"Clamp U",isSelected:function(){return n.wrapU===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapU=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(E,{label:"Clamp V",isSelected:function(){return n.wrapV===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapV=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Offset U",target:n,propertyName:"uOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Offset V",target:n,propertyName:"vOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Scale U",target:n,propertyName:"uScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(P,{globalState:this.props.globalState,label:"Scale V",target:n,propertyName:"vScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation U",target:n,globalState:this.props.globalState,propertyName:"uAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation V",target:n,globalState:this.props.globalState,propertyName:"vAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&!r&&!a&&o.createElement(B,{label:"Rotation W",target:n,globalState:this.props.globalState,propertyName:"wAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})),!this.textureBlock.hasImageSource&&o.createElement(m,{title:"SOURCE"},o.createElement(E,{label:"Embed static texture",isSelected:function(){return e.state.isEmbedded},onSelect:function(t){e.setState({isEmbedded:t}),e.textureBlock.texture=null,e.updateAfterTextureLoad()}}),r&&o.createElement(E,{label:"Load as cube texture",isSelected:function(){return e.state.loadAsCubeTexture},onSelect:function(t){return e.setState({loadAsCubeTexture:t})}}),r&&this.state.loadAsCubeTexture&&o.createElement(E,{label:"      Texture is prefiltered",isSelected:function(){return e.state.textureIsPrefiltered},onSelect:function(t){return e.setState({textureIsPrefiltered:t})}}),this.state.isEmbedded&&o.createElement(C,{label:"Upload",onClick:function(t){return e.replaceTexture(t)},accept:".jpg, .png, .tga, .dds, .env"}),!this.state.isEmbedded&&o.createElement(he,{label:"Link",globalState:this.props.globalState,value:t,onChange:function(t){return e.replaceTextureWithUrl(t)}}),!this.state.isEmbedded&&t&&o.createElement(k,{label:"Refresh",onClick:function(){return e.replaceTextureWithUrl(t+"?nocache="+e._generateRandomForCache())}}),n&&o.createElement(k,{label:"Remove",onClick:function(){return e.removeTexture()}})),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),Le=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"Cos",value:l.TrigonometryBlockOperations.Cos},{label:"Sin",value:l.TrigonometryBlockOperations.Sin},{label:"Abs",value:l.TrigonometryBlockOperations.Abs},{label:"Exp",value:l.TrigonometryBlockOperations.Exp},{label:"Exp2",value:l.TrigonometryBlockOperations.Exp2},{label:"Round",value:l.TrigonometryBlockOperations.Round},{label:"Ceiling",value:l.TrigonometryBlockOperations.Ceiling},{label:"Floor",value:l.TrigonometryBlockOperations.Floor},{label:"Sqrt",value:l.TrigonometryBlockOperations.Sqrt},{label:"ArcCos",value:l.TrigonometryBlockOperations.ArcCos},{label:"ArcSin",value:l.TrigonometryBlockOperations.ArcSin},{label:"ArcTan",value:l.TrigonometryBlockOperations.ArcTan},{label:"Tan",value:l.TrigonometryBlockOperations.Tan},{label:"Log",value:l.TrigonometryBlockOperations.Log},{label:"Fract",value:l.TrigonometryBlockOperations.Fract},{label:"Sign",value:l.TrigonometryBlockOperations.Sign},{label:"Radians to degrees",value:l.TrigonometryBlockOperations.Degrees},{label:"Degrees to radians",value:l.TrigonometryBlockOperations.Radians}];return n.sort((function(e,t){return e.label.localeCompare(t.label)})),o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Operation",options:n,target:t,propertyName:"operation",onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Me=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"Equal",value:l.ConditionalBlockConditions.Equal},{label:"NotEqual",value:l.ConditionalBlockConditions.NotEqual},{label:"LessThan",value:l.ConditionalBlockConditions.LessThan},{label:"GreaterThan",value:l.ConditionalBlockConditions.GreaterThan},{label:"LessOrEqual",value:l.ConditionalBlockConditions.LessOrEqual},{label:"GreaterOrEqual",value:l.ConditionalBlockConditions.GreaterOrEqual},{label:"Xor",value:l.ConditionalBlockConditions.Xor},{label:"Or",value:l.ConditionalBlockConditions.Or},{label:"And",value:l.ConditionalBlockConditions.And}];return n.sort((function(e,t){return e.label.localeCompare(t.label)})),o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},o.createElement(ue,{label:"Condition",options:n,target:t,propertyName:"condition",onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Re=function(e){function t(t){var n=e.call(this,t)||this,r=n.imageSourceBlock.texture;return n.state={isEmbedded:!r||"data"===r.name.substring(0,4)},n}return u(t,e),Object.defineProperty(t.prototype,"imageSourceBlock",{get:function(){return this.props.block},enumerable:!1,configurable:!0}),t.prototype.UNSAFE_componentWillUpdate=function(e,t){if(e.block!==this.props.block){var n=e.block.texture;t.isEmbedded=!n||"data"===n.name.substring(0,4),t.loadAsCubeTexture=n&&n.isCube}},t.prototype._generateRandomForCache=function(){return"xxxxxxxxxxxxxxxxxxxx".replace(/[x]/g,(function(e){return(10*Math.random()|0).toString()}))},t.prototype.updateAfterTextureLoad=function(){this.props.globalState.onUpdateRequiredObservable.notifyObservers(this.props.block),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),this.forceUpdate()},t.prototype.removeTexture=function(){var e=this.imageSourceBlock.texture;e&&(e.dispose(),e=null,this.imageSourceBlock.texture=null),this.updateAfterTextureLoad()},t.prototype._prepareTexture=function(){var e=this.imageSourceBlock.texture;e&&(e.dispose(),e=null),e||(this.imageSourceBlock.texture=new l.Texture(null,this.props.globalState.nodeMaterial.getScene(),!1,!1),(e=this.imageSourceBlock.texture).coordinatesMode=l.Texture.EQUIRECTANGULAR_MODE)},t.prototype.replaceTexture=function(e){var t=this;this._prepareTexture();var n=this.imageSourceBlock.texture;l.Tools.ReadFile(e,(function(r){var o=new Blob([r],{type:"octet/stream"}),a=new FileReader;a.readAsDataURL(o),a.onloadend=function(){var r=a.result,o=void 0;e.name.toLowerCase().indexOf(".dds")>0?o=".dds":e.name.toLowerCase().indexOf(".env")>0&&(o=".env"),n.updateURL(r,o,(function(){return t.updateAfterTextureLoad()}))}}),void 0,!0)},t.prototype.replaceTextureWithUrl=function(e){var t=this;this._prepareTexture(),this.imageSourceBlock.texture.updateURL(e,null,(function(){return t.updateAfterTextureLoad()}))},t.prototype.render=function(){var e=this,t="",n=this.imageSourceBlock.texture;n&&n.name&&"data"!==n.name.substring(0,4)&&(t=n.name),t=t.replace(/\?nocache=\d+/,"");var r=[{label:"Nearest",value:l.Texture.NEAREST_NEAREST},{label:"Linear",value:l.Texture.LINEAR_LINEAR},{label:"Linear & linear mip",value:l.Texture.LINEAR_LINEAR_MIPLINEAR},{label:"Linear & nearest mip",value:l.Texture.LINEAR_LINEAR_MIPNEAREST},{label:"Nearest & linear mip",value:l.Texture.NEAREST_NEAREST_MIPLINEAR},{label:"Nearest & nearest mip",value:l.Texture.NEAREST_NEAREST_MIPNEAREST},{label:"Nearest/Linear",value:l.Texture.NEAREST_LINEAR},{label:"Nearest/Linear & linear mip",value:l.Texture.NEAREST_LINEAR_MIPLINEAR},{label:"Nearest/Linear & nearest mip",value:l.Texture.NEAREST_LINEAR_MIPNEAREST},{label:"Linear/Nearest",value:l.Texture.LINEAR_NEAREST},{label:"Linear/Nearest & linear mip",value:l.Texture.LINEAR_NEAREST_MIPLINEAR},{label:"Linear/Nearest & nearest mip",value:l.Texture.LINEAR_NEAREST_MIPNEAREST}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"PROPERTIES"},n&&n.updateSamplingMode&&o.createElement(ue,{label:"Sampling",options:r,target:n,noDirectUpdate:!0,propertyName:"samplingMode",onSelect:function(t){n.updateSamplingMode(t),e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(E,{label:"Clamp U",isSelected:function(){return n.wrapU===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapU=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(E,{label:"Clamp V",isSelected:function(){return n.wrapV===l.Texture.CLAMP_ADDRESSMODE},onSelect:function(t){n.wrapV=t?l.Texture.CLAMP_ADDRESSMODE:l.Texture.WRAP_ADDRESSMODE,e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Offset U",target:n,propertyName:"uOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Offset V",target:n,propertyName:"vOffset",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Scale U",target:n,propertyName:"uScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(P,{globalState:this.props.globalState,label:"Scale V",target:n,propertyName:"vScale",onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation U",target:n,globalState:this.props.globalState,propertyName:"uAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation V",target:n,globalState:this.props.globalState,propertyName:"vAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}}),n&&o.createElement(B,{label:"Rotation W",target:n,globalState:this.props.globalState,propertyName:"wAng",minimum:0,maximum:2*Math.PI,useEuler:!0,step:.1,onChange:function(){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block)}})),o.createElement(m,{title:"SOURCE"},o.createElement(E,{label:"Embed static texture",isSelected:function(){return e.state.isEmbedded},onSelect:function(t){e.setState({isEmbedded:t}),e.imageSourceBlock.texture=null,e.updateAfterTextureLoad()}}),this.state.isEmbedded&&o.createElement(C,{label:"Upload",onClick:function(t){return e.replaceTexture(t)},accept:".jpg, .png, .tga, .dds, .env"}),!this.state.isEmbedded&&o.createElement(he,{label:"Link",globalState:this.props.globalState,value:t,onChange:function(t){return e.replaceTextureWithUrl(t)}}),!this.state.isEmbedded&&t&&o.createElement(k,{label:"Refresh",onClick:function(){return e.replaceTextureWithUrl(t+"?nocache="+e._generateRandomForCache())}}),n&&o.createElement(k,{label:"Remove",onClick:function(){return e.removeTexture()}})),o.createElement(ve,{globalState:this.props.globalState,block:this.props.block}))},t}(o.Component),Ie=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"X",value:"x"},{label:"Y",value:"y"},{label:"Z",value:"z"},{label:"W",value:"w"}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"SWIZZLES"},o.createElement(ue,{label:"X",options:n,target:t,propertyName:"xSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"Y",options:n,target:t,propertyName:"ySwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"Z",options:n,target:t,propertyName:"zSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"W",options:n,target:t,propertyName:"wSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),Ae=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.render=function(){var e=this,t=this.props.block,n=[{label:"R",value:"r"},{label:"G",value:"g"},{label:"B",value:"b"},{label:"A",value:"a"}];return o.createElement("div",null,o.createElement(ge,{globalState:this.props.globalState,block:this.props.block}),o.createElement(m,{title:"SWIZZLES"},o.createElement(ue,{label:"R",options:n,target:t,propertyName:"rSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"G",options:n,target:t,propertyName:"gSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"B",options:n,target:t,propertyName:"bSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}}),o.createElement(ue,{label:"A",options:n,target:t,propertyName:"aSwizzle",valuesAreStrings:!0,onSelect:function(t){e.props.globalState.onUpdateRequiredObservable.notifyObservers(e.props.block),e.props.globalState.onRebuildRequiredObservable.notifyObservers(!0),e.forceUpdate()}})))},t}(o.Component),De=function(){function e(){}return e.RegisteredControls={},e}();De.RegisteredControls.TransformBlock=Ce,De.RegisteredControls.InputBlock=_e,De.RegisteredControls.GradientBlock=Te,De.RegisteredControls.LightBlock=Be,De.RegisteredControls.LightInformationBlock=Ne,De.RegisteredControls.TextureBlock=Oe,De.RegisteredControls.ReflectionTextureBlock=Oe,De.RegisteredControls.ReflectionBlock=Oe,De.RegisteredControls.RefractionBlock=Oe,De.RegisteredControls.CurrentScreenBlock=Oe,De.RegisteredControls.ParticleTextureBlock=Oe,De.RegisteredControls.TrigonometryBlock=Le,De.RegisteredControls.ConditionalBlock=Me,De.RegisteredControls.ImageSourceBlock=Re,De.RegisteredControls.VectorMergerBlock=Ie,De.RegisteredControls.ColorMergerBlock=Ae;var Fe=function(){function e(){}return e.GetBlockFromString=function(e,t,n){switch(e){case"ElbowBlock":return new l.ElbowBlock("");case"TwirlBlock":return new l.TwirlBlock("Twirl");case"VoronoiNoiseBlock":return new l.VoronoiNoiseBlock("VoronoiNoise");case"ScreenSpaceBlock":return new l.ScreenSpaceBlock("ScreenSpace");case"CloudBlock":return new l.CloudBlock("Cloud");case"MatrixBuilderBlock":return new l.MatrixBuilderBlock("MatrixBuilder");case"DesaturateBlock":return new l.DesaturateBlock("Desaturate");case"RefractBlock":return new l.RefractBlock("Refract");case"ReflectBlock":return new l.ReflectBlock("Reflect");case"DerivativeBlock":return new l.DerivativeBlock("Derivative");case"Rotate2dBlock":return new l.Rotate2dBlock("Rotate2d");case"NormalBlendBlock":return new l.NormalBlendBlock("NormalBlend");case"WorleyNoise3DBlock":return new l.WorleyNoise3DBlock("WorleyNoise3D");case"SimplexPerlin3DBlock":return new l.SimplexPerlin3DBlock("SimplexPerlin3D");case"BonesBlock":return new l.BonesBlock("Bones");case"InstancesBlock":return new l.InstancesBlock("Instances");case"MorphTargetsBlock":return new l.MorphTargetsBlock("MorphTargets");case"DiscardBlock":return new l.DiscardBlock("Discard");case"ImageProcessingBlock":return new l.ImageProcessingBlock("ImageProcessing");case"ColorMergerBlock":return new l.ColorMergerBlock("ColorMerger");case"VectorMergerBlock":return new l.VectorMergerBlock("VectorMerger");case"ColorSplitterBlock":return new l.ColorSplitterBlock("ColorSplitter");case"VectorSplitterBlock":return new l.VectorSplitterBlock("VectorSplitter");case"TextureBlock":return new l.TextureBlock("Texture",n.mode===l.NodeMaterialModes.Particle);case"ReflectionTextureBlock":return new l.ReflectionTextureBlock("Reflection texture");case"LightBlock":return new l.LightBlock("Lights");case"FogBlock":return new l.FogBlock("Fog");case"VertexOutputBlock":return new l.VertexOutputBlock("VertexOutput");case"FragmentOutputBlock":return new l.FragmentOutputBlock("FragmentOutput");case"AddBlock":return new l.AddBlock("Add");case"ClampBlock":return new l.ClampBlock("Clamp");case"ScaleBlock":return new l.ScaleBlock("Scale");case"CrossBlock":return new l.CrossBlock("Cross");case"DotBlock":return new l.DotBlock("Dot");case"PowBlock":return new l.PowBlock("Pow");case"MultiplyBlock":return new l.MultiplyBlock("Multiply");case"TransformBlock":return new l.TransformBlock("Transform");case"TrigonometryBlock":return new l.TrigonometryBlock("Trigonometry");case"RemapBlock":return new l.RemapBlock("Remap");case"NormalizeBlock":return new l.NormalizeBlock("Normalize");case"FresnelBlock":return new l.FresnelBlock("Fresnel");case"LerpBlock":return new l.LerpBlock("Lerp");case"NLerpBlock":return new l.NLerpBlock("NLerp");case"DivideBlock":return new l.DivideBlock("Divide");case"SubtractBlock":return new l.SubtractBlock("Subtract");case"ModBlock":return new l.ModBlock("Mod");case"StepBlock":return new l.StepBlock("Step");case"SmoothStepBlock":return new l.SmoothStepBlock("Smooth step");case"OneMinusBlock":return new l.OneMinusBlock("One minus");case"ReciprocalBlock":return new l.ReciprocalBlock("Reciprocal");case"ViewDirectionBlock":return new l.ViewDirectionBlock("View direction");case"LightInformationBlock":var r=new l.LightInformationBlock("Light information");return r.light=t.lights.length?t.lights[0]:null,r;case"MaxBlock":return new l.MaxBlock("Max");case"MinBlock":return new l.MinBlock("Min");case"LengthBlock":return new l.LengthBlock("Length");case"DistanceBlock":return new l.DistanceBlock("Distance");case"NegateBlock":return new l.NegateBlock("Negate");case"PerturbNormalBlock":return new l.PerturbNormalBlock("Perturb normal");case"RandomNumberBlock":return new l.RandomNumberBlock("Random number");case"ReplaceColorBlock":return new l.ReplaceColorBlock("Replace color");case"PosterizeBlock":return new l.PosterizeBlock("Posterize");case"ArcTan2Block":return new l.ArcTan2Block("ArcTan2");case"GradientBlock":return new l.GradientBlock("Gradient");case"FrontFacingBlock":return new l.FrontFacingBlock("Front facing");case"CosBlock":var o=new l.TrigonometryBlock("Cos");return o.operation=l.TrigonometryBlockOperations.Cos,o;case"SinBlock":var a=new l.TrigonometryBlock("Sin");return a.operation=l.TrigonometryBlockOperations.Sin,a;case"AbsBlock":var i=new l.TrigonometryBlock("Abs");return i.operation=l.TrigonometryBlockOperations.Abs,i;case"SqrtBlock":var s=new l.TrigonometryBlock("Sqrt");return s.operation=l.TrigonometryBlockOperations.Sqrt,s;case"ArcCosBlock":var c=new l.TrigonometryBlock("ArcCos");return c.operation=l.TrigonometryBlockOperations.ArcCos,c;case"ArcSinBlock":var u=new l.TrigonometryBlock("ArcSin");return u.operation=l.TrigonometryBlockOperations.ArcSin,u;case"TanBlock":var p=new l.TrigonometryBlock("Tan");return p.operation=l.TrigonometryBlockOperations.Tan,p;case"ArcTanBlock":var d=new l.TrigonometryBlock("ArcTan");return d.operation=l.TrigonometryBlockOperations.ArcTan,d;case"FractBlock":var h=new l.TrigonometryBlock("Fract");return h.operation=l.TrigonometryBlockOperations.Fract,h;case"SignBlock":var f=new l.TrigonometryBlock("Sign");return f.operation=l.TrigonometryBlockOperations.Sign,f;case"LogBlock":var m=new l.TrigonometryBlock("Log");return m.operation=l.TrigonometryBlockOperations.Log,m;case"ExpBlock":var g=new l.TrigonometryBlock("Exp");return g.operation=l.TrigonometryBlockOperations.Exp,g;case"Exp2Block":var v=new l.TrigonometryBlock("Exp2");return v.operation=l.TrigonometryBlockOperations.Exp2,v;case"DegreesToRadiansBlock":var b=new l.TrigonometryBlock("Degrees to radians");return b.operation=l.TrigonometryBlockOperations.Radians,b;case"RadiansToDegreesBlock":var y=new l.TrigonometryBlock("Radians to degrees");return y.operation=l.TrigonometryBlockOperations.Degrees,y;case"RoundBlock":var x=new l.TrigonometryBlock("Round");return x.operation=l.TrigonometryBlockOperations.Round,x;case"CeilingBlock":var w=new l.TrigonometryBlock("Ceiling");return w.operation=l.TrigonometryBlockOperations.Ceiling,w;case"FloorBlock":var k=new l.TrigonometryBlock("Floor");return k.operation=l.TrigonometryBlockOperations.Floor,k;case"SawToothWaveBlock":var _=new l.WaveBlock("SawTooth wave");return _.kind=l.WaveBlockKind.SawTooth,_;case"SquareWaveBlock":var C=new l.WaveBlock("Square wave");return C.kind=l.WaveBlockKind.Square,C;case"TriangleWaveBlock":var S=new l.WaveBlock("Triangle wave");return S.kind=l.WaveBlockKind.Triangle,S;case"WorldMatrixBlock":return(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World),X;case"WorldViewMatrixBlock":var E=new l.InputBlock("World x View");return E.setAsSystemValue(l.NodeMaterialSystemValues.WorldView),E;case"WorldViewProjectionMatrixBlock":var P=new l.InputBlock("World x View x Projection");return P.setAsSystemValue(l.NodeMaterialSystemValues.WorldViewProjection),P;case"ViewMatrixBlock":var T=new l.InputBlock("View");return T.setAsSystemValue(l.NodeMaterialSystemValues.View),T;case"ViewProjectionMatrixBlock":var B=new l.InputBlock("View x Projection");return B.setAsSystemValue(l.NodeMaterialSystemValues.ViewProjection),B;case"ProjectionMatrixBlock":var N=new l.InputBlock("Projection");return N.setAsSystemValue(l.NodeMaterialSystemValues.Projection),N;case"CameraPositionBlock":var O=new l.InputBlock("Camera position");return O.setAsSystemValue(l.NodeMaterialSystemValues.CameraPosition),O;case"CameraParametersBlock":var L=new l.InputBlock("Camera parameters");L.setAsSystemValue(l.NodeMaterialSystemValues.CameraParameters);var M=new l.VectorSplitterBlock("Vector splitter");return L.connectTo(M),M;case"FogColorBlock":var R=new l.InputBlock("Fog color");return R.setAsSystemValue(l.NodeMaterialSystemValues.FogColor),R;case"PositionBlock":return(I=new l.InputBlock("position")).setAsAttribute("position"),I;case"ScreenPositionBlock":var I;return(I=new l.InputBlock("position")).setAsAttribute("position2d"),I;case"UVBlock":var A=new l.InputBlock("uv");return A.setAsAttribute("uv"),A;case"ColorBlock":var D=new l.InputBlock("color");return D.setAsAttribute("color"),D;case"NormalBlock":var F=new l.InputBlock("normal");return F.setAsAttribute("normal"),F;case"TangentBlock":var z=new l.InputBlock("tangent");return z.setAsAttribute("tangent"),z;case"MatrixIndicesBlock":var j=new l.InputBlock("matricesIndices");return j.setAsAttribute("matricesIndices"),j;case"MatrixWeightsBlock":var U=new l.InputBlock("matricesWeights");return U.setAsAttribute("matricesWeights"),U;case"TimeBlock":var V=new l.InputBlock("Time",void 0,l.NodeMaterialBlockConnectionPointTypes.Float);return V.animationType=l.AnimatedInputBlockTypes.Time,V;case"DeltaTimeBlock":return(W=new l.InputBlock("Delta time")).setAsSystemValue(l.NodeMaterialSystemValues.DeltaTime),W;case"MaterialAlphaBlock":var W;return(W=new l.InputBlock("Material alpha")).setAsSystemValue(l.NodeMaterialSystemValues.MaterialAlpha),W;case"WorldPositionBlock":var H=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"position"===e.name}));H||(H=new l.InputBlock("position")).setAsAttribute("position"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);var q=new l.TransformBlock("World position");return H.connectTo(q),X.connectTo(q),q;case"WorldNormalBlock":var Y=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"normal"===e.name}));Y||(Y=new l.InputBlock("normal")).setAsAttribute("normal"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);q=new l.TransformBlock("World normal");return Y.connectTo(q),X.connectTo(q),q;case"WorldTangentBlock":var X,G=n.getInputBlockByPredicate((function(e){return e.isAttribute&&"tangent"===e.name}));G||(G=new l.InputBlock("tangent")).setAsAttribute("tangent"),(X=n.getInputBlockByPredicate((function(e){return e.isSystemValue&&e.systemValue===l.NodeMaterialSystemValues.World})))||(X=new l.InputBlock("World")).setAsSystemValue(l.NodeMaterialSystemValues.World);q=new l.TransformBlock("World tangent");return G.connectTo(q),X.connectTo(q),q;case"PBRMetallicRoughnessBlock":return new l.PBRMetallicRoughnessBlock("PBRMetallicRoughness");case"SheenBlock":return new l.SheenBlock("Sheen");case"AnisotropyBlock":return new l.AnisotropyBlock("Anisotropy");case"ReflectionBlock":return new l.ReflectionBlock("Reflection");case"ClearCoatBlock":return new l.ClearCoatBlock("ClearCoat");case"RefractionBlock":return new l.RefractionBlock("Refraction");case"SubSurfaceBlock":return new l.SubSurfaceBlock("SubSurface");case"CurrentScreenBlock":return new l.CurrentScreenBlock("CurrentScreen");case"ParticleUVBlock":var Z=new l.InputBlock("uv");return Z.setAsAttribute("particle_uv"),Z;case"ParticleTextureBlock":return new l.ParticleTextureBlock("ParticleTexture");case"ParticleColorBlock":var Q=new l.InputBlock("Color");return Q.setAsAttribute("particle_color"),Q;case"ParticleTextureMaskBlock":var K=new l.InputBlock("TextureMask");return K.setAsAttribute("particle_texturemask"),K;case"ParticlePositionWorldBlock":var $=new l.InputBlock("PositionWorld");return $.setAsAttribute("particle_positionw"),$;case"ParticleRampGradientBlock":return new l.ParticleRampGradientBlock("ParticleRampGradient");case"ParticleBlendMultiplyBlock":return new l.ParticleBlendMultiplyBlock("ParticleBlendMultiply");case"FragCoordBlock":return new l.FragCoordBlock("FragCoord");case"ScreenSizeBlock":return new l.ScreenSizeBlock("ScreenSize");case"SceneDepthBlock":return new l.SceneDepthBlock("SceneDepth");case"EqualBlock":var J=new l.ConditionalBlock("Equal");return J.condition=l.ConditionalBlockConditions.Equal,J;case"NotEqualBlock":var ee=new l.ConditionalBlock("NotEqual");return ee.condition=l.ConditionalBlockConditions.NotEqual,ee;case"LessThanBlock":var te=new l.ConditionalBlock("LessThan");return te.condition=l.ConditionalBlockConditions.LessThan,te;case"LessOrEqualBlock":var ne=new l.ConditionalBlock("LessOrEqual");return ne.condition=l.ConditionalBlockConditions.LessOrEqual,ne;case"GreaterThanBlock":var re=new l.ConditionalBlock("GreaterThan");return re.condition=l.ConditionalBlockConditions.GreaterThan,re;case"GreaterOrEqualBlock":var oe=new l.ConditionalBlock("GreaterOrEqual");return oe.condition=l.ConditionalBlockConditions.GreaterOrEqual,oe;case"XorBlock":var ae=new l.ConditionalBlock("Xor");return ae.condition=l.ConditionalBlockConditions.Xor,ae;case"OrBlock":var ie=new l.ConditionalBlock("Or");return ie.condition=l.ConditionalBlockConditions.Or,ie;case"AndBlock":var le=new l.ConditionalBlock("And");return le.condition=l.ConditionalBlockConditions.And,le;case"ImageSourceBlock":return new l.ImageSourceBlock("ImageSource");case"ClipPlanesBlock":return new l.ClipPlanesBlock("ClipPlanes")}return null},e.GetColorFromConnectionNodeType=function(e){var t="#880000";switch(e){case l.NodeMaterialBlockConnectionPointTypes.Float:t="#cb9e27";break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:t="#16bcb1";break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:case l.NodeMaterialBlockConnectionPointTypes.Color3:t="#b786cb";break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:case l.NodeMaterialBlockConnectionPointTypes.Color4:t="#be5126";break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:t="#591990";break;case l.NodeMaterialBlockConnectionPointTypes.Object:t="#6174FA"}return t},e.GetConnectionNodeTypeFromString=function(e){switch(e){case"Float":return l.NodeMaterialBlockConnectionPointTypes.Float;case"Vector2":return l.NodeMaterialBlockConnectionPointTypes.Vector2;case"Vector3":return l.NodeMaterialBlockConnectionPointTypes.Vector3;case"Vector4":return l.NodeMaterialBlockConnectionPointTypes.Vector4;case"Matrix":return l.NodeMaterialBlockConnectionPointTypes.Matrix;case"Color3":return l.NodeMaterialBlockConnectionPointTypes.Color3;case"Color4":return l.NodeMaterialBlockConnectionPointTypes.Color4}return l.NodeMaterialBlockConnectionPointTypes.AutoDetect},e.GetStringFromConnectionNodeType=function(e){switch(e){case l.NodeMaterialBlockConnectionPointTypes.Float:return"Float";case l.NodeMaterialBlockConnectionPointTypes.Vector2:return"Vector2";case l.NodeMaterialBlockConnectionPointTypes.Vector3:return"Vector3";case l.NodeMaterialBlockConnectionPointTypes.Vector4:return"Vector4";case l.NodeMaterialBlockConnectionPointTypes.Color3:return"Color3";case l.NodeMaterialBlockConnectionPointTypes.Color4:return"Color4";case l.NodeMaterialBlockConnectionPointTypes.Matrix:return"Matrix"}return""},e}(),ze={position2d:"position",particle_uv:"uv",particle_color:"color",particle_texturemask:"textureMask",particle_positionw:"positionW"},je={position2d:"screen",particle_uv:"particle",particle_color:"particle",particle_texturemask:"particle",particle_positionw:"particle"},Ue=function(){function e(){}return e.prototype.getHeaderClass=function(e){var t=e;return t.isConstant?"constant":t.visibleInInspector?"inspector":""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(t){var n=t,r="".concat(n.name," (").concat(e.GetBaseType(n.output.type),")");return n.isAttribute&&(r=e.GetBaseType(n.output.type)),r},e.GetBaseType=function(e){return l.NodeMaterialBlockConnectionPointTypes[e]},e.prototype.getBackgroundColor=function(e){var t="",n=e;switch(n.type){case l.NodeMaterialBlockConnectionPointTypes.Color3:case l.NodeMaterialBlockConnectionPointTypes.Color4:if(n.value){t=n.value.toHexString();break}default:t=Fe.GetColorFromConnectionNodeType(n.type)}return t},e.prototype.updatePreviewContent=function(e,t){var n,r,o="",a=e;if(a.isAttribute){var i=null!==(n=ze[a.name])&&void 0!==n?n:a.name;o=(null!==(r=je[a.name])&&void 0!==r?r:"mesh")+"."+i}else if(a.isSystemValue)switch(a.systemValue){case l.NodeMaterialSystemValues.World:o="World";break;case l.NodeMaterialSystemValues.WorldView:o="World x View";break;case l.NodeMaterialSystemValues.WorldViewProjection:o="World x View x Projection";break;case l.NodeMaterialSystemValues.View:o="View";break;case l.NodeMaterialSystemValues.ViewProjection:o="View x Projection";break;case l.NodeMaterialSystemValues.Projection:o="Projection";break;case l.NodeMaterialSystemValues.CameraPosition:o="Camera position";break;case l.NodeMaterialSystemValues.FogColor:o="Fog color";break;case l.NodeMaterialSystemValues.DeltaTime:o="Delta time";break;case l.NodeMaterialSystemValues.CameraParameters:o="Camera parameters";break;case l.NodeMaterialSystemValues.MaterialAlpha:o="Material alpha"}else switch(a.type){case l.NodeMaterialBlockConnectionPointTypes.Float:o=a.animationType!==l.AnimatedInputBlockTypes.None?l.AnimatedInputBlockTypes[a.animationType]:a.value.toFixed(4);break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:var s=a.value;o="(".concat(s.x.toFixed(2),", ").concat(s.y.toFixed(2),")");break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:var c=a.value;o="(".concat(c.x.toFixed(2),", ").concat(c.y.toFixed(2),", ").concat(c.z.toFixed(2),")");break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:var u=a.value;o="(".concat(u.x.toFixed(2),", ").concat(u.y.toFixed(2),", ").concat(u.z.toFixed(2),", ").concat(u.w.toFixed(2),")")}t.innerHTML=o,t.classList.add("input-block")},e}(),Ve=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"rgb(106, 44, 131)"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("output-block")},e}(),We=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#4086BB"},e.prototype.updatePreviewContent=function(e,t){var n=e;t.classList.add("clamp-block"),t.innerHTML="[".concat(n.minimum,", ").concat(n.maximum,"]")},e}(),He=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){var t=e.colorSteps.map((function(e){return"rgb(".concat(255*e.color.r,", ").concat(255*e.color.g,", ").concat(255*e.color.b,") ").concat(100*e.step,"%")}));return t.length?"linear-gradient(90deg, ".concat(t.join(", "),")"):"black"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("gradient-block")},e}(),qe=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#4086BB"},e.prototype._extractInputValue=function(e){var t=e.connectedPoint.ownerBlock;if(t.isInput){var n=t;if(n.isUniform&&!n.isSystemValue)return n.value}return"?"},e.prototype.updatePreviewContent=function(e,t){var n=e,r=n.sourceMin.isConnected?this._extractInputValue(n.sourceMin):n.sourceRange.x,o=n.sourceMax.isConnected?this._extractInputValue(n.sourceMax):n.sourceRange.y,a=n.targetMin.isConnected?this._extractInputValue(n.targetMin):n.targetRange.x,i=n.targetMax.isConnected?this._extractInputValue(n.targetMax):n.targetRange.y;t.classList.add("remap-block"),t.innerHTML="[".concat(r,", ").concat(o,"] -> [").concat(a,", ").concat(i,"]")},e}(),Ye=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#405C86"},e.prototype.updatePreviewContent=function(e,t){var n=e;t.classList.add("trigonometry-block"),t.innerHTML=l.TrigonometryBlockOperations[n.operation]},e}(),Xe=function(e){function t(t){var n=e.call(this,t)||this;return n.state={displayRed:!0,displayGreen:!0,displayBlue:!0,displayAlpha:!0,face:0},n.canvasRef=o.createRef(),n}return u(t,e),t.prototype.shouldComponentUpdate=function(e,t){return!0},t.prototype.componentDidMount=function(){this.updatePreview()},t.prototype.componentDidUpdate=function(){this.updatePreview()},t.prototype.updatePreview=function(){t.UpdatePreview(this.canvasRef.current,this.props.texture,this.props.width,this.state,void 0,this.props.globalState)},t.UpdatePreview=function(e,n,r,o,a,i){return d(this,void 0,void 0,(function(){var s,c,u,p,d,f,m,g,v,b,y,x,w,k,_,C,S,E,P,T,B;return h(this,(function(h){switch(h.label){case 0:return!n.isReady()&&n._texture&&n._texture.onLoadedObservable.addOnce((function(){t.UpdatePreview(e,n,r,o,a,i)})),s=n.getScene(),c=s.getEngine(),u=n.getSize(),p=u.width/u.height,d=r/p|1,n.isCube?((m=new l.PassCubePostProcess("pass",1,null,l.Texture.NEAREST_SAMPLINGMODE,c,!1,l.Constants.TEXTURETYPE_UNSIGNED_INT)).face=o.face,f=m):f=new l.PassPostProcess("pass",1,null,l.Texture.NEAREST_SAMPLINGMODE,c,!1,l.Constants.TEXTURETYPE_UNSIGNED_INT),f.getEffect().isReady()?(i&&(i.blockMutationUpdates=!0),g=new l.RenderTargetTexture("temp",{width:r,height:d},s,!1),f.externalTextureSamplerBinding=!0,f.onApply=function(e){e.setTexture("textureSampler",n)},(v=g.renderTarget)?(s.postProcessManager.directRender([f],v,!0),b=4*r,y=d/2,[4,c.readPixels(0,0,r,d)]):[3,2]):(f.dispose(),setTimeout((function(){return t.UpdatePreview(e,n,r,o,a,i)}),250),[2]);case 1:if(x=h.sent(),w=new Uint8Array(x.buffer,0,x.byteLength),!(n.isCube||o.displayRed&&o.displayGreen&&o.displayBlue))for(_=0;_<r*d*4;_+=4)o.displayRed||(w[_]=0),o.displayGreen||(w[_+1]=0),o.displayBlue||(w[_+2]=0),o.displayAlpha&&(k=w[_+2],w[_]=k,w[_+1]=k,w[_+2]=k,w[_+2]=0);if(n.invertY||n.isCube)for(_=0;_<y;_++)for(C=0;C<b;C++)E=C+(d-_-1)*b,P=w[S=C+_*b],w[S]=w[E],w[E]=P;e.width=r,e.height=d,(T=e.getContext("2d"))&&(B=T.createImageData(r,d),B.data.set(w),T.putImageData(B,0,0),a&&a()),c.unBindFramebuffer(v),h.label=2;case 2:return g.dispose(),f.dispose(),e.style.height=d+"px",i&&(i.blockMutationUpdates=!1),[2]}}))}))},t.prototype.render=function(){var e=this,t=this.props.texture;return o.createElement("div",{className:"textureLine"},!this.props.hideChannelSelect&&t.isCube&&o.createElement("div",{className:"control3D"},o.createElement("button",{className:0===this.state.face?"px command selected":"px command",onClick:function(){return e.setState({face:0})}},"PX"),o.createElement("button",{className:1===this.state.face?"nx command selected":"nx command",onClick:function(){return e.setState({face:1})}},"NX"),o.createElement("button",{className:2===this.state.face?"py command selected":"py command",onClick:function(){return e.setState({face:2})}},"PY"),o.createElement("button",{className:3===this.state.face?"ny command selected":"ny command",onClick:function(){return e.setState({face:3})}},"NY"),o.createElement("button",{className:4===this.state.face?"pz command selected":"pz command",onClick:function(){return e.setState({face:4})}},"PZ"),o.createElement("button",{className:5===this.state.face?"nz command selected":"nz command",onClick:function(){return e.setState({face:5})}},"NZ")),!this.props.hideChannelSelect&&!t.isCube&&o.createElement("div",{className:"control"},o.createElement("button",{className:this.state.displayRed&&!this.state.displayGreen?"red command selected":"red command",onClick:function(){return e.setState({displayRed:!0,displayGreen:!1,displayBlue:!1,displayAlpha:!1})}},"R"),o.createElement("button",{className:this.state.displayGreen&&!this.state.displayBlue?"green command selected":"green command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!0,displayBlue:!1,displayAlpha:!1})}},"G"),o.createElement("button",{className:this.state.displayBlue&&!this.state.displayAlpha?"blue command selected":"blue command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!1,displayBlue:!0,displayAlpha:!1})}},"B"),o.createElement("button",{className:this.state.displayAlpha&&!this.state.displayRed?"alpha command selected":"alpha command",onClick:function(){return e.setState({displayRed:!1,displayGreen:!1,displayBlue:!1,displayAlpha:!0})}},"A"),o.createElement("button",{className:this.state.displayRed&&this.state.displayGreen?"all command selected":"all command",onClick:function(){return e.setState({displayRed:!0,displayGreen:!0,displayBlue:!0,displayAlpha:!0})}},"ALL")),o.createElement("canvas",{ref:this.canvasRef,className:"preview"}))},t}(o.Component),Ge=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"RefractionBlock"===e.getClassName()||"ReflectionBlock"===e.getClassName()?"#6174FA":"#323232"},e.prototype.updatePreviewContent=function(e,t){var n=this,r=e;this._previewCanvas||(t.classList.add("texture-block"),e instanceof l.TextureBlock&&t.classList.add("regular-texture-block"),e instanceof l.ReflectionBlock&&t.classList.add("reflection-block"),(e instanceof l.CurrentScreenBlock||e instanceof l.ParticleTextureBlock)&&t.classList.add("reduced-texture-block"),this._previewCanvas=t.ownerDocument.createElement("canvas"),this._previewImage=t.ownerDocument.createElement("img"),t.appendChild(this._previewImage),this._previewImage.classList.add("empty")),r.texture?Xe.UpdatePreview(this._previewCanvas,r.texture,140,{face:0,displayRed:!0,displayAlpha:!0,displayBlue:!0,displayGreen:!0},(function(){n._previewImage.src=n._previewCanvas.toDataURL("image/png"),n._previewImage.classList.remove("empty")})):this._previewImage.classList.add("empty")},e}(),Ze=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#540b0b"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("discard-block")},e}(),Qe=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#6174FA"},e.prototype.updatePreviewContent=function(e,t){t.classList.add("pbr-block")},e}(),Ke=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){var t="";switch(e.condition){case l.ConditionalBlockConditions.Equal:t="=";break;case l.ConditionalBlockConditions.NotEqual:t="!=";break;case l.ConditionalBlockConditions.LessThan:t="<";break;case l.ConditionalBlockConditions.LessOrEqual:t="<=";break;case l.ConditionalBlockConditions.GreaterThan:t=">";break;case l.ConditionalBlockConditions.GreaterOrEqual:t=">=";break;case l.ConditionalBlockConditions.Xor:t="xor";break;case l.ConditionalBlockConditions.Or:t="|";break;case l.ConditionalBlockConditions.And:t="&"}return e.name+" ("+t+")"},e.prototype.getBackgroundColor=function(e){return"#00A080"},e.prototype.updatePreviewContent=function(e,t){},e}(),$e=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!0},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){return"#323232"},e.prototype.updatePreviewContent=function(e,t){var n=this,r=e;this._previewCanvas||(t.classList.add("texture-block"),t.classList.add("image-source-block"),this._previewCanvas=t.ownerDocument.createElement("canvas"),this._previewImage=t.ownerDocument.createElement("img"),t.appendChild(this._previewImage),this._previewImage.classList.add("empty")),r.texture?Xe.UpdatePreview(this._previewCanvas,r.texture,140,{face:0,displayRed:!0,displayAlpha:!0,displayBlue:!0,displayGreen:!0},(function(){n._previewImage.src=n._previewCanvas.toDataURL("image/png"),n._previewImage.classList.remove("empty")})):this._previewImage.classList.add("empty")},e}(),Je=function(){function e(){}return e.prototype.getHeaderClass=function(e){return""},e.prototype.shouldDisplayPortLabels=function(e){return!1},e.prototype.getHeaderText=function(e){return e.name},e.prototype.getBackgroundColor=function(e){var t=e;return Fe.GetColorFromConnectionNodeType(t.input.type)},e.prototype.updatePreviewContent=function(e,t){t.parentElement.classList.add("elbow-block")},e}(),et=function(){function e(){}return e.RegisteredControls={},e}();et.RegisteredControls.InputBlock=Ue,et.RegisteredControls.VertexOutputBlock=Ve,et.RegisteredControls.FragmentOutputBlock=Ve,et.RegisteredControls.ClampBlock=We,et.RegisteredControls.GradientBlock=He,et.RegisteredControls.RemapBlock=qe,et.RegisteredControls.TrigonometryBlock=Ye,et.RegisteredControls.ConditionalBlock=Ke,et.RegisteredControls.TextureBlock=Ge,et.RegisteredControls.ReflectionTextureBlock=Ge,et.RegisteredControls.ReflectionBlock=Ge,et.RegisteredControls.RefractionBlock=Ge,et.RegisteredControls.CurrentScreenBlock=Ge,et.RegisteredControls.ParticleTextureBlock=Ge,et.RegisteredControls.DiscardBlock=Ze,et.RegisteredControls.PBRMetallicRoughnessBlock=Qe,et.RegisteredControls.AnisotropyBlock=Qe,et.RegisteredControls.ClearCoatBlock=Qe,et.RegisteredControls.SheenBlock=Qe,et.RegisteredControls.SubSurfaceBlock=Qe,et.RegisteredControls.ImageSourceBlock=$e,et.RegisteredControls.ElbowBlock=Je;var tt=function(){function e(e,t,n,r){var o=this;this.connectionPoint=t,this.node=n,this.delegatedPort=null,this._element=e.ownerDocument.createElement("div"),this._element.classList.add("port"),e.appendChild(this._element),this._globalState=r,this._img=e.ownerDocument.createElement("img"),this._element.appendChild(this._img),"port-label"===e.children[0].className&&(this._portLabelElement=e.children[0]),this._element.port=this,this._element.ondragstart=function(){return!1},this._onCandidateLinkMovedObserver=r.onCandidateLinkMoved.add((function(e){var t=o._element.getBoundingClientRect();!e||t.left>e.x||t.right<e.x||t.top>e.y||t.bottom<e.y?o._element.classList.remove("selected"):(o._element.classList.add("selected"),o._globalState.onCandidatePortSelectedObservable.notifyObservers(o))})),this._onSelectionChangedObserver=this._globalState.onSelectionChangedObservable.add((function(e){e===o?o._img.classList.add("selected"):o._img.classList.remove("selected")})),this.refresh()}return Object.defineProperty(e.prototype,"element",{get:function(){return this.delegatedPort?this.delegatedPort.element:this._element},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portName",{get:function(){var e=this.connectionPoint.displayName||this.connectionPoint.name;return this.connectionPoint.ownerBlock.isInput&&(e=this.node.name),e},set:function(e){this._portLabelElement&&(this.connectionPoint.displayName=e,this._portLabelElement.innerHTML=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"disabled",{get:function(){if(!this.connectionPoint.isConnected)return!1;if(this._isConnectedToNodeOutsideOfFrame())return!0;var e=this.node.getLinksForConnectionPoint(this.connectionPoint);return!(!e.length||e[0].nodeB!==this.node)},enumerable:!1,configurable:!0}),e.prototype.hasLabel=function(){return!!this._portLabelElement},Object.defineProperty(e.prototype,"exposedOnFrame",{get:function(){return!(!this.connectionPoint.isExposedOnFrame&&!this._isConnectedToNodeOutsideOfFrame())},set:function(e){this.disabled||(this.connectionPoint.isExposedOnFrame=e)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"exposedPortPosition",{get:function(){return this.connectionPoint.exposedPortPosition},set:function(e){this.connectionPoint.exposedPortPosition=e},enumerable:!1,configurable:!0}),e.prototype._isConnectedToNodeOutsideOfFrame=function(){var e=this.node.getLinksForConnectionPoint(this.connectionPoint);if(e.length)for(var t=0;t<e.length;t++)if(e[t].nodeA.enclosingFrameId!==e[t].nodeB.enclosingFrameId)return!0;return!1},e.prototype.refresh=function(){switch(this._element.style.background=Fe.GetColorFromConnectionNodeType(this.connectionPoint.type),this.connectionPoint.type){case l.NodeMaterialBlockConnectionPointTypes.Float:case l.NodeMaterialBlockConnectionPointTypes.Int:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IxPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48Y2lyY2xlIGNsYXNzPSJjbHMtMSIgY3g9IjEwLjUiIGN5PSIxMC41IiByPSI3LjUiLz48L2c+PC9zdmc+";break;case l.NodeMaterialBlockConnectionPointTypes.Vector2:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IyPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0zLDEwLjVhNy41Miw3LjUyLDAsMCwwLDYuNSw3LjQzVjMuMDdBNy41Miw3LjUyLDAsMCwwLDMsMTAuNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMS41LDMuMDdWMTcuOTNhNy41LDcuNSwwLDAsMCwwLTE0Ljg2WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Vector3:case l.NodeMaterialBlockConnectionPointTypes.Color3:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3IzPC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0zLjU3LDEzLjMxLDkuNSw5Ljg5VjNBNy41MSw3LjUxLDAsMCwwLDMsMTAuNDYsNy4zMiw3LjMyLDAsMCwwLDMuNTcsMTMuMzFaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNMTYuNDMsMTUsMTAuNSwxMS42Miw0LjU3LDE1YTcuNDgsNy40OCwwLDAsMCwxMS44NiwwWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTE4LDEwLjQ2QTcuNTEsNy41MSwwLDAsMCwxMS41LDNWOS44OWw1LjkzLDMuNDJBNy4zMiw3LjMyLDAsMCwwLDE4LDEwLjQ2WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Vector4:case l.NodeMaterialBlockConnectionPointTypes.Color4:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5WZWN0b3I0PC90aXRsZT48ZyBpZD0iTGF5ZXJfNSIgZGF0YS1uYW1lPSJMYXllciA1Ij48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik0xMS41LDExLjV2Ni40M2E3LjUxLDcuNTEsMCwwLDAsNi40My02LjQzWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMy4wN1Y5LjVoNi40M0E3LjUxLDcuNTEsMCwwLDAsMTEuNSwzLjA3WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTkuNSwxNy45M1YxMS41SDMuMDdBNy41MSw3LjUxLDAsMCwwLDkuNSwxNy45M1oiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05LjUsMy4wN0E3LjUxLDcuNTEsMCwwLDAsMy4wNyw5LjVIOS41WiIvPjwvZz48L3N2Zz4=";break;case l.NodeMaterialBlockConnectionPointTypes.Matrix:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAyMSAyMSI+PGRlZnM+PHN0eWxlPi5jbHMtMXtmaWxsOiNmZmY7fTwvc3R5bGU+PC9kZWZzPjx0aXRsZT5NYXRyaXg8L3RpdGxlPjxnIGlkPSJMYXllcl81IiBkYXRhLW5hbWU9IkxheWVyIDUiPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsNi4xMVY5LjVoMy4zOUE0LjUxLDQuNTEsMCwwLDAsMTEuNSw2LjExWiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMTQuODlhNC41MSw0LjUxLDAsMCwwLDMuMzktMy4zOUgxMS41WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTExLjUsMy4wN3YyQTUuNTQsNS41NCwwLDAsMSwxNS45Miw5LjVoMkE3LjUxLDcuNTEsMCwwLDAsMTEuNSwzLjA3WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTE1LjkyLDExLjVhNS41NCw1LjU0LDAsMCwxLTQuNDIsNC40MnYyYTcuNTEsNy41MSwwLDAsMCw2LjQzLTYuNDNaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNNS4wOCwxMS41aC0yQTcuNTEsNy41MSwwLDAsMCw5LjUsMTcuOTN2LTJBNS41NCw1LjU0LDAsMCwxLDUuMDgsMTEuNVoiLz48cGF0aCBjbGFzcz0iY2xzLTEiIGQ9Ik05LjUsMy4wN0E3LjUxLDcuNTEsMCwwLDAsMy4wNyw5LjVoMkE1LjU0LDUuNTQsMCwwLDEsOS41LDUuMDhaIi8+PHBhdGggY2xhc3M9ImNscy0xIiBkPSJNOS41LDExLjVINi4xMUE0LjUxLDQuNTEsMCwwLDAsOS41LDE0Ljg5WiIvPjxwYXRoIGNsYXNzPSJjbHMtMSIgZD0iTTkuNSw2LjExQTQuNTEsNC41MSwwLDAsMCw2LjExLDkuNUg5LjVaIi8+PC9nPjwvc3ZnPg==";break;case l.NodeMaterialBlockConnectionPointTypes.Object:this._img.src="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyMSIgaGVpZ2h0PSIyMSIgdmlld0JveD0iMCAwIDIxIDIxIj48Y2lyY2xlIGN4PSI3LjEiIGN5PSIxMy4wOCIgcj0iMy4yNSIgc3R5bGU9ImZpbGw6I2ZmZiIvPjxwYXRoIGQ9Ik0xMC40OSwzQTcuNTIsNy41MiwwLDAsMCwzLDEwYTUuMTMsNS4xMywwLDEsMSw2LDcuODUsNy42MSw3LjYxLDAsMCwwLDEuNTIuMTYsNy41Miw3LjUyLDAsMCwwLDAtMTVaIiBzdHlsZT0iZmlsbDojZmZmIi8+PC9zdmc+",this._img.style.width="100%",this._img.style.height="100%"}},e.prototype.dispose=function(){this._globalState.onCandidateLinkMoved.remove(this._onCandidateLinkMovedObserver),this._onSelectionChangedObserver&&this._globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},e.CreatePortElement=function(t,n,r,o,a){var i=r.ownerDocument.createElement("div"),l=t.ownerBlock;if(i.classList.add("portLine"),r.appendChild(i),!o||o.shouldDisplayPortLabels(l)){var s=r.ownerDocument.createElement("div");s.classList.add("port-label"),s.innerHTML=t.displayName||t.name,i.appendChild(s)}return new e(i,t,n,a)},e}(),nt=n(146),rt=function(){function e(e,t){var n=this;this.block=e,this._inputPorts=[],this._outputPorts=[],this._links=[],this._x=0,this._y=0,this._gridAlignedX=0,this._gridAlignedY=0,this._mouseStartPointX=null,this._mouseStartPointY=null,this._displayManager=null,this._isVisible=!0,this._enclosingFrameId=-1,this._globalState=t,this._onSelectionChangedObserver=this._globalState.onSelectionChangedObservable.add((function(e){e===n?n._visual.classList.add("selected"):setTimeout((function(){-1===n._ownerCanvas.selectedNodes.indexOf(n)&&n._visual.classList.remove("selected")}))})),this._onUpdateRequiredObserver=this._globalState.onUpdateRequiredObservable.add((function(e){e===n.block&&n.refresh()})),this._onSelectionBoxMovedObserver=this._globalState.onSelectionBoxMoved.add((function(e){var t=n._visual.getBoundingClientRect(),r=!(e.right<t.left||e.left>t.right||e.bottom<t.top||e.top>t.bottom);n.isSelected=r})),this._onFrameCreatedObserver=this._globalState.onFrameCreatedObservable.add((function(e){n._ownerCanvas.frames.some((function(e){return-1!==e.nodes.indexOf(n)}))||n.isOverlappingFrame(e)&&e.nodes.push(n)}))}return Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible=e,e?(this._visual.classList.remove("hidden"),this._upateNodePortNames()):this._visual.classList.add("hidden");for(var t=0,n=this._links;t<n.length;t++){n[t].isVisible=e}this._refreshLinks()},enumerable:!1,configurable:!0}),e.prototype._upateNodePortNames=function(){for(var e=0,t=this._inputPorts.concat(this._outputPorts);e<t.length;e++){var n=t[e];n.hasLabel()&&(n.portName=n.connectionPoint.displayName||n.connectionPoint.name)}},Object.defineProperty(e.prototype,"outputPorts",{get:function(){return this._outputPorts},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"inputPorts",{get:function(){return this._inputPorts},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"links",{get:function(){return this._links},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gridAlignedX",{get:function(){return this._gridAlignedX},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"gridAlignedY",{get:function(){return this._gridAlignedY},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this._gridAlignedX=this._ownerCanvas.getGridPosition(e),this._visual.style.left="".concat(this._gridAlignedX,"px"),this._refreshLinks(),this._refreshFrames())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this._gridAlignedY=this._ownerCanvas.getGridPosition(e),this._visual.style.top="".concat(this._gridAlignedY,"px"),this._refreshLinks(),this._refreshFrames())},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._visual.clientWidth},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._visual.clientHeight},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"id",{get:function(){return this.block.uniqueId},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this.block.name},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isSelected",{get:function(){return this._isSelected},set:function(e){if(this._isSelected!==e)if(this._isSelected=e,e)this._globalState.onSelectionChangedObservable.notifyObservers(this);else{this._visual.classList.remove("selected");var t=this._ownerCanvas.selectedNodes.indexOf(this);t>-1&&this._ownerCanvas.selectedNodes.splice(t,1)}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"enclosingFrameId",{get:function(){return this._enclosingFrameId},set:function(e){this._enclosingFrameId=e},enumerable:!1,configurable:!0}),e.prototype.isOverlappingFrame=function(e){var t=this._visual.getBoundingClientRect(),n=e.element.getBoundingClientRect();n.width-=5,n.height-=5;var r=!(n.right<t.left||n.left>t.right||n.bottom<t.top||n.top>t.bottom);return r&&(this.enclosingFrameId=e.id),r},e.prototype.getPortForConnectionPoint=function(e){for(var t=0,n=this._inputPorts;t<n.length;t++){if((a=n[t]).connectionPoint===e)return a}for(var r=0,o=this._outputPorts;r<o.length;r++){var a;if((a=o[r]).connectionPoint===e)return a}return null},e.prototype.getLinksForConnectionPoint=function(e){return this._links.filter((function(t){return t.portA.connectionPoint===e||t.portB.connectionPoint===e}))},e.prototype._refreshFrames=function(){if(!this._ownerCanvas._frameIsMoving&&!this._ownerCanvas._isLoading)for(var e=0,t=this._ownerCanvas.frames;e<t.length;e++){t[e].syncNode(this)}},e.prototype._refreshLinks=function(){if(!this._ownerCanvas._isLoading)for(var e=0,t=this._links;e<t.length;e++){t[e].update()}},e.prototype.refresh=function(){var e=this;if(this._displayManager){this._header.innerHTML=this._displayManager.getHeaderText(this.block),this._displayManager.updatePreviewContent(this.block,this._content),this._visual.style.background=this._displayManager.getBackgroundColor(this.block);var t=this._displayManager.getHeaderClass(this.block);this._header.classList.value="header",this._headerContainer.classList.value="header-container",t&&this._headerContainer.classList.add(t)}else this._header.innerHTML=this.block.name;for(var n=0,r=this._inputPorts;n<r.length;n++){r[n].refresh()}for(var o=0,a=this._outputPorts;o<a.length;o++){a[o].refresh()}if(-1!==this.enclosingFrameId){var i=this._ownerCanvas.frames.findIndex((function(t){return t.id===e.enclosingFrameId}));i>=0&&this._ownerCanvas.frames[i].isCollapsed&&this._ownerCanvas.frames[i].redrawFramePorts()}this._comments.innerHTML=this.block.comments||"",this._comments.title=this.block.comments||"","ElbowBlock"!==this.block.getClassName()&&this.block.willBeGeneratedIntoVertexShaderFromFragmentShader?this._promotionWarning.classList.add("visible"):this._promotionWarning.classList.remove("visible")},e.prototype._onDown=function(e){if(!e.srcElement||"IMG"!==e.srcElement.nodeName){-1===this._ownerCanvas.selectedNodes.indexOf(this)?this._globalState.onSelectionChangedObservable.notifyObservers(this):e.ctrlKey&&(this.isSelected=!1),e.stopPropagation();for(var t=0,n=this._ownerCanvas.selectedNodes;t<n.length;t++){n[t].cleanAccumulation()}this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,this._visual.setPointerCapture(e.pointerId)}},e.prototype.cleanAccumulation=function(e){void 0===e&&(e=!1),this.x=this._ownerCanvas.getGridPosition(this.x,e),this.y=this._ownerCanvas.getGridPosition(this.y,e)},e.prototype._onUp=function(e){e.stopPropagation();for(var t=0,n=this._ownerCanvas.selectedNodes;t<n.length;t++){n[t].cleanAccumulation()}this._mouseStartPointX=null,this._mouseStartPointY=null,this._visual.releasePointerCapture(e.pointerId)},e.prototype._onMove=function(e){if(null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&!e.ctrlKey){for(var t=(e.clientX-this._mouseStartPointX)/this._ownerCanvas.zoom,n=(e.clientY-this._mouseStartPointY)/this._ownerCanvas.zoom,r=0,o=this._ownerCanvas.selectedNodes;r<o.length;r++){var a=o[r];a.x+=t,a.y+=n}this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,e.stopPropagation()}},e.prototype.renderProperties=function(){var e=De.RegisteredControls[this.block.getClassName()];return e||(e=me),o.createElement(e,{globalState:this._globalState,block:this.block})},e.prototype.appendVisual=function(e,t){var n=this;this._ownerCanvas=t;var r=et.RegisteredControls[this.block.getClassName()];r&&(this._displayManager=new r),this._visual=e.ownerDocument.createElement("div"),this._visual.classList.add("visual"),this._visual.addEventListener("pointerdown",(function(e){return n._onDown(e)})),this._visual.addEventListener("pointerup",(function(e){return n._onUp(e)})),this._visual.addEventListener("pointermove",(function(e){return n._onMove(e)})),this._headerContainer=e.ownerDocument.createElement("div"),this._headerContainer.classList.add("header-container"),this._visual.appendChild(this._headerContainer),this._header=e.ownerDocument.createElement("div"),this._header.classList.add("header"),this._headerContainer.appendChild(this._header),this._promotionWarning=e.ownerDocument.createElement("div"),this._promotionWarning.classList.add("promotion-warning"),this._promotionWarning.title="For optimization reasons, this block will be promoted to the vertex shader. You can force it to render in the fragment shader by setting its target to Fragment";var o=e.ownerDocument.createElement("img");o.src=nt,this._promotionWarning.appendChild(o),this._visual.appendChild(this._promotionWarning);var a=e.ownerDocument.createElement("div");a.classList.add("selection-border"),this._visual.appendChild(a),this._connections=e.ownerDocument.createElement("div"),this._connections.classList.add("connections"),this._visual.appendChild(this._connections),this._inputsContainer=e.ownerDocument.createElement("div"),this._inputsContainer.classList.add("inputsContainer"),this._connections.appendChild(this._inputsContainer),this._outputsContainer=e.ownerDocument.createElement("div"),this._outputsContainer.classList.add("outputsContainer"),this._connections.appendChild(this._outputsContainer),this._content=e.ownerDocument.createElement("div"),this._content.classList.add("content"),this._visual.appendChild(this._content),e.appendChild(this._visual),this._comments=e.ownerDocument.createElement("div"),this._comments.classList.add("comments"),this._visual.appendChild(this._comments);for(var i=0,l=this.block.inputs;i<l.length;i++){var s=l[i];this._inputPorts.push(tt.CreatePortElement(s,this,this._inputsContainer,this._displayManager,this._globalState))}for(var c=0,u=this.block.outputs;c<u.length;c++){var p=u[c];this._outputPorts.push(tt.CreatePortElement(p,this,this._outputsContainer,this._displayManager,this._globalState))}this.refresh()},e.prototype.dispose=function(){this._globalState.onGraphNodeRemovalObservable.notifyObservers(this),this._onSelectionChangedObserver&&this._globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._onUpdateRequiredObserver&&this._globalState.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver),this._onSelectionBoxMovedObserver&&this._globalState.onSelectionBoxMoved.remove(this._onSelectionBoxMovedObserver),this._visual.parentElement&&this._visual.parentElement.removeChild(this._visual),this._onFrameCreatedObserver&&this._globalState.onFrameCreatedObservable.remove(this._onFrameCreatedObserver);for(var e=0,t=this._inputPorts;e<t.length;e++){t[e].dispose()}for(var n=0,r=this._outputPorts;n<r.length;n++){r[n].dispose()}for(var o=0,a=this._links.slice(0);o<a.length;o++){a[o].dispose()}this.block.dispose()},e}(),ot=n(71),at=function(){function e(e,t,n,r,o){var a=this;this._isVisible=!0,this.onDisposedObservable=new l.Observable,this._portA=t,this._portB=r,this._nodeA=n,this._nodeB=o,this._graphCanvas=e;var i=t.element.ownerDocument,s=e.svgCanvas;this._path=i.createElementNS("http://www.w3.org/2000/svg","path"),this._path.setAttribute("fill","none"),this._path.classList.add("link"),s.appendChild(this._path),this._selectionPath=i.createElementNS("http://www.w3.org/2000/svg","path"),this._selectionPath.setAttribute("fill","none"),this._selectionPath.classList.add("selection-link"),s.appendChild(this._selectionPath),this._selectionPath.onmousedown=function(){return a.onClick()},this._portB&&this.update(),this._onSelectionChangedObserver=this._graphCanvas.globalState.onSelectionChangedObservable.add((function(e){e===a?(a._path.classList.add("selected"),a._selectionPath.classList.add("selected")):(a._path.classList.remove("selected"),a._selectionPath.classList.remove("selected"))}))}return Object.defineProperty(e.prototype,"isVisible",{get:function(){return this._isVisible},set:function(e){this._isVisible=e,e?(this._path.classList.remove("hidden"),this._selectionPath.classList.remove("hidden")):(this._path.classList.add("hidden"),this._selectionPath.classList.add("hidden")),this.update()},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portA",{get:function(){return this._portA},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"portB",{get:function(){return this._portB},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeA",{get:function(){return this._nodeA},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"nodeB",{get:function(){return this._nodeB},enumerable:!1,configurable:!0}),e.prototype.update=function(e,t,n){void 0===e&&(e=0),void 0===t&&(t=0),void 0===n&&(n=!1);var r=this._portA.element.getBoundingClientRect(),o=this._graphCanvas.canvasContainer.getBoundingClientRect(),a=this._graphCanvas.zoom,i=o.left,l=o.top,s=(r.left-i+.5*r.width)/a,c=(r.top-l+.5*r.height)/a;if(this._portB){var u=this._portB.element.getBoundingClientRect();e=(u.left-i+.5*u.width)/a,t=(u.top-l+.5*u.height)/a}if(n)this._path.setAttribute("d","M".concat(s,",").concat(c," L").concat(e,",").concat(t)),this._path.setAttribute("stroke-dasharray","10, 10"),this._path.setAttribute("stroke-linecap","round");else{var p=e-s,d=t-c,h=Math.min(.5*Math.sqrt(p*p+d*d),300);this._path.setAttribute("d","M".concat(s,",").concat(c," C").concat(s+h,",").concat(c," ").concat(e-h,",").concat(t," ").concat(e,",").concat(t)),this._selectionPath.setAttribute("d","M".concat(s,",").concat(c," C").concat(s+h,",").concat(c," ").concat(e-h,",").concat(t," ").concat(e,",").concat(t))}this._path.setAttribute("stroke",this._portA.element.style.backgroundColor)},e.prototype.onClick=function(){this._graphCanvas.globalState.onSelectionChangedObservable.notifyObservers(this)},e.prototype.dispose=function(e){void 0===e&&(e=!0),this._graphCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._path.parentElement&&this._path.parentElement.removeChild(this._path),this._selectionPath.parentElement&&this._selectionPath.parentElement.removeChild(this._selectionPath),this._nodeB&&(this._nodeA.links.splice(this._nodeA.links.indexOf(this),1),this._nodeB.links.splice(this._nodeB.links.indexOf(this),1),this._graphCanvas.links.splice(this._graphCanvas.links.indexOf(this),1),this._portA.connectionPoint.disconnectFrom(this._portB.connectionPoint),ct._RefreshNode(this._nodeB)),e&&(this.onDisposedObservable.notifyObservers(this),this.onDisposedObservable.clear())},e}();n(323);var it,lt,st=function(e){return!!e&&void 0!==e.port},ct=function(e){function t(t){var n=e.call(this,t)||this;return n.MinZoom=.1,n.MaxZoom=4,n._nodes=[],n._links=[],n._mouseStartPointX=null,n._mouseStartPointY=null,n._dropPointX=0,n._dropPointY=0,n._selectionStartX=0,n._selectionStartY=0,n._candidateLinkedHasMoved=!1,n._x=0,n._y=0,n._zoom=1,n._selectedNodes=[],n._selectedLink=null,n._selectedPort=null,n._candidateLink=null,n._candidatePort=null,n._gridSize=20,n._selectionBox=null,n._selectedFrame=null,n._frameCandidate=null,n._frames=[],n._altKeyIsPressed=!1,n._ctrlKeyIsPressed=!1,n._oldY=-1,n._frameIsMoving=!1,n._isLoading=!1,t.globalState.onSelectionChangedObservable.add((function(e){e?e instanceof at?(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=e,n._selectedPort=null):e instanceof pt?(n._selectedNodes=[],n._selectedFrame=e,n._selectedLink=null,n._selectedPort=null):e instanceof rt?n._ctrlKeyIsPressed?-1===n._selectedNodes.indexOf(e)&&n._selectedNodes.push(e):n._selectedNodes=[e]:e instanceof tt?(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=null,n._selectedPort=e):(n._selectedNodes=[],n._selectedFrame=null,n._selectedLink=null,n._selectedPort=e.port):(n._selectedNodes=[],n._selectedLink=null,n._selectedFrame=null,n._selectedPort=null)})),t.globalState.onCandidatePortSelectedObservable.add((function(e){n._candidatePort=e})),t.globalState.onGridSizeChanged.add((function(){n.gridSize=l.DataStorage.ReadNumber("GridSize",20)})),n.props.globalState.hostDocument.addEventListener("keyup",(function(){return n.onKeyUp()}),!1),n.props.globalState.hostDocument.addEventListener("keydown",(function(e){n._altKeyIsPressed=e.altKey,n._ctrlKeyIsPressed=e.ctrlKey}),!1),n.props.globalState.hostDocument.defaultView.addEventListener("blur",(function(){n._altKeyIsPressed=!1,n._ctrlKeyIsPressed=!1}),!1),n.props.globalState.storeEditorData=function(e,t){if(e.frames=[],t)e.frames.push(t.serialize(!1));else{e.x=n.x,e.y=n.y,e.zoom=n.zoom;for(var r=0,o=n._frames;r<o.length;r++){var a=o[r];e.frames.push(a.serialize(!0))}}},n}var n;return u(t,e),Object.defineProperty(t.prototype,"gridSize",{get:function(){return this._gridSize},set:function(e){this._gridSize=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"globalState",{get:function(){return this.props.globalState},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"links",{get:function(){return this._links},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frames",{get:function(){return this._frames},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"zoom",{get:function(){return this._zoom},set:function(e){this._zoom!==e&&(this._zoom=e,this.updateTransform())},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"x",{get:function(){return this._x},set:function(e){this._x=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"y",{get:function(){return this._y},set:function(e){this._y=e,this.updateTransform()},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedNodes",{get:function(){return this._selectedNodes},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedLink",{get:function(){return this._selectedLink},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedFrame",{get:function(){return this._selectedFrame},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectedPort",{get:function(){return this._selectedPort},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"canvasContainer",{get:function(){return this._graphCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"hostCanvas",{get:function(){return this._hostCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"svgCanvas",{get:function(){return this._svgCanvas},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"selectionContainer",{get:function(){return this._selectionContainer},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"frameContainer",{get:function(){return this._frameContainer},enumerable:!1,configurable:!0}),t.prototype.getGridPosition=function(e,t){void 0===t&&(t=!1);var n=this.gridSize;return 0===n?e:t?n*Math.ceil(e/n):n*Math.floor(e/n)},t.prototype.getGridPositionCeil=function(e){var t=this.gridSize;return 0===t?e:t*Math.ceil(e/t)},t.prototype.updateTransform=function(){this._rootContainer.style.transform="translate(".concat(this._x,"px, ").concat(this._y,"px) scale(").concat(this._zoom,")"),l.DataStorage.ReadBoolean("ShowGrid",!0)?(this._hostCanvas.style.backgroundSize="".concat(this._gridSize*this._zoom,"px ").concat(this._gridSize*this._zoom,"px"),this._hostCanvas.style.backgroundPosition="".concat(this._x,"px ").concat(this._y,"px")):this._hostCanvas.style.backgroundSize="0"},t.prototype.onKeyUp=function(){this._altKeyIsPressed=!1,this._ctrlKeyIsPressed=!1,this._oldY=-1},t.prototype.findNodeFromBlock=function(e){return this.nodes.filter((function(t){return t.block===e}))[0]},t.prototype.reset=function(){for(var e=0,t=this._nodes;e<t.length;e++){t[e].dispose()}for(var n=0,r=this._frames.splice(0);n<r.length;n++){r[n].dispose()}this._nodes=[],this._frames=[],this._links=[],this._graphCanvas.innerHTML="",this._svgCanvas.innerHTML=""},t.prototype.connectPorts=function(e,t){var n=e.ownerBlock,r=t.ownerBlock,o=this.findNodeFromBlock(n),a=this.findNodeFromBlock(r);if(o&&a){var i=o.getPortForConnectionPoint(e),l=a.getPortForConnectionPoint(t);if(i&&l){for(var s=0,c=this._links;s<c.length;s++){var u=c[s];if(u.portA===i&&u.portB===l)return;if(u.portA===l&&u.portB===i)return}var p=new at(this,i,o,l,a);this._links.push(p),o.links.push(p),a.links.push(p)}}},t.prototype.removeLink=function(e){var t=this._links.indexOf(e);t>-1&&this._links.splice(t,1),e.dispose()},t.prototype.appendBlock=function(e){var t=new rt(e,this.props.globalState);return t.appendVisual(this._graphCanvas,this),this._nodes.push(t),t},t.prototype.distributeGraph=function(){var e=this;this.x=0,this.y=0,this.zoom=1;var t=new ot.graphlib.Graph;t.setGraph({}),t.setDefaultEdgeLabel((function(){return{}})),t.graph().rankdir="LR",this._nodes.forEach((function(n){e._frames.some((function(e){return-1!==e.nodes.indexOf(n)}))||t.setNode(n.id.toString(),{id:n.id,type:"node",width:n.width,height:n.height})})),this._frames.forEach((function(e){t.setNode(e.id.toString(),{id:e.id,type:"frame",width:e.element.clientWidth,height:e.element.clientHeight})})),this._nodes.forEach((function(n){n.block.outputs.forEach((function(r){r.hasEndpoints&&r.endpoints.forEach((function(r){var o=e._frames.filter((function(e){return-1!==e.nodes.indexOf(n)})),a=e._frames.filter((function(e){return e.nodes.some((function(e){return e.block===r.ownerBlock}))})),i=o.length>0?o[0].id:n.id,l=a.length>0?a[0].id:r.ownerBlock.uniqueId;t.setEdge(i.toString(),l.toString())}))}))})),ot.layout(t),t.nodes().map((function(e){return t.node(e)})).forEach((function(t){if(t)if("node"!==t.type)for(var n=0,r=e._frames;n<r.length;n++){var o=r[n];if(o.id===t.id)return e._frameIsMoving=!0,o.move(t.x-t.width/2,t.y-t.height/2,!1),o.cleanAccumulation(),void(e._frameIsMoving=!1)}else for(var a=0,i=e._nodes;a<i.length;a++){var l=i[a];if(l.id===t.id)return l.x=t.x-t.width/2,l.y=t.y-t.height/2,void l.cleanAccumulation()}}))},t.prototype.componentDidMount=function(){this._hostCanvas=this.props.globalState.hostDocument.getElementById("graph-canvas"),this._rootContainer=this.props.globalState.hostDocument.getElementById("graph-container"),this._graphCanvas=this.props.globalState.hostDocument.getElementById("graph-canvas-container"),this._svgCanvas=this.props.globalState.hostDocument.getElementById("graph-svg-container"),this._selectionContainer=this.props.globalState.hostDocument.getElementById("selection-container"),this._frameContainer=this.props.globalState.hostDocument.getElementById("frame-container"),this.gridSize=l.DataStorage.ReadNumber("GridSize",20),this.updateTransform()},t.prototype.onMove=function(e){if(this._selectionBox){var t=this.canvasContainer.getBoundingClientRect(),n=e.pageX-t.left,r=e.pageY-t.top;return n>this._selectionStartX?(this._selectionBox.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._selectionBox.style.width="".concat((n-this._selectionStartX)/this.zoom,"px")):(this._selectionBox.style.left="".concat(n/this.zoom,"px"),this._selectionBox.style.width="".concat((this._selectionStartX-n)/this.zoom,"px")),r>this._selectionStartY?(this._selectionBox.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._selectionBox.style.height="".concat((r-this._selectionStartY)/this.zoom,"px")):(this._selectionBox.style.top="".concat(r/this.zoom,"px"),this._selectionBox.style.height="".concat((this._selectionStartY-r)/this.zoom,"px")),void this.props.globalState.onSelectionBoxMoved.notifyObservers(this._selectionBox.getBoundingClientRect())}if(this._frameCandidate){t=this.canvasContainer.getBoundingClientRect(),n=e.pageX-t.left,r=e.pageY-t.top;return n>this._selectionStartX?(this._frameCandidate.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._frameCandidate.style.width="".concat((n-this._selectionStartX)/this.zoom,"px")):(this._frameCandidate.style.left="".concat(n/this.zoom,"px"),this._frameCandidate.style.width="".concat((this._selectionStartX-n)/this.zoom,"px")),void(r>this._selectionStartY?(this._frameCandidate.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._frameCandidate.style.height="".concat((r-this._selectionStartY)/this.zoom,"px")):(this._frameCandidate.style.top="".concat(r/this.zoom,"px"),this._frameCandidate.style.height="".concat((this._selectionStartY-r)/this.zoom,"px")))}if(this._candidateLink){t=this.canvasContainer.getBoundingClientRect();return this._candidatePort=null,this.props.globalState.onCandidateLinkMoved.notifyObservers(new l.Vector2(e.pageX,e.pageY)),this._dropPointX=(e.pageX-t.left)/this.zoom,this._dropPointY=(e.pageY-t.top)/this.zoom,this._candidateLink.update(this._dropPointX,this._dropPointY,!0),void(this._candidateLinkedHasMoved=!0)}if(this._altKeyIsPressed&&1===e.buttons){this._oldY<0&&(this._oldY=e.pageY);var o=(e.pageY-this._oldY)/10;if(Math.abs(o)>5){var a=this.zoom;this.zoom=Math.max(Math.min(this.MaxZoom,this.zoom+o/100),this.MinZoom);var i=e.currentTarget.getBoundingClientRect(),s=i.width,c=s*this.zoom-s*a,u=(e.clientX-i.left-this.x)/a/s;this.x=this.x-c*u,this._oldY=e.pageY}}else this._rootContainer.style.cursor="move",null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&(this.x+=e.clientX-this._mouseStartPointX,this.y+=e.clientY-this._mouseStartPointY,this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY)},t.prototype.onDown=function(e){if(this._rootContainer.setPointerCapture(e.pointerId),e.currentTarget===this._hostCanvas&&e.ctrlKey){this._selectionBox=this.props.globalState.hostDocument.createElement("div"),this._selectionBox.classList.add("selection-box"),this._selectionContainer.appendChild(this._selectionBox);var t=this.canvasContainer.getBoundingClientRect();return this._selectionStartX=e.pageX-t.left,this._selectionStartY=e.pageY-t.top,this._selectionBox.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._selectionBox.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._selectionBox.style.width="0px",void(this._selectionBox.style.height="0px")}if(e.currentTarget===this._hostCanvas&&e.shiftKey){this._frameCandidate=this.props.globalState.hostDocument.createElement("div"),this._frameCandidate.classList.add("frame-box"),this._frameContainer.appendChild(this._frameCandidate);t=this.canvasContainer.getBoundingClientRect();return this._selectionStartX=e.pageX-t.left,this._selectionStartY=e.pageY-t.top,this._frameCandidate.style.left="".concat(this._selectionStartX/this.zoom,"px"),this._frameCandidate.style.top="".concat(this._selectionStartY/this.zoom,"px"),this._frameCandidate.style.width="0px",void(this._frameCandidate.style.height="0px")}if(e.nativeEvent.srcElement&&"IMG"===e.nativeEvent.srcElement.nodeName){if(!this._candidateLink){var n=e.nativeEvent.srcElement.parentElement.port;this._candidateLink=new at(this,n,n.node),this._candidateLinkedHasMoved=!1}}else this.props.globalState.onSelectionChangedObservable.notifyObservers(null),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY},t.prototype.onUp=function(e){if(this._mouseStartPointX=null,this._mouseStartPointY=null,this._rootContainer.releasePointerCapture(e.pointerId),this._oldY=-1,this._candidateLink){if(this._candidateLinkedHasMoved)this.processCandidatePort(),this.props.globalState.onCandidateLinkMoved.notifyObservers(null);else if(this._candidateLink.portA instanceof ut){var t=this._candidateLink.portA,n=this.frames.find((function(e){return e.id===t.parentFrameId}));if(n){var r={frame:n,port:t};this.props.globalState.onSelectionChangedObservable.notifyObservers(r)}}else this._candidateLink.portA instanceof tt&&this.props.globalState.onSelectionChangedObservable.notifyObservers(this._candidateLink.portA);this._candidateLink.dispose(),this._candidateLink=null,this._candidatePort=null}if(this._selectionBox&&(this._selectionBox.parentElement.removeChild(this._selectionBox),this._selectionBox=null),this._frameCandidate){var o=new pt(this._frameCandidate,this);this._frames.push(o),this._frameCandidate.parentElement.removeChild(this._frameCandidate),this._frameCandidate=null,this.props.globalState.onSelectionChangedObservable.notifyObservers(o)}},t.prototype.onWheel=function(e){var t=e.deltaY<0?.1:-.1,n=this.zoom;this.zoom=Math.min(Math.max(this.MinZoom,this.zoom+t*this.zoom),this.MaxZoom);var r=e.currentTarget.getBoundingClientRect(),o=r.width,a=r.height,i=o*this.zoom-o*n,l=a*this.zoom-a*n,s=e.clientX-r.left,c=e.clientY-r.top,u=(s-this.x)/n/o,p=(c-this.y)/n/a;this.x=this.x-i*u,this.y=this.y-l*p,e.stopPropagation()},t.prototype.zoomToFit=function(){var e=this,t=0,n=0;this._nodes.forEach((function(r){e._frames.some((function(e){return-1!==e.nodes.indexOf(r)}))||(r.x<t&&(t=r.x),r.y<n&&(n=r.y))})),this._frames.forEach((function(e){e.x<t&&(t=e.x),e.y<n&&(n=e.y)})),this._frames.forEach((function(e){e.x+=-t,e.y+=-n,e.cleanAccumulation()})),this._nodes.forEach((function(e){e.x+=-t,e.y+=-n,e.cleanAccumulation()}));var r=this._rootContainer.clientWidth/this._rootContainer.scrollWidth,o=this._rootContainer.clientHeight/this._rootContainer.scrollHeight,a=r<o?r:o;this.zoom=a,this.x=0,this.y=0},t.prototype.processCandidatePort=function(){var e,n,r=this,o=this._candidateLink.portA.connectionPoint,a=this._candidateLink.portA.node;if(this._candidatePort)e=this._candidatePort.connectionPoint,n=this._candidatePort.node;else{if(o.direction===l.NodeMaterialConnectionPointDirection.Output)return;var i="output",s=void 0,c=this._candidateLink.portA.connectionPoint.createCustomInputBlock();c?(s=c[0],i=c[1]):s=new l.InputBlock(l.NodeMaterialBlockConnectionPointTypes[this._candidateLink.portA.connectionPoint.type],void 0,this._candidateLink.portA.connectionPoint.type),this.props.globalState.nodeMaterial.attachedBlocks.push(s),e=s[i],s.isInput?n=this.appendBlock(s):(s.autoConfigure(this.props.globalState.nodeMaterial),n=this.props.onEmitNewBlock(s)),n.x=this._dropPointX-200,n.y=this._dropPointY-50;var u=n.x-250,p=n.y;s.inputs.forEach((function(e){if(e.connectedPoint){var t=r.nodes.filter((function(t){return t.block===e.connectedPoint.ownerBlock}))[0];0===t.x&&0===t.y&&(t.x=u,t.y=p,t.cleanAccumulation(),p+=80)}}))}if(e.direction===l.NodeMaterialConnectionPointDirection.Input){var d=o;o=e,e=d;var h=n;n=a,a=h}if(o.connectedPoint!==e&&o!==e&&o.direction!==e.direction&&o.ownerBlock!==e.ownerBlock){var f="FragmentOutputBlock"===o.ownerBlock.getClassName(),m=e.checkCompatibilityState(o);if(!e.needDualDirectionValidation&&!o.needDualDirectionValidation||m!==l.NodeMaterialConnectionPointCompatibilityStates.Compatible||e instanceof l.InputBlock||(m=o.checkCompatibilityState(e)),m===l.NodeMaterialConnectionPointCompatibilityStates.Compatible){if(f){var g=o.ownerBlock;"rgb"===o.name&&g.rgba.isConnected?a.getLinksForConnectionPoint(g.rgba)[0].dispose():"rgba"===o.name&&g.rgb.isConnected&&a.getLinksForConnectionPoint(g.rgb)[0].dispose()}var v=null;if(o.isConnected){var b=a.getLinksForConnectionPoint(o);v=b.slice(),b.forEach((function(e){e.dispose(!1)}))}o.ownerBlock.inputsAreExclusive&&o.ownerBlock.inputs.forEach((function(e){var t=a.getLinksForConnectionPoint(e);v?v.push.apply(v,t.slice()):v=t.slice(),t.forEach((function(e){e.dispose(!1)}))})),e.connectTo(o),this.connectPorts(e,o);var y=new Set([n]),x=new Set([a.links[a.links.length-1]]);t._RefreshNode(a,y,x),null==v||v.forEach((function(e){e.onDisposedObservable.notifyObservers(e),e.onDisposedObservable.clear()})),this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)}else{var w="";switch(m){case l.NodeMaterialConnectionPointCompatibilityStates.TypeIncompatible:w="Cannot connect two different connection types";break;case l.NodeMaterialConnectionPointCompatibilityStates.TargetIncompatible:w="Source block can only work in fragment shader whereas destination block is currently aimed for the vertex shader";break;case l.NodeMaterialConnectionPointCompatibilityStates.HierarchyIssue:w="Source block cannot be connected with one of its ancestors"}this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers(w)}}},t.prototype.processEditorData=function(e){for(var t=0,n=this._frames.splice(0);t<n.length;t++){(i=n[t]).dispose()}if(this._frames=[],this.x=e.x||0,this.y=e.y||0,this.zoom=e.zoom||1,e.frames)for(var r=0,o=e.frames;r<o.length;r++){var a=o[r],i=pt.Parse(a,this,e.map);this._frames.push(i)}},t.prototype.addFrame=function(e){var t=pt.Parse(e,this,this.props.globalState.nodeMaterial.editorData.map);this._frames.push(t),this.globalState.onSelectionChangedObservable.notifyObservers(t)},t.prototype.render=function(){var e=this;return o.createElement("div",{id:"graph-canvas",onWheel:function(t){return e.onWheel(t)},onPointerMove:function(t){return e.onMove(t)},onPointerDown:function(t){return e.onDown(t)},onPointerUp:function(t){return e.onUp(t)}},o.createElement("div",{id:"graph-container"},o.createElement("div",{id:"graph-canvas-container"}),o.createElement("div",{id:"frame-container"}),o.createElement("svg",{id:"graph-svg-container"}),o.createElement("div",{id:"selection-container"})))},n=t,t._RefreshNode=function(e,t,r){e.refresh();var o=e.links;t&&o.forEach((function(e){var o=e.nodeA,a=e.nodeB;t.has(o)||(t.add(o),n._RefreshNode(o,t,r)),a&&!t.has(a)&&(t.add(a),n._RefreshNode(a,t,r))})),r&&o.forEach((function(e){r.has(e)||(r.add(e),e.update())}))},t}(o.Component),ut=function(e){function t(t,n,r,o,a,i,s){var c=e.call(this,t,n,r,o)||this;return c.connectionPoint=n,c.node=r,c._onFramePortPositionChangedObservable=new l.Observable,c._parentFrameId=s,c._isInput=a,c._framePortId=i,c._onSelectionChangedObserver=c._globalState.onSelectionChangedObservable.add((function(e){st(e)&&e.port===c?c._img.classList.add("selected"):c._img.classList.remove("selected")})),c.refresh(),c}return u(t,e),Object.defineProperty(t.prototype,"parentFrameId",{get:function(){return this._parentFrameId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"onFramePortPositionChangedObservable",{get:function(){return this._onFramePortPositionChangedObservable},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isInput",{get:function(){return this._isInput},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framePortId",{get:function(){return this._framePortId},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"framePortPosition",{get:function(){return this._framePortPosition},set:function(e){this._framePortPosition=e,this.onFramePortPositionChangedObservable.notifyObservers(this)},enumerable:!1,configurable:!0}),t.CreateFrameNodePortElement=function(e,n,r,o,a,i,l,s){var c=r.ownerDocument.createElement("div"),u=e.ownerBlock;if(c.classList.add("portLine"),null!==l&&(c.dataset.framePortId="".concat(l)),r.appendChild(c),!o||o.shouldDisplayPortLabels(u)){var p=r.ownerDocument.createElement("div");p.classList.add("port-label");var d=e.displayName||e.name;e.ownerBlock.isInput&&(d=n.name),p.innerHTML=d,c.appendChild(p)}return new t(c,e,n,a,i,l,s)},t}(tt);!function(e){e[e.Right=0]="Right",e[e.Left=1]="Left",e[e.Top=2]="Top",e[e.Bottom=3]="Bottom",e[e.TopRight=4]="TopRight",e[e.TopLeft=5]="TopLeft",e[e.BottomRight=6]="BottomRight",e[e.BottomLeft=7]="BottomLeft"}(it||(it={})),function(e){e[e.Top=0]="Top",e[e.Middle=1]="Middle",e[e.Bottom=2]="Bottom"}(lt||(lt={}));var pt=function(){function e(t,n,r){var o=this;void 0===r&&(r=!1),this.CollapsedWidth=200,this._x=0,this._y=0,this._gridAlignedX=0,this._gridAlignedY=0,this._nodes=[],this._mouseStartPointX=null,this._mouseStartPointY=null,this._onNodeLinkDisposedObservers=[],this._isCollapsed=!1,this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._exposedInPorts=[],this._exposedOutPorts=[],this._minFrameHeight=40,this._minFrameWidth=220,this.onExpandStateChanged=new l.Observable,this.CloseSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M16,15l5.85,5.84-1,1L15,15.93,9.15,21.78l-1-1L14,15,8.19,9.12l1-1L15,14l5.84-5.84,1,1Z"/></g></svg>',this.ExpandSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-6.75,6.75H11.06V14.44h3.38V11.06h1.12v3.38h3.38v1.12H15.56v3.38H14.44Z"/></g></svg>',this.CollapseSVG='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 30 30"><g id="Layer_2" data-name="Layer 2"><path d="M22.31,7.69V22.31H7.69V7.69ZM21.19,8.81H8.81V21.19H21.19Zm-2.25,6.75H11.06V14.44h7.88Z"/></g></svg>',this.initResizing=function(e){e.stopPropagation(),o._mouseStartPointX=e.clientX,o._mouseStartPointY=e.clientY,o._frameIsResizing=!0},this.cleanUpResizing=function(e){e.stopPropagation(),o._frameIsResizing=!1,o._resizingDirection=null,o._mouseStartPointX=null,o._mouseStartPointY=null,o.mouseXLimit=null,o.refresh()},this.updateMinHeightWithComments=function(){if(o.comments&&o.comments.length>0){var e=o._commentsElement.offsetHeight+40;o._minFrameHeight=e}},this._onRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(o.initResizing(e),t._resizingDirection=it.Right,t.mouseXLimit=e.clientX-(t.width-t._minFrameWidth),t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onRightHandlePointerMove))},this._onRightHandlePointerMove=function(e){var t=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,n=o._mouseStartPointX-t;o._moveRightHandle(e,n)},this._moveRightHandle=function(e,t){var n=o;if(n.mouseXLimit){if(!n._isResizingRight()||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientX<t)return;if(n._isResizingRight()){e.stopPropagation();var r=(e.clientX-n._mouseStartPointX)/n._ownerCanvas.zoom;n._expandRight(r,e.clientX),n._mouseStartPointX=e.clientX}}},this._onRightHandlePointerUp=function(e){var t=o;t._isResizingRight()&&(t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Bottom,t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomHandlePointerMove),t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomHandlePointerUp))},this._onBottomHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t;o._moveBottomHandle(e,n)},this._moveBottomHandle=function(e,t){var n=o;if(!(n._resizingDirection!==it.Bottom||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientY<t)&&n._resizingDirection===it.Bottom){e.stopPropagation();var r=(e.clientY-n._mouseStartPointY)/n._ownerCanvas.zoom;n._expandBottom(r),n._mouseStartPointY=e.clientY}},this._onBottomHandlePointerUp=function(e){var t=o;t._resizingDirection===it.Bottom&&(t.height=parseFloat(t.element.style.height.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomHandlePointerMove),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomHandlePointerUp),t.cleanUpResizing(e))},this._onLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Left,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onLeftHandlePointerMove))},this._onLeftHandlePointerMove=function(e){var t=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,n=o._mouseStartPointX+t;o._moveLeftHandle(e,n)},this._moveLeftHandle=function(e,t){var n=o;if(n.mouseXLimit){if(n._resizingDirection!==it.Left||null===n._mouseStartPointX||null===n._mouseStartPointY||e.clientX>t)return;if(n._resizingDirection===it.Left){e.stopPropagation();var r=(e.clientX-n._mouseStartPointX)/n._ownerCanvas.zoom;n._expandLeft(r),n._mouseStartPointX=e.clientX}}},this._onLeftHandlePointerUp=function(e){var t=o;t._resizingDirection===it.Left&&(t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onLeftHandlePointerMove),t.cleanUpResizing(e))},this._onTopHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.Top,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopHandlePointerMove))},this._onTopHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t;o._moveTopHandle(e,n)},this._moveTopHandle=function(e,t){var n=o;if(n._isResizingTop()&&null!==n._mouseStartPointX&&null!==n._mouseStartPointY&&!(e.clientY>t)&&n._isResizingTop()){e.stopPropagation();var r=(e.clientY-n._mouseStartPointY)/n._ownerCanvas.zoom;n._expandTop(r),n._mouseStartPointY=e.clientY}},this._onTopHandlePointerUp=function(e){var t=o;t._isResizingTop()&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopHandlePointerMove),t.cleanUpResizing(e))},this._onTopRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.TopRight,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopRightHandlePointerMove))},this._onTopRightHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX-r;o._moveTopRightHandle(e,a,n)},this._moveTopRightHandle=function(e,t,n){var r=o;if(r._isResizingTop()&&r._isResizingRight()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingRight()&&r._isResizingTop())if(e.stopPropagation(),e.clientY<n&&e.clientX>t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}else if(e.clientY>n&&e.clientX>t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX}else if(e.clientY<n&&e.clientX<t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}},this._onTopRightHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.TopRight&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomRightHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.BottomRight,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomRightHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomRightHandlePointerMove))},this._onBottomRightHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX-r;o._moveBottomRightHandle(e,a,n)},this._moveBottomRightHandle=function(e,t,n){var r=o;if(r._isResizingBottom()&&r._isResizingRight()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingRight()&&r._isResizingBottom())if(e.stopPropagation(),e.clientY>n&&e.clientX>t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}else if(e.clientY<n&&e.clientX>t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandRight(a,e.clientX),r._mouseStartPointX=e.clientX}else if(e.clientY>n&&e.clientX<t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}},this._onBottomRightHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.BottomRight&&(t.height=parseFloat(t.element.style.height.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomRightHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomRightHandlePointerMove),t.cleanUpResizing(e))},this._onBottomLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.BottomLeft,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onBottomLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onBottomLeftHandlePointerMove))},this._onBottomLeftHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY-t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX+r;o._moveBottomLeftHandle(e,a,n)},this._moveBottomLeftHandle=function(e,t,n){var r=o;if(r._isResizingBottom()&&r._isResizingLeft()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingLeft()&&r._isResizingBottom())if(e.stopPropagation(),e.clientY>n&&e.clientX<t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}else if(e.clientY<n&&e.clientX<t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX}else if(e.clientY>n&&e.clientX>t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandBottom(i),r._mouseStartPointY=e.clientY}},this._onBottomLeftHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.BottomLeft&&(t.height=parseFloat(t.element.style.height.replace("px","")),t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onBottomLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onBottomLeftHandlePointerMove),t.cleanUpResizing(e))},this._onTopLeftHandlePointerDown=function(e){var t=o;t.isCollapsed||(t.initResizing(e),t._resizingDirection=it.TopLeft,t.mouseXLimit=e.clientX+t.width-t._minFrameWidth,t._ownerCanvas.hostCanvas.addEventListener("pointerup",t._onTopLeftHandlePointerUp),t._ownerCanvas.hostCanvas.addEventListener("pointermove",t._onTopLeftHandlePointerMove))},this._onTopLeftHandlePointerMove=function(e){var t=(o.element.offsetHeight-o._minFrameHeight)*o._ownerCanvas.zoom,n=o._mouseStartPointY+t,r=(o.element.offsetWidth-o._minFrameWidth)*o._ownerCanvas.zoom,a=o._mouseStartPointX+r;o._moveTopLeftHandle(e,a,n)},this._moveTopLeftHandle=function(e,t,n){var r=o;if(r._isResizingTop()&&r._isResizingLeft()&&null!==r._mouseStartPointX&&null!==r._mouseStartPointY&&r._isResizingLeft()&&r._isResizingTop())if(e.stopPropagation(),e.clientY<n&&e.clientX<t){var a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX;var i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}else if(e.clientY>n&&e.clientX<t){a=(e.clientX-r._mouseStartPointX)/r._ownerCanvas.zoom;r._expandLeft(a),r._mouseStartPointX=e.clientX}else if(e.clientY<n&&e.clientX>t){i=(e.clientY-r._mouseStartPointY)/r._ownerCanvas.zoom;r._expandTop(i),r._mouseStartPointY=e.clientY}},this._onTopLeftHandlePointerUp=function(e){e.stopPropagation();var t=o;t._resizingDirection===it.TopLeft&&(t.y=parseFloat(t.element.style.top.replace("px","")),t.height=parseFloat(t.element.style.height.replace("px","")),t.x=parseFloat(t.element.style.left.replace("px","")),t.width=parseFloat(t.element.style.width.replace("px","")),t._ownerCanvas.hostCanvas.removeEventListener("pointerup",t._onTopLeftHandlePointerUp),t._ownerCanvas.hostCanvas.removeEventListener("pointermove",t._onTopLeftHandlePointerMove),t.cleanUpResizing(e))},this._id=e._FrameCounter++,this._ownerCanvas=n;var a=n.frameContainer;this.element=a.ownerDocument.createElement("div"),this.element.classList.add("frame-box"),a.appendChild(this.element),this._headerElement=a.ownerDocument.createElement("div"),this._headerElement.classList.add("frame-box-header"),this._headerElement.addEventListener("dblclick",(function(){o.isCollapsed=!o.isCollapsed})),this.element.appendChild(this._headerElement),this._borderElement=a.ownerDocument.createElement("div"),this._borderElement.classList.add("frame-box-border"),this.element.appendChild(this._borderElement);var i=a.ownerDocument.createElement("div");i.className="handle right-handle",this.element.appendChild(i),i.addEventListener("pointerdown",this._onRightHandlePointerDown);var s=a.ownerDocument.createElement("div");s.className="handle left-handle",this.element.appendChild(s),s.addEventListener("pointerdown",this._onLeftHandlePointerDown);var c=a.ownerDocument.createElement("div");c.className="handle bottom-handle",this.element.appendChild(c),c.addEventListener("pointerdown",this._onBottomHandlePointerDown);var u=a.ownerDocument.createElement("div");u.className="handle top-handle",this.element.appendChild(u),u.addEventListener("pointerdown",this._onTopHandlePointerDown);var p=a.ownerDocument.createElement("div");p.className="handle right-handle top-right-corner-handle",this.element.appendChild(p),p.addEventListener("pointerdown",this._onTopRightHandlePointerDown);var d=a.ownerDocument.createElement("div");d.className="handle right-handle bottom-right-corner-handle",this.element.appendChild(d),d.addEventListener("pointerdown",this._onBottomRightHandlePointerDown);var h=a.ownerDocument.createElement("div");h.className="handle left-handle top-left-corner-handle",this.element.appendChild(h),h.addEventListener("pointerdown",this._onTopLeftHandlePointerDown);var f=a.ownerDocument.createElement("div");f.className="handle left-handle bottom-left-corner-handle",this.element.appendChild(f),f.addEventListener("pointerdown",this._onBottomLeftHandlePointerDown),this._headerTextElement=a.ownerDocument.createElement("div"),this._headerTextElement.classList.add("frame-box-header-title"),this._headerElement.appendChild(this._headerTextElement),this._headerCollapseElement=a.ownerDocument.createElement("div"),this._headerCollapseElement.classList.add("frame-box-header-collapse"),this._headerCollapseElement.classList.add("frame-box-header-button"),this._headerCollapseElement.title="Collapse",this._headerCollapseElement.ondragstart=function(){return!1},this._headerCollapseElement.addEventListener("pointerdown",(function(e){o._headerCollapseElement.classList.add("down"),e.stopPropagation()})),this._headerCollapseElement.addEventListener("pointerup",(function(e){e.stopPropagation(),o._headerCollapseElement.classList.remove("down"),o.isCollapsed=!o.isCollapsed})),this._headerCollapseElement.innerHTML=this.CollapseSVG,this._headerElement.appendChild(this._headerCollapseElement),this._headerCloseElement=a.ownerDocument.createElement("div"),this._headerCloseElement.classList.add("frame-box-header-close"),this._headerCloseElement.classList.add("frame-box-header-button"),this._headerCloseElement.title="Close",this._headerCloseElement.ondragstart=function(){return!1},this._headerCloseElement.addEventListener("pointerdown",(function(e){e.stopPropagation()})),this._headerCloseElement.addEventListener("pointerup",(function(e){e.stopPropagation(),o.dispose()})),this._headerCloseElement.innerHTML=this.CloseSVG,this._headerElement.appendChild(this._headerCloseElement),this._portContainer=a.ownerDocument.createElement("div"),this._portContainer.classList.add("port-container"),this.element.appendChild(this._portContainer),this._outputPortContainer=a.ownerDocument.createElement("div"),this._outputPortContainer.classList.add("outputsContainer"),this._portContainer.appendChild(this._outputPortContainer),this._inputPortContainer=a.ownerDocument.createElement("div"),this._inputPortContainer.classList.add("inputsContainer"),this._portContainer.appendChild(this._inputPortContainer),this.name="Frame",this.color=l.Color3.FromInts(72,72,72),t&&(this.x=parseFloat(t.style.left.replace("px","")),this.y=parseFloat(t.style.top.replace("px","")),this.width=parseFloat(t.style.width.replace("px","")),this.height=parseFloat(t.style.height.replace("px","")),this.cleanAccumulation()),this._headerTextElement.addEventListener("pointerdown",(function(e){return o._onDown(e)})),this._headerTextElement.addEventListener("pointerup",(function(e){return o._onUp(e)})),this._headerTextElement.addEventListener("pointermove",(function(e){return o._onMove(e)})),this._onSelectionChangedObserver=n.globalState.onSelectionChangedObservable.add((function(e){e===o?o.element.classList.add("selected"):o.element.classList.remove("selected")})),this._onGraphNodeRemovalObserver=n.globalState.onGraphNodeRemovalObservable.add((function(e){var t=o._nodes.indexOf(e);-1!==t&&(e.enclosingFrameId=-1,o._nodes.splice(t,1))})),this._onExposePortOnFrameObserver=n.globalState.onExposePortOnFrameObservable.add((function(e){-1!==o.nodes.indexOf(e)&&o.redrawFramePorts()})),this._commentsElement=document.createElement("div"),this._commentsElement.className="frame-comments",this._commentsElement.style.color="white",this._commentsElement.style.fontSize="16px";var m=document.createElement("span");m.className="frame-comment-span",this._commentsElement.appendChild(m),this.element.appendChild(this._commentsElement),r||this.refresh()}return Object.defineProperty(e.prototype,"id",{get:function(){return this._id},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isCollapsed",{get:function(){return this._isCollapsed},set:function(e){if(this._isCollapsed!==e){if(this._isCollapsed=e,this._ownerCanvas._frameIsMoving=!0,e)this.element.classList.add("collapsed"),this._moveFrame((this.width-this.CollapsedWidth)/2,0),this._createFramePorts(),this._markFramePortPositions();else{this.element.classList.remove("collapsed"),this._outputPortContainer.innerHTML="",this._inputPortContainer.innerHTML="",this._frameInPorts.forEach((function(e){e.dispose()})),this._frameOutPorts.forEach((function(e){e.dispose()})),this._controlledPorts.forEach((function(e){e.delegatedPort=null,e.refresh()})),this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._onNodeLinkDisposedObservers=[];for(var t=0,n=this._nodes;t<n.length;t++){n[t].isVisible=!0}this._moveFrame(-(this.width-this.CollapsedWidth)/2,0)}this.cleanAccumulation(),this._ownerCanvas._frameIsMoving=!1,this._isCollapsed?(this._headerCollapseElement.innerHTML=this.ExpandSVG,this._headerCollapseElement.title="Expand"):(this._headerCollapseElement.innerHTML=this.CollapseSVG,this._headerCollapseElement.title="Collapse"),this.onExpandStateChanged.notifyObservers(this)}},enumerable:!1,configurable:!0}),e.prototype._createInputPort=function(t,n){var r=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._inputPortContainer,null,this._ownerCanvas.globalState,!0,e._FramePortCounter++,this.id);this._frameInPorts.push(r),t.delegatedPort=r,this._controlledPorts.push(t),t.exposedPortPosition=this._exposedInPorts.findIndex((function(e){return e===t})),t.exposedPortPosition<0&&(this._exposedInPorts.push(t),t.exposedPortPosition=this._exposedInPorts.length-1)},e.prototype._markFramePortPositions=function(){if(2==this._frameInPorts.length)this._frameInPorts[0].framePortPosition=lt.Top,this._frameInPorts[1].framePortPosition=lt.Bottom;else for(var e=0;e<this._frameInPorts.length;e++){var t=this._frameInPorts[e];0===e?t.framePortPosition=lt.Top:e===this._frameInPorts.length-1?t.framePortPosition=lt.Bottom:t.framePortPosition=lt.Middle}if(2==this._frameOutPorts.length)this._frameOutPorts[0].framePortPosition=lt.Top,this._frameOutPorts[1].framePortPosition=lt.Bottom;else for(e=0;e<this._frameOutPorts.length;e++){t=this._frameOutPorts[e];0===e?t.framePortPosition=lt.Top:e===this._frameInPorts.length-1?t.framePortPosition=lt.Bottom:t.framePortPosition=lt.Middle}},e.prototype._createFramePorts=function(){for(var e=0,t=this._nodes;e<t.length;e++){(a=t[e]).isVisible=!1}for(var n=0;n<this._exposedOutPorts.length;){if(null===(d=this._exposedOutPorts[n]).node||d.node.enclosingFrameId!=this.id){if(this.removePortFromExposedWithNode(d,this._exposedOutPorts))continue}else if(!this.createOutputPorts(d,d.node)&&this.removePortFromExposedWithNode(d,this._exposedOutPorts))continue;++n}for(n=0;n<this._exposedInPorts.length;){if((d=this._exposedInPorts[n])&&null!==d.node&&d.node.enclosingFrameId==this.id){if(!this.createInputPorts(d,d.node)&&this.removePortFromExposedWithNode(d,this._exposedInPorts))continue}else if(this.removePortFromExposedWithNode(d,this._exposedInPorts))continue;++n}for(var r=0,o=this._nodes;r<o.length;r++){for(var a=o[r],i=function(e){e.exposedPortPosition=l._exposedOutPorts.findIndex((function(t){return t===e})),e.exposedPortPosition<0&&l.createOutputPorts(e,a)&&(e.node.enclosingFrameId=l.id,l._exposedOutPorts.push(e),e.exposedPortPosition=l._exposedOutPorts.length-1)},l=this,s=0,c=a.outputPorts;s<c.length;s++){i(c[s])}for(var u=0,p=a.inputPorts;u<p.length;u++){var d;(d=p[u]).exposedPortPosition=this._exposedInPorts.findIndex((function(e){return e===d})),d.exposedPortPosition<0&&this.createInputPorts(d,a)}}},e.prototype.removePortFromExposedWithNode=function(e,t){var n=t.findIndex((function(t){return t===e}));return n>=0&&(t.splice(n,1),e&&(e.exposedPortPosition=-1),!0)},e.prototype.removePortFromExposedWithLink=function(e,t){var n=t.findIndex((function(t){return t===e.portA})),r=t.findIndex((function(t){return t===e.portB}));if(n>=0){if(!e.portA.exposedOnFrame)return t.splice(n,1),e.portA.exposedPortPosition=-1,!0}else if(r>=0&&e.portB&&!e.portB.exposedOnFrame)return t.splice(r,1),e.portB.exposedPortPosition=-1,!0;return!1},e.prototype.createInputPorts=function(e,t){var n=this;if(e.connectionPoint.isConnected){for(var r=!1,o=0,a=t.links;o<a.length;o++){var i=a[o];if(i.portB===e&&-1===this.nodes.indexOf(i.nodeA)){this._createInputPort(e,t),i.isVisible=!0,r=!0;var l=i.onDisposedObservable.add((function(e){n.removePortFromExposedWithLink(e,n._exposedInPorts)&&n.redrawFramePorts()}));this._onNodeLinkDisposedObservers.push(l)}}if(r)return!0}else if(e.exposedOnFrame)return this._createInputPort(e,t),!0;return!1},e.prototype.createOutputPorts=function(t,n){var r=this;if(t.connectionPoint.hasEndpoints){for(var o=!1,a=0,i=n.links;a<i.length;a++){var l=i[a];if(l.portA===t&&-1===this.nodes.indexOf(l.nodeB)){var s=void 0;if(o)-1===this.nodes.indexOf(l.nodeB)?(l.isVisible=!0,s=this.ports.filter((function(e){return e.connectionPoint===t.connectionPoint}))[0]):s=this.ports.filter((function(e){return e.connectionPoint===t.connectionPoint}))[0];else{o=!0,s=ut.CreateFrameNodePortElement(t.connectionPoint,l.nodeA,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id),this._frameOutPorts.push(s),l.isVisible=!0;var c=l.onDisposedObservable.add((function(e){r.removePortFromExposedWithLink(e,r._exposedOutPorts)&&r.redrawFramePorts()}));this._onNodeLinkDisposedObservers.push(c)}t.delegatedPort=s,this._controlledPorts.push(t)}else if(t.exposedPortPosition>=0&&!o){s=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id);this._frameOutPorts.push(s),t.delegatedPort=s,this._controlledPorts.push(t),o=!0}}if(o)return!0}else if(t.exposedOnFrame){s=ut.CreateFrameNodePortElement(t.connectionPoint,n,this._outputPortContainer,null,this._ownerCanvas.globalState,!1,e._FramePortCounter++,this.id);return this._frameOutPorts.push(s),t.delegatedPort=s,this._controlledPorts.push(t),!0}return!1},e.prototype.redrawFramePorts=function(){this.isCollapsed&&(this._outputPortContainer.innerHTML="",this._inputPortContainer.innerHTML="",this.ports.forEach((function(e){e.dispose()})),this._controlledPorts.forEach((function(e){e.delegatedPort=null,e.refresh()})),this._frameInPorts=[],this._frameOutPorts=[],this._controlledPorts=[],this._createFramePorts(),this._markFramePortPositions(),this.ports.forEach((function(e){return e.node._refreshLinks()})))},Object.defineProperty(e.prototype,"nodes",{get:function(){return this._nodes},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"ports",{get:function(){return this._frameInPorts.concat(this._frameOutPorts)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"name",{get:function(){return this._name},set:function(e){this._name=e,this._headerTextElement.innerHTML=e},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"color",{get:function(){return this._color},set:function(e){this._color=e,this._headerElement.style.background="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 1)"),this._headerElement.style.borderColor="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 1)"),this.element.style.background="rgba(".concat(255*e.r,", ").concat(255*e.g,", ").concat(255*e.b,", 0.7)")},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"x",{get:function(){return this._x},set:function(e){this._x!==e&&(this._x=e,this._gridAlignedX=this._ownerCanvas.getGridPosition(e),this.element.style.left="".concat(this._gridAlignedX,"px"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"y",{get:function(){return this._y},set:function(e){this._y!==e&&(this._y=e,this._gridAlignedY=this._ownerCanvas.getGridPosition(e),this.element.style.top="".concat(this._gridAlignedY,"px"))},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"width",{get:function(){return this._width},set:function(e){if(this._width!==e){var t=e>this._minFrameWidth?e:this._minFrameWidth;this._width=t;var n=this._ownerCanvas.getGridPositionCeil(t+this._gridAlignedX);this.element.style.width="".concat(n-this._gridAlignedX,"px")}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"height",{get:function(){return this._height},set:function(e){if(this._height!==e){this._height=e;var t=this._ownerCanvas.getGridPositionCeil(e+this._gridAlignedY);this.element.style.height="".concat(t-this._gridAlignedY,"px")}},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"comments",{get:function(){return this._comments},set:function(e){e&&!this._comments&&e.length>0?(this.element.style.gridTemplateRows="40px min-content 1fr",this._borderElement.style.gridRow="1 / span 3",this._portContainer.style.gridRow="3",this._commentsElement.classList.add("has-comments")):e||(this.element.style.gridTemplateRows="40px calc(100% - 40px)",this._borderElement.style.gridRow="1 / span 2",this._portContainer.style.gridRow="2",this._commentsElement.classList.remove("has-comments")),(""===e||e&&e.length>=0)&&(this._commentsElement.children[0].innerText=e),this.height=this._borderElement.offsetHeight,this._comments=e,this.updateMinHeightWithComments()},enumerable:!1,configurable:!0}),e.prototype.refresh=function(){this._nodes=[],this._ownerCanvas.globalState.onFrameCreatedObservable.notifyObservers(this)},e.prototype.addNode=function(e){-1===this.nodes.indexOf(e)&&this.nodes.push(e)},e.prototype.removeNode=function(e){var t=this.nodes.indexOf(e);t>-1&&(e.enclosingFrameId=-1,this.nodes.splice(t,1))},e.prototype.syncNode=function(e){this.isCollapsed||(e.isOverlappingFrame(this)?this.addNode(e):this.removeNode(e))},e.prototype.cleanAccumulation=function(){for(var e=0,t=this._nodes;e<t.length;e++){t[e].cleanAccumulation()}this.x=this._ownerCanvas.getGridPosition(this.x),this.y=this._ownerCanvas.getGridPosition(this.y)},e.prototype._onDown=function(e){e.stopPropagation(),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,this._headerTextElement.setPointerCapture(e.pointerId),this._ownerCanvas.globalState.onSelectionChangedObservable.notifyObservers(this),this._ownerCanvas._frameIsMoving=!0,this.move(this._ownerCanvas.getGridPosition(this.x),this._ownerCanvas.getGridPosition(this.y))},e.prototype.move=function(e,t,n){void 0===n&&(n=!0);var r=this.x,o=this.y;this.x=e,this.y=t;for(var a=0,i=this._nodes;a<i.length;a++){var l=i[a];l.x+=this.x-r,l.y+=this.y-o,n&&l.cleanAccumulation(!0)}},e.prototype._onUp=function(e){e.stopPropagation(),this.cleanAccumulation(),this._mouseStartPointX=null,this._mouseStartPointY=null,this._headerTextElement.releasePointerCapture(e.pointerId),this._ownerCanvas._frameIsMoving=!1},e.prototype._moveFrame=function(e,t){this.x+=e,this.y+=t;for(var n=0,r=this._nodes;n<r.length;n++){var o=r[n];o.x+=e,o.y+=t}},e.prototype._onMove=function(e){if(null!==this._mouseStartPointX&&null!==this._mouseStartPointY&&!e.ctrlKey&&!this._frameIsResizing){var t=(e.clientX-this._mouseStartPointX)/this._ownerCanvas.zoom,n=(e.clientY-this._mouseStartPointY)/this._ownerCanvas.zoom;this._moveFrame(t,n),this._mouseStartPointX=e.clientX,this._mouseStartPointY=e.clientY,e.stopPropagation()}},e.prototype.moveFramePortUp=function(e){var t,n,r;if(e.isInput){if(this._inputPortContainer.children.length<2)return;r=Array.from(this._inputPortContainer.childNodes);var o=this._frameInPorts.findIndex((function(t){return t===e}));t=[this._exposedInPorts[o],this._exposedInPorts[o-1]],this._exposedInPorts[o-1]=t[0],this._exposedInPorts[o]=t[1],this._movePortUp(r,e,this._frameInPorts)}else{if(this._outputPortContainer.children.length<2)return;r=Array.from(this._outputPortContainer.childNodes);o=this._frameOutPorts.findIndex((function(t){return t===e}));n=[this._exposedOutPorts[o],this._exposedOutPorts[o-1]],this._exposedOutPorts[o-1]=n[0],this._exposedOutPorts[o]=n[1],this._movePortUp(r,e,this._frameOutPorts)}this.ports.forEach((function(e){return e.node._refreshLinks()}))},e.prototype._movePortUp=function(e,t,n){var r,o,a=e.findIndex((function(e){return e.dataset.framePortId==="".concat(t.framePortId)}));if(0!==a){var i=e[a],l=e[a-1];null===(o=l.parentElement)||void 0===o||o.insertBefore(i,l);var s=n.findIndex((function(e){return e===t}));r=[n[s],n[s-1]],n[s-1]=r[0],n[s]=r[1],2==n.length?(n[1].framePortPosition=lt.Bottom,n[0].framePortPosition=lt.Top):1===a?(n[1].framePortPosition=lt.Middle,n[0].framePortPosition=lt.Top):s===e.length-1?(n[n.length-1].framePortPosition=lt.Bottom,n[n.length-2].framePortPosition=lt.Middle):t.framePortPosition=lt.Middle}},e.prototype.moveFramePortDown=function(e){var t,n,r;if(e.isInput){if(this._inputPortContainer.children.length<2)return;r=Array.from(this._inputPortContainer.childNodes);var o=this._frameInPorts.findIndex((function(t){return t===e}));t=[this._exposedInPorts[o+1],this._exposedInPorts[o]],this._exposedInPorts[o]=t[0],this._exposedInPorts[o+1]=t[1],this._movePortDown(r,e,this._frameInPorts)}else{if(this._outputPortContainer.children.length<2)return;r=Array.from(this._outputPortContainer.childNodes);o=this._frameOutPorts.findIndex((function(t){return t===e}));n=[this._exposedOutPorts[o+1],this._exposedOutPorts[o]],this._exposedOutPorts[o]=n[0],this._exposedOutPorts[o+1]=n[1],this._movePortDown(r,e,this._frameOutPorts)}this.ports.forEach((function(e){return e.node._refreshLinks()}))},e.prototype._movePortDown=function(e,t,n){var r,o,a=e.findIndex((function(e){return e.dataset.framePortId==="".concat(t.framePortId)}));if(a!==e.length-1){var i=e[a],l=e[a+1];null===(o=i.parentElement)||void 0===o||o.insertBefore(l,i);var s=n.findIndex((function(e){return e===t}));r=[n[s+1],n[s]],n[s]=r[0],n[s+1]=r[1],2==n.length?(n[0].framePortPosition=lt.Top,n[1].framePortPosition=lt.Bottom):s===e.length-2?(n[e.length-2].framePortPosition=lt.Middle,n[e.length-1].framePortPosition=lt.Bottom):0===s?(n[0].framePortPosition=lt.Top,n[1].framePortPosition=lt.Middle):t.framePortPosition=lt.Middle}},e.prototype._isResizingTop=function(){return this._resizingDirection===it.Top||this._resizingDirection===it.TopRight||this._resizingDirection===it.TopLeft},e.prototype._isResizingRight=function(){return this._resizingDirection===it.Right||this._resizingDirection===it.TopRight||this._resizingDirection===it.BottomRight},e.prototype._isResizingBottom=function(){return this._resizingDirection===it.Bottom||this._resizingDirection===it.BottomLeft||this._resizingDirection===it.BottomRight},e.prototype._isResizingLeft=function(){return this._resizingDirection===it.Left||this._resizingDirection===it.TopLeft||this._resizingDirection===it.BottomLeft},e.prototype._expandLeft=function(e){var t=parseFloat(this.element.style.width.replace("px","")),n=parseFloat(this.element.style.left.replace("px",""));this.element.style.width="".concat(t-e,"px"),this.element.style.left="".concat(n+e,"px"),this.updateMinHeightWithComments()},e.prototype._expandTop=function(e){var t=parseFloat(this.element.style.height.replace("px","")),n=parseFloat(this.element.style.top.replace("px",""));this.element.style.height="".concat(t-e,"px"),this.element.style.top="".concat(n+e,"px")},e.prototype._expandRight=function(e,t){var n=parseFloat(this.element.style.width.replace("px",""));n+e>20&&(this._mouseStartPointX=t,this.element.style.width="".concat(n+e,"px")),this.updateMinHeightWithComments()},e.prototype._expandBottom=function(e){var t=parseFloat(this.element.style.height.replace("px",""));this.element.style.height="".concat(t+e,"px")},e.prototype.dispose=function(){var e;this._onSelectionChangedObserver&&this._ownerCanvas.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver),this._onGraphNodeRemovalObserver&&this._ownerCanvas.globalState.onGraphNodeRemovalObservable.remove(this._onGraphNodeRemovalObserver),this._onExposePortOnFrameObserver&&this._ownerCanvas.globalState.onExposePortOnFrameObservable.remove(this._onExposePortOnFrameObserver),null===(e=this.element.parentElement)||void 0===e||e.removeChild(this.element),this._ownerCanvas.frames.splice(this._ownerCanvas.frames.indexOf(this),1),this.onExpandStateChanged.clear()},e.prototype.serializePortData=function(e){if(e.length>0)for(var t=0;t<e.length;++t)e[t]&&(e[t].exposedPortPosition=t)},e.prototype.serialize=function(e){return this.serializePortData(this._exposedInPorts),this.serializePortData(this._exposedOutPorts),{x:this._x,y:this._y,width:this._width,height:this._height,color:this._color.asArray(),name:this.name,isCollapsed:!e||this.isCollapsed,blocks:this.nodes.map((function(e){return e.block.uniqueId})),comments:this._comments}},e.prototype.export=function(){var e=this._ownerCanvas.globalState,t=S.Serialize(e.nodeMaterial,e,this);_.DownloadAsFile(e.hostDocument,t,this._name+".json")},e.prototype.adjustPorts=function(){for(var e=0,t=this.nodes;e<t.length;e++){for(var n=t[e],r=0,o=n.outputPorts;r<o.length;r++){(l=o[r]).exposedOnFrame&&-1!==l.exposedPortPosition&&(this._exposedOutPorts[l.exposedPortPosition]=l)}for(var a=0,i=n.inputPorts;a<i.length;a++){var l;(l=i[a]).exposedOnFrame&&-1!==l.exposedPortPosition&&(this._exposedInPorts[l.exposedPortPosition]=l)}}},e.Parse=function(t,n,r){var o=new e(null,n,!0),a=!!t.isCollapsed;if(o.x=t.x,o.y=t.y,o.width=t.width,o.height=t.height,o.name=t.name,o.color=l.Color3.FromArray(t.color),o.comments=t.comments,t.blocks&&r)for(var i=function(){var e=r[u],t=n.nodes.filter((function(t){return t.block.uniqueId===e}));t.length&&(o.nodes.push(t[0]),t[0].enclosingFrameId=o.id)},s=0,c=t.blocks;s<c.length;s++){var u=c[s];i()}else o.refresh();if(o.adjustPorts(),o.isCollapsed=a,a){n._frameIsMoving=!0,o._moveFrame(-(o.width-o.CollapsedWidth)/2,0);var p=t.x-o.x;o._moveFrame(p,0),o.cleanAccumulation();for(var d=0,h=o.nodes;d<h.length;d++){h[d].refresh()}n._frameIsMoving=!1}return o},e._FrameCounter=0,e._FramePortCounter=0,e}();n(129);var dt=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.processInputBlockUpdate=function(e){this.props.globalState.onUpdateRequiredObservable.notifyObservers(e),e.isConstant&&this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.renderInputBlock=function(e){var t=this;switch(e.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var n=isNaN(e.min)||isNaN(e.max)||e.min===e.max;return o.createElement("div",{key:e.uniqueId},e.isBoolean&&o.createElement(E,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",onValueChanged:function(){t.processInputBlockUpdate(e)}}),!e.isBoolean&&n&&o.createElement(P,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}}),!e.isBoolean&&!n&&o.createElement(B,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",step:(e.max-e.min)/100,minimum:e.min,maximum:e.max,globalState:this.props.globalState,onChange:function(){return t.processInputBlockUpdate(e)}}));case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(oe,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(we,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Z,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(ie,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(se,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}})}return null},t.prototype.render=function(){var e=this;return o.createElement(m,{title:"INPUTS"},this.props.inputs.map((function(t){return t.isUniform&&!t.isSystemValue&&t.name?e.renderInputBlock(t):null})))},t}(o.Component),ht=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.onFrameExpandStateChangedObserver=this.props.frame.onExpandStateChanged.add((function(){return e.forceUpdate()}))},t.prototype.componentWillUnmount=function(){this.onFrameExpandStateChangedObserver&&(this.props.frame.onExpandStateChanged.remove(this.onFrameExpandStateChangedObserver),this.onFrameExpandStateChangedObserver=null)},t.prototype.render=function(){var e=this,t=[];return this.props.frame.nodes.forEach((function(e){e.block.isInput&&e.block.visibleOnFrame&&t.push(e.block)})),t=t.sort((function(e,t){return e.name.localeCompare(t.name)})),o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(he,{globalState:this.props.globalState,label:"Name",propertyName:"name",target:this.props.frame}),o.createElement(oe,{globalState:this.props.globalState,label:"Color",target:this.props.frame,propertyName:"color"}),o.createElement(he,{globalState:this.props.globalState,label:"Comments",propertyName:"comments",target:this.props.frame}),!this.props.frame.isCollapsed&&o.createElement(k,{label:"Collapse",onClick:function(){e.props.frame.isCollapsed=!0}}),this.props.frame.isCollapsed&&o.createElement(k,{label:"Expand",onClick:function(){e.props.frame.isCollapsed=!1}}),o.createElement(k,{label:"Export",onClick:function(){e.props.frame.export()}})),o.createElement(dt,{globalState:this.props.globalState,inputs:t})))},t}(o.Component),ft=function(e){function t(t){var n=e.call(this,t)||this;n.state={port:n.props.frameNodePort};var r=n;return n._onSelectionChangedObserver=n.props.globalState.onSelectionChangedObservable.add((function(e){st(e)&&(e.port.onFramePortPositionChangedObservable.clear(),r._onFramePortPositionChangedObserver=e.port.onFramePortPositionChangedObservable.add((function(e){r.setState({port:e})})),r.setState({port:e.port}))})),n._onFramePortPositionChangedObserver=n.props.frameNodePort.onFramePortPositionChangedObservable.add((function(e){r.setState({port:e})})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.frameNodePort.onFramePortPositionChangedObservable.remove(this._onFramePortPositionChangedObserver),this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},t.prototype.render=function(){var e=this;return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(he,{globalState:this.props.globalState,label:"Port Name",propertyName:"portName",target:this.props.frameNodePort}),this.props.frameNodePort.framePortPosition!==lt.Top&&o.createElement(k,{label:"Move Port Up",onClick:function(){e.props.frame.moveFramePortUp(e.props.frameNodePort)}}),this.props.frameNodePort.framePortPosition!==lt.Bottom&&o.createElement(k,{label:"Move Port Down",onClick:function(){e.props.frame.moveFramePortDown(e.props.frameNodePort)}}))))},t}(o.Component),mt=function(e){function t(t){return e.call(this,t)||this}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onSelectionChangedObservable.remove(this._onSelectionChangedObserver)},t.prototype.toggleExposeOnFrame=function(e){this.props.nodePort.exposedOnFrame=e,this.props.globalState.onExposePortOnFrameObservable.notifyObservers(this.props.nodePort.node)},t.prototype.render=function(){var e=this,t=this.props.nodePort.hasLabel()?o.createElement(o.Fragment,null,this.props.nodePort.hasLabel()&&o.createElement(he,{globalState:this.props.globalState,label:"Port Label",propertyName:"portName",target:this.props.nodePort}),-1!==this.props.nodePort.node.enclosingFrameId&&o.createElement(E,{label:"Expose Port on Frame",target:this.props.nodePort,isSelected:function(){return e.props.nodePort.exposedOnFrame},onSelect:function(t){return e.toggleExposeOnFrame(t)},propertyName:"exposedOnFrame",disabled:this.props.nodePort.disabled})):o.createElement(fe,{label:"This node is a constant input node and cannot be exposed to the frame.",value:" "});return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},t)))},t}(o.Component);n(129);var gt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:null,uploadInProgress:!1},n._modeSelect=o.createRef(),n}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.props.globalState.onSelectionChangedObservable.add((function(t){t instanceof rt?e.setState({currentNode:t,currentFrame:null,currentFrameNodePort:null,currentNodePort:null}):t instanceof pt?e.setState({currentNode:null,currentFrame:t,currentFrameNodePort:null,currentNodePort:null}):st(t)?e.setState({currentNode:null,currentFrame:t.frame,currentFrameNodePort:t.port,currentNodePort:null}):t instanceof tt?e.setState({currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:t}):e.setState({currentNode:null,currentFrame:null,currentFrameNodePort:null,currentNodePort:null})})),this._onBuiltObserver=this.props.globalState.onBuiltObservable.add((function(){e.forceUpdate()}))},t.prototype.componentWillUnmount=function(){this.props.globalState.onBuiltObservable.remove(this._onBuiltObserver)},t.prototype.processInputBlockUpdate=function(e){this.props.globalState.onUpdateRequiredObservable.notifyObservers(e),e.isConstant&&this.props.globalState.onRebuildRequiredObservable.notifyObservers(!0)},t.prototype.renderInputBlock=function(e){var t=this;switch(e.type){case l.NodeMaterialBlockConnectionPointTypes.Float:var n=isNaN(e.min)||isNaN(e.max)||e.min===e.max;return o.createElement("div",{key:e.uniqueId},e.isBoolean&&o.createElement(E,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",onValueChanged:function(){t.processInputBlockUpdate(e)}}),!e.isBoolean&&n&&o.createElement(P,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}}),!e.isBoolean&&!n&&o.createElement(B,{key:e.uniqueId,label:e.name,target:e,propertyName:"value",step:(e.max-e.min)/100,minimum:e.min,maximum:e.max,globalState:this.props.globalState,onChange:function(){return t.processInputBlockUpdate(e)}}));case l.NodeMaterialBlockConnectionPointTypes.Color3:return o.createElement(oe,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Color4:return o.createElement(we,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector2:return o.createElement(Z,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector3:return o.createElement(ie,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}});case l.NodeMaterialBlockConnectionPointTypes.Vector4:return o.createElement(se,{globalState:this.props.globalState,key:e.uniqueId,label:e.name,target:e,propertyName:"value",onChange:function(){return t.processInputBlockUpdate(e)}})}return null},t.prototype.load=function(e){var t=this;l.Tools.ReadFile(e,(function(e){var n=new TextDecoder("utf-8");S.Deserialize(JSON.parse(n.decode(e)),t.props.globalState),t.changeMode(t.props.globalState.nodeMaterial.mode,!0,!1)||t.props.globalState.onResetRequiredObservable.notifyObservers(),t.props.globalState.onSelectionChangedObservable.notifyObservers(null)}),void 0,!0)},t.prototype.loadFrame=function(e){var t=this;l.Tools.ReadFile(e,(function(e){var n=new TextDecoder("utf-8"),r=JSON.parse(n.decode(e));S.AddFrameToMaterial(r,t.props.globalState,t.props.globalState.nodeMaterial)}),void 0,!0)},t.prototype.save=function(){var e=S.Serialize(this.props.globalState.nodeMaterial,this.props.globalState);_.DownloadAsFile(this.props.globalState.hostDocument,e,"nodeMaterial.json")},t.prototype.customSave=function(){var e=this;this.setState({uploadInProgress:!0}),this.props.globalState.onLogRequiredObservable.notifyObservers({message:"Saving your material to Babylon.js snippet server...",isError:!1}),this.props.globalState.customSave.action(S.Serialize(this.props.globalState.nodeMaterial,this.props.globalState)).then((function(){e.props.globalState.onLogRequiredObservable.notifyObservers({message:"Material saved successfully",isError:!1}),e.setState({uploadInProgress:!1})})).catch((function(t){e.props.globalState.onLogRequiredObservable.notifyObservers({message:t,isError:!0}),e.setState({uploadInProgress:!1})}))},t.prototype.saveToSnippetServer=function(){var e=this,t=this.props.globalState.nodeMaterial,n=new XMLHttpRequest,r=S.Serialize(t,this.props.globalState);n.onreadystatechange=function(){if(4==n.readyState)if(200==n.status){var r=JSON.parse(n.responseText),a=t.snippetId;t.snippetId=r.id,r.version&&"0"!=r.version&&(t.snippetId+="#"+r.version),e.forceUpdate(),navigator.clipboard&&navigator.clipboard.writeText(t.snippetId);var i=window;i.Playground&&a&&i.Playground.onRequestCodeChangeObservable.notifyObservers({regex:new RegExp(a,"g"),replace:t.snippetId}),e.props.globalState.hostDocument.defaultView.alert("NodeMaterial saved with ID: "+t.snippetId+" (please note that the id was also saved to your clipboard)")}else e.props.globalState.hostDocument.defaultView.alert("Unable to save your node material. It may be too large (".concat((o.payload.length/1024).toFixed(2)," KB) because of embedded textures. Please reduce texture sizes or point to a specific url instead of embedding them and try again."))},n.open("POST",l.NodeMaterial.SnippetUrl+(t.snippetId?"/"+t.snippetId:""),!0),n.setRequestHeader("Content-Type","application/json");var o={payload:JSON.stringify({nodeMaterial:r}),name:"",description:"",tags:""};n.send(JSON.stringify(o))},t.prototype.loadFromSnippet=function(){var e=this,t=this.props.globalState.nodeMaterial,n=t.getScene(),r=window.prompt("Please enter the snippet ID to use");r&&(this.props.globalState.onSelectionChangedObservable.notifyObservers(null),l.NodeMaterial.ParseFromSnippetAsync(r,n,"",t).then((function(){t.build(),e.changeMode(e.props.globalState.nodeMaterial.mode,!0,!1)||e.props.globalState.onResetRequiredObservable.notifyObservers()})).catch((function(t){e.props.globalState.hostDocument.defaultView.alert("Unable to load your node material: "+t)})))},t.prototype.changeMode=function(e,t,n){var o,a;if(void 0===t&&(t=!1),void 0===n&&(n=!0),this.props.globalState.mode===e)return!1;if(!t&&!this.props.globalState.hostDocument.defaultView.confirm("Are your sure? You will lose your current changes (if any) if they are not saved!"))return null===(o=this._modeSelect.current)||void 0===o||o.setValue(this.props.globalState.mode),!1;if(t&&(null===(a=this._modeSelect.current)||void 0===a||a.setValue(e)),n)switch(e){case l.NodeMaterialModes.Material:this.props.globalState.nodeMaterial.setToDefault();break;case l.NodeMaterialModes.PostProcess:this.props.globalState.nodeMaterial.setToDefaultPostProcess();break;case l.NodeMaterialModes.Particle:this.props.globalState.nodeMaterial.setToDefaultParticle();break;case l.NodeMaterialModes.ProceduralTexture:this.props.globalState.nodeMaterial.setToDefaultProceduralTexture()}switch(e){case l.NodeMaterialModes.Material:this.props.globalState.previewType=r.Sphere;break;case l.NodeMaterialModes.Particle:this.props.globalState.previewType=r.Bubbles}return this.props.globalState.listOfCustomPreviewFiles=[],this.props.globalState.previewFile=void 0,l.DataStorage.WriteNumber("PreviewType",this.props.globalState.previewType),this.props.globalState.mode=e,this.props.globalState.onResetRequiredObservable.notifyObservers(),!0},t.prototype.render=function(){var e,t,n=this;if(this.state.currentNode)return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),(null===(e=this.state.currentNode)||void 0===e?void 0:e.renderProperties())||(null===(t=this.state.currentNodePort)||void 0===t?void 0:t.node.renderProperties()));if(this.state.currentFrameNodePort&&this.state.currentFrame)return o.createElement(ft,{globalState:this.props.globalState,frame:this.state.currentFrame,frameNodePort:this.state.currentFrameNodePort});if(this.state.currentNodePort)return o.createElement(mt,{globalState:this.props.globalState,nodePort:this.state.currentNodePort});if(this.state.currentFrame)return o.createElement(ht,{globalState:this.props.globalState,frame:this.state.currentFrame});var r=l.DataStorage.ReadNumber("GridSize",20),a=[{label:"Material",value:l.NodeMaterialModes.Material},{label:"Post Process",value:l.NodeMaterialModes.PostProcess},{label:"Particle",value:l.NodeMaterialModes.Particle},{label:"Procedural",value:l.NodeMaterialModes.ProceduralTexture}],i=[{label:"Combine",value:l.Constants.ALPHA_COMBINE},{label:"One one",value:l.Constants.ALPHA_ONEONE},{label:"Add",value:l.Constants.ALPHA_ADD},{label:"Subtract",value:l.Constants.ALPHA_SUBTRACT},{label:"Multiply",value:l.Constants.ALPHA_MULTIPLY},{label:"Maximized",value:l.Constants.ALPHA_MAXIMIZED},{label:"Pre-multiplied",value:l.Constants.ALPHA_PREMULTIPLIED}];return o.createElement("div",{id:"propertyTab"},o.createElement("div",{id:"header"},o.createElement("img",{id:"logo",src:"https://www.babylonjs.com/Assets/logo-babylonjs-social-twitter.png"}),o.createElement("div",{id:"title"},"NODE MATERIAL EDITOR")),o.createElement("div",null,o.createElement(m,{title:"GENERAL"},o.createElement(ue,{ref:this._modeSelect,label:"Mode",target:this,getSelection:function(e){return n.props.globalState.mode},options:a,onSelect:function(e){return n.changeMode(e)}}),o.createElement(fe,{label:"Version",value:l.Engine.Version}),o.createElement(fe,{label:"Help",value:"doc.babylonjs.com",underline:!0,onLink:function(){return window.open("https://doc.babylonjs.com/how_to/node_material","_blank")}}),o.createElement(he,{label:"Comment",multilines:!0,value:this.props.globalState.nodeMaterial.comment,target:this.props.globalState.nodeMaterial,propertyName:"comment",globalState:this.props.globalState}),o.createElement(k,{label:"Reset to default",onClick:function(){switch(n.props.globalState.mode){case l.NodeMaterialModes.Material:n.props.globalState.nodeMaterial.setToDefault();break;case l.NodeMaterialModes.PostProcess:n.props.globalState.nodeMaterial.setToDefaultPostProcess();break;case l.NodeMaterialModes.Particle:n.props.globalState.nodeMaterial.setToDefaultParticle();break;case l.NodeMaterialModes.ProceduralTexture:n.props.globalState.nodeMaterial.setToDefaultProceduralTexture()}n.props.globalState.onResetRequiredObservable.notifyObservers()}})),o.createElement(m,{title:"UI"},o.createElement(k,{label:"Zoom to fit",onClick:function(){n.props.globalState.onZoomToFitRequiredObservable.notifyObservers()}}),o.createElement(k,{label:"Reorganize",onClick:function(){n.props.globalState.onReOrganizedRequiredObservable.notifyObservers()}})),o.createElement(m,{title:"OPTIONS"},o.createElement(E,{label:"Embed textures when saving",isSelected:function(){return l.DataStorage.ReadBoolean("EmbedTextures",!0)},onSelect:function(e){l.DataStorage.WriteBoolean("EmbedTextures",e)}}),o.createElement(B,{label:"Grid size",minimum:0,maximum:100,step:5,decimalCount:0,globalState:this.props.globalState,directValue:r,onChange:function(e){l.DataStorage.WriteNumber("GridSize",e),n.props.globalState.onGridSizeChanged.notifyObservers(),n.forceUpdate()}}),o.createElement(E,{label:"Show grid",isSelected:function(){return l.DataStorage.ReadBoolean("ShowGrid",!0)},onSelect:function(e){l.DataStorage.WriteBoolean("ShowGrid",e),n.props.globalState.onGridSizeChanged.notifyObservers()}})),o.createElement(m,{title:"FILE"},o.createElement(C,{label:"Load",onClick:function(e){return n.load(e)},accept:".json"}),o.createElement(k,{label:"Save",onClick:function(){n.save()}}),o.createElement(k,{label:"Generate code",onClick:function(){_.DownloadAsFile(n.props.globalState.hostDocument,n.props.globalState.nodeMaterial.generateCode(),"code.txt")}}),o.createElement(k,{label:"Export shaders",onClick:function(){n.props.globalState.nodeMaterial.build(),_.DownloadAsFile(n.props.globalState.hostDocument,n.props.globalState.nodeMaterial.compiledShaders,"shaders.txt")}}),this.props.globalState.customSave&&o.createElement(k,{label:this.props.globalState.customSave.label,isDisabled:this.state.uploadInProgress,onClick:function(){n.customSave()}}),o.createElement(C,{label:"Load Frame",uploadName:"frame-upload",onClick:function(e){return n.loadFrame(e)},accept:".json"})),!this.props.globalState.customSave&&o.createElement(m,{title:"SNIPPET"},this.props.globalState.nodeMaterial.snippetId&&o.createElement(fe,{label:"Snippet ID",value:this.props.globalState.nodeMaterial.snippetId}),o.createElement(k,{label:"Load from snippet server",onClick:function(){return n.loadFromSnippet()}}),o.createElement(k,{label:"Save to snippet server",onClick:function(){n.saveToSnippetServer()}})),o.createElement(m,{title:"TRANSPARENCY"},o.createElement(E,{label:"Force alpha blending",target:this.props.globalState.nodeMaterial,propertyName:"forceAlphaBlending",onValueChanged:function(){return n.props.globalState.onUpdateRequiredObservable.notifyObservers(null)}}),o.createElement(ue,{label:"Alpha mode",options:i,target:this.props.globalState.nodeMaterial,propertyName:"alphaMode",onSelect:function(){return n.props.globalState.onUpdateRequiredObservable.notifyObservers(null)}})),o.createElement(dt,{globalState:this.props.globalState,inputs:this.props.globalState.nodeMaterial.getInputBlocks()})))},t}(o.Component),vt=function(e){function t(){return null!==e&&e.apply(this,arguments)||this}return u(t,e),t.prototype.render=function(){return i.createPortal(this.props.children,this.props.globalState.hostElement)},t}(o.Component);n(326);var bt=function(e,t){this.message=e,this.isError=t},yt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={logs:[]},n}return u(t,e),t.prototype.componentDidMount=function(){var e=this;this.props.globalState.onLogRequiredObservable.add((function(t){var n=e.state.logs;n.push(t),e.setState({logs:n})}))},t.prototype.componentDidUpdate=function(){var e=i.findDOMNode(this.refs["nme-log-console"]);e&&(e.scrollTop=e.scrollHeight)},t.prototype.render=function(){var e=new Date,t=e.getHours(),n=e.getMinutes(),r=e.getSeconds();return o.createElement("div",{id:"nme-log-console",ref:"log-console"},this.state.logs.map((function(e,a){return o.createElement("div",{key:a,className:"log"+(e.isError?" error":"")},t+":"+n+":"+r+": "+e.message)})))},t}(o.Component),xt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={message:"",isError:!1},n.props.globalState.onErrorMessageDialogRequiredObservable.add((function(e){n.setState({message:e,isError:!0})})),n}return u(t,e),t.prototype.render=function(){var e=this;return this.state.message?o.createElement("div",{className:"dialog-container"},o.createElement("div",{className:"dialog"},o.createElement("div",{className:"dialog-message"},this.state.message),o.createElement("div",{className:"dialog-buttons"},o.createElement("div",{className:"dialog-button-ok"+(this.state.isError?" error":""),onClick:function(){return e.setState({message:""})}},"OK")))):null},t}(o.Component),wt=function(){function e(e,t){var n=this;this._nodeMaterial=t.nodeMaterial,this._globalState=t,this._onBuildObserver=this._nodeMaterial.onBuildObservable.add((function(e){var t=e.serialize();n._updatePreview(t)})),this._onPreviewCommandActivatedObserver=t.onPreviewCommandActivated.add((function(e){e&&(n._currentType=-1,n._scene.disableDepthRenderer()),n._refreshPreviewMesh()})),this._onLightUpdatedObserver=t.onLightUpdated.add((function(){n._prepareLights()})),this._onUpdateRequiredObserver=t.onUpdateRequiredObservable.add((function(){var e=n._nodeMaterial.serialize();n._updatePreview(e)})),this._onPreviewBackgroundChangedObserver=t.onPreviewBackgroundChanged.add((function(){n._scene.clearColor=n._globalState.backgroundColor})),this._onAnimationCommandActivatedObserver=t.onAnimationCommandActivated.add((function(){n._handleAnimations()})),this._onBackFaceCullingChangedObserver=t.onBackFaceCullingChanged.add((function(){n._material.backFaceCulling=n._globalState.backFaceCulling})),this._onDepthPrePassChangedObserver=t.onDepthPrePassChanged.add((function(){n._material.needDepthPrePass=n._globalState.depthPrePass})),this._engine=new l.Engine(e,!0),this._scene=new l.Scene(this._engine),this._scene.clearColor=this._globalState.backgroundColor,this._scene.ambientColor=new l.Color3(1,1,1),this._camera=new l.ArcRotateCamera("Camera",0,.8,4,l.Vector3.Zero(),this._scene),this._camera.lowerRadiusLimit=3,this._camera.upperRadiusLimit=10,this._camera.wheelPrecision=20,this._camera.minZ=.1,this._camera.attachControl(!1),this._lightParent=new l.TransformNode("LightParent",this._scene),this._refreshPreviewMesh(),this._engine.runRenderLoop((function(){n._engine.resize(),n._scene.render()}));var r=void 0;this._scene.onPointerObservable.add((function(e){if(!n._globalState.controlCamera)if(e.type!==l.PointerEventTypes.POINTERUP){if(1===e.event.buttons){void 0===r&&(r=e.event.offsetX);var t=.01*(r-e.event.offsetX);n._lightParent.rotation.y+=t,r=e.event.offsetX}}else r=void 0}))}return e.prototype._handleAnimations=function(){if(this._scene.stopAllAnimations(),this._globalState.rotatePreview)for(var e=0,t=this._scene.rootNodes;e<t.length;e++){var n=t[e],r=n;"TransformNode"!==r.getClassName()&&"Mesh"!==r.getClassName()&&"GroundMesh"!==r.getClassName()||(r.rotationQuaternion&&(r.rotation=r.rotationQuaternion.toEulerAngles(),r.rotationQuaternion=null),l.Animation.CreateAndStartAnimation("turnTable",n,"rotation.y",60,1200,r.rotation.y,r.rotation.y+2*Math.PI,1))}},e.prototype._prepareLights=function(){for(var e=0,t=this._scene.lights.slice(0);e<t.length;e++){t[e].dispose()}if(this._globalState.hemisphericLight&&new l.HemisphericLight("Hemispheric light",new l.Vector3(0,1,0),this._scene),this._globalState.directionalLight0){var n=new l.DirectionalLight("Directional light #0",new l.Vector3(.841626576496605,-.2193391004130599,-.49351298337996535),this._scene);n.intensity=.9,n.diffuse=new l.Color3(.9294117647058824,.9725490196078431,.996078431372549),n.specular=new l.Color3(.9294117647058824,.9725490196078431,.996078431372549),n.parent=this._lightParent}if(this._globalState.directionalLight1){var r=new l.DirectionalLight("Directional light #1",new l.Vector3(-.9519937437504213,-.24389315636999764,-.1849974057546125),this._scene);r.intensity=1.2,r.specular=new l.Color3(.9803921568627451,.9529411764705882,.7725490196078432),r.diffuse=new l.Color3(.9803921568627451,.9529411764705882,.7725490196078432),r.parent=this._lightParent}},e.prototype._prepareScene=function(){var e,t,n=this;switch(this._camera.useFramingBehavior=this._globalState.mode===l.NodeMaterialModes.Material,this._globalState.mode){case l.NodeMaterialModes.Material:this._prepareLights();var o=this._camera.getBehaviorByName("Framing");setTimeout((function(){if(o.framingTime=0,o.elevationReturnTime=-1,n._scene.meshes.length){var e=n._scene.getWorldExtends();n._camera.lowerRadiusLimit=null,n._camera.upperRadiusLimit=null,o.zoomOnBoundingInfo(e.min,e.max)}n._camera.pinchPrecision=200/n._camera.radius,n._camera.upperRadiusLimit=5*n._camera.radius})),this._camera.wheelDeltaPercentage=.01,this._camera.pinchDeltaPercentage=.01,this._handleAnimations();break;case l.NodeMaterialModes.PostProcess:case l.NodeMaterialModes.ProceduralTexture:this._camera.radius=4,this._camera.upperRadiusLimit=10;break;case l.NodeMaterialModes.Particle:this._camera.radius=this._globalState.previewType===r.Explosion?50:this._globalState.previewType===r.DefaultParticleSystem?6:20,this._camera.upperRadiusLimit=5e3,this._globalState.particleSystemBlendMode=null!==(t=null===(e=this._particleSystem)||void 0===e?void 0:e.blendMode)&&void 0!==t?t:l.ParticleSystem.BLENDMODE_STANDARD}var a=this._nodeMaterial.serialize();this._updatePreview(a)},e.prototype._refreshPreviewMesh=function(){var e=this;if(this._currentType!==this._globalState.previewType||this._currentType===r.Custom){if(this._currentType=this._globalState.previewType,this._meshes&&this._meshes.length)for(var t=0,n=this._meshes;t<n.length;t++){n[t].dispose()}this._meshes=[],this._layer&&(this._layer.dispose(),this._layer=null);for(var o=0,a=this._scene.lights.slice(0);o<a.length;o++){a[o].dispose()}if(this._engine.releaseEffects(),this._particleSystem&&(this._particleSystem.onBeforeDrawParticlesObservable.clear(),this._particleSystem.onDisposeObservable.clear(),this._particleSystem.stop(),this._particleSystem.dispose(),this._particleSystem=null),l.SceneLoader.ShowLoadingScreen=!1,this._globalState.onIsLoadingChanged.notifyObservers(!0),this._globalState.mode===l.NodeMaterialModes.Material)switch(this._globalState.previewType){case r.Box:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","roundedCube.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Sphere:this._meshes.push(Object(l.CreateSphere)("dummy-sphere",{segments:32,diameter:2},this._scene));break;case r.Torus:this._meshes.push(Object(l.CreateTorus)("dummy-torus",{diameter:2,thickness:.5,tessellation:32},this._scene));break;case r.Cylinder:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","roundedCylinder.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Plane:var i=Object(l.CreateGround)("dummy-plane",{width:2,height:2,subdivisions:128},this._scene);i.scaling.y=-1,i.rotation.x=Math.PI,this._meshes.push(i);break;case r.ShaderBall:return void l.SceneLoader.AppendAsync("https://models.babylonjs.com/","shaderBall.glb",this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}));case r.Custom:return void l.SceneLoader.AppendAsync("file:",this._globalState.previewFile,this._scene).then((function(){var t;(t=e._meshes).push.apply(t,e._scene.meshes),e._prepareScene()}))}else if(this._globalState.mode===l.NodeMaterialModes.ProceduralTexture)this._layer=new l.Layer("proceduralLayer",null,this._scene);else if(this._globalState.mode===l.NodeMaterialModes.Particle)switch(this._globalState.previewType){case r.DefaultParticleSystem:this._particleSystem=l.ParticleHelper.CreateDefault(new l.Vector3(0,0,0),500,this._scene),this._particleSystem.blendMode=l.DataStorage.ReadNumber("DefaultParticleSystemBlendMode",l.ParticleSystem.BLENDMODE_ONEONE),this._particleSystem.start();break;case r.Bubbles:this._particleSystem=new l.ParticleSystem("particles",4e3,this._scene),this._particleSystem.particleTexture=new l.Texture("https://assets.babylonjs.com/particles/textures/explosion/Flare.png",this._scene),this._particleSystem.minSize=.1,this._particleSystem.maxSize=1,this._particleSystem.minLifeTime=.5,this._particleSystem.maxLifeTime=5,this._particleSystem.minEmitPower=.5,this._particleSystem.maxEmitPower=3,this._particleSystem.createBoxEmitter(new l.Vector3(-1,1,-1),new l.Vector3(1,1,1),new l.Vector3(-.1,-.1,-.1),new l.Vector3(.1,.1,.1)),this._particleSystem.emitRate=100,this._particleSystem.blendMode=l.DataStorage.ReadNumber("DefaultParticleSystemBlendMode",l.ParticleSystem.BLENDMODE_ONEONE),this._particleSystem.color1=new l.Color4(1,1,0,1),this._particleSystem.color2=new l.Color4(1,.5,0,1),this._particleSystem.gravity=new l.Vector3(0,-1,0),this._particleSystem.start();break;case r.Explosion:return void this._loadParticleSystem(this._globalState.previewType,1);case r.Fire:case r.Rain:case r.Smoke:return void this._loadParticleSystem(this._globalState.previewType);case r.Custom:return void Object(l.ReadFile)(this._globalState.previewFile,(function(t){e._particleSystem=l.ParticleSystem.Parse(JSON.parse(t),e._scene,""),e._particleSystem.start(),e._prepareScene()}),void 0,!1,(function(e){console.log(e)}))}this._prepareScene()}},e.prototype._loadParticleSystem=function(e,t,n){var o=this;void 0===t&&(t=0),void 0===n&&(n=!0);var a="";switch(e){case r.Explosion:a="explosion";break;case r.Fire:a="fire";break;case r.Rain:a="rain";break;case r.Smoke:a="smoke"}l.ParticleHelper.CreateAsync(a,this._scene).then((function(r){for(var a=0;a<r.systems.length;++a)a==t?(o._particleSystem=r.systems[a],o._particleSystem.disposeOnStop=!0,o._particleSystem.onDisposeObservable.add((function(){o._loadParticleSystem(e,t,!1)})),o._particleSystem.start()):r.systems[a].dispose();if(n)o._prepareScene();else{var i=o._nodeMaterial.serialize();o._updatePreview(i)}}))},e.prototype._forceCompilationAsync=function(e,t){return e.forceCompilationAsync(t)},e.prototype._updatePreview=function(e){var t=this;try{var n=l.NodeMaterial.IgnoreTexturesAtLoadTime;l.NodeMaterial.IgnoreTexturesAtLoadTime=!1;var r=l.NodeMaterial.Parse(e,this._scene);switch(l.NodeMaterial.IgnoreTexturesAtLoadTime=n,r.backFaceCulling=this._globalState.backFaceCulling,r.needDepthPrePass=this._globalState.depthPrePass,this._postprocess&&(this._postprocess.dispose(this._camera),this._postprocess=null),this._proceduralTexture&&(this._proceduralTexture.dispose(),this._proceduralTexture=null),this._globalState.mode){case l.NodeMaterialModes.PostProcess:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._postprocess=r.createPostProcess(this._camera,1,l.Constants.TEXTURE_NEAREST_SAMPLINGMODE,this._engine);var o=r.getBlockByPredicate((function(e){return e instanceof l.CurrentScreenBlock}));o&&this._postprocess&&(this._postprocess.externalTextureSamplerBinding=!0,this._postprocess.onApplyObservable.add((function(e){e.setTexture("textureSampler",o.texture)}))),this._material&&this._material.dispose(!1,!0),this._material=r;break;case l.NodeMaterialModes.ProceduralTexture:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._proceduralTexture=r.createProceduralTexture(512,this._scene),this._material&&this._material.dispose(!1,!0),this._layer&&(this._layer.texture=this._proceduralTexture);break;case l.NodeMaterialModes.Particle:this._globalState.onIsLoadingChanged.notifyObservers(!1),this._particleSystem.onBeforeDrawParticlesObservable.clear(),this._particleSystem.onBeforeDrawParticlesObservable.add((function(e){var t=r.getBlockByPredicate((function(e){return e instanceof l.ParticleTextureBlock}));t&&t.texture&&e&&e.setTexture("diffuseSampler",t.texture)})),r.createEffectForParticles(this._particleSystem),this._particleSystem.blendMode=this._globalState.particleSystemBlendMode,this._material&&this._material.dispose(!1,!0),this._material=r;break;default:if(this._meshes.length){var a=this._meshes.map((function(e){return t._forceCompilationAsync(r,e)}));Promise.all(a).then((function(){for(var e=0,n=t._meshes;e<n.length;e++){n[e].material=r}t._material&&t._material.dispose(!1,!0),t._material=r,t._globalState.onIsLoadingChanged.notifyObservers(!1)})).catch((function(e){t._globalState.onLogRequiredObservable.notifyObservers(new bt("Shader compilation error:\r\n"+e,!0)),t._globalState.onIsLoadingChanged.notifyObservers(!1)}))}else this._material=r}}catch(e){this._globalState.onIsLoadingChanged.notifyObservers(!1)}},e.prototype.dispose=function(){this._nodeMaterial.onBuildObservable.remove(this._onBuildObserver),this._globalState.onPreviewCommandActivated.remove(this._onPreviewCommandActivatedObserver),this._globalState.onUpdateRequiredObservable.remove(this._onUpdateRequiredObserver),this._globalState.onAnimationCommandActivated.remove(this._onAnimationCommandActivatedObserver),this._globalState.onPreviewBackgroundChanged.remove(this._onPreviewBackgroundChangedObserver),this._globalState.onBackFaceCullingChanged.remove(this._onBackFaceCullingChangedObserver),this._globalState.onDepthPrePassChanged.remove(this._onDepthPrePassChangedObserver),this._globalState.onLightUpdated.remove(this._onLightUpdatedObserver),this._material&&this._material.dispose(!1,!0),this._camera.dispose();for(var e=0,t=this._meshes;e<t.length;e++){t[e].dispose()}this._scene.dispose(),this._engine.dispose()},e}(),kt=n(328),_t=n(329),Ct=n(330),St=n(331),Et=function(e){function t(t){var n=e.call(this,t)||this;return n.colorInputRef=o.createRef(),n.filePickerRef=o.createRef(),n._onResetRequiredObserver=n.props.globalState.onResetRequiredObservable.add((function(){n.forceUpdate()})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onResetRequiredObservable.remove(this._onResetRequiredObserver)},t.prototype.changeMeshType=function(e){this.props.globalState.previewType!==e&&(this.props.globalState.previewType=e,this.props.globalState.onPreviewCommandActivated.notifyObservers(!1),l.DataStorage.WriteNumber("PreviewType",e),this.forceUpdate())},t.prototype.useCustomMesh=function(e){var t=e.target.files;if(t&&t.length){var n=t[0];this.props.globalState.previewFile=n,this.props.globalState.previewType=r.Custom,this.props.globalState.onPreviewCommandActivated.notifyObservers(!1),this.props.globalState.listOfCustomPreviewFiles=[n],this.forceUpdate()}this.filePickerRef.current&&(this.filePickerRef.current.value="")},t.prototype.onPopUp=function(){this.props.togglePreviewAreaComponent()},t.prototype.changeAnimation=function(){this.props.globalState.rotatePreview=!this.props.globalState.rotatePreview,this.props.globalState.onAnimationCommandActivated.notifyObservers(),this.forceUpdate()},t.prototype.changeBackground=function(e){var t=l.Color3.FromHexString(e);l.DataStorage.WriteNumber("BackgroundColorR",t.r),l.DataStorage.WriteNumber("BackgroundColorG",t.g),l.DataStorage.WriteNumber("BackgroundColorB",t.b);var n=l.Color4.FromColor3(t,1);this.props.globalState.backgroundColor=n,this.props.globalState.onPreviewBackgroundChanged.notifyObservers()},t.prototype.changeBackgroundClick=function(){var e;null===(e=this.colorInputRef.current)||void 0===e||e.click()},t.prototype.render=function(){var e=this,t=[{label:"Cube",value:r.Box},{label:"Cylinder",value:r.Cylinder},{label:"Plane",value:r.Plane},{label:"Shader ball",value:r.ShaderBall},{label:"Sphere",value:r.Sphere},{label:"Load...",value:r.Custom+1}],n=[{label:"Default",value:r.DefaultParticleSystem},{label:"Bubbles",value:r.Bubbles},{label:"Explosion",value:r.Explosion},{label:"Fire",value:r.Fire},{label:"Rain",value:r.Rain},{label:"Smoke",value:r.Smoke},{label:"Load...",value:r.Custom+1}];this.props.globalState.listOfCustomPreviewFiles.length>0&&(t.splice(0,0,{label:"Custom",value:r.Custom}),n.splice(0,0,{label:"Custom",value:r.Custom}));var a=this.props.globalState.mode===l.NodeMaterialModes.Particle?n:t,i=this.props.globalState.mode===l.NodeMaterialModes.Particle?".json":".gltf, .glb, .babylon, .obj";return o.createElement("div",{id:"preview-mesh-bar"},(this.props.globalState.mode===l.NodeMaterialModes.Material||this.props.globalState.mode===l.NodeMaterialModes.Particle)&&o.createElement(o.Fragment,null,o.createElement(ue,{label:"",options:a,target:this.props.globalState,propertyName:"previewType",noDirectUpdate:!0,onSelect:function(t){var n;t!==r.Custom+1?e.changeMeshType(t):null===(n=e.filePickerRef.current)||void 0===n||n.click()}}),o.createElement("div",{style:{display:"none"},title:"Preview with a custom mesh"},o.createElement("input",{ref:this.filePickerRef,id:"file-picker",type:"file",onChange:function(t){return e.useCustomMesh(t)},accept:i}))),this.props.globalState.mode===l.NodeMaterialModes.Material&&o.createElement(o.Fragment,null,o.createElement("div",{title:"Turn-table animation",onClick:function(){return e.changeAnimation()},className:"button",id:"play-button"},this.props.globalState.rotatePreview?o.createElement("img",{src:Ct,alt:""}):o.createElement("img",{src:St,alt:""})),o.createElement("div",{id:"color-picker-button",title:"Background color",className:"button align",onClick:function(t){return e.changeBackgroundClick()}},o.createElement("img",{src:_t,alt:"",id:"color-picker-image"}),o.createElement("input",{ref:this.colorInputRef,id:"color-picker",type:"color",onChange:function(t){return e.changeBackground(t.target.value)}}))),o.createElement("div",{title:"Open preview in new window",id:"preview-new-window",onClick:function(){return e.onPopUp()},className:"button"},o.createElement("img",{src:kt,alt:""})))},t}(o.Component),Pt=n(332),Tt=n(333),Bt=n(334),Nt=n(335),Ot=n(336),Lt=function(e){function t(t){var n=e.call(this,t)||this;return n.state={isLoading:!0},n._onIsLoadingChangedObserver=n.props.globalState.onIsLoadingChanged.add((function(e){return n.setState({isLoading:e})})),n._onResetRequiredObserver=n.props.globalState.onResetRequiredObservable.add((function(){n.forceUpdate()})),n}return u(t,e),t.prototype.componentWillUnmount=function(){this.props.globalState.onIsLoadingChanged.remove(this._onIsLoadingChangedObserver),this.props.globalState.onResetRequiredObservable.remove(this._onResetRequiredObserver)},t.prototype.changeBackFaceCulling=function(e){this.props.globalState.backFaceCulling=e,l.DataStorage.WriteBoolean("BackFaceCulling",e),this.props.globalState.onBackFaceCullingChanged.notifyObservers(),this.forceUpdate()},t.prototype.changeDepthPrePass=function(e){this.props.globalState.depthPrePass=e,l.DataStorage.WriteBoolean("DepthPrePass",e),this.props.globalState.onDepthPrePassChanged.notifyObservers(),this.forceUpdate()},t.prototype.changeParticleSystemBlendMode=function(e){this.props.globalState.particleSystemBlendMode!==e&&(this.props.globalState.particleSystemBlendMode=e,this.props.globalState.onUpdateRequiredObservable.notifyObservers(null),l.DataStorage.WriteNumber("DefaultParticleSystemBlendMode",e),this.forceUpdate())},t.prototype.render=function(){var e=this,t=[{label:"Add",value:l.ParticleSystem.BLENDMODE_ADD},{label:"Multiply",value:l.ParticleSystem.BLENDMODE_MULTIPLY},{label:"Multiply Add",value:l.ParticleSystem.BLENDMODE_MULTIPLYADD},{label:"OneOne",value:l.ParticleSystem.BLENDMODE_ONEONE},{label:"Standard",value:l.ParticleSystem.BLENDMODE_STANDARD}];return o.createElement(o.Fragment,null,o.createElement("div",{id:"preview",style:{height:this.props.width+"px"}},o.createElement("canvas",{id:"preview-canvas"}),o.createElement("div",{className:"waitPanel"+(this.state.isLoading?"":" hidden")},"Please wait, loading...")),this.props.globalState.mode===l.NodeMaterialModes.Particle&&o.createElement("div",{id:"preview-config-bar",className:"extended"},o.createElement(ue,{label:"Blend mode",options:t,target:this.props.globalState,propertyName:"particleSystemBlendMode",noDirectUpdate:!0,onSelect:function(t){e.changeParticleSystemBlendMode(t)}})),this.props.globalState.mode===l.NodeMaterialModes.Material&&o.createElement(o.Fragment,null,o.createElement("div",{id:"preview-config-bar"},o.createElement("div",{title:"Render without back face culling",onClick:function(){return e.changeBackFaceCulling(!e.props.globalState.backFaceCulling)},className:"button back-face"+(this.props.globalState.backFaceCulling?"":" selected")},o.createElement("img",{src:Pt,alt:""})),o.createElement("div",{title:"Render with depth pre-pass",onClick:function(){return e.changeDepthPrePass(!e.props.globalState.depthPrePass)},className:"button depth-pass"+(this.props.globalState.depthPrePass?" selected":"")},o.createElement("img",{src:Tt,alt:""})),o.createElement("div",{title:"Turn on/off hemispheric light",onClick:function(){e.props.globalState.hemisphericLight=!e.props.globalState.hemisphericLight,l.DataStorage.WriteBoolean("HemisphericLight",e.props.globalState.hemisphericLight),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button hemispheric-light"+(this.props.globalState.hemisphericLight?" selected":"")},o.createElement("img",{src:Bt,alt:""})),o.createElement("div",{title:"Turn on/off direction light #1",onClick:function(){e.props.globalState.directionalLight1=!e.props.globalState.directionalLight1,l.DataStorage.WriteBoolean("DirectionalLight1",e.props.globalState.directionalLight1),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button direction-light-1"+(this.props.globalState.directionalLight1?" selected":"")},o.createElement("img",{src:Nt,alt:""})),o.createElement("div",{title:"Turn on/off direction light #0",onClick:function(){e.props.globalState.directionalLight0=!e.props.globalState.directionalLight0,l.DataStorage.WriteBoolean("DirectionalLight0",e.props.globalState.directionalLight0),e.props.globalState.onLightUpdated.notifyObservers(),e.forceUpdate()},className:"button direction-light-0"+(this.props.globalState.directionalLight0?" selected":"")},o.createElement("img",{src:Ot,alt:""})))))},t}(o.Component),Mt=function(){function e(){}return e.CreatePopup=function(e,t,n,r){var o=this;void 0===n&&(n=300),void 0===r&&(r=800);var a={width:n,height:r,top:(window.innerHeight-n)/2+window.screenY,left:(window.innerWidth-r)/2+window.screenX},i=Object.keys(a).map((function(e){return e+"="+a[e]})).join(","),l=window.open("",e,i);if(!l)return null;var s=l.document,c=s.createElement("link");c.rel="stylesheet",c.href="https://use.typekit.net/cta4xsb.css",s.head.appendChild(c),s.title=e,s.body.style.width="100%",s.body.style.height="100%",s.body.style.margin="0",s.body.style.padding="0";var u=s.createElement("div");return u.style.width="100%",u.style.height="100%",u.style.margin="0",u.style.padding="0",l.document.body.appendChild(u),this._CopyStyles(window.document,s),setTimeout((function(){o._CopyStyles(window.document,s)}),0),this[t]=l,u},e._CopyStyles=function(e,t){for(var n=0;n<e.styleSheets.length;n++){var r=e.styleSheets[n];try{if(r.cssRules){for(var o=e.createElement("style"),a=0,i=r.cssRules;a<i.length;a++){var l=i[a];o.appendChild(e.createTextNode(l.cssText))}t.head.appendChild(o)}else if(r.href){var s=e.createElement("link");s.rel="stylesheet",s.href=r.href,t.head.appendChild(s)}}catch(e){}}},e}();n(337);var Rt=function(e){function t(t){var n=e.call(this,t)||this;return n.NodeWidth=100,n._leftWidth=l.DataStorage.ReadNumber("LeftWidth",200),n._rightWidth=l.DataStorage.ReadNumber("RightWidth",300),n._blocks=new Array,n._copiedNodes=[],n._copiedFrame=null,n._mouseLocationX=0,n._mouseLocationY=0,n.handlePopUp=function(){n.setState({showPreviewPopUp:!0}),n.createPopUp(),n.props.globalState.hostWindow.addEventListener("beforeunload",n.handleClosingPopUp)},n.handleClosingPopUp=function(){n._previewManager&&n._previewManager.dispose(),n._popUpWindow.close(),n.setState({showPreviewPopUp:!1},(function(){return n.initiatePreviewArea()}))},n.initiatePreviewArea=function(e){void 0===e&&(e=n.props.globalState.hostDocument.getElementById("preview-canvas")),n._previewManager=new wt(e,n.props.globalState)},n.createPopUp=function(){var e=p({embedHostWidth:"100%"},{original:!0,popup:!0,overlay:!1,embedMode:!1,enableClose:!0,handleResize:!0,enablePopup:!0}),t=n.createPopupWindow("PREVIEW AREA","_PreviewHostWindow");if(t){t.addEventListener("beforeunload",n.handleClosingPopUp);var r=t.document.getElementById("node-editor-graph-root");n.createPreviewMeshControlHost(e,r),n.createPreviewHost(e,r),r&&(n.fixPopUpStyles(r.ownerDocument),n.initiatePreviewArea(r.ownerDocument.getElementById("preview-canvas")))}},n.createPopupWindow=function(e,t,r,o){void 0===r&&(r=500),void 0===o&&(o=500);var a={width:r,height:o,top:(n.props.globalState.hostWindow.innerHeight-r)/2+window.screenY,left:(n.props.globalState.hostWindow.innerWidth-o)/2+window.screenX},i=Object.keys(a).map((function(e){return e+"="+a[e]})).join(","),l=n.props.globalState.hostWindow.open("",e,i);if(!l)return null;var s=l.document;s.title=e,s.body.style.width="100%",s.body.style.height="100%",s.body.style.margin="0",s.body.style.padding="0";var c=s.createElement("div");return c.style.width="100%",c.style.height="100%",c.style.margin="0",c.style.padding="0",c.style.display="grid",c.style.gridTemplateRows="40px auto",c.id="node-editor-graph-root",c.className="right-panel popup",l.document.body.appendChild(c),Mt._CopyStyles(n.props.globalState.hostWindow.document,s),n[t]=l,n._popUpWindow=l,l},n.createPreviewMeshControlHost=function(e,t){if(t){var r=t.ownerDocument.createElement("div");r.id="PreviewMeshControl-host",r.style.width=e.embedHostWidth||"auto",t.appendChild(r);var a=o.createElement(Et,{globalState:n.props.globalState,togglePreviewAreaComponent:n.handlePopUp});i.render(a,r)}},n.createPreviewHost=function(e,t){if(t){var r=t.ownerDocument.createElement("div");r.id="PreviewAreaComponent-host",r.style.width=e.embedHostWidth||"auto",r.style.height="100%",r.style.overflow="hidden",r.style.display="grid",r.style.gridRow="2",r.style.gridTemplateRows="auto 40px",r.style.gridTemplateRows="calc(100% - 40px) 40px",t.appendChild(r),n._previewHost=r,e.overlay||(n._previewHost.style.position="relative")}if(n._previewHost){var a=o.createElement(Lt,{globalState:n.props.globalState,width:200});i.render(a,n._previewHost)}},n.fixPopUpStyles=function(e){var t=e.getElementById("preview");t&&(t.style.height="auto",t.style.gridRow="1");var n=e.getElementById("preview-config-bar");n&&(n.style.gridRow="2");var r=e.getElementById("preview-new-window");r&&(r.style.display="none");var o=e.getElementById("preview-mesh-bar");o&&(o.style.gridTemplateColumns="auto 1fr 40px 40px")},n.state={showPreviewPopUp:!1},n.props.globalState.onRebuildRequiredObservable.add((function(e){n.props.globalState.nodeMaterial&&n.buildMaterial(e)})),n.props.globalState.onResetRequiredObservable.add((function(){n.build(),n.props.globalState.nodeMaterial&&n.buildMaterial()})),n.props.globalState.onImportFrameObservable.add((function(e){var t=e.editorData.frames[0];n.props.globalState.nodeMaterial.attachedBlocks.slice(-t.blocks.length).forEach((function(e){n.createNodeFromObject(e)})),n._graphCanvas.addFrame(t),n.reOrganize(n.props.globalState.nodeMaterial.editorData,!0)})),n.props.globalState.onZoomToFitRequiredObservable.add((function(){n.zoomToFit()})),n.props.globalState.onReOrganizedRequiredObservable.add((function(){n.reOrganize()})),n.props.globalState.onGetNodeFromBlock=function(e){return n._graphCanvas.findNodeFromBlock(e)},n.props.globalState.hostDocument.addEventListener("keydown",(function(e){if((46===e.keyCode||8===e.keyCode)&&!n.props.globalState.blockKeyboardEvents){for(var t=0,r=s=n._graphCanvas.selectedNodes;t<r.length;t++){var o=r[t];o.dispose();var a=o.block;n.props.globalState.nodeMaterial.removeBlock(a),(l=n._blocks.indexOf(a))>-1&&n._blocks.splice(l,1)}if(n._graphCanvas.selectedLink&&n._graphCanvas.selectedLink.dispose(),n._graphCanvas.selectedFrame){var i=n._graphCanvas.selectedFrame;if(i.isCollapsed){for(;i.nodes.length>0;){var l;a=i.nodes[0].block;n.props.globalState.nodeMaterial.removeBlock(a),(l=n._blocks.indexOf(a))>-1&&n._blocks.splice(l,1),i.nodes[0].dispose()}i.isCollapsed=!1}else i.nodes.forEach((function(e){e.enclosingFrameId=-1}));n._graphCanvas.selectedFrame.dispose()}return n.props.globalState.onSelectionChangedObservable.notifyObservers(null),void n.props.globalState.onRebuildRequiredObservable.notifyObservers(!1)}if(e.ctrlKey&&!n.props.globalState.blockKeyboardEvents)if("c"===e.key||"C"===e.key){if(n._copiedNodes=[],n._copiedFrame=null,n._graphCanvas.selectedFrame)return n._copiedFrame=n._graphCanvas.selectedFrame,void n._copiedFrame.serialize(!0);var s;if(!(s=n._graphCanvas.selectedNodes).length)return;if(!s[0].block)return;n._copiedNodes=s.slice(0)}else if("v"===e.key||"V"===e.key){var c=n.props.globalState.hostDocument.querySelector(".diagram-container"),u=n._graphCanvas.zoom,p=(n._mouseLocationY-c.offsetTop-n._graphCanvas.y-20)/u;if(n._copiedFrame){var d=new pt(null,n._graphCanvas,!0);n._graphCanvas.frames.push(d),d.width=n._copiedFrame.width,d.height=n._copiedFrame.height,d.width,d.name=n._copiedFrame.name,d.color=n._copiedFrame.color;var h=(n._mouseLocationX-c.offsetLeft-n._graphCanvas.x)/u;if(d.x=h-d.width/2,d.y=p,n._copiedFrame.nodes.length){h=d.x+n._copiedFrame.nodes[0].x-n._copiedFrame.x,p=d.y+n._copiedFrame.nodes[0].y-n._copiedFrame.y,n._graphCanvas._frameIsMoving=!0;var f=n.pasteSelection(n._copiedFrame.nodes,h,p);if(f)for(var m=0,g=f;m<g.length;m++){var v=g[m];d.syncNode(v)}n._graphCanvas._frameIsMoving=!1}return d.adjustPorts(),n._copiedFrame.isCollapsed&&(d.isCollapsed=!0),void n.props.globalState.onSelectionChangedObservable.notifyObservers(d)}if(!n._copiedNodes.length)return;var b=(n._mouseLocationX-c.offsetLeft-n._graphCanvas.x-n.NodeWidth)/u;n.pasteSelection(n._copiedNodes,b,p,!0)}}),!1),n}return u(t,e),t.prototype.createNodeFromObject=function(e,t){if(void 0===t&&(t=!0),-1!==this._blocks.indexOf(e))return this._graphCanvas.nodes.filter((function(t){return t.block===e}))[0];if(this._blocks.push(e),-1===this.props.globalState.nodeMaterial.attachedBlocks.indexOf(e)&&this.props.globalState.nodeMaterial.attachedBlocks.push(e),e.isFinalMerger&&this.props.globalState.nodeMaterial.addOutputNode(e),e.inputs.length)for(var n=0,r=e.inputs;n<r.length;n++){(l=r[n]).isConnected&&t&&this.createNodeFromObject(l.sourceBlock)}var o=this._graphCanvas.appendBlock(e);if(e.inputs.length&&t)for(var a=0,i=e.inputs;a<i.length;a++){var l;(l=i[a]).isConnected&&this._graphCanvas.connectPorts(l.connectedPoint,l)}return o},t.prototype.addValueNode=function(e){var t=Fe.GetConnectionNodeTypeFromString(e),n=new l.InputBlock(e,void 0,t);return this.createNodeFromObject(n)},t.prototype.componentDidMount=function(){var e=this;this.props.globalState.hostDocument&&(this._graphCanvas=this.refs.graphCanvas,this._previewManager=new wt(this.props.globalState.hostDocument.getElementById("preview-canvas"),this.props.globalState),this.props.globalState._previewManager=this._previewManager),-1!==navigator.userAgent.indexOf("Mobile")&&((this.props.globalState.hostDocument||document).querySelector(".blocker").style.visibility="visible"),this.props.globalState.onPopupClosedObservable.addOnce((function(){e.componentWillUnmount()})),this.build()},t.prototype.componentWillUnmount=function(){this.props.globalState.hostDocument&&this.props.globalState.hostDocument.removeEventListener("keyup",this._onWidgetKeyUpPointer,!1),this._previewManager&&(this._previewManager.dispose(),this._previewManager=null)},t.prototype.reconnectNewNodes=function(e,t,n,r){if(!r[e]){for(var o=t[e],a=o.block,i=n[e],l=function(){var e=i.block.inputs[c],o=a.inputs[c];if(!e.isConnected)return"continue";var l=e.connectedPoint.ownerBlock,u=n.filter((function(e){return e.block===l}));if(u.length>0){var p=u[0],d=n.indexOf(p);s.reconnectNewNodes(d,t,n,r);var h=l.outputs.indexOf(e.connectedPoint);t[d].block.outputs[h].connectTo(o)}else e._connectedPoint.connectTo(o);s._graphCanvas.connectPorts(o.connectedPoint,o)},s=this,c=0;c<i.block.inputs.length;c++)l();o.refresh(),r[e]=!0}},t.prototype.pasteSelection=function(e,t,n,r){void 0===r&&(r=!1);var o=null,a=[];e=e.slice(),this.props.globalState.onSelectionChangedObservable.notifyObservers(null);for(var i=0,l=e;i<l.length;i++){var s=l[i],c=s.block;if(c){var u=c.clone(this.props.globalState.nodeMaterial.getScene());if(!u)return;var p=this.createNodeFromObject(u,!1),d=0,h=0;o?(d=t+s.x-o.x,h=n+s.y-o.y):(o=s,d=t,h=n),p.x=d,p.y=h,p.cleanAccumulation(),a.push(p),r&&this.props.globalState.onSelectionChangedObservable.notifyObservers(p)}}for(var f=new Array(a.length),m=0;m<a.length;m++)this.reconnectNewNodes(m,a,e,f);return a},t.prototype.zoomToFit=function(){this._graphCanvas.zoomToFit()},t.prototype.buildMaterial=function(e){if(void 0===e&&(e=!0),this.props.globalState.nodeMaterial){try{this.props.globalState.nodeMaterial.options.emitComments=!0,this.props.globalState.nodeMaterial.build(!0,void 0,e),this.props.globalState.onLogRequiredObservable.notifyObservers(new bt("Node material build successful",!1))}catch(e){this.props.globalState.onLogRequiredObservable.notifyObservers(new bt(e,!0))}S.UpdateLocations(this.props.globalState.nodeMaterial,this.props.globalState),this.props.globalState.onBuiltObservable.notifyObservers()}},t.prototype.build=function(){var e=this.props.globalState.nodeMaterial.editorData;this._graphCanvas._isLoading=!0,e instanceof Array&&(e={locations:e}),this._blocks=[],this._graphCanvas.reset(),this.props.globalState.nodeMaterial&&this.loadGraph(),this.reOrganize(e)},t.prototype.loadGraph=function(){var e=this,t=this.props.globalState.nodeMaterial;t._vertexOutputNodes.forEach((function(t){e.createNodeFromObject(t,!0)})),t._fragmentOutputNodes.forEach((function(t){e.createNodeFromObject(t,!0)})),t.attachedBlocks.forEach((function(t){e.createNodeFromObject(t,!0)})),t.attachedBlocks.forEach((function(t){if(t.inputs.length)for(var n=0,r=t.inputs;n<r.length;n++){var o=r[n];o.isConnected&&e._graphCanvas.connectPorts(o.connectedPoint,o)}}))},t.prototype.showWaitScreen=function(){var e;null===(e=this.props.globalState.hostDocument.querySelector(".wait-screen"))||void 0===e||e.classList.remove("hidden")},t.prototype.hideWaitScreen=function(){var e;null===(e=this.props.globalState.hostDocument.querySelector(".wait-screen"))||void 0===e||e.classList.add("hidden")},t.prototype.reOrganize=function(e,t){var n=this;void 0===e&&(e=null),void 0===t&&(t=!1),this.showWaitScreen(),this._graphCanvas._isLoading=!0,setTimeout((function(){if(e&&e.locations){for(var r=0,o=e.locations;r<o.length;r++)for(var a=o[r],i=0,l=n._graphCanvas.nodes;i<l.length;i++){if((u=l[i]).block&&u.block.uniqueId===a.blockId){u.x=a.x,u.y=a.y,u.cleanAccumulation();break}}t||n._graphCanvas.processEditorData(e)}else n._graphCanvas.distributeGraph();n._graphCanvas._isLoading=!1;for(var s=0,c=n._graphCanvas.nodes;s<c.length;s++){var u;(u=c[s])._refreshLinks()}n.hideWaitScreen()}))},t.prototype.onPointerDown=function(e){this._startX=e.clientX,this._moveInProgress=!0,e.currentTarget.setPointerCapture(e.pointerId)},t.prototype.onPointerUp=function(e){this._moveInProgress=!1,e.currentTarget.releasePointerCapture(e.pointerId)},t.prototype.resizeColumns=function(e,t){if(void 0===t&&(t=!0),this._moveInProgress){var n=e.clientX-this._startX,r=e.currentTarget.ownerDocument.getElementById("node-editor-graph-root");t?(this._leftWidth+=n,this._leftWidth=Math.max(150,Math.min(400,this._leftWidth)),l.DataStorage.WriteNumber("LeftWidth",this._leftWidth)):(this._rightWidth-=n,this._rightWidth=Math.max(250,Math.min(500,this._rightWidth)),l.DataStorage.WriteNumber("RightWidth",this._rightWidth),r.ownerDocument.getElementById("preview").style.height=this._rightWidth+"px"),r.style.gridTemplateColumns=this.buildColumnLayout(),this._startX=e.clientX}},t.prototype.buildColumnLayout=function(){return"".concat(this._leftWidth,"px 4px calc(100% - ").concat(this._leftWidth+8+this._rightWidth,"px) 4px ").concat(this._rightWidth,"px")},t.prototype.emitNewBlock=function(e){var t,n,r=this,o=e.dataTransfer.getData("babylonjs-material-node");if(o.indexOf("CustomBlock")>-1){if(!(a=localStorage.getItem(o)))return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("Error loading custom block");if(!(n=JSON.parse(a)))return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("Error parsing custom block")}else if(o.indexOf("Custom")>-1){var a;if(a=localStorage.getItem(o)){var i=JSON.parse(a),s=(e.clientX-e.currentTarget.offsetLeft-this._graphCanvas.x-this.NodeWidth)/this._graphCanvas.zoom,c=(e.clientY-e.currentTarget.offsetTop-this._graphCanvas.y-20)/this._graphCanvas.zoom,u=i.editorData.frames[0].x,p=i.editorData.frames[0].y;i.editorData.frames[0].x=s,i.editorData.frames[0].y=c;for(var d=0,h=i.editorData.locations;d<h.length;d++){var f=h[d];f.x+=s-u,f.y+=c-p}return S.AddFrameToMaterial(i,this.props.globalState,this.props.globalState.nodeMaterial),this._graphCanvas.frames[this._graphCanvas.frames.length-1].cleanAccumulation(),void this.forceUpdate()}}if(-1===o.indexOf("Block"))t=this.addValueNode(o);else{var m;if(n?(m=new l.CustomBlock("")).options=n:m=Fe.GetBlockFromString(o,this.props.globalState.nodeMaterial.getScene(),this.props.globalState.nodeMaterial),m.isUnique)for(var g=m.getClassName(),v=0,b=this._blocks;v<b.length;v++){var y=b[v];if(y!==m&&y.getClassName()===g)return void this.props.globalState.onErrorMessageDialogRequiredObservable.notifyObservers("You can only have one ".concat(g," per graph"))}m.autoConfigure(this.props.globalState.nodeMaterial),t=this.createNodeFromObject(m)}var x=e.clientX-e.currentTarget.offsetLeft-this._graphCanvas.x-this.NodeWidth,w=e.clientY-e.currentTarget.offsetTop-this._graphCanvas.y-20;t.x=x/this._graphCanvas.zoom,t.y=w/this._graphCanvas.zoom,t.cleanAccumulation(),this.props.globalState.onSelectionChangedObservable.notifyObservers(null),this.props.globalState.onSelectionChangedObservable.notifyObservers(t);var k=t.block;x-=this.NodeWidth+150,k.inputs.forEach((function(e){if(e.connectedPoint){var t=r._graphCanvas.nodes.filter((function(t){return t.block===e.connectedPoint.ownerBlock}))[0];0===t.x&&0===t.y&&(t.x=x/r._graphCanvas.zoom,t.y=w/r._graphCanvas.zoom,t.cleanAccumulation(),w+=80)}})),this.forceUpdate()},t.prototype.render=function(){var e=this;return o.createElement(vt,{globalState:this.props.globalState},o.createElement("div",{id:"node-editor-graph-root",style:{gridTemplateColumns:this.buildColumnLayout()},onMouseMove:function(t){e._mouseLocationX=t.pageX,e._mouseLocationY=t.pageY},onMouseDown:function(t){"INPUT"!==t.target.nodeName&&(e.props.globalState.blockKeyboardEvents=!1)}},o.createElement(w,{globalState:this.props.globalState}),o.createElement("div",{id:"leftGrab",onPointerDown:function(t){return e.onPointerDown(t)},onPointerUp:function(t){return e.onPointerUp(t)},onPointerMove:function(t){return e.resizeColumns(t)}}),o.createElement("div",{className:"diagram-container",onDrop:function(t){e.emitNewBlock(t)},onDragOver:function(e){e.preventDefault()}},o.createElement(ct,{ref:"graphCanvas",globalState:this.props.globalState,onEmitNewBlock:function(t){return e.createNodeFromObject(t)}})),o.createElement("div",{id:"rightGrab",onPointerDown:function(t){return e.onPointerDown(t)},onPointerUp:function(t){return e.onPointerUp(t)},onPointerMove:function(t){return e.resizeColumns(t,!1)}}),o.createElement("div",{className:"right-panel"},o.createElement(gt,{globalState:this.props.globalState}),this.state.showPreviewPopUp?null:o.createElement(Et,{globalState:this.props.globalState,togglePreviewAreaComponent:this.handlePopUp}),this.state.showPreviewPopUp?null:o.createElement(Lt,{globalState:this.props.globalState,width:this._rightWidth})),o.createElement(yt,{globalState:this.props.globalState})),o.createElement(xt,{globalState:this.props.globalState}),o.createElement("div",{className:"blocker"},"Node Material Editor runs only on desktop"),o.createElement("div",{className:"wait-screen hidden"},"Processing...please wait"))},t}(o.Component),It=function(){function e(){}return e.Show=function(e){this._CurrentState&&((c=Mt["node-editor"])&&c.close());var t=e.hostElement;t||(t=Mt.CreatePopup("BABYLON.JS NODE EDITOR","node-editor",1e3,800));var n=new s;n.nodeMaterial=e.nodeMaterial,n.mode=e.nodeMaterial.mode,n.hostElement=t,n.hostDocument=t.ownerDocument,n.customSave=e.customSave,n.hostWindow=t.ownerDocument.defaultView;var a=o.createElement(Rt,{globalState:n});i.render(a,t),e.customLoadObservable&&e.customLoadObservable.add((function(t){S.Deserialize(t,n),n.mode=e.nodeMaterial.mode,n.onResetRequiredObservable.notifyObservers(),n.onBuiltObservable.notifyObservers()})),this._CurrentState=n,n.hostWindow.addEventListener("beforeunload",(function(){n.onPopupClosedObservable.notifyObservers()}));var c=Mt["node-editor"];n.nodeMaterial&&c&&(n.nodeMaterial.getScene().onDisposeObservable.addOnce((function(){c&&c.close()})),window.onbeforeunload=function(){var e=Mt["node-editor"];e&&e.close()}),window.addEventListener("beforeunload",(function(){l.DataStorage.ReadNumber("PreviewType",r.Box)===r.Custom&&l.DataStorage.WriteNumber("PreviewType",n.mode===l.NodeMaterialModes.Material?r.Box:r.Bubbles)}))},e}()},function(e,t){e.exports="data:image/svg+xml,%3Csvg viewBox='0 0 24 24' version='1.1' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink' width='24' height='24'%3E %3C!-- Generator: Sketch 59.1 (86144) - https://sketch.com --%3E %3Ctitle%3Eic_fluent_copy_24_regular%3C/title%3E %3Cdesc%3ECreated with Sketch.%3C/desc%3E %3Cg id='🔍-Product-Icons' stroke='none' stroke-width='1' fill='none' fill-rule='evenodd'%3E %3Cg id='ic_fluent_copy_24_regular' fill='white' fill-rule='nonzero'%3E %3Cpath d='M5.50280381,4.62704038 L5.5,6.75 L5.5,17.2542087 C5.5,19.0491342 6.95507456,20.5042087 8.75,20.5042087 L17.3662868,20.5044622 C17.057338,21.3782241 16.2239751,22.0042087 15.2444057,22.0042087 L8.75,22.0042087 C6.12664744,22.0042087 4,19.8775613 4,17.2542087 L4,6.75 C4,5.76928848 4.62744523,4.93512464 5.50280381,4.62704038 Z M17.75,2 C18.9926407,2 20,3.00735931 20,4.25 L20,17.25 C20,18.4926407 18.9926407,19.5 17.75,19.5 L8.75,19.5 C7.50735931,19.5 6.5,18.4926407 6.5,17.25 L6.5,4.25 C6.5,3.00735931 7.50735931,2 8.75,2 L17.75,2 Z M17.75,3.5 L8.75,3.5 C8.33578644,3.5 8,3.83578644 8,4.25 L8,17.25 C8,17.6642136 8.33578644,18 8.75,18 L17.75,18 C18.1642136,18 18.5,17.6642136 18.5,17.25 L18.5,4.25 C18.5,3.83578644 18.1642136,3.5 17.75,3.5 Z' id='🎨-Color'%3E%3C/path%3E %3C/g%3E %3C/g%3E %3C/svg%3E"},function(e,t,n){"use strict";var r=n(6);e.exports=o;function o(e){this._isDirected=!r.has(e,"directed")||e.directed,this._isMultigraph=!!r.has(e,"multigraph")&&e.multigraph,this._isCompound=!!r.has(e,"compound")&&e.compound,this._label=void 0,this._defaultNodeLabelFn=r.constant(void 0),this._defaultEdgeLabelFn=r.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children["\0"]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}function a(e,t){e[t]?e[t]++:e[t]=1}function i(e,t){--e[t]||delete e[t]}function l(e,t,n,o){var a=""+t,i=""+n;if(!e&&a>i){var l=a;a=i,i=l}return a+""+i+""+(r.isUndefined(o)?"\0":o)}function s(e,t,n,r){var o=""+t,a=""+n;if(!e&&o>a){var i=o;o=a,a=i}var l={v:o,w:a};return r&&(l.name=r),l}function c(e,t){return l(e,t.v,t.w,t.name)}o.prototype._nodeCount=0,o.prototype._edgeCount=0,o.prototype.isDirected=function(){return this._isDirected},o.prototype.isMultigraph=function(){return this._isMultigraph},o.prototype.isCompound=function(){return this._isCompound},o.prototype.setGraph=function(e){return this._label=e,this},o.prototype.graph=function(){return this._label},o.prototype.setDefaultNodeLabel=function(e){return r.isFunction(e)||(e=r.constant(e)),this._defaultNodeLabelFn=e,this},o.prototype.nodeCount=function(){return this._nodeCount},o.prototype.nodes=function(){return r.keys(this._nodes)},o.prototype.sources=function(){var e=this;return r.filter(this.nodes(),(function(t){return r.isEmpty(e._in[t])}))},o.prototype.sinks=function(){var e=this;return r.filter(this.nodes(),(function(t){return r.isEmpty(e._out[t])}))},o.prototype.setNodes=function(e,t){var n=arguments,o=this;return r.each(e,(function(e){n.length>1?o.setNode(e,t):o.setNode(e)})),this},o.prototype.setNode=function(e,t){return r.has(this._nodes,e)?(arguments.length>1&&(this._nodes[e]=t),this):(this._nodes[e]=arguments.length>1?t:this._defaultNodeLabelFn(e),this._isCompound&&(this._parent[e]="\0",this._children[e]={},this._children["\0"][e]=!0),this._in[e]={},this._preds[e]={},this._out[e]={},this._sucs[e]={},++this._nodeCount,this)},o.prototype.node=function(e){return this._nodes[e]},o.prototype.hasNode=function(e){return r.has(this._nodes,e)},o.prototype.removeNode=function(e){var t=this;if(r.has(this._nodes,e)){var n=function(e){t.removeEdge(t._edgeObjs[e])};delete this._nodes[e],this._isCompound&&(this._removeFromParentsChildList(e),delete this._parent[e],r.each(this.children(e),(function(e){t.setParent(e)})),delete this._children[e]),r.each(r.keys(this._in[e]),n),delete this._in[e],delete this._preds[e],r.each(r.keys(this._out[e]),n),delete this._out[e],delete this._sucs[e],--this._nodeCount}return this},o.prototype.setParent=function(e,t){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(r.isUndefined(t))t="\0";else{for(var n=t+="";!r.isUndefined(n);n=this.parent(n))if(n===e)throw new Error("Setting "+t+" as parent of "+e+" would create a cycle");this.setNode(t)}return this.setNode(e),this._removeFromParentsChildList(e),this._parent[e]=t,this._children[t][e]=!0,this},o.prototype._removeFromParentsChildList=function(e){delete this._children[this._parent[e]][e]},o.prototype.parent=function(e){if(this._isCompound){var t=this._parent[e];if("\0"!==t)return t}},o.prototype.children=function(e){if(r.isUndefined(e)&&(e="\0"),this._isCompound){var t=this._children[e];if(t)return r.keys(t)}else{if("\0"===e)return this.nodes();if(this.hasNode(e))return[]}},o.prototype.predecessors=function(e){var t=this._preds[e];if(t)return r.keys(t)},o.prototype.successors=function(e){var t=this._sucs[e];if(t)return r.keys(t)},o.prototype.neighbors=function(e){var t=this.predecessors(e);if(t)return r.union(t,this.successors(e))},o.prototype.isLeaf=function(e){return 0===(this.isDirected()?this.successors(e):this.neighbors(e)).length},o.prototype.filterNodes=function(e){var t=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});t.setGraph(this.graph());var n=this;r.each(this._nodes,(function(n,r){e(r)&&t.setNode(r,n)})),r.each(this._edgeObjs,(function(e){t.hasNode(e.v)&&t.hasNode(e.w)&&t.setEdge(e,n.edge(e))}));var o={};return this._isCompound&&r.each(t.nodes(),(function(e){t.setParent(e,function e(r){var a=n.parent(r);return void 0===a||t.hasNode(a)?(o[r]=a,a):a in o?o[a]:e(a)}(e))})),t},o.prototype.setDefaultEdgeLabel=function(e){return r.isFunction(e)||(e=r.constant(e)),this._defaultEdgeLabelFn=e,this},o.prototype.edgeCount=function(){return this._edgeCount},o.prototype.edges=function(){return r.values(this._edgeObjs)},o.prototype.setPath=function(e,t){var n=this,o=arguments;return r.reduce(e,(function(e,r){return o.length>1?n.setEdge(e,r,t):n.setEdge(e,r),r})),this},o.prototype.setEdge=function(){var e,t,n,o,i=!1,c=arguments[0];"object"==typeof c&&null!==c&&"v"in c?(e=c.v,t=c.w,n=c.name,2===arguments.length&&(o=arguments[1],i=!0)):(e=c,t=arguments[1],n=arguments[3],arguments.length>2&&(o=arguments[2],i=!0)),e=""+e,t=""+t,r.isUndefined(n)||(n=""+n);var u=l(this._isDirected,e,t,n);if(r.has(this._edgeLabels,u))return i&&(this._edgeLabels[u]=o),this;if(!r.isUndefined(n)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(e),this.setNode(t),this._edgeLabels[u]=i?o:this._defaultEdgeLabelFn(e,t,n);var p=s(this._isDirected,e,t,n);return e=p.v,t=p.w,Object.freeze(p),this._edgeObjs[u]=p,a(this._preds[t],e),a(this._sucs[e],t),this._in[t][u]=p,this._out[e][u]=p,this._edgeCount++,this},o.prototype.edge=function(e,t,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n);return this._edgeLabels[r]},o.prototype.hasEdge=function(e,t,n){var o=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n);return r.has(this._edgeLabels,o)},o.prototype.removeEdge=function(e,t,n){var r=1===arguments.length?c(this._isDirected,arguments[0]):l(this._isDirected,e,t,n),o=this._edgeObjs[r];return o&&(e=o.v,t=o.w,delete this._edgeLabels[r],delete this._edgeObjs[r],i(this._preds[t],e),i(this._sucs[e],t),delete this._in[t][r],delete this._out[e][r],this._edgeCount--),this},o.prototype.inEdges=function(e,t){var n=this._in[e];if(n){var o=r.values(n);return t?r.filter(o,(function(e){return e.v===t})):o}},o.prototype.outEdges=function(e,t){var n=this._out[e];if(n){var o=r.values(n);return t?r.filter(o,(function(e){return e.w===t})):o}},o.prototype.nodeEdges=function(e,t){var n=this.inEdges(e,t);if(n)return n.concat(this.outEdges(e,t))}},function(e,t,n){var r=n(16)(n(10),"Map");e.exports=r},function(e,t,n){var r=n(166),o=n(173),a=n(175),i=n(176),l=n(177);function s(e){var t=-1,n=null==e?0:e.length;for(this.clear();++t<n;){var r=e[t];this.set(r[0],r[1])}}s.prototype.clear=r,s.prototype.delete=o,s.prototype.get=a,s.prototype.has=i,s.prototype.set=l,e.exports=s},function(e,t){e.exports=function(e,t){for(var n=-1,r=null==e?0:e.length;++n<r&&!1!==t(e[n],n,e););return e}},function(e,t){e.exports=function(e){return e.webpackPolyfill||(e.deprecate=function(){},e.paths=[],e.children||(e.children=[]),Object.defineProperty(e,"loaded",{enumerable:!0,get:function(){return e.l}}),Object.defineProperty(e,"id",{enumerable:!0,get:function(){return e.i}}),e.webpackPolyfill=1),e}},function(e,t){e.exports=function(e){return"number"==typeof e&&e>-1&&e%1==0&&e<=9007199254740991}},function(e,t,n){(function(e){var r=n(77),o=t&&!t.nodeType&&t,a=o&&"object"==typeof e&&e&&!e.nodeType&&e,i=a&&a.exports===o&&r.process,l=function(){try{var e=a&&a.require&&a.require("util").types;return e||i&&i.binding&&i.binding("util")}catch(e){}}();e.exports=l}).call(this,n(57)(e))},function(e,t,n){var r=n(42),o=n(183),a=Object.prototype.hasOwnProperty;e.exports=function(e){if(!r(e))return o(e);var t=[];for(var n in Object(e))a.call(e,n)&&"constructor"!=n&&t.push(n);return t}},function(e,t,n){var r=n(84),o=n(85),a=Object.prototype.propertyIsEnumerable,i=Object.getOwnPropertySymbols,l=i?function(e){return null==e?[]:(e=Object(e),r(i(e),(function(t){return a.call(e,t)})))}:o;e.exports=l},function(e,t){e.exports=function(e,t){for(var n=-1,r=t.length,o=e.length;++n<r;)e[o+n]=t[n];return e}},function(e,t,n){var r=n(90);e.exports=function(e){var t=new e.constructor(e.byteLength);return new r(t).set(new r(e)),t}},function(e,t){e.exports=function(e){return function(){return e}}},function(e,t,n){var r=n(66),o=n(15);e.exports=function(e,t){return e&&r(e,t,o)}},function(e,t,n){var r=n(202)();e.exports=r},function(e,t){e.exports=function(e){var t=-1,n=Array(e.size);return e.forEach((function(e){n[++t]=e})),n}},function(e,t,n){var r=n(4),o=n(25),a=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,i=/^\w*$/;e.exports=function(e,t){if(r(e))return!1;var n=typeof e;return!("number"!=n&&"symbol"!=n&&"boolean"!=n&&null!=e&&!o(e))||(i.test(e)||!a.test(e)||null!=t&&e in Object(t))}},function(e,t,n){var r=n(62),o=n(236);e.exports=function e(t,n,a,i,l){var s=-1,c=t.length;for(a||(a=o),l||(l=[]);++s<c;){var u=t[s];n>0&&a(u)?n>1?e(u,n-1,a,i,l):r(l,u):i||(l[l.length]=u)}return l}},function(e,t,n){var r=n(25);e.exports=function(e,t,n){for(var o=-1,a=e.length;++o<a;){var i=e[o],l=t(i);if(null!=l&&(void 0===s?l==l&&!r(l):n(l,s)))var s=l,c=i}return c}},function(e,t,n){e.exports={graphlib:n(9),layout:n(260),debug:n(321),util:{time:n(5).time,notime:n(5).notime},version:n(322)}},function(e,t,n){"use strict";
25
25
  /*
26
26
  object-assign
27
27
  (c) Sindre Sorhus