import{r as i,e,h as s,f as t,g as l}from"./p-15c07fa9.js";import{S as a}from"./p-cbb8e351.js";import{I as o}from"./p-d68904a9.js";import{ArrayUtils as d}from"@sankhyalabs/core";import"./p-9019a32f.js";const r=class{constructor(s){i(this,s),this.fieldListChanged=e(this,"fieldListChanged",7),this.availableFields=[],this.dataUnit=void 0,this.filterTerm="",this.messagesBuilder=void 0}onAddField(i){const e=this.addItemInPosition(i.newIndex,i.item.fieldConfig);this.fieldListChanged.emit(e)}addItemInPosition(i,e){return[...this.availableFields.slice(0,i),e,...this.availableFields.slice(i)]}onRemoveField(i){const e=i.item,s=e.fieldConfig.name,t=[...this.availableFields.filter((i=>i.name!==s))];this.fieldListChanged.emit(t),requestAnimationFrame((()=>e.remove()))}renderFields(){return d.applyStringFilter(this.filterTerm,this.availableFields).map((i=>s("field-item",{key:i.name,dataUnit:this.dataUnit,fieldConfig:i,messagesBuilder:this.messagesBuilder})))}getCountText(){return this.availableFields.length?1===this.availableFields.length?this.getMessage("snkFormConfig.availableFields.labelOneField"):`${this.availableFields.length} ${this.getMessage("snkFormConfig.availableFields.labelAvailableFields")}`:this.getMessage("snkFormConfig.availableFields.labelNoFields")}initializeDraggableContainer(){new a(this.el.querySelector(`#${o}`),{group:"fields",direction:"vertical",ghostClass:"ghost",animation:15,onAdd:i=>this.onAddField(i),onRemove:i=>this.onRemoveField(i)})}getMessage(i,e){var s;return null===(s=this.messagesBuilder)||void 0===s?void 0:s.getMessage(i,e)}componentDidRender(){this.initializeDraggableContainer()}render(){return s(t,{class:"ez-col ez-col--sd-4 ez-col--tb-4 ez-padding--medium"},s("span",{class:"fields-label ez-padding-bottom--small"},this.getMessage("snkFormConfig.availableFields.title")),s("ez-filter-input",{class:"filter-input",slot:"content",mode:"slim",label:this.getMessage("snkFormConfig.availableFields.labelSearchField"),onEzChange:i=>this.filterTerm=i.detail}),s("span",{class:"fields-count"},this.getCountText()),s("ez-scroller",{direction:"vertical",activeShadow:!0},s("div",{id:o,class:"fields-container"},this.renderFields())))}get el(){return l(this)}};r.style=".sc-fields-selector-h{width:33.33333%;display:flex;box-shadow:var(--shadow--small, 0 0 16px rgba(0, 38, 111, 0.07));border-radius:var(--border--radius-medium, 6px);height:var(--snk-form-config-container-height);max-width:260px}.fields-label.sc-fields-selector{display:block;font-size:16px;font-weight:500;width:100%}.fields-count.sc-fields-selector{display:block;color:#AFB6C0;font-size:14px;padding:12px 0;font-weight:400;width:100%}.fields-container.sc-fields-selector{display:flex;flex-direction:column;gap:12px;height:calc(100vh - 220px);width:100%}.ghost.sc-fields-selector{opacity:.5;background:#c8fbe2}.filter-input.sc-fields-selector{padding-right:var(--space--2xs, 8px)}";export{r as fields_selector}