{"version":3,"file":"css-var.mjs","names":[],"sources":["../src/css-var.ts"],"sourcesContent":["/**\n * Browser-safe `cssVarRef(path, prefix)` helper. Exported through the\n * `@unpunnyfuns/swatchbook-core/css-var` subpath so the addon's hooks\n * and the blocks-side display surface share one implementation — any\n * future naming-policy shift in Terrazzo (casing, unicode, prefix\n * handling) reaches both at once instead of needing parallel updates.\n *\n * Wraps `@terrazzo/token-tools/css`'s `makeCSSVar` because its `prefix`\n * option is a function-argument-position concern (per call) while\n * `wrapVar: true` is a here-always concern (every caller wants the\n * `var(--…)` wrapper). The two-argument shape `(path, prefix)` is the\n * ergonomic minimum.\n */\nimport { makeCSSVar } from '@terrazzo/token-tools/css';\nimport type { Project } from '#/types.ts';\n\n/** A `var(--…)` reference for `path` — the wrapped form, not the bare property name (see `cssVarName`). */\nexport function cssVarRef(path: string, prefix: string): string {\n  return prefix ? makeCSSVar(path, { prefix, wrapVar: true }) : makeCSSVar(path, { wrapVar: true });\n}\n\n/**\n * Authoritative custom-property name (bare `--…`, no `var()` wrapper) for a\n * token path. Listing-first: a resolver-backed project's listing carries the\n * exact names plugin-css emitted, so reading it can never drift from the\n * consumer's real output. Falls back to Terrazzo's own derivation for\n * listing-less projects — never a hand-rolled dot-to-dash, which diverges on\n * camelCase segments (`color.brandPrimary` is `--color-brand-primary` in\n * plugin-css output, not `--color-brandPrimary`).\n */\nexport function cssVarName(path: string, project: Pick<Project, 'listing' | 'config'>): string {\n  const listed = project.listing[path]?.$extensions['app.terrazzo.listing'].names['css'];\n  if (listed) return listed;\n  const prefix = project.config.cssVarPrefix;\n  return prefix ? makeCSSVar(path, { prefix }) : makeCSSVar(path);\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiBA,SAAgB,UAAU,MAAc,QAAwB;AAC9D,QAAO,SAAS,WAAW,MAAM;EAAE;EAAQ,SAAS;EAAM,CAAC,GAAG,WAAW,MAAM,EAAE,SAAS,MAAM,CAAC;;;;;;;;;;;AAYnG,SAAgB,WAAW,MAAc,SAAsD;CAC7F,MAAM,SAAS,QAAQ,QAAQ,OAAO,YAAY,wBAAwB,MAAM;AAChF,KAAI,OAAQ,QAAO;CACnB,MAAM,SAAS,QAAQ,OAAO;AAC9B,QAAO,SAAS,WAAW,MAAM,EAAE,QAAQ,CAAC,GAAG,WAAW,KAAK"}