{"version":3,"file":"client.cjs","sources":["../src/core/YamlMergerBrowser.ts","../src/core/ViteHelper.ts"],"sourcesContent":["import * as yaml from 'js-yaml';\n\nexport class YamlMerger {\n  /**\n   * Merge multiple YAML content strings in order\n   */\n  mergeContent(contents: Array<{ content: string; name?: string }>): any {\n    let result = {};\n\n    for (const item of contents) {\n      let parsedContent: any;\n\n      try {\n        parsedContent = yaml.load(item.content);\n      } catch (error) {\n        const name = item.name || 'unknown content';\n        throw new Error(`Invalid YAML in ${name}: ${error instanceof Error ? error.message : String(error)}`);\n      }\n\n      if (parsedContent !== null && typeof parsedContent === 'object') {\n        result = this.deepMerge(result, parsedContent);\n      }\n    }\n\n    return result;\n  }\n\n  /**\n   * Deep merge two objects\n   * Rules:\n   * - Objects: merge properties, source overrides target\n   * - Arrays: source replaces target\n   * - Primitives: source overrides target\n   */\n  deepMerge(target: any, source: any): any {\n    // If source is null/undefined, return target\n    if (source === null || source === undefined) {\n      return target;\n    }\n\n    // If target is null/undefined, return source\n    if (target === null || target === undefined) {\n      return source;\n    }\n\n    // If both are arrays, the later content replaces the earlier content\n    if (Array.isArray(source) && Array.isArray(target)) {\n      return source;\n    }\n\n    // If source is not an object (or is an array but target isn't), it replaces target\n    if (typeof source !== 'object' || Array.isArray(source)) {\n      return source;\n    }\n\n    // If target is not an object, source replaces it\n    if (typeof target !== 'object' || Array.isArray(target)) {\n      return source;\n    }\n\n    // Both are objects, merge them\n    const result = { ...target };\n\n    for (const key in source) {\n      if (source.hasOwnProperty(key)) {\n        if (key in result) {\n          result[key] = this.deepMerge(result[key], source[key]);\n        } else {\n          result[key] = source[key];\n        }\n      }\n    }\n\n    return result;\n  }\n}\n","import { YamlMerger } from './YamlMergerBrowser';\n\n/**\n * Helper function for Vite environments\n * Works with import.meta.glob() to merge YAML files\n */\nexport async function stitchFromViteImports(\n  imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n  const contents = await Promise.all(\n    Object.entries(imports).map(async ([path, importFn]) => ({\n      content: (await importFn()).default,\n      name: path\n    }))\n  );\n  \n  const merger = new YamlMerger();\n  return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for ordered Vite imports\n * Ensures files are merged in a specific order based on the array\n */\nexport async function stitchFromOrderedViteImports(\n  orderedPaths: string[],\n  imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n  const contents = await Promise.all(\n    orderedPaths.map(async (path) => {\n      const importFn = imports[path];\n      if (!importFn) {\n        throw new Error(`Import not found for path: ${path}`);\n      }\n      return {\n        content: (await importFn()).default,\n        name: path\n      };\n    })\n  );\n  \n  const merger = new YamlMerger();\n  return merger.mergeContent(contents);\n}\n\n/**\n * Helper function for glob pattern imports with sorting\n * Useful when you want alphabetical ordering of files\n */\nexport async function stitchFromSortedViteImports(\n  imports: Record<string, () => Promise<{ default: string }>>\n): Promise<any> {\n  const sortedPaths = Object.keys(imports).sort();\n  return stitchFromOrderedViteImports(sortedPaths, imports);\n}\n\n/**\n * Direct content merging for when you already have the YAML strings\n */\nexport function stitchFromContent(\n  contents: Array<{ content: string; name?: string }>\n): any {\n  const merger = new YamlMerger();\n  return merger.mergeContent(contents);\n}\n\n/**\n * Convenience function for merging raw YAML strings without names\n */\nexport function stitchFromRawContent(yamlStrings: string[]): any {\n  const contents = yamlStrings.map((content, index) => ({\n    content,\n    name: `content-${index}`\n  }));\n  \n  return stitchFromContent(contents);\n}"],"names":["YamlMerger","contents","result","item","parsedContent","yaml","error","name","target","source","key","stitchFromViteImports","imports","path","importFn","stitchFromOrderedViteImports","orderedPaths","stitchFromSortedViteImports","sortedPaths","stitchFromContent","stitchFromRawContent","yamlStrings","content","index"],"mappings":"qYAEO,MAAMA,CAAW,CAItB,aAAaC,EAA0D,CACrE,IAAIC,EAAS,CAAC,EAEd,UAAWC,KAAQF,EAAU,CACvB,IAAAG,EAEA,GAAA,CACcA,EAAAC,EAAK,KAAKF,EAAK,OAAO,QAC/BG,EAAO,CACR,MAAAC,EAAOJ,EAAK,MAAQ,kBAC1B,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