export interface Tool { name: string; type?: 'software' | 'method' | 'concept'; projectUrl?: string | null; license?: string; knowledgebase?: boolean; domains?: string[]; phases?: string[]; platforms?: string[]; skillLevel?: string; description?: string; tags?: string[]; related_concepts?: string[]; } export function createToolSlug(toolName: string): string { if (!toolName || typeof toolName !== 'string') { console.warn('[toolHelpers] Invalid toolName provided to createToolSlug:', toolName); return ''; } return toolName.toLowerCase() .replace(/[^a-z0-9\s-]/g, '') // Remove special characters .replace(/\s+/g, '-') // Replace spaces with hyphens .replace(/-+/g, '-') // Remove duplicate hyphens .replace(/^-|-$/g, ''); // Remove leading/trailing hyphens } export function findToolByIdentifier(tools: Tool[], identifier: string): Tool | undefined { if (!identifier || !Array.isArray(tools)) return undefined; return tools.find(tool => tool.name === identifier || createToolSlug(tool.name) === identifier.toLowerCase() ); } export function isToolHosted(tool: Tool): boolean { return tool.projectUrl !== undefined && tool.projectUrl !== null && tool.projectUrl !== "" && tool.projectUrl.trim() !== ""; }