/** * Template profiles map human-friendly preset names (e.g. "heading", * "table_header") to paraPrIDRef / charPrIDRef values that already exist in a * specific template's header.xml. Callers of build_document can reference * presets instead of providing inline styles, which preserves the template's * exact styling (fonts, colors, hanging indents, etc.) without a post- * processing pass. * * Safety: every profile carries a short list of "assertions" — expected * (paraPrIDRef, font_size_hundredths, hangul_font_face_id) tuples — used to * verify that the opened document actually matches the profile before preset * resolution. If the assertions fail we refuse to resolve, so a preset call * against an unrelated document can never silently corrupt styling. */ export interface StylePresetEntry { /** paraPrIDRef to stamp onto `` */ paraPrIDRef: string; /** charPrIDRef to stamp onto the paragraph's leading `` */ charPrIDRef: string; /** Short human description for error messages and tool discovery */ description?: string; } export interface TableCellPresetEntry { paraPrIDRef: string; charPrIDRef: string; /** Optional borderFillIDRef override for the cell's ``. */ borderFillIDRef?: string; description?: string; } export interface StylePaletteAssertion { /** Kind of entry being asserted. */ kind: 'charPr' | 'paraPr' | 'borderFill'; /** The id attribute value to look up. */ id: string; /** Partial match: any field listed must equal the extracted value. */ expect: { /** For charPr: height attribute value (hwpunit; pt × 100). */ height?: string; /** For charPr: face name recorded in fontface/ * for the hangul font id referenced by this charPr. */ hangulFontFace?: string; /** For charPr: bold presence. */ bold?: boolean; /** For paraPr: horizontal alignment enum value. */ align?: string; /** For paraPr: line spacing value (100 = 1.0×). */ lineSpacingValue?: string; /** For borderFill: left border type (SOLID, NONE, ...). */ leftBorderType?: string; /** For borderFill: left border width string ("0.12 mm", etc.). */ leftBorderWidth?: string; /** For borderFill: expected winBrush faceColor (e.g. "#E5E5E5"). Pass * the string 'none' to assert that the borderFill has NO winBrush. */ winBrushFaceColor?: string; }; } export interface TemplateProfile { /** Stable identifier used in build_document.template_profile. */ name: string; /** Short description for tool-listing/introspection. */ description?: string; /** Preset name -> paragraph/run style pointer. */ presets: Record; /** Table cell style presets (used by build_document table elements). */ tableCellPresets: Record; /** * Lightweight fingerprint assertions validated against the opened document's * header.xml before any preset is resolved. All listed tuples must match; * otherwise preset resolution errors out (fail closed). */ assertions: StylePaletteAssertion[]; } /** Look up a profile by name, or `undefined` if not registered. */ export declare function getTemplateProfile(name: string): TemplateProfile | undefined; /** Enumerate all registered profile names (for discovery). */ export declare function listTemplateProfiles(): TemplateProfile[]; /** * Compute a short stable digest of the style-palette subset of the document's * header.xml. We hash only the elements that affect styling (not ui-layout * miscellany) so that trivial edits to the template's description text or * paper-size metadata don't invalidate the fingerprint. */ export declare function computeStylePaletteFingerprint(headerXml: string): string; export interface ProfileAssertionResult { ok: boolean; failures: string[]; } /** * Validate that every assertion in `profile.assertions` holds against the * given header.xml. Returns the list of failures (empty = all good). Never * throws; caller decides how to react (we want fail-closed, so callers should * reject preset resolution if !ok). */ export declare function verifyProfileAgainstHeader(profile: TemplateProfile, headerXml: string): ProfileAssertionResult; /** * Convenience: resolve a paragraph preset against a validated profile. * Returns undefined when the preset name is unknown; caller decides whether to * fail loudly or fall back to inline styles. */ export declare function resolveParagraphPreset(profile: TemplateProfile, presetName: string): StylePresetEntry | undefined; /** Same as above for table cell presets. */ export declare function resolveTableCellPreset(profile: TemplateProfile, presetName: string): TableCellPresetEntry | undefined;