const CORE_ENTITY_CONFIGS = {
  user: {
    entityType: "user",
    tableName: "users",
    // ✅ Plural to match database table
    metaTableName: "users_metas",
    // ✅ Plural to match database table
    idColumn: "userId",
    apiPath: "users"
  }
};
function getEntityMetaConfig(entityType) {
  if (entityType in CORE_ENTITY_CONFIGS) {
    return CORE_ENTITY_CONFIGS[entityType];
  }
  try {
    const { ENTITY_REGISTRY } = require("@nextsparkjs/registries/entity-registry");
    const entityConfig = ENTITY_REGISTRY[entityType];
    if (entityConfig) {
      const slug = entityConfig.apiPath || entityType;
      const tableName = slug.replace(/-/g, "_");
      return {
        entityType,
        tableName,
        // Use converted tableName (e.g., 'tasks', 'ai_history', 'audit_logs')
        metaTableName: `${tableName}_metas`,
        // e.g., 'tasks_metas', 'ai_history_metas'
        idColumn: "entityId",
        // All theme entity metas tables use generic 'entityId' column
        apiPath: slug
        // Keep original slug for API paths (with hyphens for URLs)
      };
    }
  } catch (error) {
    console.warn(`Could not load entity registry for ${entityType}, falling back to convention`);
  }
  const fallbackTableName = entityType.replace(/-/g, "_");
  return {
    entityType,
    tableName: fallbackTableName,
    metaTableName: `${fallbackTableName}_metas`,
    idColumn: "entityId",
    // All theme entity metas tables use generic 'entityId' column
    apiPath: `${fallbackTableName}s`
  };
}
function isCoreEntity(entityType) {
  return entityType in CORE_ENTITY_CONFIGS;
}
function getMetaValue(meta, key, defaultValue) {
  return (meta == null ? void 0 : meta[key]) ?? defaultValue;
}
export {
  CORE_ENTITY_CONFIGS,
  getEntityMetaConfig,
  getMetaValue,
  isCoreEntity
};
