1import{r as e}from"./rolldown-runtime-B0Z9INg1.js";import{n as t}from"./supabase-1QV27Coa.js";var n=e({bustContentCache:()=>u,fetchAllContent:()=>l,getContentByKey:()=>o,updateContent:()=>c}),r=null,i=null;function a(){return r?Promise.resolve(r):i||(i=(async()=>{let e=3;for(;e>0;){let{data:n,error:i}=await t.from(`site_content`).select(`content_key, content_text`);if(!i&&n){r=new Map;for(let e of n)r.set(e.content_key,e.content_text);return r}console.warn(`[siteContent] ensureCache attempt failed (${4-e}/3):`,i?.message),e--,e>0&&await new Promise(e=>setTimeout(e,500))}return console.error(`[siteContent] ensureCache: all retries exhausted, using empty cache`),r=new Map,r})(),i)}async function o(e){let n=await a();if(n.has(e))return n.get(e);let{data:r,error:i}=await t.from(`site_content`).select(`content_text`).eq(`content_key`,e).maybeSingle();if(i||!r)return null;let o=r.content_text;return n.set(e,o),o}async function s(e,n){let{data:r,error:i}=await t.from(`site_content`).upsert({content_key:e,content_text:n,updated_at:new Date().toISOString()},{onConflict:`content_key`}).select(`content_key`);return i?{ok:!1,blocked:i.code===`42501`||/row-level security|policy/i.test(i.message||``),message:i.message}:!r||r.length===0?{ok:!1,blocked:!0,message:`RLS blocked write (0 rows) â token likely stale`}:{ok:!0,blocked:!1}}async function c(e,n){let i=await s(e,n);if(!i.ok&&i.blocked){console.warn(`[siteContent] updateContent("${e}") blocked â refreshing session and retrying...`);try{await t.auth.refreshSession()}catch(e){console.warn(`[siteContent] refreshSession failed:`,e)}i=await s(e,n)}return i.ok?(r&&r.set(e,n),!0):(console.error(`[siteContent] updateContent("${e}") FAILED to persist:`,i.message),r&&r.has(e),!1)}async function l(){let{data:e,error:n}=await t.from(`site_content`).select(`*`).order(`content_key`,{ascending:!0});return n?(console.error(`[siteContent] fetchAllContent error:`,n),[]):e||[]}function u(){r=null,i=null}export{c as a,n as i,l as n,o as r,u as t}; 2//# sourceMappingURL=siteContent-7FCzdPWQ.js.map
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.