import path from 'path';
import os from 'os';
import { fileURLToPath } from 'url';

export const PKG_DIR = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..');
export const DATA_DIR = path.join(os.homedir(), '.bloby');
export const WORKSPACE_DIR = process.env.BLOBY_WORKSPACE || path.join(PKG_DIR, 'workspace');

const cfName = process.platform === 'win32' ? 'cloudflared.exe' : 'cloudflared';

export const paths = {
  config: path.join(DATA_DIR, 'config.json'),
  db: path.join(DATA_DIR, 'memory.db'),
  widgetJs: path.join(PKG_DIR, 'supervisor', 'widget.js'),
  supervisorPublic: path.join(PKG_DIR, 'supervisor', 'public'),
  cloudflared: path.join(DATA_DIR, 'bin', cfName),
  files: path.join(WORKSPACE_DIR, 'files'),
  filesAudio: path.join(WORKSPACE_DIR, 'files', 'audio'),
  filesImages: path.join(WORKSPACE_DIR, 'files', 'images'),
  filesDocuments: path.join(WORKSPACE_DIR, 'files', 'documents'),
};
