import"./router-BkUH5xox.js";import{r}from"./jwt-decode.esm-hjaWXwux.js";import{T as v}from"./tables-DvBVnXSM.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},s=new Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="fb39f834-2aaa-44b7-af2f-19734d0e1d5b",e._sentryDebugIdIdentifier="sentry-dbid-fb39f834-2aaa-44b7-af2f-19734d0e1d5b")}catch{}})();const l=new Map,n=new Set,m=e=>{const s=r([]),i=r(!1),f=r(null),u=async(t=!1)=>{if(!t&&l.has(e))return s.value=l.get(e),s.value;if(n.has(e)){for(;n.has(e);)await new Promise(a=>setTimeout(a,100));return s.value=l.get(e)||[],s.value}try{i.value=!0,n.add(e),f.value=null;const a=await v.list(e);return s.value=a,l.set(e,a),a}catch(a){throw f.value=a,console.error("Error fetching tables:",a),a}finally{i.value=!1,n.delete(e)}},o=t=>s.value.find(a=>a.id===t)||null,b=t=>{const a=l.get(e);a&&l.set(e,a.filter(c=>c.id!==t))},d=()=>{l.delete(e)},h=()=>{l.clear()};return!l.has(e)&&!n.has(e)?u():l.has(e)&&(s.value=l.get(e)),{tables:s,loading:i,error:f,fetchTables:u,getTableById:o,removeFromCache:b,invalidateCache:d,invalidateAllCache:h}};export{m as u};
//# sourceMappingURL=useTables-CI6fUDCs.js.map
