"use strict";Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const F=require("clsx"),b=require("lodash-unified"),x=require("vue"),M=require("../../ap-grid/utils/editable.js"),q=require("../../ap-table/utils.js"),S=require("../../editable-table/utils.js");require("../../utils/index.js");const $=require("../editable/utils.js"),A=require("../../utils/is.js");function v(t,n,r){t.__skipNextRefresh?t.__skipNextRefresh[n]=r:t.__skipNextRefresh={[n]:r}}function G(t,n,r){t.__prevEditable?t.__prevEditable[n]=r:t.__prevEditable={[n]:r}}const w=(t,n,r)=>{const h=x.ref([]);x.watch(()=>t.columns,e=>{if(!e?.length){h.value=[];return}function o(a){return a.map(d=>({...d,_requireMark:S.getColumnIsRequired(d),children:o(d.children||[]),...C(d)}))}h.value=o(e)},{immediate:!0,deep:!0});function C(e){const o=e.editable,a=r?[r]:b.isArray(t.name)?t.name:[t.name];return!o||e.children?.length?{_path:[...a]}:{customRender({value:d,originalNode:N,params:l,...i}){const c=b.isFunction(e.editable)?e.editable(i.text,i.record,i.rowIndex):!!e.editable;let f=N;const k=b.isArray(e.dataIndex)?e.dataIndex:[e.dataIndex],g=$.getRowKey(i.record,i.rowIndex,t.rowKey);if(c){const _=q.updateFormProps(e,q.getFieldProps(e.fieldProps,{value:d,...i})),R={};t.onFieldChange&&(R[`onUpdate:${_.valuePropName||"value"}`]=y=>t.onFieldChange?.(i.rowIndex,e.dataIndex,y,i.record));const E={name:[...a,String(g),...k],..._||{},field:{style:"width: 100%",..._?.field||{},...R,class:F.clsx("is-editable",_.class)}};f=M.getFinalEditableNode(e,E,i.record,x.unref(n))}e.customRender&&(f=e.customRender({value:d,...i,editable:c,originalNode:f,index:i.rowIndex,renderIndex:i.rowIndex,path:[...a,String(g)]}));const u=l.node,s=l.column.getColId(),I=u.__prevEditable?.[s];return!u.__skipNextRefresh?.[s]&&A.isDef(I)&&I!==c&&(v(u,s,!0),setTimeout(()=>{l?.api.refreshCells({rowNodes:[l.node],columns:[l.column.getColId()],force:!0}),v(u,s,!1)},0)),G(u,s,c),f},_path:[...a]}}return h};exports.default=w;exports.useGetEditableColumns=w;
