{"version":3,"file":"registry-DltAe79Q.mjs","names":["resistorSchema","capacitorSchema","groundSchema","switchSchema","batterySchema","voltageSourceSchema","diodeSchema","transistorNpnSchema","ledSchema","icSchema","componentRegistry: Record<string, ComponentSchema>","schema: ComponentSchema","id: string","category: string"],"sources":["../../src/registry/components/index.ts","../../src/registry/index.ts"],"sourcesContent":["/**\n * Component registry loader\n *\n * This module imports and registers all component schemas\n */\n\nimport { registerComponent } from '../index';\nimport { ComponentSchema } from '../../schemas/componentSchema';\n\n// Import component schemas\nimport resistorSchema from './resistor.json';\nimport capacitorSchema from './capacitor.json';\nimport batterySchema from './battery.json';\nimport groundSchema from './ground.json';\nimport switchSchema from './switch.json';\nimport voltageSourceSchema from './voltage-source.json';\nimport diodeSchema from './diode.json';\nimport transistorNpnSchema from './transistor-npn.json';\nimport ledSchema from './led.json';\nimport icSchema from './ic.json';\n\n// Register components\nconst registerBuiltInComponents = () => {\n  // Basic components\n  registerComponent(resistorSchema as ComponentSchema);\n  registerComponent(capacitorSchema as ComponentSchema);\n  registerComponent(groundSchema as ComponentSchema);\n  registerComponent(switchSchema as ComponentSchema);\n\n  // Sources\n  registerComponent(batterySchema as ComponentSchema);\n  registerComponent(voltageSourceSchema as ComponentSchema);\n\n  // Semiconductors\n  registerComponent(diodeSchema as ComponentSchema);\n  registerComponent(transistorNpnSchema as ComponentSchema);\n  registerComponent(ledSchema as ComponentSchema);\n\n  // Advanced components\n  registerComponent(icSchema as ComponentSchema);\n\n  // Add more component registrations here as they are created\n};\n\nexport default registerBuiltInComponents;\n","/**\n * Registry module for component schemas\n *\n * This module provides utilities for registering, retrieving, and managing component schemas.\n * The component registry is a central repository of all available component types that can\n * be used in circuits. Each component is defined by a schema that specifies its appearance,\n * ports, and configurable properties.\n *\n * @module Registry\n */\n\nimport { ComponentSchema } from '../schemas/componentSchema';\nimport { validateComponentSchema } from '../utils/zodValidation';\nimport registerBuiltInComponents from './components';\n\n// Internal registry storage\nconst componentRegistry: Record<string, ComponentSchema> = {};\n\n/**\n * Register a component schema in the registry\n *\n * This function adds a new component schema to the registry or updates an existing one.\n * Custom components can be registered to extend the library with new circuit elements.\n *\n * @param {ComponentSchema} schema - The component schema to register\n *\n * @example\n * // Register a custom LED component\n * registerComponent({\n *   id: 'custom-led',\n *   name: 'Custom LED',\n *   category: 'output',\n *   description: 'A light-emitting diode with customizable color',\n *   defaultWidth: 30,\n *   defaultHeight: 20,\n *   ports: [\n *     { id: 'anode', x: 0, y: 10, type: 'input' },\n *     { id: 'cathode', x: 30, y: 10, type: 'output' }\n *   ],\n *   properties: [\n *     { id: 'color', name: 'Color', type: 'color', default: '#ff0000' }\n *   ],\n *   svgPath: `<circle cx=\"15\" cy=\"10\" r=\"8\" fill=\"currentColor\" />`\n * });\n */\nexport function registerComponent(schema: ComponentSchema): void {\n  // Validate the schema using ZOD\n  const validationResult = validateComponentSchema(schema);\n\n  if (!validationResult.success) {\n    throw new Error(`Invalid component schema: ${validationResult.error}`);\n  }\n\n  if (componentRegistry[schema.id]) {\n    console.warn(`Component with ID ${schema.id} already exists in registry. Overwriting.`);\n  }\n\n  componentRegistry[schema.id] = schema;\n}\n\n/**\n * Get a component schema from the registry by ID\n *\n * Retrieves a component's schema definition by its unique identifier.\n * Returns undefined if no component with the specified ID exists.\n *\n * @param {string} id - The unique identifier of the component\n * @returns {ComponentSchema | undefined} The component schema or undefined if not found\n *\n * @example\n * const resistorSchema = getComponentSchema('resistor');\n * if (resistorSchema) {\n *   console.log(`Resistor has ${resistorSchema.ports.length} ports`);\n * }\n */\nexport function getComponentSchema(id: string): ComponentSchema | undefined {\n  return componentRegistry[id];\n}\n\n/**\n * Get all component schemas in the registry\n */\nexport function getAllComponents(): ComponentSchema[] {\n  return Object.values(componentRegistry);\n}\n\n/**\n * Get component schemas by category\n */\nexport function getComponentsByCategory(category: string): ComponentSchema[] {\n  return Object.values(componentRegistry)\n    .filter(schema => schema.category === category);\n}\n\n// Register built-in components\nregisterBuiltInComponents();\n\nexport default componentRegistry;\n"],"mappings":";;;;AAsBA,MAAM,4BAA4B,MAAM;AAEtC,mBAAkBA,iBAAkC;AACpD,mBAAkBC,kBAAmC;AACrD,mBAAkBC,eAAgC;AAClD,mBAAkBC,eAAgC;AAGlD,mBAAkBC,gBAAiC;AACnD,mBAAkBC,uBAAuC;AAGzD,mBAAkBC,cAA+B;AACjD,mBAAkBC,uBAAuC;AACzD,mBAAkBC,YAA6B;AAG/C,mBAAkBC,WAA4B;AAG/C;AAED,yBAAe;;;;AC5Bf,MAAMC,oBAAqD,CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6B7D,SAAgB,kBAAkBC,QAA+B;CAE/D,MAAM,mBAAmB,wBAAwB,OAAO;AAExD,MAAK,iBAAiB,QACpB,OAAM,IAAI,OAAO,4BAA4B,iBAAiB,MAAM;AAGtE,KAAI,kBAAkB,OAAO,IAC3B,SAAQ,MAAM,oBAAoB,OAAO,GAAG,2CAA2C;AAGzF,mBAAkB,OAAO,MAAM;AAChC;;;;;;;;;;;;;;;;AAiBD,SAAgB,mBAAmBC,IAAyC;AAC1E,QAAO,kBAAkB;AAC1B;;;;AAKD,SAAgB,mBAAsC;AACpD,QAAO,OAAO,OAAO,kBAAkB;AACxC;;;;AAKD,SAAgB,wBAAwBC,UAAqC;AAC3E,QAAO,OAAO,OAAO,kBAAkB,CACpC,OAAO,YAAU,OAAO,aAAa,SAAS;AAClD;AAGD,oBAA2B"}