import { IKosDataModel, KosCreationContext } from '../../../core/core/kosModel';
import { IKosIdentifiable } from '../../../core/core/types';
import { PublicModelInterface } from '../../../core/types';
import { LogBlockOptions } from './types';
export declare const MODEL_TYPE = "log-block-model";
/**
 * Log Block Model - Individual log data block management within streaming log systems.
 *
 * This model represents a single block of log data within a LogStreamModel, providing efficient
 * memory management and organized access to log lines. Log blocks are the fundamental storage
 * units that enable high-performance log streaming by breaking large log streams into
 * manageable, sequential segments with precise line numbering and timing information.
 *
 * ## Key Features
 * - **Block-based Storage** - Efficient memory usage through segmented log storage
 * - **Line Management** - Precise line numbering with start/end tracking
 * - **Time-based Organization** - Temporal ordering with start and end timestamps
 * - **Dynamic Loading** - On-demand synchronization of log lines from source
 * - **Incremental Updates** - Add new lines without full reload
 * - **Stream Integration** - Seamless integration with LogStreamModel containers
 *
 * ## Architecture Relationship
 * LogBlock works as a component within the broader log streaming architecture:
 * - **LogStreamModel** contains multiple LogBlockModels via LogBlockContainerModel
 * - **LogBlockContainerModel** manages and sorts blocks by block number
 * - **LogBlockModel** stores the actual log lines and metadata for a specific segment
 * - This design enables efficient memory usage and fast access to recent log data
 *
 * ## Common Use Cases
 * - **Memory-efficient Log Storage** - Break large log streams into manageable blocks
 * - **Sequential Log Access** - Navigate through log history by block
 * - **Selective Loading** - Load only needed blocks for performance
 * - **Log Line Management** - Add, retrieve, and manage individual log entries
 * - **Time-based Log Analysis** - Filter and analyze logs by time ranges
 * - **Stream Synchronization** - Keep log blocks synchronized with source streams
 *
 * @interface
 * @example Basic Usage
 * ```typescript
 * // Typically accessed through LogStreamModel, not created directly
 * const logStream = LogStream.instance('app-logs')
 *   .options({ name: 'application-logs', nodeId: 'primary' })
 *   .build();
 *
 * await logStream.load();
 *
 * // Access blocks within the stream
 * const blocks = logStream.blocks;
 * const currentBlock = logStream.currentBlock;
 *
 * if (currentBlock) {
 *   console.log(`Block ${currentBlock.blockNum}`);
 *   console.log(`Lines: ${currentBlock.startLineNum}-${currentBlock.endLineNum}`);
 *   console.log(`Time range: ${currentBlock.startTime} to ${currentBlock.endTime}`);
 *   console.log(`Line count: ${currentBlock.lineCount}`);
 * }
 * ```
 *
 * @example Block Line Management
 * ```typescript
 * // Access through log stream
 * const logStream = LogStream.instance('system-logs').build();
 * const block = logStream.currentBlock;
 *
 * if (block) {
 *   // Get current lines
 *   console.log(`Block has ${block.lines.length} loaded lines`);
 *
 *   // Add new lines (typically done automatically by stream)
 *   block.addLines(['New log entry 1', 'New log entry 2']);
 *
 *   // Sync with remote source
 *   await block.syncLines();
 *
 *   // Process lines
 *   block.lines.forEach((line, index) => {
 *     const globalLineNum = block.startLineNum + index;
 *     console.log(`Line ${globalLineNum}: ${line}`);
 *   });
 * }
 * ```
 *
 * @example Block Analysis and Filtering
 * ```typescript
 * // Analyze blocks within a stream
 * const logStream = LogStream.instance('error-logs').build();
 * await logStream.load();
 *
 * // Find blocks within a time range
 * const startTime = new Date('2024-01-01T00:00:00Z');
 * const endTime = new Date('2024-01-01T23:59:59Z');
 *
 * const blocksInRange = logStream.blocks.filter(block =>
 *   block.startTime >= startTime && block.endTime <= endTime
 * );
 *
 * console.log(`Found ${blocksInRange.length} blocks in date range`);
 *
 * // Process error logs from specific blocks
 * for (const block of blocksInRange) {
 *   await block.syncLines(); // Ensure lines are loaded
 *
 *   const errorLines = block.lines
 *     .map((line, index) => ({ line, lineNum: block.startLineNum + index }))
 *     .filter(({ line }) => line.includes('ERROR'));
 *
 *   if (errorLines.length > 0) {
 *     console.log(`Block ${block.blockNum} has ${errorLines.length} errors`);
 *     errorLines.forEach(({ line, lineNum }) => {
 *       console.log(`Line ${lineNum}: ${line}`);
 *     });
 *   }
 * }
 * ```
 *
 * @example Block Container Integration
 * ```typescript
 * // Access blocks through their container
 * const logStream = LogStream.instance('debug-logs').build();
 * const blockContainer = logStream.blocks; // This is a LogBlockContainerModel
 *
 * // Blocks are automatically sorted by block number
 * const sortedBlocks = blockContainer.data;
 * console.log(`Stream has ${sortedBlocks.length} blocks`);
 *
 * // Get specific block by ID
 * const blockId = 'debug-logs-block-5';
 * const specificBlock = blockContainer.getModel(blockId);
 *
 * if (specificBlock) {
 *   console.log(`Block ${specificBlock.blockNum} loaded`);
 *   await specificBlock.syncLines();
 * }
 *
 * // Add new block to container (typically done automatically)
 * const newBlockOptions: LogBlockOptions = {
 *   nodeId: 'primary',
 *   stream: 'debug-logs',
 *   blockNum: 10,
 *   startLineNum: 1000,
 *   endLineNum: 1099,
 *   startTime: new Date(),
 *   endTime: new Date(Date.now() + 60000),
 *   lineCount: 100
 * };
 *
 * const newBlock = LogBlock.instance('debug-logs-block-10')
 *   .options(newBlockOptions)
 *   .build();
 *
 * blockContainer.addModel(newBlock);
 * ```
 *
 * @example Block Update and Synchronization
 * ```typescript
 * const block = logStream.currentBlock;
 *
 * if (block) {
 *   // Update block metadata (typically done by stream management)
 *   const updatedOptions: LogBlockOptions = {
 *     ...block,
 *     endLineNum: block.endLineNum + 50,
 *     endTime: new Date(),
 *     lineCount: block.lineCount + 50
 *   };
 *
 *   block.updateModel(updatedOptions);
 *
 *   // Sync to get new lines
 *   await block.syncLines();
 *
 *   console.log(`Block now has ${block.lines.length} lines loaded`);
 *   console.log(`Updated end time: ${block.endTime}`);
 * }
 * ```
 *
 * @group KOS Model
 * @category Device Logging
 * @useDeclaredType
 *
 * @see {@link LogStreamModel} - Parent stream model that contains log blocks
 * @see {@link LogBlockContainerModel} - Container that manages multiple log blocks
 * @see {@link LogBlockOptions} - Configuration options for log block instances
 * @see {@link LogBlockType} - Type definition for block data exchange
 * @see {@link LogLinesType} - Type definition for line data with block metadata
 */
export type LogBlockModel = PublicModelInterface<LogBlockModelImpl>;
/**
 * @ignore
 * @internal
 */
export declare class LogBlockModelImpl implements IKosDataModel, IKosIdentifiable {
    id: string;
    private logger;
    nodeId: string;
    stream: string;
    blockNum: number;
    startLineNum: number;
    endLineNum: number;
    startTime: Date;
    endTime: Date;
    lineCount: number;
    lines: string[];
    inc: number;
    constructor(modelId: string, options: LogBlockOptions, context: KosCreationContext);
    syncLines(): Promise<void>;
    updateModel(options: LogBlockOptions): void;
    addLines(lines: string[], replace?: boolean): void;
    init(): Promise<void>;
    load(): Promise<void>;
}
//# sourceMappingURL=log-block-model.d.ts.map