import{isEmpty}from"../../base/helpers.mjs";import{FormView}from"../../view/forms/base.mjs";import{Controller}from"../base.mjs";import{EngineSizeInputView,RefinerEngineSizeInputView,InpainterEngineSizeInputView}from"../common/model-manager.mjs";class EngineForm extends FormView{static autoSubmit=!0;static collapseFieldSets=!0;static fieldSets={Engine:{size:{label:"Engine Size",class:EngineSizeInputView,config:{required:!1,value:null}},refinerSize:{label:"Refining Engine Size",class:RefinerEngineSizeInputView,config:{required:!1,value:null}},inpainterSize:{label:"Inpainting Engine Size",class:InpainterEngineSizeInputView,config:{required:!1,value:null}}}}}class EngineController extends Controller{getState(){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 EngineForm(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)||"checkpoint"===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():"checkpoint"!==this.engine.modelType&&this.engineForm.hide()}))}}export{EngineController as SidebarController};
