import{r as t,e as i,h as o,f as n}from"./p-15c07fa9.js";import{ObjectUtils as s}from"@sankhyalabs/core";import{ApplicationUtils as e}from"@sankhyalabs/ezui/dist/collection/utils";const a=class{constructor(o){t(this,o),this.formConfigOptionSelected=i(this,"formConfigOptionSelected",7),this.configOptions=[],this.selectedConfig=void 0,this.hasChanges=!1,this.messagesBuilder=void 0}getMessage(t,i){return this.messagesBuilder.getMessage(t,i)}async showShareConfigOptions(){this._refOptionsPopover&&this._refShareConfigBtn&&await this._refOptionsPopover.showUnder(this._refShareConfigBtn)}async handleSelectOption(t){if(!s.equals(t,this.selectedConfig)){if(this.hasChanges){const t=this.getMessage("snkFormConfig.confirm.title"),i=this.getMessage("snkFormConfig.confirm.cancel");if(!await e.confirm(t,i))return}this.selectedConfig=t,this.formConfigOptionSelected.emit(t),await this._refOptionsPopover.hide()}}getButtonLabel(){var t,i;return null!==(i=null===(t=this.selectedConfig)||void 0===t?void 0:t.name)&&void 0!==i?i:this.getMessage("snkFormConfig.configs.buttonLabel")}renderConfigOptions(){return this.configOptions.map((t=>o("div",{class:"main-item",onClick:async()=>await this.handleSelectOption(t)},o("span",{class:"item-label"}," ",t.name),this.renderCheckIcon(t))))}renderCheckIcon(t){if(this.selectedConfig&&this.selectedConfig.origin===t.origin)return o("ez-icon",{iconName:"check"})}render(){return o(n,null,o("ez-button",{ref:t=>this._refShareConfigBtn=t,label:this.getButtonLabel(),onClick:async()=>await this.showShareConfigOptions()},o("ez-icon",{slot:"rightIcon",iconName:"chevron-down"})),o("ez-popover-plus",{ref:t=>this._refOptionsPopover=t,autoClose:!0,overlayType:"none"},o("div",{class:"dropdown-container"},this.renderConfigOptions())))}};a.style=".dropdown-container.sc-configs-button{font-family:'Roboto';font-size:12px;font-weight:400;display:flex;flex-direction:column;color:#2b3a54;width:200px}.main-item.sc-configs-button{padding:12px;font-size:14px;cursor:pointer;transition:all .2s ease-in-out;display:flex;flex-direction:row;gap:8px;align-items:center;justify-content:start}.main-item.sc-configs-button ez-icon.sc-configs-button{--ez-icon--color:#008561}.main-item.sc-configs-button:nth-of-type(1){padding-bottom:6px}.main-item.sc-configs-button:nth-of-type(2){padding-top:6px}.main-item.sc-configs-button:hover{background-color:#FAFCFF}.item-label.sc-configs-button{display:flex}";export{a as configs_button}