import{InputView}from"../base.mjs";import{TextInputView}from"../string.mjs";import{ButtonInputView}from"../misc.mjs";class AddSecondaryPromptInputView extends ButtonInputView{static defaultValue="Add Secondary";static tooltip="Secondary prompts are input into the secondary text encoder when using SDXL. When not using SDXL, secondary prompts and primary prompts will be merged.";static className="add-secondary-prompt"}class RemoveSecondaryPromptInputView extends AddSecondaryPromptInputView{static defaultValue="Remove Secondary";static className="remove-secondary-prompt"}class PromptInputView extends InputView{static tagName="enfugue-prompt-input-view";static textInputClass=TextInputView;constructor(e,t,s){super(e,t,s),this.primary=new TextInputView(this.config,"primary"),this.secondary=new TextInputView(this.config,"secondary"),this.primary.addClass("primary-prompt"),this.secondary.addClass("secondary-prompt"),this.addSecondary=new AddSecondaryPromptInputView(this.config),this.removeSecondary=new RemoveSecondaryPromptInputView(this.config),this.addSecondary.onChange((()=>this.addSecondaryPrompt())),this.removeSecondary.onChange((()=>this.removeSecondaryPrompt())),this.removeSecondaryPrompt(),this.primary.onInput((()=>this.inputted())),this.secondary.onInput((()=>this.inputted())),this.primary.onChange((()=>this.changed())),this.secondary.onChange((()=>this.changed())),this.primary.onKeyPress((e=>this.keyPressed(e))),this.secondary.onKeyPress((e=>this.keyPressed(e)))}getValue(){return this.showSecondary?[this.primary.getValue(),this.secondary.getValue()]:this.primary.getValue()}setValue(e,t){Array.isArray(e)?null===e[1]?(this.primary.setValue(e[0],!1),this.secondary.setValue("",!1),this.removeClass("show-secondary")):(this.addSecondaryPrompt(),this.primary.setValue(e[0],!1),this.secondary.setValue(e[1],!1)):this.primary.setValue(e,!1),super.setValue(e,t)}addSecondaryPrompt(){let e=!0===this.showSecondary;this.showSecondary=!0,this.addClass("show-secondary"),e&&this.changed()}removeSecondaryPrompt(){let e=!0===this.showSecondary;this.showSecondary=!1,this.removeClass("show-secondary"),e&&this.changed()}async build(){let e=await super.build(),t=e.data("tooltip"),s=await this.primary.getNode(),a=await this.secondary.getNode();return e.data("tooltip",null),s.data("tooltip",t),a.data("tooltip",t),e.append(await this.addSecondary.getNode(),await this.removeSecondary.getNode(),s,a)}}export{PromptInputView};
