import o from"path";import{stat as s,readFile as n}from"fs/promises";import{writeFileSync as c}from"fs";import{removeTrailingSlash as m}from"../../utils/url/remove-trailing-slash.js";import{ensureDir as f}from"./fs.js";import{sanitizeWindowsFilename as p}from"./sanitize-windows-filename.js";const y=(t,r,a)=>{const i=e(t,a);c(f(i),JSON.stringify(r),"utf-8")},g=async(t,r)=>{const a=e(t,r);return await u(a)?n(a,"utf-8").then(i=>JSON.parse(i)):{}},e=(t,r)=>{const a=m(t.slice(1)),i=process.platform==="win32"?p(a):a;return o.join(r,"static-data",`${i}.json`)};async function u(t){try{return await s(t),!0}catch{return!1}}export{g as readStaticData,y as writeStaticData};
