"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("vue"),i=require("../utils.js"),g=r=>{const u=o.ref([]),c=o.ref([]);function l(t=[]){return t.filter(e=>!e.hideInTable).map(e=>{if(e.children?.length){const n=l(e.children);return n?.length?{...e,children:n}:null}return e}).filter(Boolean)}function f(t){return u.value.find(e=>i.getStringKey(e.key)===t)}function s(t){const e=[];for(const n of t)n.children?.length?e.push(...s(n.children)):e.push(i.getStringKey(n.key));return e.filter(Boolean)}const a=o.computed(()=>s(u.value));async function m(t,e){return await i.runPipelineHooks(r.plugins,t,n=>n.beforeColumnsChange?.bind(n),e)}o.watch(()=>r.columns,async()=>{const t=l(r.columns),e=await m(t,u.value);u.value=e,c.value=e,r.onShownColumnsChange?.(e)},{deep:!0,immediate:!0});function d(t){for(const e of t)if(e.children){const n=d(e.children);if(n)return n}else if(e.defaultSortOrder){const n=e.field??e.dataIndex??e.key;return{colKey:e.key,field:n,order:e.defaultSortOrder}}}const h=o.computed(()=>d(l(r.columns)));return{columns:u,shownColumns:c,columnKeys:a,getTargetColumnByKey:f,defaultSortOrder:h,getColKeys:s}};exports.useColumns=g;
