import{isEmpty}from"../../base/helpers.mjs";import{EngineFormView}from"../../forms/enfugue/engine.mjs";import{Controller}from"../base.mjs";class EngineController extends Controller{getState(e=!0){return{engine:this.engineForm.values}}setState(e){isEmpty(e.engine)||this.engineForm.setValues(e.engine).then((()=>this.engineForm.submit()))}getDefaultState(){return{engine:{size:null,refinerSize:null,inpainterSize:null}}}async initialize(){this.engineForm=new EngineFormView(this.config),this.engineForm.onSubmit((async e=>{this.engine.size=e.size,this.engine.refinerSize=e.refinerSize,this.engine.inpainterSize=e.inpainterSize})),this.application.sidebar.addChild(this.engineForm),this.subscribe("engineModelTypeChange",(e=>{isEmpty(e)||"model"!==e?this.engineForm.show():this.engineForm.hide()})),this.subscribe("engineRefinerChange",(e=>{isEmpty(e)?this.engineForm.removeClass("show-refiner"):this.engineForm.addClass("show-refiner")})),this.subscribe("engineInpainterChange",(e=>{isEmpty(e)?this.engineForm.removeClass("show-inpainter"):this.engineForm.addClass("show-inpainter")})),this.subscribe("engineModelChange",(e=>{isEmpty(e)?this.engineForm.show():"model"===this.engine.modelType&&this.engineForm.hide()}))}}export{EngineController as SidebarController};
