{"version":3,"sources":["../src/types.ts"],"names":[],"mappings":";;;AA0EO,SAAS,MAAA,CAAyB,KAAoB,IAAA,EAA6C;AACxG,EAAA,OAAO,GAAA,CAAI,IAAA,KAAS,IAAA,IAAQ,GAAA,CAAI,KAAK,KAAA,KAAU,IAAA;AACjD;AAKO,SAAS,YAAA,CAAiC,KAAoB,KAAA,EAAsD;AACzH,EAAA,MAAM,OAAA,GAAU,GAAA,CAAI,IAAA,IAAQ,GAAA,CAAI,IAAA,CAAK,KAAA;AACrC,EAAA,IAAI,KAAA,CAAM,OAAA,CAAQ,OAAO,CAAA,EAAG;AAC1B,IAAA,OAAO,QAAQ,IAAA,CAAK,CAAC,MAAM,KAAA,CAAM,QAAA,CAAS,CAAc,CAAC,CAAA;AAAA,EAC3D;AACA,EAAA,OAAO,KAAA,CAAM,SAAS,OAAoB,CAAA;AAC5C;AAWO,SAAS,oBAA6C,IAAA,EAA0B;AACrF,EAAA,OAAO,CAAC,MAA4B,OAAA,MAA2C;AAAA,IAC7E,IAAA;AAAA,IACA,IAAA,EAAM,EAAE,KAAA,EAAO,IAAA,EAAM,GAAG,IAAA,EAAK;AAAA,IAC7B;AAAA,GACF,CAAA;AACF","file":"chunk-EYNAQ42G.cjs","sourcesContent":["/**\n * JSON-LD style properties that can appear on any object in flat mode\n */\nexport interface LDProperties {\n  $id?: string\n  $type?: string | string[]\n  $context?: string | string[] | Record<string, unknown>\n}\n\n/**\n * Data object with optional JSON-LD properties\n */\nexport type MDXLDData = LDProperties & Record<string, unknown>\n\n/**\n * Helper type to create typed data with $type discriminator\n * Used by extension packages (schema.org.ai, business.org.ai) to create discriminated unions\n *\n * @example\n * ```ts\n * // In schema.org.ai package:\n * type ArticleData = TypedData<'Article', { headline: string; author: string }>\n * type PersonData = TypedData<'Person', { name: string; email: string }>\n * type SchemaOrgData = ArticleData | PersonData\n * ```\n */\nexport type TypedData<TType extends string, TFields extends Record<string, unknown> = Record<string, unknown>> = {\n  $type: TType\n} & Omit<LDProperties, '$type'> &\n  TFields\n\n/**\n * Helper to extract $type literal from typed data\n */\nexport type ExtractType<T extends MDXLDData> = T extends { $type: infer TType } ? TType : string | string[]\n\n/**\n * Root MDXLD document structure with generic data type support\n *\n * @typeParam TData - The type of the data object, defaults to MDXLDData\n *\n * @example\n * ```ts\n * // Basic usage\n * const doc: MDXLDDocument = parse(content)\n *\n * // With typed data from extension package\n * import { SchemaOrgData } from 'schema.org.ai'\n * const doc: MDXLDDocument<SchemaOrgData> = parse(content) as MDXLDDocument<SchemaOrgData>\n * ```\n */\nexport interface MDXLDDocument<TData extends MDXLDData = MDXLDData> {\n  /** Document identifier (maps to $id in flat mode) */\n  id?: string\n  /** Document type (maps to $type in flat mode) */\n  type?: ExtractType<TData>\n  /** JSON-LD context (maps to $context in flat mode) */\n  context?: string | string[] | Record<string, unknown>\n  /** Structured data from YAML frontmatter */\n  data: TData\n  /** Raw MDX content body */\n  content: string\n}\n\n/**\n * Type guard to check if document has a specific $type\n *\n * @example\n * ```ts\n * if (isType(doc, 'Article')) {\n *   // doc.type is 'Article', doc.data.$type is 'Article'\n * }\n * ```\n */\nexport function isType<T extends string>(doc: MDXLDDocument, type: T): doc is MDXLDDocument<TypedData<T>> {\n  return doc.type === type || doc.data.$type === type\n}\n\n/**\n * Type guard to check if document has one of multiple types\n */\nexport function isOneOfTypes<T extends string[]>(doc: MDXLDDocument, types: T): doc is MDXLDDocument<TypedData<T[number]>> {\n  const docType = doc.type ?? doc.data.$type\n  if (Array.isArray(docType)) {\n    return docType.some((t) => types.includes(t as T[number]))\n  }\n  return types.includes(docType as T[number])\n}\n\n/**\n * Create a typed document factory for a specific type\n *\n * @example\n * ```ts\n * const createArticle = createTypedDocument<ArticleData>('Article')\n * const article = createArticle({ headline: 'Hello', author: 'John' }, '# Content')\n * ```\n */\nexport function createTypedDocument<TData extends MDXLDData>(type: ExtractType<TData>) {\n  return (data: Omit<TData, '$type'>, content: string): MDXLDDocument<TData> => ({\n    type,\n    data: { $type: type, ...data } as TData,\n    content,\n  })\n}\n\n/**\n * Extended document with AST (added by mdxld/ast)\n */\nexport interface MDXLDDocumentWithAST<TData extends MDXLDData = MDXLDData> extends MDXLDDocument<TData> {\n  /** Parsed AST representation */\n  ast: MDXLDAst\n}\n\n/**\n * Extended document with compiled code (added by mdxld/compile)\n */\nexport interface MDXLDDocumentWithCode<TData extends MDXLDData = MDXLDData> extends MDXLDDocument<TData> {\n  /** Compiled JavaScript code */\n  code: string\n  /** React component (when evaluated) */\n  component?: unknown\n}\n\n/**\n * Fully extended document with all properties\n */\nexport interface MDXLDDocumentFull<TData extends MDXLDData = MDXLDData> extends MDXLDDocument<TData> {\n  ast?: MDXLDAst\n  code?: string\n  component?: unknown\n}\n\n/**\n * AST node types\n */\nexport type MDXLDAstNodeType =\n  | 'root'\n  | 'yaml'\n  | 'paragraph'\n  | 'heading'\n  | 'text'\n  | 'emphasis'\n  | 'strong'\n  | 'inlineCode'\n  | 'code'\n  | 'link'\n  | 'image'\n  | 'list'\n  | 'listItem'\n  | 'blockquote'\n  | 'thematicBreak'\n  | 'html'\n  | 'mdxJsxFlowElement'\n  | 'mdxJsxTextElement'\n  | 'mdxFlowExpression'\n  | 'mdxTextExpression'\n  | 'mdxjsEsm'\n\n/**\n * Base AST node\n */\nexport interface MDXLDAstNode {\n  type: MDXLDAstNodeType | string\n  children?: MDXLDAstNode[]\n  value?: string\n  position?: {\n    start: { line: number; column: number; offset: number }\n    end: { line: number; column: number; offset: number }\n  }\n  [key: string]: unknown\n}\n\n/**\n * Root AST node\n */\nexport interface MDXLDAst extends MDXLDAstNode {\n  type: 'root'\n  children: MDXLDAstNode[]\n}\n\n/**\n * Parse options\n */\nexport interface ParseOptions {\n  /**\n   * Output mode for data properties\n   * - 'expanded': Use id, type, context at root level (default)\n   * - 'flat': Keep $id, $type, $context in data object\n   */\n  mode?: 'expanded' | 'flat'\n}\n\n/**\n * Stringify options\n */\nexport interface StringifyOptions {\n  /**\n   * Output mode for YAML frontmatter\n   * - 'expanded': Read from id, type, context and write as $id, $type, $context\n   * - 'flat': Write data object as-is with $id, $type, $context\n   */\n  mode?: 'expanded' | 'flat'\n}\n"]}