import{isEmpty}from"../../base/helpers.mjs";import{Controller}from"../base.mjs";import{RefiningFormView}from"../../forms/enfugue/refining.mjs";class RefiningController extends Controller{getState(e=!0){return{refining:this.refiningForm.values}}getDefaultState(){return{refining:{refinerStart:.85,refinerStrength:.3,refinerGuidanceScale:5,refinerAestheticScore:6,refinerNegativeAestheticScore:2.5,refinerPrompt:null,refinerNegativePrompt:null}}}setState(e){isEmpty(e.refining)||this.refiningForm.setValues(e.refining).then((()=>this.refiningForm.submit()))}async initialize(){this.refiningForm=new RefiningFormView(this.config),this.refiningForm.onSubmit((async e=>{this.engine.refinerStart=e.refinerStart,this.engine.refinerStrength=e.refinerStrength,this.engine.refinerGuidanceScale=e.refinerGuidanceScale,this.engine.refinerAestheticScore=e.refinerAestheticScore,this.engine.refinerNegativeAestheticScore=e.refinerNegativeAestheticScore,this.engine.refinerPrompt=e.refinerPrompt,this.engine.refinerNegativePrompt=e.refinerNegativePrompt})),this.refiningForm.hide(),this.application.sidebar.addChild(this.refiningForm),this.subscribe("modelPickerChange",(e=>{if(isEmpty(e)||isEmpty(e.status)||isEmpty(e.status.refiner))this.refiningForm.hide();else{let i=e.defaultConfiguration,r={};isEmpty(i.refiner_start)||(r.refinerStart=i.refiner_start),isEmpty(i.refiner_strength)||(r.refinerStrength=i.refiner_strength),isEmpty(i.refiner_guidance_scale)||(r.refinerGuidanceScale=i.refiner_guidance_scale),isEmpty(i.refiner_aesthetic_score)||(r.refinerAestheticScore=i.refiner_aesthetic_score),isEmpty(i.refiner_negative_aesthetic_score)||(r.refinerNegativeAestheticScore=i.refiner_negative_aesthetic_score),isEmpty(r)||this.refiningForm.setValues(r),this.refiningForm.show()}})),this.subscribe("engineRefinerChange",(e=>{isEmpty(e)?this.refiningForm.hide():this.refiningForm.show()}))}}export{RefiningController as SidebarController};
