var e=Object.defineProperty,t=Object.defineProperties,r=Object.getOwnPropertyDescriptors,n=Object.getOwnPropertySymbols,s=Object.prototype.hasOwnProperty,a=Object.prototype.propertyIsEnumerable,i=e=>{throw TypeError(e)},o=(t,r,n)=>r in t?e(t,r,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[r]=n,l=(e,t)=>{for(var r in t||(t={}))s.call(t,r)&&o(e,r,t[r]);if(n)for(var r of n(t))a.call(t,r)&&o(e,r,t[r]);return e},c=(e,t,r)=>o(e,"symbol"!=typeof t?t+"":t,r),u=(e,t,r)=>(((e,t,r)=>{t.has(e)||i("Cannot "+r)})(e,t,"read from private field"),r?r.call(e):t.get(e)),h=(e,t,r)=>new Promise((n,s)=>{var a=e=>{try{o(r.next(e))}catch(t){s(t)}},i=e=>{try{o(r.throw(e))}catch(t){s(t)}},o=e=>e.done?n(e.value):Promise.resolve(e.value).then(a,i);o((r=r.apply(e,t)).next())});import{r as f,c as d,e as g,aZ as y,f as m,aP as p,dk as C,n as v}from"./index-BeZn6wgH.js";import{u as b}from"./useTableColumns-CLIpqO4Y.js";const A=function(){var e;class t{constructor(){var t,r,n;t=this,r=e,n=new Map,r.has(t)?i("Cannot add the same private member more than once"):r instanceof WeakSet?r.add(t):r.set(t,n)}compare(e,t){const r=typeof e,n=typeof t;return"string"===r&&"string"===n?e.localeCompare(t):"number"===r&&"number"===n?e-t:String.prototype.localeCompare.call(this.serialize(e,!0),this.serialize(t,!0))}serialize(e,t){if(null===e)return"null";switch(typeof e){case"string":return t?e:`'${e}'`;case"bigint":return`${e}n`;case"object":return this.$object(e);case"function":return this.$function(e)}return String(e)}serializeObject(e){const t=Object.prototype.toString.call(e);if("[object Object]"!==t)return this.serializeBuiltInType(t.length<10?`unknown:${t}`:t.slice(8,-1),e);const r=e.constructor,n=r===Object||void 0===r?"":r.name;if(""!==n&&globalThis[n]===r)return this.serializeBuiltInType(n,e);if("function"==typeof e.toJSON){const t=e.toJSON();return n+(null!==t&&"object"==typeof t?this.$object(t):`(${this.serialize(t)})`)}return this.serializeObjectEntries(n,Object.entries(e))}serializeBuiltInType(e,t){const r=this["$"+e];if(r)return r.call(this,t);if("function"==typeof(null==t?void 0:t.entries))return this.serializeObjectEntries(e,t.entries());throw new Error(`Cannot serialize ${e}`)}serializeObjectEntries(e,t){const r=Array.from(t).sort((e,t)=>this.compare(e[0],t[0]));let n=`${e}{`;for(let s=0;sthis.compare(e,t)))}`}$Map(e){return this.serializeObjectEntries("Map",e.entries())}}e=new WeakMap;for(const r of["Error","RegExp","URL"])t.prototype["$"+r]=function(e){return`${r}(${e})`};for(const r of["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array"])t.prototype["$"+r]=function(e){return`${r}[${e.join(",")}]`};for(const r of["BigInt64Array","BigUint64Array"])t.prototype["$"+r]=function(e){return`${r}[${e.join("n,")}${e.length>0?"n":""}]`};return t}(),w=[1779033703,-1150833019,1013904242,-1521486534,1359893119,-1694144372,528734635,1541459225],z=[1116352408,1899447441,-1245643825,-373957723,961987163,1508970993,-1841331548,-1424204075,-670586216,310598401,607225278,1426881987,1925078388,-2132889090,-1680079193,-1046744716,-459576895,-272742522,264347078,604807628,770255983,1249150122,1555081692,1996064986,-1740746414,-1473132947,-1341970488,-1084653625,-958395405,-710438585,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,-2117940946,-1838011259,-1564481375,-1474664885,-1035236496,-949202525,-778901479,-694614492,-200395387,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,-2067236844,-1933114872,-1866530822,-1538233109,-1090935817,-965641998],$=[];class _{constructor(){c(this,"_data",new E),c(this,"_hash",new E([...w])),c(this,"_nDataBytes",0),c(this,"_minBufferSize",0)}finalize(e){e&&this._append(e);const t=8*this._nDataBytes,r=8*this._data.sigBytes;return this._data.words[r>>>5]|=128<<24-r%32,this._data.words[14+(r+64>>>9<<4)]=Math.floor(t/4294967296),this._data.words[15+(r+64>>>9<<4)]=t,this._data.sigBytes=4*this._data.words.length,this._process(),this._hash}_doProcessBlock(e,t){const r=this._hash.words;let n=r[0],s=r[1],a=r[2],i=r[3],o=r[4],l=r[5],c=r[6],u=r[7];for(let h=0;h<64;h++){if(h<16)$[h]=0|e[t+h];else{const e=$[h-15],t=(e<<25|e>>>7)^(e<<14|e>>>18)^e>>>3,r=$[h-2],n=(r<<15|r>>>17)^(r<<13|r>>>19)^r>>>10;$[h]=t+$[h-7]+n+$[h-16]}const r=n&s^n&a^s&a,f=(n<<30|n>>>2)^(n<<19|n>>>13)^(n<<10|n>>>22),d=u+((o<<26|o>>>6)^(o<<21|o>>>11)^(o<<7|o>>>25))+(o&l^~o&c)+z[h]+$[h];u=c,c=l,l=o,o=i+d|0,i=a,a=s,s=n,n=d+(f+r)|0}r[0]=r[0]+n|0,r[1]=r[1]+s|0,r[2]=r[2]+a|0,r[3]=r[3]+i|0,r[4]=r[4]+o|0,r[5]=r[5]+l|0,r[6]=r[6]+c|0,r[7]=r[7]+u|0}_append(e){"string"==typeof e&&(e=E.fromUtf8(e)),this._data.concat(e),this._nDataBytes+=e.sigBytes}_process(e){let t,r=this._data.sigBytes/64;r=e?Math.ceil(r):Math.max((0|r)-this._minBufferSize,0);const n=16*r,s=Math.min(4*n,this._data.sigBytes);if(n){for(let e=0;e>>2]|=(255&t.charCodeAt(s))<<24-s%4*8;return new E(n,r)}toBase64(){const e=[];for(let t=0;t>>2]>>>24-t%4*8&255)<<16|(this.words[t+1>>>2]>>>24-(t+1)%4*8&255)<<8|this.words[t+2>>>2]>>>24-(t+2)%4*8&255;for(let n=0;n<4&&8*t+6*n<8*this.sigBytes;n++)e.push("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_".charAt(r>>>6*(3-n)&63))}return e.join("")}concat(e){if(this.words[this.sigBytes>>>2]&=4294967295<<32-this.sigBytes%4*8,this.words.length=Math.ceil(this.sigBytes/4),this.sigBytes%4)for(let t=0;t>>2]>>>24-t%4*8&255;this.words[this.sigBytes+t>>>2]|=r<<24-(this.sigBytes+t)%4*8}else for(let t=0;t>>2]=e.words[t>>>2];this.sigBytes+=e.sigBytes}}function R(e){return t="string"==typeof(r=e)?`'${r}'`:(new A).serialize(r),(new _).finalize(t).toBase64();var t,r}var B=(e=>(e.CLEAR_ALL="clear_all",e.CLEAR_CURRENT="clear_current",e.CLEAR_PAGINATION="clear_pagination",e.KEEP_ALL="keep_all",e))(B||{});class j{constructor(e=3e5,t=50,r=!1){c(this,"cache",new Map),c(this,"cacheTime"),c(this,"maxSize"),c(this,"enableLog"),this.cacheTime=e,this.maxSize=t,this.enableLog=r}log(e,...t){this.enableLog}generateKey(e){return R(e)}generateTags(e){const t=new Set,r=Object.keys(e).filter(t=>!["current","size","total"].includes(t)&&void 0!==e[t]&&""!==e[t]&&null!==e[t]);if(r.length>0){const n=r.map(t=>`${t}:${String(e[t])}`).join("|");t.add(`search:${n}`)}else t.add("search:default");return t.add(`pagination:${e.size||10}`),t.add("pagination"),t}evictLRU(){if(this.cache.size<=this.maxSize)return;let e="",t=1/0,r=1/0;for(const[n,s]of this.cache.entries())(s.accessCountthis.cacheTime?(this.cache.delete(t),null):(r.accessCount++,r.lastAccessTime=Date.now(),r):null}clearByTags(e){let t=0;for(const[r,n]of this.cache.entries()){e.some(e=>Array.from(n.tags).some(t=>t.includes(e)))&&(this.cache.delete(r),t++)}return t}clearCurrentSearch(e){const t=this.generateKey(e);return this.cache.delete(t)?1:0}clearPagination(){return this.clearByTags(["pagination"])}clear(){this.cache.clear()}getStats(){const e=this.cache.size;let t=0,r=0;for(const n of this.cache.values())t+=JSON.stringify(n.data).length,r+=n.accessCount;return{total:e,size:`${(t/1024).toFixed(2)}KB`,hitRate:`${e>0?(r/e).toFixed(1):"0"} avg hits`}}cleanupExpired(){let e=0;const t=Date.now();for(const[r,n]of this.cache.entries())t-n.timestamp>this.cacheTime&&(this.cache.delete(r),e++);return e}}const L=["list","data","records","items","result","rows"],T=["total","count"],O=["current","page","pageNum"],S=["size","pageSize","limit","page_size"],P={current:"current",size:"size"};function U(e,t){for(const r of t)if(r in e&&Array.isArray(e[r]))return e[r];return[]}function k(e,t,r){for(const n of r)if(n in e&&"number"==typeof e[n])return e[n];return t.length}function N(e,t){const r={},n=[e,null!=t?t:{}],s=O;for(const i of n){for(const e of s)if(e in i&&"number"==typeof i[e]){r.current=i[e];break}if(void 0!==r.current)break}const a=S;for(const i of n){for(const e of a)if(e in i&&"number"==typeof i[e]){r.size=i[e];break}if(void 0!==r.size)break}if(void 0!==r.current||void 0!==r.size)return r}const D=e=>{const t=L;if(!e)return{records:[],total:0};if(Array.isArray(e))return{records:e,total:e.length};if("object"!=typeof e)return{records:[],total:0};const r=e;let n,s=[],a=0;if(s=U(r,t),a=k(r,s,T),n=N(r),0===s.length&&"data"in r&&"object"==typeof r.data){const e=r.data;s=U(e,["list","records","items"]),a=k(e,s,T),n=N(r,e),Array.isArray(r.data)&&(s=r.data,a=s.length)}!t.some(e=>e in r)&&s.length;const i={records:s,total:a};return n&&Object.assign(i,n),i},I=(e,t)=>{var r,n;e.total=null!=(n=null!=(r=t.total)?r:e.total)?n:0,void 0!==t.current&&(e.current=t.current);const s=Math.max(1,Math.ceil(e.total/(e.size||1)));e.current>s&&(e.current=s)};function x(e){return function(e){const{core:{apiFn:n,apiParams:s={},excludeParams:a=[],immediate:i=!0,columnsFactory:o,paginationKey:c},transform:{dataTransformer:u,responseAdapter:A=D}={},performance:{enableCache:w=!1,cacheTime:z=3e5,debounceTime:$=300,maxCacheSize:_=50}={},hooks:{onSuccess:E,onError:R,onCacheHit:L,resetFormCallback:T}={},debug:{enableLog:O=!1}={}}=e,S=(null==c?void 0:c.current)||P.current,U=(null==c?void 0:c.size)||P.size,k=f(0),N={log:(e,...t)=>{},warn:(e,...t)=>{},error:(e,...t)=>{}},x=w?new j(z,_,O):null,M=f("idle"),K=d(()=>"loading"===M.value),F=f(null),G=f([]);let J=null,W=null;const q=g(Object.assign({[S]:1,[U]:10},s||{})),H=g({current:q[S]||1,size:q[U]||10,total:0}),{width:Z}=y(),Q=d(()=>{return e=l({},H),n={small:Z.value<768},t(e,r(n));var e,n}),V=o?b(o):null,X=null==V?void 0:V.columns,Y=null==V?void 0:V.columnChecks,ee=d(()=>G.value.length>0),te=d(()=>(k.value,x?x.getStats():{total:0,size:"0KB",hitRate:"0 avg hits"})),re=(e=>{const t=(e,...t)=>{};return(r,n)=>{const s={code:"UNKNOWN_ERROR",message:"未知错误",details:r};return r instanceof Error?(s.message=r.message,s.code=r.name):"string"==typeof r&&(s.message=r),t(`${n}:`,r),null==e||e(s),s}})(R,O),ne=(e,t)=>{if(!x)return;let r=0;switch(e){case B.CLEAR_ALL:x.clear(),N.log(`清空所有缓存 - ${t||""}`);break;case B.CLEAR_CURRENT:r=x.clearCurrentSearch(q),N.log(`清空当前搜索缓存 ${r} 条 - ${t||""}`);break;case B.CLEAR_PAGINATION:r=x.clearPagination(),N.log(`清空分页缓存 ${r} 条 - ${t||""}`);break;case B.KEEP_ALL:default:N.log(`保持缓存不变 - ${t||""}`)}k.value++},se=(e,...t)=>h(this,[e,...t],function*(e,t=w){J&&J.abort();const r=new AbortController;J=r,M.value="loading",F.value=null;try{let s=Object.assign({},q,{[S]:H.current,[U]:H.size},e||{});if(a.length>0){const e=l({},s);a.forEach(t=>{delete e[t]}),s=e}if(t&&x){const e=x.get(s);if(e){G.value=e.data,I(H,e.response);const t=q;return t[S]!==H.current&&(t[S]=H.current),t[U]!==H.size&&(t[U]=H.size),M.value="success",L&&L(e.data,e.response),N.log("缓存命中"),e.response}}const i=yield n(s);if(r.signal.aborted)throw new Error("请求已取消");const o=A(i);let c=(e=>{const t=e.records||e.data||[];return Array.isArray(t)?t:[]})(o);u&&(c=u(c)),G.value=c,I(H,o);const h=q;return h[S]!==H.current&&(h[S]=H.current),h[U]!==H.size&&(h[U]=H.size),t&&x&&(x.set(s,c,o),k.value++,N.log("数据已缓存")),M.value="success",E&&E(c,o),o}catch(s){if(s instanceof Error&&"请求已取消"===s.message)return M.value="idle",{records:[],total:0,current:1,size:10};M.value="error",G.value=[];throw re(s,"获取表格数据失败")}finally{J===r&&(J=null)}}),ae=e=>h(this,null,function*(){try{return yield se(e)}catch(t){return Promise.resolve()}}),ie=e=>h(this,null,function*(){H.current=1;const t=e||l({},q);t[S]=1,ne(B.CLEAR_CURRENT,"搜索数据");try{return yield se(t,!1)}catch(r){return Promise.resolve()}}),oe=((e,t)=>{let r=null,n=null,s=null,a=null;const i=(...i)=>new Promise((o,l)=>{r&&clearTimeout(r),n=i,s=o,a=l,r=setTimeout(()=>h(void 0,null,function*(){try{const t=yield e(...i);o(t)}catch(F){l(F)}finally{r=null,n=null,s=null,a=null}}),t)});return i.cancel=()=>{r&&clearTimeout(r),r=null,n=null,s=null,a=null},i.flush=()=>h(void 0,null,function*(){if(r&&n&&s&&a){clearTimeout(r),r=null;const t=n,i=s,o=a;n=null,s=null,a=null;try{const r=yield e(...t);return i(r),r}catch(F){throw o(F),F}}return Promise.resolve()}),i})(ie,$),le=()=>h(this,null,function*(){oe.cancel();const e=q,t={[S]:1,[U]:e[U]||10};Object.keys(q).forEach(t=>{delete e[t]}),Object.assign(q,s||{},t),H.current=1,H.size=t[U],F.value=null,ne(B.CLEAR_ALL,"重置搜索"),yield ae(),T&&(yield v(),T())});let ce=!1;const ue=e=>h(this,null,function*(){if(e<=0)return;oe.cancel();const t=q;H.size=e,H.current=1,t[U]=e,t[S]=1,ne(B.CLEAR_CURRENT,"分页大小变化"),yield ae()}),he=e=>h(this,null,function*(){if(!(e<=0||ce))if(H.current!==e)try{ce=!0,H.current=e;const t=l({},q);t[S]=e,yield ae(t)}finally{ce=!1}else N.log("分页页码未变化,跳过请求")}),fe=()=>h(this,null,function*(){oe.cancel(),H.current=1;const e=l({},q);e[S]=1,ne(B.CLEAR_PAGINATION,"新增数据"),yield ae(e)}),de=()=>h(this,null,function*(){ne(B.CLEAR_CURRENT,"编辑数据"),yield ae()}),ge=()=>h(this,null,function*(){const{current:e}=H;if(ne(B.CLEAR_CURRENT,"删除数据"),yield ae(),0===G.value.length&&e>1){H.current=e-1;const t=l({},q);t[S]=e-1,yield ae(t)}}),ye=()=>h(this,null,function*(){oe.cancel(),ne(B.CLEAR_ALL,"手动刷新"),yield ae()}),me=()=>h(this,null,function*(){ne(B.CLEAR_CURRENT,"软刷新"),yield ae()}),pe=()=>{J&&J.abort(),oe.cancel()},Ce=()=>{G.value=[],F.value=null,ne(B.CLEAR_ALL,"清空数据")},ve=()=>{if(!x)return 0;const e=x.cleanupExpired();return e>0&&k.value++,e};w&&x&&(W=setInterval(()=>{const e=x.cleanupExpired();e>0&&(N.log(`自动清理 ${e} 条过期缓存`),k.value++)},z/2));i&&m(()=>h(this,null,function*(){yield ae()}));return p(()=>{pe(),x&&x.clear(),W&&clearInterval(W)}),l({data:G,loading:C(K),error:C(F),isEmpty:d(()=>0===G.value.length),hasData:ee,pagination:C(H),paginationMobile:Q,handleSizeChange:ue,handleCurrentChange:he,searchParams:q,resetSearchParams:le,fetchData:ae,getData:ie,getDataDebounced:oe,clearData:Ce,refreshData:ye,refreshSoft:me,refreshCreate:fe,refreshUpdate:de,refreshRemove:ge,cacheInfo:te,clearCache:ne,clearExpiredCache:ve,cancelRequest:pe},V&&{columns:X,columnChecks:Y,addColumn:V.addColumn,removeColumn:V.removeColumn,toggleColumn:V.toggleColumn,updateColumn:V.updateColumn,batchUpdateColumns:V.batchUpdateColumns,reorderColumns:V.reorderColumns,getColumnConfig:V.getColumnConfig,getAllColumns:V.getAllColumns,resetColumns:V.resetColumns})}(e)}export{x as u};