import { ElementNode } from '../util/xml.js'; import { ColorInput } from '../types/index.js'; import { IDMLStylesContext } from './Styles.js'; /** * The fully-resolved, derived view of an object style's surface properties. * * This is Layer 2: it is COMPUTED by walking the `BasedOn` chain down to the * `[None]` root. It is never stored on the `ObjectStyle` instances themselves — * those stay faithful to the XML. Every field here is concrete because `[None]` * always supplies a base value (and we fall back to InDesign's documented * `[None]` defaults if the chain can't be resolved at all). */ export type MergedObjectStyle = { fillColorId: string; fillTint: number; strokeColorId: string; strokeWeight: number; strokeTint: number; strokeAlignment: string; gradientFillAngle?: number; gradientStrokeAngle?: number; }; /** * InDesign's built-in `[None]` object style defaults. Used as the resolution * floor so a `MergedObjectStyle` is always concrete, even for malformed files * that lack a `[None]` style or reference a missing object style. */ export declare const NONE_OBJECT_STYLE: MergedObjectStyle; /** * Layer 1 — a faithful mirror of a single `` element. * * It exposes ONLY what the element literally carries: its own attributes * (`undefined` when an attribute is genuinely absent) and `BasedOn` as a * *relation* (a reference id, resolved on demand via the IDML registry — the * same idiom as `getStrokeColor()` → `getColorById()`). It does NOT fold in * the parent's properties; that flattening is the derived `getResolved()` view. * * Read-only by design: object styles are intentionally NOT registered in * `IDMLStylesController.elementsImplemented`, so serialization passes the * original `RootObjectStyleGroup` through untouched. This whole class is pure * abstraction on top of the preserved original structure. */ export declare class ObjectStyle { id: string; private context; name?: string; fillColorId?: string; fillTint?: number; strokeColorId?: string; strokeWeight?: number; strokeTint?: number; strokeAlignment?: string; gradientFillAngle?: number; gradientStrokeAngle?: number; appliedParagraphStyleId?: string; private basedOnId?; /** * The original `` DOM node, when parsed from a file. It is the * single faithful source for serialization: object styles carry ~15 kinds of * nested children (TransformAttributeOption, ObjectExportOption, effects * categories, …) that a property-only rebuild would silently drop, so we * NEVER rebuild from typed fields — we patch this node in place on edit and * round-trip it untouched. The typed fields above are a parsed read view kept * in sync by the setters. */ private sourceElement?; constructor(id: string, opts: { name?: string; fillColorId?: string; fillTint?: number; strokeColorId?: string; strokeWeight?: number; strokeTint?: number; strokeAlignment?: string; gradientFillAngle?: number; gradientStrokeAngle?: number; appliedParagraphStyleId?: string; basedOnId?: string; sourceElement?: Element; }, context: IDMLStylesContext); /** The original `` DOM node (faithful structure), if parsed from a file. */ getSourceElement(): Element | undefined; /** The parent object style this one is based on, resolved as a relation. */ getBasedOn(): ObjectStyle | undefined; /** * The inheritance chain, most-specific first: [self, parent, ..., [None]]. * Guards against cycles (malformed files can self-reference). */ getChain(): ObjectStyle[]; /** * Layer 2 — flatten the BasedOn chain into a concrete surface style. * First-defined-wins scanning from the most specific style; the `[None]` * defaults fill any property no style in the chain defined. */ getResolved(): MergedObjectStyle; private patchAttribute; setName(name: string): void; setFillColorId(id?: string): void; setFillColor(color: ColorInput): void; setFillTint(tint?: number): void; setStrokeColorId(id?: string): void; setStrokeColor(color: ColorInput): void; setStrokeWeight(weight?: number): void; setStrokeTint(tint?: number): void; setStrokeAlignment(alignment?: string): void; setGradientFillAngle(angle?: number): void; setGradientStrokeAngle(angle?: number): void; /** * Re-parent this style in the cascade. `BasedOn` lives in a nested * `` element, so we patch there (creating the nodes if * absent). Pass `undefined` to detach (the chain then terminates here). */ setBasedOnId(id?: string): void; /** * Faithful serialization: clone the original node so every nested child is * preserved exactly. (The controller round-trips object styles via the live * tree; this is exposed for completeness and for copying styles.) Styles * created from scratch with no source node fall back to a minimal element. */ serialize(): ElementNode; static parseElement(element: Element, context: IDMLStylesContext): ObjectStyle; } //# sourceMappingURL=ObjectStyle.d.ts.map