import{b as m}from"./chunk-J4X74MLG.js";import{a as d}from"./chunk-T6NRFYFX.js";import{g as a}from"./chunk-RQCMKSAN.js";import{a as u,b as r}from"./chunk-5VDVFGVW.js";import{a as o,qa as c}from"./chunk-J476KISY.js";var f=class extends m{constructor(e,s){super(e,{featureId:"DatagridEditFormFeature",onSelected:t=>{if(!r.isSet(t.commitRecord)||r.isFunction(this.featureSettings.recordFeature)&&!this.featureSettings.recordFeature(t.commitRecord,t))return;let n=this.getInputFields(t);if(!n)return;let i=this.dialogService.open({title:this.featureSettings.title||"",styleClass:this.featureSettings.styleClass,size:this.featureSettings.size,onClose:()=>{t.clearAddRecord(),t.clearCommitRecord(),t.clearSelection()},component:d,bindings:{fields:n,groups:this.featureSettings.groups,grouppingStyleClass:this.featureSettings.grouppingStyleClass,model:o({},t.commitRecord),actions:[{id:"datagrid-edit-record-cancel",label:"Cancel",type:"paw-chip-btn",onSelected:()=>{i.close()}}],settings:{onSubmit:(l,p)=>this.featureSettings.submitRecord(l,t)},submitAction:{id:"datagrid-edit-record-submit"}}})},display:"selection"}),this.featureSettings=s,this.dialogService=c(a),e.icon="fa-regular fa-edit",e.label=""}recordFeature(e,s){return this.featureSettings.recordFeature?this.featureSettings.recordFeature(e,s):!0}getInputFields(e){return r.isFunction(this.featureSettings.getColumns)?this.getInputFieldsForColumns(e):r.isFunction(this.featureSettings.getInputFields)?this.getInputFieldsFromCustomFields(e):null}getInputFieldsForColumns(e){if(!r.isSet(e.commitRecord)||!this.featureSettings.getColumns)return null;let s=e.getInputFieldsFor(e.commitRecord);if(!r.isSet(s))return null;let t=e.getFieldSet(e.commitRecord);return u.iterate(this.featureSettings.getColumns(),n=>{let i=r.isFunction(n.inputField)?n.inputField(e.commitRecord,e):n.inputField;!i||u.exists(s,l=>l.id===i.id)||(i.bind.fieldSet=t,s.push(o({},i)))}),s}getInputFieldsFromCustomFields(e){if(!r.isSet(e.commitRecord)||!this.featureSettings.getInputFields)return null;let s=e.getInputFieldsFor(e.commitRecord);if(!r.isSet(s))return null;let t=[],n=e.getFieldSet(e.commitRecord);return u.iterate(this.featureSettings.getInputFields(),i=>{i&&(i.bind||(i.bind={}),i.bind.fieldSet=n,t.push(o({},i)))}),t}};export{f as a};
