const path=require("path");function buildSfxFilename(displayName,fileHash,fileUrl){const safeName=displayName.replace(/[\\/:*?"<>|]/g,"_");let ext="";try{ext=path.extname(new URL(fileUrl).pathname)}catch(e){ext=path.extname(displayName)}return ext||(ext=".mp3"),`${safeName}_${fileHash}${ext}`}function extractFileHashFromFilename(filename){const match=filename.match(/_([a-f0-9]{8,64})\.[^.]+$/i);return match?match[1]:null}function filenameMatchesHash(filename,fileHash){return extractFileHashFromFilename(filename)===fileHash}function buildSfxFilePath(cacheDir,displayName,fileHash,fileUrl){const filename=buildSfxFilename(displayName,fileHash,fileUrl);return path.join(cacheDir,filename)}module.exports={buildSfxFilename:buildSfxFilename,extractFileHashFromFilename:extractFileHashFromFilename,filenameMatchesHash:filenameMatchesHash,buildSfxFilePath:buildSfxFilePath};