{"version":3,"file":"index.cjs","names":["parseColumnIdSafely","isPObjectKey","DataColumn","isColumnDiscoveredKey","ColumnDiscoveredRecipe","isColumnOverriddenKey","ColumnOverriddenRecipe","isColumnFilteredKey","ColumnFilteredRecipe"],"sources":["../../../src/columns/column_recipes/index.ts"],"sourcesContent":["import {\n  isColumnDiscoveredKey,\n  isColumnOverriddenKey,\n  parseColumnIdSafely,\n  type ColumnUniversalId,\n  type PObjectId,\n  isPObjectKey,\n  isColumnFilteredKey,\n} from \"@milaboratories/pl-model-common\";\nimport type { GlobalCfgRenderCtx } from \"../../render/internal\";\nimport { DataColumn } from \"../data_column\";\nimport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nimport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nimport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\nimport type {\n  ColumnRecipe as ColumnRecipeBase,\n  ColumnRecipeId,\n  ColumnResolutionStatus,\n} from \"./types\";\n\nexport type { ColumnFieldStatus, ColumnRecipeId, ColumnResolutionStatus, SpecQuery } from \"./types\";\nexport { ColumnDiscoveredRecipe } from \"./column_discovered_recipe\";\nexport { ColumnFilteredRecipe } from \"./column_filtered_recipe\";\nexport { ColumnOverriddenRecipe } from \"./column_overrided_recipe\";\n\n// Re-declare the interface locally so the name can merge with the dispatcher\n// value declared below: a single name `ColumnRecipe` resolves to the\n// interface in type position and to the factory function (`Object.assign`d\n// with `.getStatus`) in value position.\n// (Type-only re-exports do not participate in TS declaration merging.)\nexport interface ColumnRecipe<\n  ID extends ColumnRecipeId = ColumnRecipeId,\n> extends ColumnRecipeBase<ID> {}\n\n/**\n * Build a `ColumnRecipe` from a stringified id. Dispatches to the matching\n * concrete recipe variant based on the id's encoding and recurses on\n * wrappers' inner `source`:\n *\n *   - bare {@link PObjectId} (non-JSON)               → `DataColumnRecipe.fromId`\n *   - `ColumnDiscoveredKey`                          → {@link ColumnDiscoveredRecipe}\n *   - `ColumnOverriddenKey { source, specOverrides }` → recurse on `source`,\n *                                                       then {@link ColumnOverriddenRecipe.wrap}\n *   - `ColumnFilteredKey { source, axisFilters }`     → recurse on `source`,\n *                                                       then {@link ColumnFilteredRecipe.wrap}\n *\n * Returns `undefined` for unsupported variants (e.g. AnchoredPColumnId,\n * which needs an anchor map to resolve) or when a nested source itself\n * cannot be built.\n */\nfunction ColumnRecipeBuild(\n  id: ColumnUniversalId,\n  opts: { ctx?: GlobalCfgRenderCtx } = {},\n): undefined | ColumnRecipe {\n  const parsed = parseColumnIdSafely(id);\n\n  if (isPObjectKey(parsed)) {\n    return DataColumn.fromId(id as PObjectId, opts);\n  }\n\n  if (isColumnDiscoveredKey(parsed)) {\n    return ColumnDiscoveredRecipe.fromKey(parsed, opts);\n  }\n\n  if (isColumnOverriddenKey(parsed)) {\n    const inner = ColumnRecipe(parsed.source, opts);\n    if (inner === undefined) return undefined;\n    return ColumnOverriddenRecipe.wrap(inner, parsed.specOverrides);\n  }\n\n  if (isColumnFilteredKey(parsed)) {\n    // ColumnFilteredKey.source is a stringified ColumnUniversalId (leaf or\n    // any nested wrapper). Legacy `FilteredPColumnId` with an AnchoredPColumnId\n    // (object) source is not supported here — guard against it explicitly.\n    if (typeof parsed.source !== \"string\") {\n      throw new Error(\n        `Unsupported ColumnRecipe id variant: filtered column with non-string source (${JSON.stringify(parsed.source)})`,\n      );\n    }\n    const inner = ColumnRecipe(parsed.source, opts);\n    if (inner === undefined) return undefined;\n    return ColumnFilteredRecipe.wrap(inner, parsed.axisFilters);\n  }\n\n  throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\n/**\n * Resolution status counterpart to {@link ColumnRecipeBuild}. Dispatches on\n * the parsed id shape to the matching `getStatusBy*` static — never\n * constructs the recipe. Use this at boundaries (resolver, filter/sort\n * targets) to tell an `absent` column from a `resolving` one: the recipe\n * factory returns `undefined` for both.\n */\nfunction ColumnRecipeGetStatus(\n  id: ColumnUniversalId,\n  opts: { ctx?: GlobalCfgRenderCtx } = {},\n): ColumnResolutionStatus {\n  const parsed = parseColumnIdSafely(id);\n  if (isPObjectKey(parsed)) return DataColumn.getStatusById(id as PObjectId, opts);\n  if (isColumnDiscoveredKey(parsed)) return ColumnDiscoveredRecipe.getStatusByKey(parsed, opts);\n  if (isColumnOverriddenKey(parsed)) return ColumnOverriddenRecipe.getStatusByKey(parsed, opts);\n  if (isColumnFilteredKey(parsed)) return ColumnFilteredRecipe.getStatusByKey(parsed, opts);\n  throw new Error(`Unsupported ColumnRecipe id variant: ${id}`);\n}\n\nexport const ColumnRecipe: typeof ColumnRecipeBuild & {\n  readonly getStatus: typeof ColumnRecipeGetStatus;\n} = Object.assign(ColumnRecipeBuild, {\n  getStatus: ColumnRecipeGetStatus,\n});\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAkDA,SAAS,kBACP,IACA,OAAqC,CAAC,GACZ;CAC1B,MAAM,UAAA,GAASA,gCAAAA,oBAAAA,CAAoB,EAAE;CAErC,KAAA,GAAIC,gCAAAA,aAAAA,CAAa,MAAM,GACrB,OAAOC,oBAAAA,WAAW,OAAO,IAAiB,IAAI;CAGhD,KAAA,GAAIC,gCAAAA,sBAAAA,CAAsB,MAAM,GAC9B,OAAOC,iCAAAA,uBAAuB,QAAQ,QAAQ,IAAI;CAGpD,KAAA,GAAIC,gCAAAA,sBAAAA,CAAsB,MAAM,GAAG;EACjC,MAAM,QAAQ,aAAa,OAAO,QAAQ,IAAI;EAC9C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,OAAOC,gCAAAA,uBAAuB,KAAK,OAAO,OAAO,aAAa;CAChE;CAEA,KAAA,GAAIC,gCAAAA,oBAAAA,CAAoB,MAAM,GAAG;EAI/B,IAAI,OAAO,OAAO,WAAW,UAC3B,MAAM,IAAI,MACR,gFAAgF,KAAK,UAAU,OAAO,MAAM,EAAE,EAChH;EAEF,MAAM,QAAQ,aAAa,OAAO,QAAQ,IAAI;EAC9C,IAAI,UAAU,KAAA,GAAW,OAAO,KAAA;EAChC,O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