interface BorderAttribute {
    width: number;
    style: string;
    color: ColorRGB;
}

interface FontAttribute {
    fontFamily: string;
    fontStyle: string;
    fontSize: number;
    fontWeight: string;
    color: ColorRGB | null;
    backgroundColor?: ColorRGB | null;
}

interface SelectionAttribute {
    color: ColorRGB | null;
    backgroundColor: ColorRGB | null;
}

interface BoxBorder {
    borderTop: BorderAttribute;
    borderRight: BorderAttribute;
    borderBottom: BorderAttribute;
    borderLeft: BorderAttribute;
}

interface BoxStyle extends Partial<BoxBorder> {
    backgroundSize: string;
    backgroundRepeat: string;
    backgroundPositionX: string;
    backgroundPositionY: string;
    backgroundColor?: ColorRGB;
    backgroundClip?: BoxRect;
    backgroundOrigin?: BoxRect;
    borderRadius?: string[];
    outline?: BorderAttribute;
    backgroundImage?: ResourceBackgroundImage[];
}

interface Gradient {
    type: "conic" | "radial" | "linear";
    colorStops: ColorStop[];
    dimension: Dimension | null;
    colorInterpolation?: string;
}

interface ImageSet {
    value: string | Gradient;
    resolution: string;
    type?: string;
}

interface FragmentTargetText {
    textStart: string;
    textEnd?: string;
    prefix?: string;
    suffix?: string;
}

interface RepeatingGradient extends Gradient {
    repeating: boolean;
}

interface LinearGradient extends RepeatingGradient {
    angle: number;
    angleExtent: Point;
}

interface RadialGradient extends RepeatingGradient {
    shape: string;
    center: BoxRectPosition;
    radius: number;
    radiusExtent: number;
    closestSide: number;
    farthestSide: number;
    closestCorner: number;
    farthestCorner: number;
}

interface ConicGradient extends Gradient {
    angle: number;
    center: BoxRectPosition;
}

interface ColorStop {
    color: ColorRGB;
    offset: number;
}

interface ResourceMap extends ObjectMap<Map<string | DocumentRoot, unknown> | unknown[] | number> {
    resourceId: number;
}

interface ResourceAssetsMap extends ResourceMap {
    fonts: AssetsFonts;
    image: AssetsImage;
    metadata: AssetsMetadata;
    video?: AssetsVideo;
    audio?: AssetsAudio;
    rawData?: AssetsRawData;
    other?: AssetsOther;
    keyframes?: AssetsKeyframes;
    fontFeatureValues?: AssetsFontFeatureValues;
}

interface ResourceStoredMap extends ResourceMap {
    ids: StoredIds;
    strings: StoredStrings;
    arrays: StoredArrays;
    fonts: StoredFonts;
    colors: StoredColors;
    images: StoredImages;
}

/** @deprecated Intl.LocalesArgument */
type ResourceIntlLocales = string[] | null;
type ResourceSessionAsset = Optional<ResourceAssetsMap>[];
type ResourceSessionStored<T = ResourceStoredMap> = Optional<T>[];
type ResourceBackgroundImage = string | ImageSet[] | Gradient;
type KeyframesMap = Map<string, KeyframeData>;
type FontFeatureValuesMap = Map<string, FontFeatureValuesData>;
type AssetsFonts = Map<string, FontFaceData[]>;
type AssetsImage = Map<string, ImageAsset>;
type AssetsVideo = Map<string, Asset & MetadataAction>;
type AssetsAudio = Map<string, Asset & MetadataAction>;
type AssetsRawData = Map<string, RawAsset>;
type AssetsMetadata = Map<string, PlainObject>;
type AssetsOther = RawAsset[];
type AssetsKeyframes = Map<DocumentRoot, KeyframesMap>;
type AssetsFontFeatureValues = Map<DocumentRoot, FontFeatureValuesMap>;
type StoredIds = Map<string, string[]>;
type StoredStrings = Map<string, string>;
type StoredArrays = Map<string, string[]>;
type StoredFonts = Map<string, StringMap>;
type StoredColors = Map<string, string>;
type StoredImages = Map<string, StringMap>;