// frontend/src/branding.ts — single source of truth for the firm name
// Paliad's UI renders. Mirrors internal/branding/firm.go on the server.
//
// At build time this resolves twice:
//   1. In the server-side render path (build.ts → renderXxx() returning HTML)
//      Bun is running under Node, so process.env.FIRM_NAME is the real env
//      var the deployer set; this file is loaded as a regular ESM module.
//   2. In the bundled client modules (e.g. client/i18n.ts) Bun.build replaces
//      `process.env.FIRM_NAME` with a string literal via the `define` option
//      configured in build.ts. Browsers never see process.env — every
//      reference is statically substituted before the bundle is emitted.
//
// Both paths default to "HLC" when FIRM_NAME is unset.
//
// IMPORTANT: do NOT guard the read with `typeof process !== "undefined"` or
// any check on `process` itself. The minifier rewrites that guard into a
// short-string lexical comparison (`typeof process < "u"`) which evaluates
// false in the browser and would short-circuit the value back to "HLC" even
// when define has substituted the env var. The bare `process.env.FIRM_NAME`
// reference is only safe because build.ts's `define` rewrites it away
// completely for browser bundles.
//
// Why a runtime constant rather than i18n placeholder substitution: every
// Paliad surface (HTML title, hero headline, email body, PDF footer) has the
// firm name baked in literally; threading {{firm}} placeholders + a
// formatter through every t() call would be a far larger churn for the same
// firm-agnostic outcome. Re-deploying with FIRM_NAME=Acme rebuilds every
// asset with the new name in one step.

const RAW: string = (process.env.FIRM_NAME ?? "").trim();
export const FIRM: string = RAW !== "" ? RAW : "HLC";
