import"./router-D53qV9Zg.js";import{r as u}from"./jwt-decode.esm-BYfS37aG.js";import{T as v}from"./tables-nYEEmE6H.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]="e4ebd4ee-e848-4779-8d8c-20a0b5dba7e3",e._sentryDebugIdIdentifier="sentry-dbid-e4ebd4ee-e848-4779-8d8c-20a0b5dba7e3")}catch{}})();const l=new Map,n=new Set,m=e=>{const s=u([]),i=u(!1),r=u(null),o=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),r.value=null;const a=await v.list(e);return s.value=a,l.set(e,a),a}catch(a){throw r.value=a,console.error("Error fetching tables:",a),a}finally{i.value=!1,n.delete(e)}},f=t=>s.value.find(a=>a.id===t)||null,b=t=>{const a=l.get(e);a&&l.set(e,a.filter(h=>h.id!==t))},d=()=>{l.delete(e)},c=()=>{l.clear()};return!l.has(e)&&!n.has(e)?o():l.has(e)&&(s.value=l.get(e)),{tables:s,loading:i,error:r,fetchTables:o,getTableById:f,removeFromCache:b,invalidateCache:d,invalidateAllCache:c}};export{m as u};
//# sourceMappingURL=useTables-CD8vx4pj.js.map
