"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("lodash-unified"),m=require("vue"),b=require("../../utils/warning.js"),A=require("./useKeepAliveFlag.js");function F(d){const r=m.ref(null),{isShowRowSelection:f=!0,clearSelectionOnRequest:p=!0,transformSearchFormValues:a,api:s,tableRefresh:o=!1,...g}=d||{};let l=null;const u=()=>{r.value?.rowSelection?.clearAll()},S=async e=>{l=e.sort;const t=a?a(e):e;try{if(!s)throw new Error("api is not defined");const{records:n,total:v}=await s(t);return p&&u(),{data:n,total:v}}catch(n){return b.warning(!1,n),{data:[],total:0}}};A.useKeepAliveFlag({afterActivated(){(c.isFunction(o)?o():o)&&i()}});const h=c.merge({scroll:{x:"100%",y:"100%"},tableLayout:"fixed",columnResizable:!0,class:"ap-table--sticky",request:s?S:void 0,rowSelection:f?{mode:"internal",fixed:"left",columnWidth:50}:void 0,ref(e){r.value=e},card:!0},g),i=()=>{r.value?.submit()};return[h,{reload:i,reset:()=>{r.value?.reset()},getSearchFormValues:e=>{const t=r.value?.getSearchFormValues(e)||{};return a?a(t):t},getApTableInstance:()=>r.value,getSearchFormValuesAndSorted:e=>{const t=r.value?.getSearchFormValues(e)||{};return t.sort=l&&c.cloneDeep(l),a?a(t):t},clearSelection:u}]}exports.usePageListApTable=F;
