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EAAA;AAChE,MAAO,OAAA,IAAA;AAAA;AACT;AAOF,EAAO,OAAA,KAAA;AACT;AArBgB,MAAA,CAAA,qBAAA,EAAA,uBAAA,CAAA;AAiDT,SAAS,uBAAuB,KAA+C,EAAA;AACpF,EAAA,OAAO,mBAAoB,CAAA,KAAK,CAC9B,IAAA,KAAA,IAAS,SACT,QAAY,IAAA,KAAA;AAChB;AAJgB,MAAA,CAAA,sBAAA,EAAA,wBAAA,CAAA;AAoBT,SAAS,wBAAwB,KAAgD,EAAA;AACtF,EAAO,OAAA,mBAAA,CAAoB,KAAK,CAAA,IAC9B,MAAU,IAAA,KAAA;AACd;AAHgB,MAAA,CAAA,uBAAA,EAAA,yBAAA,CAAA","file":"chunk-MNK7EBJ3.mjs","sourcesContent":["/**\n * Type definitions for content loading with metadata support\n */\n\n/**\n * Result of loading content with rich metadata\n */\nexport interface LoadContentResult {\n // Always available properties\n content: string; // File contents (or section if extracted)\n filename: string; // \"README.md\"\n relative: string; // \"./docs/README.md\"\n absolute: string; // \"/Users/adam/project/docs/README.md\"\n \n // Lazy-evaluated properties (implemented as getters)\n tokest: number; // Estimated tokens (KB-based)\n tokens: number; // Exact tokens (tiktoken)\n fm: any | undefined; // Frontmatter (markdown only)\n json: any | undefined; // Parsed JSON (JSON files only)\n}\n\n/**\n * Type guard for LoadContentResult\n */\nexport function isLoadContentResult(value: unknown): value is LoadContentResult {\n return (\n typeof value === 'object' &&\n value !== null &&\n 'content' in value &&\n 'filename' in value &&\n 'relative' in value &&\n 'absolute' in value\n );\n}\n\n/**\n * Array of LoadContentResult with special toString behavior\n */\nexport interface LoadContentResultArray extends Array<LoadContentResult> {\n toString(): string;\n}\n\n/**\n * Type guard for LoadContentResultArray\n */\nexport function isLoadContentResultArray(value: unknown): value is LoadContentResultArray {\n // Check for tagged Variable first\n const variable = (value as any)?.__variable;\n if (variable && variable.type === 'array' && variable.metadata?.arrayType === 'load-content-result') {\n return true;\n }\n \n // Original check for actual LoadContentResult arrays\n // Do not treat empty arrays as LoadContentResult arrays to avoid\n // misclassifying generic empty arrays (e.g., for-expression results).\n return Array.isArray(value) && value.length > 0 && value.every(isLoadContentResult);\n}\n\n/**\n * Array of renamed content strings\n */\nexport interface RenamedContentArray extends Array<string> {\n toString(): string;\n}\n\n/**\n * Type guard for RenamedContentArray\n */\nexport function isRenamedContentArray(value: unknown): value is RenamedContentArray {\n // Check for tagged Variable first\n const variable = (value as any)?.__variable;\n if (variable && variable.type === 'array' && variable.metadata?.arrayType === 'renamed-content') {\n return true;\n }\n \n // Check if it's a string array with custom toString\n if (Array.isArray(value) && value.every(item => typeof item === 'string')) {\n // Check if it has the custom toString behavior\n const hasCustomToString = value.toString !== Array.prototype.toString;\n if (hasCustomToString && value.toString() === value.join('\\n\\n')) {\n return true;\n }\n }\n \n // REMOVED: The broken content-based check that was too generic\n // DO NOT use: Array.isArray(value) && value.every(item => typeof item === 'string')\n // This would match ANY string array, not just RenamedContentArray\n \n return false;\n}\n\n/**\n * Extended metadata for URL content\n */\nexport interface LoadContentResultURL extends LoadContentResult {\n // URL-specific properties\n url: string; // The source URL\n domain: string; // Just the domain part\n title?: string; // Page title from HTML\n description?: string; // Meta description from HTML\n \n // Response metadata\n status?: number; // HTTP status code\n headers?: Record<string, string>; // Response headers\n rawContent: string; // Raw response (before conversion)\n \n // Content type properties\n contentType?: string; // MIME type from headers\n html?: string; // Raw HTML (same as rawContent for HTML)\n text?: string; // Plain text extraction (HTML stripped)\n json?: any; // Parsed JSON (for JSON responses)\n md?: string; // Markdown (deprecated, use content)\n}\n\n/**\n * Type guard for URL content results\n */\nexport function isLoadContentResultURL(value: unknown): value is LoadContentResultURL {\n return isLoadContentResult(value) && \n 'url' in value && \n 'domain' in value;\n}\n\n/**\n * Extended metadata for HTML file content\n */\nexport interface LoadContentResultHTML extends LoadContentResult {\n // HTML-specific properties\n title?: string; // Page title from <title> tag\n description?: string; // Meta description\n html: string; // Raw HTML content\n text?: string; // Plain text extraction (lazy)\n}\n\n/**\n * Type guard for HTML content results\n */\nexport function isLoadContentResultHTML(value: unknown): value is LoadContentResultHTML {\n return isLoadContentResult(value) && \n 'html' in value;\n}\n"]}