import{isEmpty}from"../../base/helpers.mjs";import{FormView}from"../../view/forms/base.mjs";import{Controller}from"../base.mjs";import{NumberInputView,FloatInputView,CheckboxInputView}from"../../view/forms/input.mjs";let defaultGuidanceScale=7.5,defaultInferenceSteps=50;class TweaksForm extends FormView{static autoSubmit=!0;static collapseFieldSets=!0;static fieldSets={Tweaks:{guidanceScale:{label:"Guidance Scale",class:FloatInputView,config:{min:0,max:100,value:defaultGuidanceScale,step:.1,tooltip:"How closely to follow the text prompt; high values result in high-contrast images closely adhering to your text, low values result in low-contrast images with more randomness."}},inferenceSteps:{label:"Inference Steps",class:NumberInputView,config:{min:5,max:250,value:defaultInferenceSteps,tooltip:"How many steps to take during primary inference, larger values take longer to process but can produce better results."}}}}}class TweaksController extends Controller{getState(){return{tweaks:this.tweaksForm.values}}setState(e){isEmpty(e.tweaks)||this.tweaksForm.setValues(e.tweaks).then((()=>this.tweaksForm.submit()))}getDefaultState(){return{tweaks:{guidanceScale:defaultGuidanceScale,inferenceSteps:defaultInferenceSteps}}}async initialize(){defaultGuidanceScale=this.application.config.model.invocation.guidanceScale,defaultInferenceSteps=this.application.config.model.invocation.inferenceSteps,this.tweaksForm=new TweaksForm(this.config),this.tweaksForm.onSubmit((async e=>{this.engine.guidanceScale=e.guidanceScale,this.engine.inferenceSteps=e.inferenceSteps})),this.application.sidebar.addChild(this.tweaksForm)}}export{TweaksController as SidebarController};
