"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const o=require("lodash-unified"),f=require("vue"),q=require("../../ap-grid/utils/col.js"),y=require("../../ap-table/utils.js");require("../../config-provider/index.js");require("../../utils/index.js");require("../components/body-cell/index.vue.js");require("../components/header-cell/index.vue.js");require("../components/tooltip/index.vue.js");const x=require("../renderer/index.js"),D=require("../../config-provider/hooks/use-global-config.js"),R=require("../../config-provider/hooks/use-namespace.js"),I=require("../components/body-cell/index.vue2.js"),P=require("../components/tooltip/index.vue2.js"),k=require("../../utils/is.js"),h=require("../components/header-cell/index.vue2.js");function G(r){return o.isNumber(r)&&r>1}function M(r,l){return d=>({...o.isFunction(l)?l(d):l??{},...r})}function V(r,l){if(l.bodyCellTooltip)return o.isFunction(l.bodyCellTooltip)?l.bodyCellTooltip(r.value,r.data):l.bodyCellTooltip;if(l.renderText)return l.renderText({value:r.value,record:r.data,column:l,text:r.value});const d=l.valueType||"text",u=x.rendererMap[d];if(u){const v=y.getTableRenderProps({...l,valueType:d},{value:r.value,text:r.value,record:r.data,column:r.column,rowIndex:r.node?.rowIndex,pinned:r.node?.rowPinned});return u(v)}return y.objectToString(r.value)}const F=(r,l,d,u)=>{const C=D.useGlobalConfig("valueTypeMap"),v=f.ref(),{em:T}=R.useNamespace("ag-grid"),g=t=>{const a={cellRenderer:I.default,cellRendererParams:{column:t,extraValueType:f.unref(C),rowKey:l.rowKey}};if(t.customRender)return a;if(t.renderText)return{valueFormatter:s=>{const i=s.colDef.colId,n=s.context.masks||{},c=i?n[i]:!1;return t.renderText({value:s.value,record:s.data,column:t,text:s.value,maskVisible:c})}};const p=t.valueType||"text",e=x.rendererMap[p];return e?{valueFormatter:s=>{const i=s.colDef.colId,n=s.context.masks||{};if(i?n[i]:!1)return"****";const b=y.getTableRenderProps({...t,valueType:p},{value:s.value,text:s.value,record:s.data,column:s.column,rowIndex:s.node?.rowIndex,pinned:s.node?.rowPinned});return e(b)}}:a},_=t=>{const a=t.valueType||"text",p=x.rendererMap[a],e={},s=t.bodyCellTooltip||!t.customRender&&p&&(t.ellipsis===!0||t.ellipsis==="tooltip"||o.isNumber(t.ellipsis)),i=o.isNumber(t.ellipsis)&&t.ellipsis>1,n=o.isNumber(t.ellipsis)?t.ellipsis:1;return e.tooltipValueGetter=s?c=>V(c,t):void 0,e.wrapText=!t.ellipsis||i,e.cellStyle=M({"--ag-grid-line-clamp":n},t.cellStyle),e.tooltipComponent=P.default,e.tooltipComponentParams={lineClamp:n,gridWrapperRef:v},e},S=f.computed(()=>{const t=f.unref(r);function a(p){return p.map(e=>{const s={field:q.dataIndexToField(e.dataIndex),colId:k.isDef(e.key)?String(e.key):void 0,sortable:!!e.sorter,comparator:e.sorter===!0?()=>0:e.sorter,headerComponentParams:{column:e,headerCell:u},resizable:e.resizable,width:e.width,minWidth:e.minWidth,maxWidth:e.maxWidth,suppressKeyboardEvent:()=>!0,flex:e.width?void 0:e.flex??1,pinned:e.fixed||null,colSpan:e.colSpan,spanRows:e.spanRows,cellClass:d(i=>{const n=e.cellClass||"",c=o.isFunction(n)?n(i.data,i.node):n;return[`${T("cell",e.align||"left")}`,G(e.ellipsis)?T("cell","multiline"):null,c].flat().filter(Boolean)}),cellStyle:e.cellStyle,headerStyle:e.headerStyle,headerClass:e.headerClass,columnGroupShow:e.columnGroupShow,autoHeight:!0,..._(e),...g(e)};return e.children?.length?{...s,headerGroupComponent:h.default,headerGroupComponentParams:{column:e,headerCell:u},children:a(e.children)}:s})}return a(t)}),w=f.computed(()=>({headerComponent:h.default,resizable:l.columnResizable,suppressMovable:!0,cellDataType:!1}));return{columnDefs:S,defaultColDef:w,gridWrapperRef:v}};exports.useColumnsDef=F;
