@eva/plugin-ui 2.1.0-beta.1

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e,t=require("@eva/eva.js"),n=require("@eva/plugin-renderer-graphics"),i=require("pixi.js"),a=require("@pixi/ui");exports.UIShapeType=void 0,(e=exports.UIShapeType||(exports.UIShapeType={})).RECT="rect",e.CIRCLE="circle",e.ELLIPSE="ellipse",e.ROUNDED_RECT="roundedRect";class r extends t.Component{constructor(){super(...arguments),this.componentName="UI",this.shapes=[]}static getInspectorMetadata(){const e=[{name:"fill",type:"color",isArray:!1},{name:"stroke",type:"color",isArray:!1},{name:"lineWidth",type:"number",isArray:!1},{name:"alpha",type:"number",isArray:!1},{name:"x",type:"number",isArray:!1},{name:"y",type:"number",isArray:!1},{name:"width",type:"number",isArray:!1},{name:"height",type:"number",isArray:!1},{name:"radius",type:"number",isArray:!1}];return{name:r.componentName,type:"object",isArray:!1,isFolder:!0,children:[{name:"componentName",type:"string",isArray:!1},{name:"shapes",type:"object",isArray:!0,children:[{name:"type",type:"string",isArray:!1},{name:"style",type:"object",isArray:!1,children:e}]},{name:"type",type:"string",isArray:!1},{name:"style",type:"object",isArray:!1,children:e}]}}init(e){var t;e&&(this.componentName=null!==(t=e.componentName)&&void 0!==t?t:this.componentName,e.shapes?this.shapes=e.shapes:e.type&&e.style&&(this.shapes=[{type:e.type,style:e.style}]))}awake(){this.redraw()}start(){this.redraw(),queueMicrotask(()=>this.redraw())}parseLinearGradient(e){const t=e.match(/linear-gradient\s*\(\s*([^,]+),\s*(.+)\)/);if(!t)return null;const n=t[1].trim(),i=parseFloat(n),a=[],r=t[2].split(/,(?![^(]*\))/);for(const e of r){const t=e.trim().match(/(.+?)\s+(\d+)%/);if(t){const e=t[1].trim(),n=parseFloat(t[2])/100;a.push({color:e,position:n})}}return{angle:i,colorStops:a}}createGradient(e,t,n,a,r=0,s=0){let l=0,o=0,d=0,c=0;if(0===e)l=.5,o=1,d=.5,c=0;else if(90===e)l=0,o=.5,d=1,c=.5;else if(180===e)l=.5,o=0,d=.5,c=1;else if(270===e)l=1,o=.5,d=0,c=.5;else{const t=(90-e)*(Math.PI/180),i=.5,r=.5,s=Math.max(n,a),p=Math.sqrt(n*n+a*a)/(2*s);l=i-Math.cos(t)*p,o=r-Math.sin(t)*p,d=i+Math.cos(t)*p,c=r+Math.sin(t)*p}const p=new i.FillGradient(l,o,d,c);return t.forEach(e=>{p.addColorStop(e.position,e.color)}),p}getShapeBounds(e,t){const n=t.x||0,i=t.y||0;switch(e){case exports.UIShapeType.RECT:case exports.UIShapeType.ROUNDED_RECT:return{width:t.width,height:t.height,x:n,y:i};case exports.UIShapeType.CIRCLE:return{width:2*t.radius,height:2*t.radius,x:n,y:i};case exports.UIShapeType.ELLIPSE:return{width:t.width,height:t.height,x:n,y:i};default:return{width:100,height:100,x:n,y:i}}}redraw(){if(!this.gameObject)return;let e=this.gameObject.getComponent("Graphics");e||(e=this.gameObject.addComponent(new n.Graphics));const t=e.graphics;t?(t.clear(),this.shapes.forEach(e=>{this.drawShape(t,e.type,e.style)})):console.warn("Graphics component has no graphics instance")}drawShape(e,t,n){switch(void 0!==n.alpha&&(e.alpha=n.alpha),n.stroke&&void 0!==n.lineWidth?e.setStrokeStyle({color:n.stroke,width:n.lineWidth}):n.stroke&&e.setStrokeStyle({color:n.stroke,width:1}),t){case exports.UIShapeType.RECT:this.drawRect(e,n);break;case exports.UIShapeType.CIRCLE:this.drawCircle(e,n);break;case exports.UIShapeType.ELLIPSE:this.drawEllipse(e,n);break;case exports.UIShapeType.ROUNDED_RECT:this.drawRoundedRect(e,n);break;default:console.warn(`Unknown shape type: ${t}`)}if(n.fill)if("string"==typeof n.fill&&n.fill.includes("linear-gradient")){const i=this.parseLinearGradient(n.fill);if(i){const a=this.getShapeBounds(t,n),r=this.createGradient(i.angle,i.colorStops,a.width,a.height,a.x,a.y);e.fill(r)}else console.warn(`Failed to parse gradient: ${n.fill}`),e.fill("#000000")}else e.fill(n.fill)}drawRect(e,t){const n=t.x||0,i=t.y||0;e.rect(n,i,t.width,t.height)}drawCircle(e,t){const n=t.x||0,i=t.y||0;e.circle(n,i,t.radius)}drawEllipse(e,t){const n=t.x||0,i=t.y||0;e.ellipse(n,i,t.width/2,t.height/2)}drawRoundedRect(e,t){const n=t.x||0,i=t.y||0,a=t.radius||0;e.roundRect(n,i,t.width,t.height,a)}addShape(e,t){this.shapes.push({type:e,style:t}),this.redraw()}clearShapes(){this.shapes=[],this.redraw()}updateShape(e,t,n){e>=0&&e<this.shapes.length&&(this.shapes[e]={type:t,style:n},this.redraw())}removeShape(e){e>=0&&e<this.shapes.length&&(this.shapes.splice(e,1),this.redraw())}getShapeCount(){return this.shapes.length}getShape(e){return e>=0&&e<this.shapes.length?this.shapes[e]:null}setAlpha(e){this.shapes.forEach(t=>{t.style.alpha=e}),this.redraw()}setFill(e){this.shapes.forEach(t=>{t.style.fill=e}),this.redraw()}setStroke(e,t=1){this.shapes.forEach(n=>{n.style.stroke=e,n.style.lineWidth=t}),this.redraw()}}function s(e,t){var n,i,a;if(!e||!t)return null;const r=function(e){var t,n,i,a,r,s;const l=null===(n=(t=e).getSystem)||void 0===n?void 0:n.call(t,"Renderer");if(l)return l;const o=null!==(i=e.systems)&&void 0!==i?i:[];for(const e of o){const t=null!==(r=null===(a=null==e?void 0:e.constructor)||void 0===a?void 0:a.systemName)&&void 0!==r?r:null===(s=null==e?void 0:e.constructor)||void 0===s?void 0:s.name;if("Renderer"===t||"RendererSystem"===t)return e;if("Renderer"===(null==e?void 0:e.name)||"RendererSystem"===(null==e?void 0:e.name))return e;if(null==e?void 0:e.containerManager)return e}return null}(e),s=null!==(n=null==r?void 0:r.containerManager)&&void 0!==n?n:null===(i=null==r?void 0:r.rendererManager)||void 0===i?void 0:i.containerManager;return(null==s?void 0:s.getContainer)&&null!==(a=s.getContainer(t.id))&&void 0!==a?a:null}function l(e,t,n){const i=s(e,t);if(!i)return!1;try{return n.parent&&n.parent!==i&&n.parent.removeChild(n),"function"==typeof i.addChildAt?i.addChildAt(n,0):i.addChild(n),!0}catch(e){return!1}}function o(e,t,n){if(!n)return;const i=s(e,t);try{i&&n.parent===i&&i.removeChild(n),"function"==typeof n.destroy&&n.destroy({children:!0})}catch(e){}}function d(e,t,n,i=4){const a=s(e,t);a?n(a):i<=0||queueMicrotask(()=>d(e,t,n,i-1))}function c(e,t,n){var a;if(!n)return null;if("entityName"in n){const i=function(e,t){var n,i,a;if("function"==typeof e.findChildByName)try{const n=e.findChildByName(t);if(n)return n}catch(e){}const r=null!==(i=null===(n=e.transform)||void 0===n?void 0:n.children)&&void 0!==i?i:[];for(const e of r)if((null===(a=null==e?void 0:e.gameObject)||void 0===a?void 0:a.name)===t)return e.gameObject;return null}(t,n.entityName);if(i){const t=s(e,i);if(t){try{t.parent&&t.parent.removeChild(t)}catch(e){}return t}}return n.fallback?c(e,t,n.fallback):null}if("ui"in n)return null!==(a=function(e){var t,n,a;if(!e||!e.type)return null;const r=new i.Graphics,{style:s}=e,l=null!==(t=s.width)&&void 0!==t?t:0,o=null!==(n=s.height)&&void 0!==n?n:0,d=null!==(a=s.radius)&&void 0!==a?a:0;switch(e.type){case"rect":r.rect(0,0,l,o);break;case"roundedRect":r.roundRect(0,0,l,o,d);break;case"circle":r.circle(d,d,d);break;case"ellipse":r.ellipse(l/2,o/2,l/2,o/2)}void 0!==s.fill&&r.fill(s.fill);void 0!==s.stroke&&void 0!==s.lineWidth&&(r.setStrokeStyle({color:s.stroke,width:s.lineWidth}),r.stroke());void 0!==s.alpha&&(r.alpha=s.alpha);return r}(n.ui))&&void 0!==a?a:n.fallback?c(e,t,n.fallback):null;if("texture"in n){const a=function(e,t){var n,a;const r=null!==(n=null==e?void 0:e.resource)&&void 0!==n?n:null;if(null===(a=null==r?void 0:r.instances)||void 0===a?void 0:a[t]){const e=r.instances[t];if(e instanceof i.Texture)return e;if((null==e?void 0:e.image)instanceof i.Texture)return e.image}try{return i.Texture.from(t)}catch(e){return null}}(e,n.texture);return a?new i.Sprite(a):n.fallback?c(e,t,n.fallback):null}if("color"in n)try{const e=new i.Graphics;return n.radius&&n.radius>0?e.roundRect(0,0,n.width,n.height,n.radius):e.rect(0,0,n.width,n.height),e.fill(n.color),e}catch(e){return console.error("[view-resolver] color view create failed",e),null}return null}r.componentName="UI";class p extends t.Component{constructor(){super(...arguments),this.toggleCount=0,this.pressCount=0,this.hoverCount=0,this.changeCount=0,this.updateCount=0,this.selectCount=0,this.focused=!1}init(e){e&&this.applyParams(e)}applyDeclarativeProps(e,t){this.applyParams(e)}applyParams(e){const t=this.constructor.__def;if(t)for(const[n,i]of Object.entries(t.fields)){if(!(n in e))continue;const t=e[n];if(void 0!==t)switch(i.kind){case"scalar":case"opaque":this[n]=t;break;case"shallowMerge":this[n]=Object.assign(Object.assign({},this[n]),t);break;case"arrayCopy":Array.isArray(t)&&(this[n]=t.slice());break;case"tuple":!Array.isArray(t)||i.tupleLength&&t.length!==i.tupleLength||(this[n]=t.slice())}}}}function u(e){const t=e.name;class n extends p{constructor(n){super(n),this.componentName=t;for(const[t,n]of Object.entries(e.fields))void 0!==n.default?this[t]=h(n.default):t in this||(this[t]=void 0)}static getInspectorMetadata(){return function(e){const t=[];for(const[n,i]of Object.entries(e.fields))i.inspector&&t.push(Object.assign(Object.assign({},i.inspector),{name:i.inspector.name||n}));return{name:e.name,type:"object",isArray:!1,isFolder:!0,children:t}}(e)}}const i=n;i.componentName=t,i.__def=e;try{Object.defineProperty(i,"name",{value:t})}catch(e){}if(e.mixin)for(const[t,i]of Object.entries(e.mixin))n.prototype[t]=i;return i}function h(e){return null===e||"object"!=typeof e?e:Array.isArray(e)?e.slice():Object.assign({},e)}const f={kind:"scalar",default:!0,inspector:{name:"enabled",type:"boolean"}},m={kind:"scalar",inspector:{name:"bindToStore",type:"string"}};function g(){const[e,t]=this.valueRange;if(t<=e)return 0;return(Math.max(e,Math.min(t,this.value))-e)/(t-e)*100}function y(e){if(void 0!==e)return"string"==typeof e?parseInt(e.replace("#",""),16):e}const v={name:"Button",signalPrefix:"button",pixiClass:a.ButtonContainer,fields:{enabled:f,view:{kind:"opaque",inspector:{name:"view",type:"object"}}},views:{kind:"single",key:"view",required:!0},positional:!0,optionsBuilder:(e,t)=>[t.single],postCreate:(e,t)=>{e.enabled=t.enabled},signalMap:e=>({press:()=>(e.pressCount+=1,{}),down:!0,up:!0,hover:!0}),syncOnChange:(e,t)=>{e.enabled=t.enabled}},b={name:"FancyButton",signalPrefix:"fancybutton",pixiClass:a.FancyButton,fields:{enabled:f,state:{kind:"scalar",default:"default",inspector:{name:"state",type:"string"}},selected:{kind:"scalar",default:!1,inspector:{name:"selected",type:"boolean"}},text:{kind:"scalar",inspector:{name:"text",type:"string"}},padding:{kind:"scalar",inspector:{name:"padding",type:"number"}},selectedTint:{kind:"scalar",default:"#FFD680",inspector:{name:"selectedTint",type:"color"}},views:{kind:"shallowMerge",default:{},inspector:{name:"views",type:"object",isFolder:!0,children:[{name:"default",type:"object"},{name:"hover",type:"object"},{name:"pressed",type:"object"},{name:"disabled",type:"object"}]}},offset:{kind:"shallowMerge",default:{}},textOffset:{kind:"shallowMerge",default:{}},nineSliceSprite:{kind:"opaque"}},views:{kind:"object",folder:"views",keys:[{name:"default",required:!1},{name:"hover",required:!1},{name:"pressed",required:!1},{name:"disabled",required:!1}]},optionsBuilder:(e,t)=>{var n,i,a,r;const s={text:e.text,padding:e.padding,offset:e.offset,textOffset:e.textOffset,nineSliceSprite:e.nineSliceSprite};return(null===(n=t.object)||void 0===n?void 0:n.default)&&(s.defaultView=t.object.default),(null===(i=t.object)||void 0===i?void 0:i.hover)&&(s.hoverView=t.object.hover),(null===(a=t.object)||void 0===a?void 0:a.pressed)&&(s.pressedView=t.object.pressed),(null===(r=t.object)||void 0===r?void 0:r.disabled)&&(s.disabledView=t.object.disabled),s},postCreate:(e,t)=>{e.enabled=t.enabled,t.selected&&k(e,t)},signalMap:e=>({press:()=>(e.pressCount+=1,{}),hover:()=>(e.hoverCount+=1,{}),down:!0,up:!0}),syncOnChange:(e,t)=>{e.enabled=t.enabled,void 0!==t.text&&e.text!==t.text&&(e.text=t.text),void 0!==t.padding&&e.padding!==t.padding&&(e.padding=t.padding),k(e,t)}};function k(e,t){try{const n=e.defaultView;n&&"tint"in n&&(n.tint=t.selected?t.selectedTint:16777215)}catch(e){}}const x={name:"CheckBox",signalPrefix:"checkbox",pixiClass:a.CheckBox,fields:{enabled:f,checked:{kind:"scalar",default:!1,inspector:{name:"checked",type:"boolean"}},text:{kind:"scalar",inspector:{name:"text",type:"string"}},bindToStore:m,views:{kind:"shallowMerge",default:{},inspector:{name:"views",type:"object",isFolder:!0,children:[{name:"checked",type:"object"},{name:"unchecked",type:"object"}]}},disabledStyle:{kind:"shallowMerge",default:{alpha:.4,scale:1}}},views:{kind:"object",folder:"views",keys:[{name:"checked",required:!0},{name:"unchecked",required:!0}]},optionsBuilder:(e,t)=>({style:{checked:t.object.checked,unchecked:t.object.unchecked},text:e.text,checked:e.checked}),signalMap:e=>({check:t=>(e.checked=t,e.toggleCount+=1,{value:t})}),syncOnChange:(e,t)=>{e.checked!==t.checked&&(e.checked=t.checked)}},w={name:"Switcher",signalPrefix:"switcher",pixiClass:a.Switcher,fields:{active:{kind:"scalar",default:0,inspector:{name:"active",type:"number"}},views:{kind:"arrayCopy",default:[]},triggerEvent:{kind:"scalar",default:"onPress",inspector:{name:"triggerEvent",type:"string"}},bindToStore:m},views:{kind:"array",key:"views",minLength:2},positional:!0,optionsBuilder:(e,t)=>[t.array,e.triggerEvent,e.active],signalMap:e=>({change:t=>(e.active="number"==typeof t?t:t?1:0,e.changeCount+=1,{active:e.active})}),syncOnChange:(e,t)=>{e.active!==t.active&&(e.active=t.active)}},C={name:"Slider",signalPrefix:"slider",pixiClass:a.Slider,fields:{enabled:f,value:{kind:"scalar",default:0,inspector:{name:"value",type:"number"}},min:{kind:"scalar",default:0,inspector:{name:"min",type:"number"}},max:{kind:"scalar",default:100,inspector:{name:"max",type:"number"}},step:{kind:"scalar",default:1,inspector:{name:"step",type:"number"}},orientation:{kind:"scalar",default:"horizontal",inspector:{name:"orientation",type:"string"}},showValue:{kind:"scalar",default:!1,inspector:{name:"showValue",type:"boolean"}},views:{kind:"shallowMerge",default:{}},bindToStore:m},views:{kind:"object",folder:"views",keys:[{name:"bg",required:!0},{name:"fill",required:!0},{name:"thumb",required:!0}]},optionsBuilder:(e,t)=>(S(t.object.thumb),{bg:t.object.bg,fill:t.object.fill,slider:t.object.thumb,min:e.min,max:e.max,step:e.step,value:e.value,showValue:e.showValue}),signalMap:e=>({update:t=>(e.value=t,e.updateCount+=1,{value:t}),change:t=>(e.value=t,e.changeCount+=1,{value:t})}),syncOnChange:(e,t)=>{e.value!==t.value&&(e.value=t.value)}};function S(e){var t,n,i,a;if(!e)return;if(e.anchor)return;let r=0;try{const a=null===(t=e.getBounds)||void 0===t?void 0:t.call(e);r=null!==(i=null!==(n=null==a?void 0:a.height)&&void 0!==n?n:e.height)&&void 0!==i?i:0}catch(t){r=null!==(a=e.height)&&void 0!==a?a:0}r>0&&e.pivot&&e.pivot.set(0,r/2)}const _={name:"DoubleSlider",signalPrefix:"doubleslider",pixiClass:a.DoubleSlider,fields:{enabled:f,value1:{kind:"scalar",default:0,inspector:{name:"value1",type:"number"}},value2:{kind:"scalar",default:100,inspector:{name:"value2",type:"number"}},min:{kind:"scalar",default:0,inspector:{name:"min",type:"number"}},max:{kind:"scalar",default:100,inspector:{name:"max",type:"number"}},step:{kind:"scalar",default:1},showValue:{kind:"scalar",default:!1,inspector:{name:"showValue",type:"boolean"}},views:{kind:"shallowMerge",default:{}},bindToStore1:{kind:"scalar"},bindToStore2:{kind:"scalar"}},views:{kind:"object",folder:"views",keys:[{name:"bg",required:!0},{name:"fill",required:!0},{name:"slider1",required:!0},{name:"slider2",required:!0}]},optionsBuilder:(e,t)=>(S(t.object.slider1),S(t.object.slider2),{bg:t.object.bg,fill:t.object.fill,slider1:t.object.slider1,slider2:t.object.slider2,min:e.min,max:e.max,value1:e.value1,value2:e.value2,showValue:e.showValue}),signalMap:e=>({update:(t,n)=>(e.value1=t,e.value2=n,e.updateCount+=1,{value1:t,value2:n}),change:(t,n)=>(e.value1=t,e.value2=n,e.changeCount+=1,{value1:t,value2:n})}),syncOnChange:(e,t)=>{e.value1!==t.value1&&(e.value1=t.value1),e.value2!==t.value2&&(e.value2=t.value2)}},M={name:"ProgressBar",signalPrefix:"progressbar",pixiClass:a.ProgressBar,fields:{value:{kind:"scalar",default:0,inspector:{name:"value",type:"number"}},valueRange:{kind:"tuple",tupleLength:2,default:[0,100],inspector:{name:"valueRange",type:"number",isArray:!0}},bgView:{kind:"opaque"},fillView:{kind:"opaque"},nineSliceSprite:{kind:"opaque"},fillPaddings:{kind:"shallowMerge",default:{}},bindToStore:m},views:{kind:"object",folder:"__progress_views__",keys:[]},optionsBuilder:(e,t)=>({bg:e.__resolved_bg,fill:e.__resolved_fill,fillPaddings:e.fillPaddings,progress:P(e)}),syncOnChange:(e,t)=>{const n=P(t);e.progress!==n&&(e.progress=n)},mixin:{getProgressPct:g}};function P(e){const[t,n]=e.valueRange;if(n<=t)return 0;return(Math.max(t,Math.min(n,e.value))-t)/(n-t)*100}const j={name:"CircularProgressBar",signalPrefix:"circularprogressbar",pixiClass:a.CircularProgressBar,fields:{value:{kind:"scalar",default:0,inspector:{name:"value",type:"number"}},valueRange:{kind:"tuple",tupleLength:2,default:[0,100],inspector:{name:"valueRange",type:"number",isArray:!0}},radius:{kind:"scalar",default:60,inspector:{name:"radius",type:"number"}},lineWidth:{kind:"scalar",default:12,inspector:{name:"lineWidth",type:"number"}},startAngle:{kind:"scalar",default:-90,inspector:{name:"startAngle",type:"number",step:5}},backgroundColor:{kind:"scalar",default:"#1f2937",inspector:{name:"backgroundColor",type:"color"}},fillColor:{kind:"scalar",default:"#22c55e",inspector:{name:"fillColor",type:"color"}},backgroundAlpha:{kind:"scalar",default:1,inspector:{name:"backgroundAlpha",type:"number",step:.05}},fillAlpha:{kind:"scalar",default:1,inspector:{name:"fillAlpha",type:"number",step:.05}},bindToStore:m},optionsBuilder:e=>({radius:e.radius,lineWidth:e.lineWidth,backgroundColor:e.backgroundColor,fillColor:e.fillColor,backgroundAlpha:e.backgroundAlpha,fillAlpha:e.fillAlpha,value:P(e)}),syncOnChange:(e,t)=>{const n=P(t);e.progress!==n&&(e.progress=n)},mixin:{getProgressPct:g}},O={name:"Input",signalPrefix:"input",pixiClass:a.Input,fields:{enabled:f,value:{kind:"scalar",default:"",inspector:{name:"value",type:"string"}},placeholder:{kind:"scalar",default:"",inspector:{name:"placeholder",type:"string"}},maxLength:{kind:"scalar",default:100,inspector:{name:"maxLength",type:"number"}},secure:{kind:"scalar",default:!1,inspector:{name:"secure",type:"boolean"}},align:{kind:"scalar",default:"left",inspector:{name:"align",type:"string"}},padding:{kind:"tuple",tupleLength:4,default:[8,8,8,8]},textStyle:{kind:"shallowMerge",default:{fontFamily:"Arial",fontSize:16,fill:"#222"}},bgView:{kind:"opaque"},nineSliceSprite:{kind:"opaque"},cleanOnFocus:{kind:"scalar",default:!1,inspector:{name:"cleanOnFocus",type:"boolean"}},addMask:{kind:"scalar",default:!1,inspector:{name:"addMask",type:"boolean"}},bindToStore:m},views:{kind:"single",key:"bgView",required:!0},optionsBuilder:(e,t)=>({bg:t.single,textStyle:e.textStyle,placeholder:e.placeholder,value:e.value,maxLength:e.maxLength,secure:e.secure,align:e.align,padding:e.padding,cleanOnFocus:e.cleanOnFocus,nineSliceSprite:e.nineSliceSprite,addMask:e.addMask}),signalMap:e=>({change:t=>(e.value=t,e.changeCount+=1,{value:t}),enter:e=>({value:e})}),syncOnChange:(e,t)=>{e.value!==t.value&&(e.value=t.value)}},R={name:"List",signalPrefix:"list",pixiClass:a.List,fields:{type:{kind:"scalar",default:"vertical",inspector:{name:"type",type:"string"}},elementsMargin:{kind:"scalar",default:0,inspector:{name:"elementsMargin",type:"number"}},padding:{kind:"scalar"},vertPadding:{kind:"scalar"},horPadding:{kind:"scalar"},topPadding:{kind:"scalar"},bottomPadding:{kind:"scalar"},leftPadding:{kind:"scalar"},rightPadding:{kind:"scalar"},maxWidth:{kind:"scalar"},maxHeight:{kind:"scalar"},itemsChildName:{kind:"scalar",default:"items"}},optionsBuilder:(e,t)=>{var n;return{type:e.type,elementsMargin:e.elementsMargin,padding:e.padding,vertPadding:e.vertPadding,horPadding:e.horPadding,topPadding:e.topPadding,bottomPadding:e.bottomPadding,leftPadding:e.leftPadding,rightPadding:e.rightPadding,maxWidth:e.maxWidth,maxHeight:e.maxHeight,children:null!==(n=e.__resolved_items)&&void 0!==n?n:[]}},syncOnChange:(e,t)=>{e.type!==t.type&&(e.type=t.type),e.elementsMargin!==t.elementsMargin&&(e.elementsMargin=t.elementsMargin),"function"==typeof e.arrangeChildren&&e.arrangeChildren()}},B={name:"ScrollBox",signalPrefix:"scrollbox",pixiClass:a.ScrollBox,fields:{width:{kind:"scalar",default:320,inspector:{name:"width",type:"number"}},height:{kind:"scalar",default:240,inspector:{name:"height",type:"number"}},direction:{kind:"scalar",default:"vertical",inspector:{name:"direction",type:"string"}},contentChildName:{kind:"scalar",default:"content"},background:{kind:"scalar",default:1118481,inspector:{name:"background",type:"color"}},radius:{kind:"scalar",default:0,inspector:{name:"radius",type:"number"}},elementsMargin:{kind:"scalar",default:0},disableDynamicRendering:{kind:"scalar",default:!1},disableEasing:{kind:"scalar",default:!1,inspector:{name:"disableEasing",type:"boolean"}},padding:{kind:"scalar",default:0},inertia:{kind:"scalar",default:!0},inertiaDecay:{kind:"scalar",default:.92},bounceFactor:{kind:"scalar",default:.18}},mixin:{applyOffset(){},getBounds:()=>({minX:0,maxX:0,minY:0,maxY:0})},optionsBuilder:(e,t)=>{var n,i;return{width:e.width,height:e.height,type:null!==(n={horizontal:"horizontal",vertical:"vertical",both:"bidirectional"}[e.direction])&&void 0!==n?n:"vertical",background:e.background,radius:e.radius,elementsMargin:e.elementsMargin,padding:e.padding,disableEasing:e.disableEasing,disableDynamicRendering:e.disableDynamicRendering,items:null!==(i=e.__resolved_items)&&void 0!==i?i:[]}},signalMap:()=>({scroll:e=>({value:e})}),syncOnChange:(e,t)=>{if("function"==typeof e.resize)try{e.resize(t.width,t.height)}catch(e){}}},E={name:"Select",signalPrefix:"select",pixiClass:a.Select,fields:{items:{kind:"arrayCopy",default:[]},selectedIndex:{kind:"scalar",default:-1,inspector:{name:"selectedIndex",type:"number"}},placeholder:{kind:"scalar",default:"",inspector:{name:"placeholder",type:"string"}},closedView:{kind:"opaque"},openView:{kind:"opaque"},textStyle:{kind:"shallowMerge",default:{fontFamily:"Arial",fontSize:14,fill:"#222"}},nineSliceSprite:{kind:"opaque"},bindToStore:m},views:{kind:"object",folder:"__select_views__",keys:[]},optionsBuilder:e=>{var t;return{closedBG:e.__resolved_closedView,openBG:e.__resolved_openView,textStyle:e.textStyle,items:{items:(null!==(t=e.items)&&void 0!==t?t:[]).map(e=>e.text),backgroundColor:0,hoverColor:6710886,width:200,height:30,textStyle:e.textStyle,radius:4},selected:e.selectedIndex>=0?e.selectedIndex:void 0,nineSliceSprite:e.nineSliceSprite}},signalMap:e=>({select:(t,n)=>(e.selectedIndex=t,e.selectCount+=1,{index:t,text:n})})},I={name:"Dialog",signalPrefix:"dialog",pixiClass:a.Dialog,fields:{open:{kind:"scalar",default:!1,inspector:{name:"open",type:"boolean"}},title:{kind:"scalar",inspector:{name:"title",type:"string"}},width:{kind:"scalar",inspector:{name:"width",type:"number"}},height:{kind:"scalar",inspector:{name:"height",type:"number"}},padding:{kind:"scalar",inspector:{name:"padding",type:"number"}},backdropColor:{kind:"scalar",default:0,inspector:{name:"backdropColor",type:"color"}},backdropAlpha:{kind:"scalar",default:.5,inspector:{name:"backdropAlpha",type:"number",step:.05}},backdropView:{kind:"opaque"},backgroundView:{kind:"opaque"},closeOnBackdropClick:{kind:"scalar",default:!0,inspector:{name:"closeOnBackdropClick",type:"boolean"}},contentChildName:{kind:"scalar",default:"content",inspector:{name:"contentChildName",type:"string"}},nineSliceSprite:{kind:"opaque"},bindToStore:m},optionsBuilder:e=>{var t;return{backdrop:e.__resolved_backdropView,backdropColor:y(e.backdropColor),backdropAlpha:e.backdropAlpha,background:null!==(t=e.__resolved_backgroundView)&&void 0!==t?t:new i.Container,title:e.title,width:e.width,height:e.height,padding:e.padding,closeOnBackdropClick:e.closeOnBackdropClick,nineSliceSprite:e.nineSliceSprite}},postCreate:(e,t)=>{t.open&&"function"==typeof e.open&&e.open()},signalMap:e=>({close:()=>(e.open=!1,{}),select:(e,t)=>({index:e,text:t})}),syncOnChange:(e,t)=>{t.open&&!e.isOpen&&"function"==typeof e.open?e.open():!t.open&&e.isOpen&&"function"==typeof e.close&&e.close()}},A={name:"MaskedFrame",signalPrefix:"maskedframe",pixiClass:a.MaskedFrame,fields:{targetView:{kind:"opaque"},maskView:{kind:"opaque"},borderView:{kind:"opaque"}},optionsBuilder:e=>({target:e.__resolved_targetView,mask:e.__resolved_maskView,borderWidth:0,borderColor:0})},V=u(v),T=u(b),N=u(x),q=u(w),G=u(C),D=u(_),F=u(M),U=u(j),L=u(O),W=u(R),Y=u(B),$=u(E),z=u(I),H=u(A),X={Button:v,FancyButton:b,CheckBox:x,Switcher:w,Slider:C,DoubleSlider:_,ProgressBar:M,CircularProgressBar:j,Input:O,List:R,ScrollBox:B,Select:E,Dialog:I,MaskedFrame:A};class J extends t.Component{constructor(){super(...arguments),this.componentName="RadioGroup",this.direction="vertical",this.elementsMargin=4,this.boundCheckBoxes=[]}static getInspectorMetadata(){return{name:J.componentName,type:"object",isArray:!1,isFolder:!0,children:[{name:"selectedId",type:"string",isArray:!1},{name:"direction",type:"string",isArray:!1},{name:"elementsMargin",type:"number",isArray:!1},{name:"childNames",type:"string",isArray:!0}]}}init(e){e&&this.applyParams(e)}applyDeclarativeProps(e,t){this.applyParams(e)}applySelection(){for(const{name:e,cb:t}of this.boundCheckBoxes){const n=e===this.selectedId;t.checked!==n&&(t.checked=n)}}applyParams(e){"string"==typeof e.selectedId&&(this.selectedId=e.selectedId),Array.isArray(e.childNames)&&(this.childNames=e.childNames.slice()),e.direction&&(this.direction=e.direction),"number"==typeof e.elementsMargin&&(this.elementsMargin=e.elementsMargin)}}function K(e,t,n){const i=[],{go:a,prefix:r,emitToMx:s=!0}=t;for(const[t,l]of Object.entries(n)){const n=Q(e,t);if(!n)continue;const o=n.connect((...e)=>{var n,i,o,d,c;const p=!0===l?e[0]:Z(l,e),u="object"==typeof p&&null!==p?Object.assign({entityName:a.name},p):{entityName:a.name,value:p};try{null===(i=(n=a).emit)||void 0===i||i.call(n,t,u)}catch(e){}try{null===(d=(o=a).emit)||void 0===d||d.call(o,`${r}:${t}`,u)}catch(e){}if(s){const e="undefined"!=typeof globalThis?globalThis.mx:void 0;if(null===(c=null==e?void 0:e.event)||void 0===c?void 0:c.emit)try{e.event.emit(`${r}:${t}`,u)}catch(e){}}});i.push(()=>{try{o.disconnect()}catch(e){}})}return i}function Q(e,t){const n=[`on${t.charAt(0).toUpperCase()}${t.slice(1)}`,`on${t.charAt(0).toUpperCase()}${t.slice(1)}Change`];for(const t of n){const n=null==e?void 0:e[t];if(n&&"function"==typeof n.connect)return n}return null}function Z(e,t){var n;try{return null!==(n=e(...t))&&void 0!==n?n:{}}catch(e){return{}}}J.componentName="RadioGroup","function"==typeof SuppressedError&&SuppressedError;let ee=class extends t.System{constructor(){super(...arguments),this.name="UISystem",this.instances=new Map,this.signalCleanups=new Map,this.radioGroupInstances=new Map}get checkBoxInstances(){let e=this.instances.get("CheckBox");return e||(e=new Map,this.instances.set("CheckBox",e)),e}update(e){var t,n,i;const a=null!==(i=null===(n=null===(t=this.componentObserver)||void 0===t?void 0:t.clear)||void 0===n?void 0:n.call(t))&&void 0!==i?i:[];for(const e of a)this.componentChanged(e)}componentChanged(e){const t=e.componentName;if("UI"===t)return this.handleUI(e);if("RadioGroup"===t)return this.handleRadioGroup(e);const n=X[t];return n?this.handleGeneric(n,e):void 0}handleUI(e){if(e.type===t.OBSERVER_TYPE.ADD||e.type===t.OBSERVER_TYPE.CHANGE){const t=e.component;"function"==typeof t.redraw&&t.redraw()}}handleGeneric(e,n){var i;const a=n.component,r=a.gameObject;if(!r)return;const s=this.getInstanceMap(e.name);if(n.type===t.OBSERVER_TYPE.ADD)d(this.gameRef(r),r,()=>this.attachGeneric(e,a,r,s));else if(n.type===t.OBSERVER_TYPE.CHANGE){const t=s.get(r.id);if(!t)return void d(this.gameRef(r),r,()=>this.attachGeneric(e,a,r,s));null===(i=e.syncOnChange)||void 0===i||i.call(e,t,a)}else n.type===t.OBSERVER_TYPE.REMOVE&&this.detachGeneric(r.id,s,r)}attachGeneric(e,t,n,i){var a,r,o,d,p,u,h;if(i.has(n.id))return;const f=this.gameRef(n),m=function(e,t,n,i){var a,r;if(!i)return{};switch(i.kind){case"single":{const a=n[i.key],r=c(e,t,a);return i.required&&!r?null:{single:r}}case"object":{const r=null!==(a=n[i.folder])&&void 0!==a?a:{},s={};for(const{name:n,required:a}of i.keys){const i=c(e,t,r[n]);if(a&&!i)return null;s[n]=i}return{object:s}}case"array":{const a=(null!==(r=n[i.key])&&void 0!==r?r:[]).map(n=>c(e,t,n)).filter(Boolean);return a.length<i.minLength?null:{array:a}}}}(f,n,t,e.views);if(e.views&&null===m)return;if(function(e,t,n,i){switch(e){case"ProgressBar":t.__resolved_bg=c(n,i,t.bgView),t.__resolved_fill=c(n,i,t.fillView);break;case"Select":t.__resolved_closedView=c(n,i,t.closedView),t.__resolved_openView=c(n,i,t.openView);break;case"Dialog":t.__resolved_backdropView=c(n,i,t.backdropView),t.__resolved_backgroundView=c(n,i,t.backgroundView);break;case"MaskedFrame":t.__resolved_targetView=c(n,i,t.targetView),t.__resolved_maskView=c(n,i,t.maskView)}}(e.name,t,f,n),!function(e,t){switch(e){case"ProgressBar":return!(!t.__resolved_bg||!t.__resolved_fill);case"Select":return!(!t.__resolved_closedView||!t.__resolved_openView);case"Dialog":default:return!0;case"MaskedFrame":return!(!t.__resolved_targetView||!t.__resolved_maskView)}}(e.name,t))return;if("List"===e.name||"ScrollBox"===e.name){const i="List"===e.name?t.itemsChildName:t.contentChildName;t.__resolved_items=function(e,t,n){var i,a,r;const l=[],o=ne(t,n);if(!o)return l;const d=(null===(i=o.transform)||void 0===i?void 0:i.children)||[];for(const t of d){const n=null==t?void 0:t.gameObject;if(!n)continue;const i=s(e,n);if(i){try{null===(r=null===(a=i.parent)||void 0===a?void 0:a.removeChild)||void 0===r||r.call(a,i)}catch(e){}l.push(i)}}return l}(f,n,i)}const g=e.optionsBuilder(t,null!=m?m:{}),y=e.positional?new e.pixiClass(...g):new e.pixiClass(g);if(null===(a=e.postCreate)||void 0===a||a.call(e,y,t),i.set(n.id,y),l(f,n,y),"Dialog"===e.name){const e=ne(n,null!==(r=t.contentChildName)&&void 0!==r?r:"content");if(e){const t=s(f,e);if(t)try{null===(d=(o=y).addChild)||void 0===d||d.call(o,t)}catch(e){}}}if("MaskedFrame"===e.name&&t.borderView){const e=c(f,n,t.borderView);if(e)try{null===(u=(p=y).addChild)||void 0===u||u.call(p,e)}catch(e){}}if(e.signalMap){const i=K(y,{go:n,prefix:e.signalPrefix},e.signalMap(t));this.signalCleanups.set(n.id,i)}null===(h=e.onAttachedExtra)||void 0===h||h.call(e,y,t,n,f)}detachGeneric(e,t,n){const i=t.get(e);o(this.gameRef(n),n,i),t.delete(e);const a=this.signalCleanups.get(e);a&&(a.forEach(e=>e()),this.signalCleanups.delete(e))}handleRadioGroup(e){const n=e.component,i=n.gameObject;if(i)if(e.type===t.OBSERVER_TYPE.ADD)d(this.gameRef(i),i,()=>queueMicrotask(()=>this.attachRadioGroup(n)));else if(e.type===t.OBSERVER_TYPE.CHANGE)n.applySelection();else if(e.type===t.OBSERVER_TYPE.REMOVE){const e=this.radioGroupInstances.get(i.id);o(this.gameRef(i),i,e),this.radioGroupInstances.delete(i.id);const t=this.signalCleanups.get(i.id);t&&(t.forEach(e=>e()),this.signalCleanups.delete(i.id))}}attachRadioGroup(e){var t,n,i,r,s;const o=e.gameObject,d=this.gameRef(o);if(!o||this.radioGroupInstances.has(o.id))return;e.boundCheckBoxes=[];const c=[],p=[],u=(null===(t=o.transform)||void 0===t?void 0:t.children)||[];for(const t of u){const a=null==t?void 0:t.gameObject;if(!a)continue;if(e.childNames&&!e.childNames.includes(a.name))continue;const s=null===(n=a.getComponent)||void 0===n?void 0:n.call(a,"CheckBox");if(!s)continue;const l=this.checkBoxInstances.get(a.id);if(l){try{null===(r=null===(i=l.parent)||void 0===i?void 0:i.removeChild)||void 0===r||r.call(i,l)}catch(e){}c.push(l),p.push(a.name),e.boundCheckBoxes.push({name:a.name,cb:s})}}if(0===c.length)return;const h=e.selectedId?Math.max(0,p.indexOf(e.selectedId)):0,f=new a.RadioGroup({items:c,type:null!==(s={horizontal:"horizontal",vertical:"vertical",bidirectional:"bidirectional"}[e.direction])&&void 0!==s?s:"vertical",elementsMargin:e.elementsMargin,selectedItem:h});this.radioGroupInstances.set(o.id,f),l(d,o,f);const m=K(f,{go:o,prefix:"radiogroup"},{change:(t,n)=>{var i;const a=null!==(i=p[t])&&void 0!==i?i:n;return e.selectedId=a,{selectedId:e.selectedId,index:t}}});this.signalCleanups.set(o.id,m)}getInstanceMap(e){let t=this.instances.get(e);return t||(t=new Map,this.instances.set(e,t)),t}gameRef(e){var t,n,i;const a=this.game;return a||(e&&null!==(i=null!==(t=e.game)&&void 0!==t?t:null===(n=e.scene)||void 0===n?void 0:n.game)&&void 0!==i?i:null)}};ee.systemName="UISystem",ee=function(e,t,n,i){var a,r=arguments.length,s=r<3?t:null===i?i=Object.getOwnPropertyDescriptor(t,n):i;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(e,t,n,i);else for(var l=e.length-1;l>=0;l--)(a=e[l])&&(s=(r<3?a(s):r>3?a(t,n,s):a(t,n))||s);return r>3&&s&&Object.defineProperty(t,n,s),s}([t.decorators.componentObserver(function(){const e={UI:[{prop:["shapes"],deep:!0}],RadioGroup:[{prop:["selectedId"],deep:!1},{prop:["direction"],deep:!1},{prop:["elementsMargin"],deep:!1}]};for(const[t,n]of Object.entries(X)){const i=[];for(const[e,t]of Object.entries(n.fields)){const n="shallowMerge"===t.kind||"tuple"===t.kind||"arrayCopy"===t.kind;i.push({prop:[e],deep:n})}e[t]=i}return e}())],ee);var te=ee;function ne(e,t){var n,i;if(!e)return null;if("function"==typeof e.findChildByName)try{const n=e.findChildByName(t);if(n)return n}catch(e){}const a=(null===(n=e.transform)||void 0===n?void 0:n.children)||[];for(const e of a)if((null===(i=null==e?void 0:e.gameObject)||void 0===i?void 0:i.name)===t)return e.gameObject;return null}exports.Button=V,exports.COMPONENT_DEFINITIONS=X,exports.CheckBox=N,exports.CircularProgressBar=U,exports.Dialog=z,exports.DoubleSlider=D,exports.FancyButton=T,exports.Input=L,exports.List=W,exports.MaskedFrame=H,exports.PixiUiComponent=p,exports.PluginUiSystem=te,exports.ProgressBar=F,exports.RadioGroup=J,exports.ScrollBox=Y,exports.Select=$,exports.Slider=G,exports.Switcher=q,exports.UI=r,exports.UISystem=te,exports.defineUiComponent=u;