{"version":3,"sources":["../src/font.ts"],"sourcesContent":["export type FarmFontDisplay = \"auto\" | \"block\" | \"swap\" | \"fallback\" | \"optional\";\n\nexport interface FarmFontSource {\n  /** Local file path or remote URL, depending on the loader. */\n  path: string;\n  /** A fixed weight (`400`) or variable range (`100 900`). */\n  weight?: number | string;\n  /** Font style for this source. */\n  style?: string;\n  /** Optional CSS unicode-range descriptor. */\n  unicodeRange?: string;\n}\n\nexport interface FarmFontOptions {\n  /** CSS font-family name. */\n  family: string;\n  /** A fixed weight (`400`) or variable range (`100 900`). */\n  weight?: number | string;\n  /** Font style. @default \"normal\" */\n  style?: string;\n  /** Browser loading behavior. @default \"swap\" */\n  display?: FarmFontDisplay;\n  /** CSS custom property populated by `variable`, for example `--font-sans`. */\n  variable?: `--${string}`;\n  /** Fallback family names appended to the generated stack. */\n  fallback?: string[];\n  /** Emit font preload hints. @default true */\n  preload?: boolean;\n}\n\nexport interface LocalFontOptions extends FarmFontOptions {\n  /**\n   * A file relative to this module, a package font specifier, or explicit\n   * sources for a multi-weight family.\n   */\n  src: string | FarmFontSource[];\n}\n\nexport interface RemoteFontSource extends FarmFontSource {\n  /** Optional integrity value for this source. Overrides the family-level value. */\n  integrity?: string;\n}\n\nexport interface RemoteFontOptions extends FarmFontOptions {\n  /** HTTPS font URL, or explicit remote sources for a multi-weight family. */\n  src: string | RemoteFontSource[];\n  /** Download and fingerprint the font during the build, or retain its URL. */\n  strategy?: \"self-host\" | \"external\";\n  /** Optional Subresource Integrity value checked while self-hosting. */\n  integrity?: string;\n}\n\nexport interface FarmFont {\n  /** Generated class that applies the font family and fallback stack. */\n  className: string;\n  /** Generated class that defines the configured CSS custom property. */\n  variable: string;\n  /** Inline-style equivalent of the generated family. */\n  style: Readonly<{\n    fontFamily: string;\n    fontStyle?: string;\n    fontWeight?: number | string;\n  }>;\n  /** Compiled resources that should be preloaded when this font is selected. */\n  preloads: readonly Readonly<{\n    href: string;\n    type: string;\n  }>[];\n}\n\n/** Semantic font roles inherited by framework-owned surfaces such as Farm Docs. */\nexport interface FarmLayoutFonts {\n  /** Default text and prose font. */\n  body?: FarmFont;\n  /** Code, keyboard input, and other technical UI font. */\n  code?: FarmFont;\n}\n\nexport interface FarmLayoutFontModule {\n  fonts?: FarmLayoutFonts;\n}\n\n/**\n * Define the semantic fonts exported by a layout.\n *\n * Layouts are resolved from the root toward the requested route. A nearer\n * layout overrides only the roles it defines, so it can replace `body` while\n * continuing to inherit `code` from a parent layout.\n */\nexport function defineLayoutFonts<const T extends FarmLayoutFonts>(fonts: T): T {\n  return fonts;\n}\n\n/** Resolve semantic font roles from root layout to nearest layout. */\nexport function resolveFarmLayoutFonts(\n  layouts: readonly FarmLayoutFontModule[],\n): FarmLayoutFonts | undefined {\n  let resolved: FarmLayoutFonts | undefined;\n\n  for (const layout of layouts) {\n    if (!layout.fonts) continue;\n    resolved = { ...resolved, ...layout.fonts };\n  }\n\n  return resolved;\n}\n\nfunction fontCompilerError(loader: string): never {\n  throw new Error(\n    `[Farm fonts] ${loader}() must be called at module scope with static options and compiled by the Farm Vite plugin.`,\n  );\n}\n\n/**\n * Compile local font files into hashed application assets and generated CSS.\n * The call is removed at build time and adds no font-loader runtime code.\n */\nexport function localFont(_options: LocalFontOptions): FarmFont {\n  return fontCompilerError(\"localFont\");\n}\n\n/**\n * Compile a remote font into a self-hosted application asset by default.\n * Use `strategy: \"external\"` only when the browser should retain the remote URL.\n */\nexport function remoteFont(_options: RemoteFontOptions): FarmFont {\n  return fontCompilerError(\"remoteFont\");\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyFO,SAAS,kBAAmD,OAAa;AAC9E,SAAO;AACT;AAFgB;AAKT,SAAS,uBACd,SAC6B;AAC7B,MAAI;AAEJ,aAAW,UAAU,SAAS;AAC5B,QAAI,CAAC,OAAO,MAAO;AACnB,eAAW,EAAE,GAAG,UAAU,GAAG,OAAO,MAAM;AAAA,EAC5C;AAEA,SAAO;AACT;AAXgB;AAahB,SAAS,kBAAkB,QAAuB;AAChD,QAAM,IAAI;AAAA,IACR,gBAAgB,MAAM;AAAA,EACxB;AACF;AAJS;AAUF,SAAS,UAAU,UAAsC;AAC9D,SAAO,kBAAkB,WAAW;AACtC;AAFgB;AAQT,SAAS,WAAW,UAAuC;AAChE,SAAO,kBAAkB,YAAY;AACvC;AAFgB;","names":[]}