import{LitElement as t,html as e,css as i}from"lit";import{dispatchCustomEvent as s}from"./lib/events.js";import{formSubmit as o}from"./lib/form/form-submit-directive.js";import{i18n as a}from"./translation.js";import"./cc-button.js";import"./cc-input-text.js";class n extends t{static get properties(){return{disabled:{type:Boolean},state:{type:Object},_value:{type:String,state:!0}}}constructor(){super(),this.disabled=!1,this.state={type:"loading"},this._value="",this._onFormSubmit=this._onFormSubmit.bind(this)}_onValueInput(t){this._value=t.detail}_onFormSubmit(t){"loading"!==this.state.type&&s(this,"update-value",t.value)}willUpdate(t){t.has("state")&&(this._value="loading"===this.state.type?"":this.state.value)}render(){const t="loading"===this.state.type,i="saving"===this.state.type,s=this.disabled;return e`<form ${o(this._onFormSubmit)}><cc-input-text name=value label=${a("cc-kv-string-editor.form.value")} .skeleton=${t} ?disabled=${s} ?readonly=${i} clipboard multi .resetValue=${this._value} .value=${this._value} @cc-input-text:input=${this._onValueInput}></cc-input-text><div class=buttons><cc-button type=reset .skeleton=${t} .disabled=${s||i}>${a("cc-kv-string-editor.form.reset")}</cc-button><cc-button type=submit primary .skeleton=${t} .disabled=${s} .waiting=${i}>${a("cc-kv-string-editor.form.save")}</cc-button></div></form>`}static get styles(){return[i`:host{display:block}.buttons{display:flex;gap:.5em;justify-content:end;margin-top:1em}`]}}window.customElements.define("cc-kv-string-editor-beta",n);export{n as CcKvStringEditor};
//# sourceMappingURL=cc-kv-string-editor.js.map
