modern-idoc 0.6.6 → 0.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +32 -22
- package/dist/index.d.cts +13 -15
- package/dist/index.d.mts +13 -15
- package/dist/index.d.ts +13 -15
- package/dist/index.js +1 -1
- package/dist/index.mjs +32 -23
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -41,6 +41,15 @@ function clearUndef(obj, deep = false) {
|
|
|
41
41
|
}
|
|
42
42
|
return newObj;
|
|
43
43
|
}
|
|
44
|
+
function pick(obj, keys) {
|
|
45
|
+
const result = {};
|
|
46
|
+
keys.forEach((key) => {
|
|
47
|
+
if (key in obj) {
|
|
48
|
+
result[key] = obj[key];
|
|
49
|
+
}
|
|
50
|
+
});
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
44
53
|
|
|
45
54
|
function parseColor(color) {
|
|
46
55
|
let input;
|
|
@@ -672,7 +681,7 @@ function parseRadialGradientNode(node) {
|
|
|
672
681
|
};
|
|
673
682
|
}
|
|
674
683
|
function isGradient(cssText) {
|
|
675
|
-
return cssText.startsWith("linear-gradient") || cssText.startsWith("radial-gradient");
|
|
684
|
+
return cssText.startsWith("linear-gradient(") || cssText.startsWith("radial-gradient(");
|
|
676
685
|
}
|
|
677
686
|
function normalizeGradient(cssText) {
|
|
678
687
|
return parseGradient(cssText).map((node) => {
|
|
@@ -710,18 +719,20 @@ function normalizeGradientFill(fill) {
|
|
|
710
719
|
} else {
|
|
711
720
|
obj = fill;
|
|
712
721
|
}
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
722
|
+
if (obj.image) {
|
|
723
|
+
const { type, ...props } = normalizeGradient(obj.image)[0] ?? {};
|
|
724
|
+
switch (type) {
|
|
725
|
+
case "radial-gradient":
|
|
726
|
+
return {
|
|
727
|
+
radialGradient: props
|
|
728
|
+
};
|
|
729
|
+
case "linear-gradient":
|
|
730
|
+
return {
|
|
731
|
+
linearGradient: props
|
|
732
|
+
};
|
|
733
|
+
}
|
|
723
734
|
}
|
|
724
|
-
return
|
|
735
|
+
return obj;
|
|
725
736
|
}
|
|
726
737
|
|
|
727
738
|
function normalizeImageFill(fill) {
|
|
@@ -755,7 +766,7 @@ function isColorFill(fill) {
|
|
|
755
766
|
return typeof fill === "string" ? isColor(fill) : isColorFillObject(fill);
|
|
756
767
|
}
|
|
757
768
|
function isGradientFillObject(fill) {
|
|
758
|
-
return !isNone(fill.image) && isGradient(fill.image);
|
|
769
|
+
return !isNone(fill.image) && isGradient(fill.image) || Boolean(fill.linearGradient) || Boolean(fill.radialGradient);
|
|
759
770
|
}
|
|
760
771
|
function isGradientFill(fill) {
|
|
761
772
|
return typeof fill === "string" ? isGradient(fill) : isGradientFillObject(fill);
|
|
@@ -788,13 +799,12 @@ function normalizeFill(fill) {
|
|
|
788
799
|
function normalizeBackground(background) {
|
|
789
800
|
if (typeof background === "string") {
|
|
790
801
|
return {
|
|
791
|
-
...normalizeFill(background)
|
|
792
|
-
fillWithShape: false
|
|
802
|
+
...normalizeFill(background)
|
|
793
803
|
};
|
|
794
804
|
} else {
|
|
795
805
|
return {
|
|
796
806
|
...normalizeFill(background),
|
|
797
|
-
|
|
807
|
+
...pick(background, ["fillWithShape"])
|
|
798
808
|
};
|
|
799
809
|
}
|
|
800
810
|
}
|
|
@@ -847,13 +857,12 @@ function normalizeEffect(effect) {
|
|
|
847
857
|
function normalizeForeground(foreground) {
|
|
848
858
|
if (typeof foreground === "string") {
|
|
849
859
|
return {
|
|
850
|
-
...normalizeFill(foreground)
|
|
851
|
-
fillWithShape: false
|
|
860
|
+
...normalizeFill(foreground)
|
|
852
861
|
};
|
|
853
862
|
} else {
|
|
854
863
|
return {
|
|
855
864
|
...normalizeFill(foreground),
|
|
856
|
-
|
|
865
|
+
...pick(foreground, ["fillWithShape"])
|
|
857
866
|
};
|
|
858
867
|
}
|
|
859
868
|
}
|
|
@@ -861,12 +870,12 @@ function normalizeForeground(foreground) {
|
|
|
861
870
|
function normalizeOutline(outline) {
|
|
862
871
|
if (typeof outline === "string") {
|
|
863
872
|
return {
|
|
864
|
-
|
|
873
|
+
...normalizeFill(outline)
|
|
865
874
|
};
|
|
866
875
|
} else {
|
|
867
876
|
return {
|
|
868
|
-
...outline,
|
|
869
|
-
|
|
877
|
+
...normalizeFill(outline),
|
|
878
|
+
...pick(outline, ["width", "style", "headEnd", "tailEnd"])
|
|
870
879
|
};
|
|
871
880
|
}
|
|
872
881
|
}
|
|
@@ -1236,5 +1245,6 @@ exports.normalizeTextContent = normalizeTextContent;
|
|
|
1236
1245
|
exports.normalizeVideo = normalizeVideo;
|
|
1237
1246
|
exports.parseColor = parseColor;
|
|
1238
1247
|
exports.parseGradient = parseGradient;
|
|
1248
|
+
exports.pick = pick;
|
|
1239
1249
|
exports.round = round;
|
|
1240
1250
|
exports.stringifyGradient = stringifyGradient;
|
package/dist/index.d.cts
CHANGED
|
@@ -223,9 +223,9 @@ interface NormalizedColorFill {
|
|
|
223
223
|
}
|
|
224
224
|
declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill;
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
image
|
|
228
|
-
}
|
|
226
|
+
type GradientFillObject = {
|
|
227
|
+
image?: string;
|
|
228
|
+
} & Partial<NormalizedGradientFill>;
|
|
229
229
|
type GradientFill = string | GradientFillObject;
|
|
230
230
|
interface NormalizedGradientFill {
|
|
231
231
|
linearGradient?: LinearGradient;
|
|
@@ -308,10 +308,10 @@ declare function isPresetFill(fill: Fill): fill is PresetFill;
|
|
|
308
308
|
declare function normalizeFill(fill: Fill): NormalizedFill;
|
|
309
309
|
|
|
310
310
|
interface NormalizedBaseBackground {
|
|
311
|
-
fillWithShape
|
|
311
|
+
fillWithShape?: boolean;
|
|
312
312
|
}
|
|
313
|
-
type NormalizedBackground =
|
|
314
|
-
type BackgroundObject = Partial<NormalizedBaseBackground
|
|
313
|
+
type NormalizedBackground = NormalizedFill & NormalizedBaseBackground;
|
|
314
|
+
type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
@@ -358,7 +358,7 @@ type Effect = EffectObject;
|
|
|
358
358
|
declare function normalizeEffect(effect: Effect): NormalizedEffect;
|
|
359
359
|
|
|
360
360
|
interface NormalizedBaseForeground {
|
|
361
|
-
fillWithShape
|
|
361
|
+
fillWithShape?: boolean;
|
|
362
362
|
}
|
|
363
363
|
type NormalizedForeground = NormalizedBaseForeground & NormalizedFill;
|
|
364
364
|
type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject;
|
|
@@ -390,18 +390,15 @@ interface TailEnd {
|
|
|
390
390
|
height?: WithNone<LineEndSize>;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
type NormalizedOutlineFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill>;
|
|
394
393
|
type OutlineStyle = 'dashed' | 'solid' | string;
|
|
395
|
-
interface
|
|
394
|
+
interface NormalizedBaseOutline {
|
|
396
395
|
width?: number;
|
|
397
|
-
color?: NormalizedColor;
|
|
398
396
|
style?: OutlineStyle;
|
|
399
397
|
headEnd?: HeadEnd;
|
|
400
398
|
tailEnd?: TailEnd;
|
|
401
399
|
}
|
|
402
|
-
type
|
|
403
|
-
|
|
404
|
-
};
|
|
400
|
+
type NormalizedOutline = NormalizedFill & NormalizedBaseOutline;
|
|
401
|
+
type OutlineObject = FillObject & Partial<NormalizedBaseOutline>;
|
|
405
402
|
type Outline = string | OutlineObject;
|
|
406
403
|
declare function normalizeOutline(outline: Outline): NormalizedOutline;
|
|
407
404
|
|
|
@@ -730,6 +727,7 @@ declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
|
730
727
|
declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
|
|
731
728
|
declare function round(number: number, digits?: number, base?: number): number;
|
|
732
729
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
730
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
733
731
|
|
|
734
|
-
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
|
|
735
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline,
|
|
732
|
+
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, round, stringifyGradient };
|
|
733
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphContent, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextContentFlat, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.mts
CHANGED
|
@@ -223,9 +223,9 @@ interface NormalizedColorFill {
|
|
|
223
223
|
}
|
|
224
224
|
declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill;
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
image
|
|
228
|
-
}
|
|
226
|
+
type GradientFillObject = {
|
|
227
|
+
image?: string;
|
|
228
|
+
} & Partial<NormalizedGradientFill>;
|
|
229
229
|
type GradientFill = string | GradientFillObject;
|
|
230
230
|
interface NormalizedGradientFill {
|
|
231
231
|
linearGradient?: LinearGradient;
|
|
@@ -308,10 +308,10 @@ declare function isPresetFill(fill: Fill): fill is PresetFill;
|
|
|
308
308
|
declare function normalizeFill(fill: Fill): NormalizedFill;
|
|
309
309
|
|
|
310
310
|
interface NormalizedBaseBackground {
|
|
311
|
-
fillWithShape
|
|
311
|
+
fillWithShape?: boolean;
|
|
312
312
|
}
|
|
313
|
-
type NormalizedBackground =
|
|
314
|
-
type BackgroundObject = Partial<NormalizedBaseBackground
|
|
313
|
+
type NormalizedBackground = NormalizedFill & NormalizedBaseBackground;
|
|
314
|
+
type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
@@ -358,7 +358,7 @@ type Effect = EffectObject;
|
|
|
358
358
|
declare function normalizeEffect(effect: Effect): NormalizedEffect;
|
|
359
359
|
|
|
360
360
|
interface NormalizedBaseForeground {
|
|
361
|
-
fillWithShape
|
|
361
|
+
fillWithShape?: boolean;
|
|
362
362
|
}
|
|
363
363
|
type NormalizedForeground = NormalizedBaseForeground & NormalizedFill;
|
|
364
364
|
type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject;
|
|
@@ -390,18 +390,15 @@ interface TailEnd {
|
|
|
390
390
|
height?: WithNone<LineEndSize>;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
type NormalizedOutlineFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill>;
|
|
394
393
|
type OutlineStyle = 'dashed' | 'solid' | string;
|
|
395
|
-
interface
|
|
394
|
+
interface NormalizedBaseOutline {
|
|
396
395
|
width?: number;
|
|
397
|
-
color?: NormalizedColor;
|
|
398
396
|
style?: OutlineStyle;
|
|
399
397
|
headEnd?: HeadEnd;
|
|
400
398
|
tailEnd?: TailEnd;
|
|
401
399
|
}
|
|
402
|
-
type
|
|
403
|
-
|
|
404
|
-
};
|
|
400
|
+
type NormalizedOutline = NormalizedFill & NormalizedBaseOutline;
|
|
401
|
+
type OutlineObject = FillObject & Partial<NormalizedBaseOutline>;
|
|
405
402
|
type Outline = string | OutlineObject;
|
|
406
403
|
declare function normalizeOutline(outline: Outline): NormalizedOutline;
|
|
407
404
|
|
|
@@ -730,6 +727,7 @@ declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
|
730
727
|
declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
|
|
731
728
|
declare function round(number: number, digits?: number, base?: number): number;
|
|
732
729
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
730
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
733
731
|
|
|
734
|
-
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
|
|
735
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline,
|
|
732
|
+
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, round, stringifyGradient };
|
|
733
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphContent, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextContentFlat, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -223,9 +223,9 @@ interface NormalizedColorFill {
|
|
|
223
223
|
}
|
|
224
224
|
declare function normalizeColorFill(fill: ColorFill): NormalizedColorFill;
|
|
225
225
|
|
|
226
|
-
|
|
227
|
-
image
|
|
228
|
-
}
|
|
226
|
+
type GradientFillObject = {
|
|
227
|
+
image?: string;
|
|
228
|
+
} & Partial<NormalizedGradientFill>;
|
|
229
229
|
type GradientFill = string | GradientFillObject;
|
|
230
230
|
interface NormalizedGradientFill {
|
|
231
231
|
linearGradient?: LinearGradient;
|
|
@@ -308,10 +308,10 @@ declare function isPresetFill(fill: Fill): fill is PresetFill;
|
|
|
308
308
|
declare function normalizeFill(fill: Fill): NormalizedFill;
|
|
309
309
|
|
|
310
310
|
interface NormalizedBaseBackground {
|
|
311
|
-
fillWithShape
|
|
311
|
+
fillWithShape?: boolean;
|
|
312
312
|
}
|
|
313
|
-
type NormalizedBackground =
|
|
314
|
-
type BackgroundObject = Partial<NormalizedBaseBackground
|
|
313
|
+
type NormalizedBackground = NormalizedFill & NormalizedBaseBackground;
|
|
314
|
+
type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
|
|
315
315
|
type Background = string | BackgroundObject;
|
|
316
316
|
declare function normalizeBackground(background: Background): NormalizedBackground;
|
|
317
317
|
|
|
@@ -358,7 +358,7 @@ type Effect = EffectObject;
|
|
|
358
358
|
declare function normalizeEffect(effect: Effect): NormalizedEffect;
|
|
359
359
|
|
|
360
360
|
interface NormalizedBaseForeground {
|
|
361
|
-
fillWithShape
|
|
361
|
+
fillWithShape?: boolean;
|
|
362
362
|
}
|
|
363
363
|
type NormalizedForeground = NormalizedBaseForeground & NormalizedFill;
|
|
364
364
|
type ForegroundObject = Partial<NormalizedBaseForeground> & FillObject;
|
|
@@ -390,18 +390,15 @@ interface TailEnd {
|
|
|
390
390
|
height?: WithNone<LineEndSize>;
|
|
391
391
|
}
|
|
392
392
|
|
|
393
|
-
type NormalizedOutlineFill = Partial<NormalizedColorFill> & Partial<NormalizedGradientFill>;
|
|
394
393
|
type OutlineStyle = 'dashed' | 'solid' | string;
|
|
395
|
-
interface
|
|
394
|
+
interface NormalizedBaseOutline {
|
|
396
395
|
width?: number;
|
|
397
|
-
color?: NormalizedColor;
|
|
398
396
|
style?: OutlineStyle;
|
|
399
397
|
headEnd?: HeadEnd;
|
|
400
398
|
tailEnd?: TailEnd;
|
|
401
399
|
}
|
|
402
|
-
type
|
|
403
|
-
|
|
404
|
-
};
|
|
400
|
+
type NormalizedOutline = NormalizedFill & NormalizedBaseOutline;
|
|
401
|
+
type OutlineObject = FillObject & Partial<NormalizedBaseOutline>;
|
|
405
402
|
type Outline = string | OutlineObject;
|
|
406
403
|
declare function normalizeOutline(outline: Outline): NormalizedOutline;
|
|
407
404
|
|
|
@@ -730,6 +727,7 @@ declare function normalizeDocument(doc: Document): NormalizedDocument;
|
|
|
730
727
|
declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
|
|
731
728
|
declare function round(number: number, digits?: number, base?: number): number;
|
|
732
729
|
declare function clearUndef<T>(obj: T, deep?: boolean): T;
|
|
730
|
+
declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
|
|
733
731
|
|
|
734
|
-
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
|
|
735
|
-
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline,
|
|
732
|
+
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, round, stringifyGradient };
|
|
733
|
+
export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Direction, DirectionalNode, Display, Document, Effect, EffectObject, Element, EmNode, ExtentKeywordNode, Fill, FillObject, FillRule, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentContent, GradientFill, GradientFillObject, GradientNode, HeadEnd, Hex8Color, HexNode, HighlightColormap, HighlightImage, HighlightLine, HighlightReferImage, HighlightSize, HighlightThickness, HslColor, HslaColor, HsvColor, HsvaColor, HwbColor, HwbaColor, ImageFill, ImageFillCropRect, ImageFillObject, ImageFillStretchRect, ImageFillTile, InnerShadow, InnerShadowObject, Justify, LabColor, LabaColor, LchColor, LchaColor, LineEndSize, LineEndType, LinearGradient, LinearGradientNode, LinearGradientWithType, ListStyleColormap, ListStyleImage, ListStylePosition, ListStyleSize, ListStyleType, LiteralNode, Meta, Node, None, NormalizedAudio, NormalizedBackground, NormalizedBaseBackground, NormalizedBaseForeground, NormalizedBaseOuterShadow, NormalizedBaseOutline, NormalizedColor, NormalizedColorFill, NormalizedDocument, NormalizedEffect, NormalizedElement, NormalizedElementStyle, NormalizedFill, NormalizedForeground, NormalizedGradientFill, NormalizedHighlight, NormalizedHighlightStyle, NormalizedImageFill, NormalizedInnerShadow, NormalizedLayoutStyle, NormalizedListStyle, NormalizedListStyleStyle, NormalizedOuterShadow, NormalizedOutline, NormalizedPresetFill, NormalizedShadow, NormalizedShadowStyle, NormalizedShape, NormalizedSoftEdge, NormalizedStyle, NormalizedText, NormalizedTextContent, NormalizedTextDrawStyle, NormalizedTextInlineStyle, NormalizedTextLineStyle, NormalizedTextStyle, NormalizedTransformStyle, NormalizedVideo, ObjectColor, OuterShadow, OuterShadowObject, Outline, OutlineObject, OutlineStyle, Overflow, ParagraphContent, PercentNode, PointerEvents, Position, PositionKeywordNode, PositionNode, PresetFill, PresetFillObject, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, RepeatingLinearGradientNode, RepeatingRadialGradientNode, RgbColor, RgbNode, RgbaColor, RgbaNode, SVGPathData, Shadow, ShadowObject, Shape, ShapeNode, ShapePath, ShapePathStyle, SoftEdge, StrokeLinecap, StrokeLinejoin, Style, StyleObject, StyleUnit, TailEnd, Text, TextAlign, TextContent, TextContentFlat, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(o,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(o=typeof globalThis<"u"?globalThis:o||self,k(o.modernIdoc={}))})(this,function(o){"use strict";function k(t){return typeof t=="string"?{src:t}:t}var Yt={grad:.9,turn:360,rad:360/(2*Math.PI)},S=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},h=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=Math.pow(10,e)),Math.round(r*t)/r+0},b=function(t,e,r){return e===void 0&&(e=0),r===void 0&&(r=1),t>r?r:t>e?t:e},J=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Q=function(t){return{r:b(t.r,0,255),g:b(t.g,0,255),b:b(t.b,0,255),a:b(t.a)}},W=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},Ut=/^#([0-9a-f]{3,8})$/i,E=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},Z=function(t){var e=t.r,r=t.g,n=t.b,a=t.a,l=Math.max(e,r,n),c=l-Math.min(e,r,n),d=c?l===e?(r-n)/c:l===r?2+(n-e)/c:4+(e-r)/c:0;return{h:60*(d<0?d+6:d),s:l?c/l*100:0,v:l/255*100,a}},tt=function(t){var e=t.h,r=t.s,n=t.v,a=t.a;e=e/360*6,r/=100,n/=100;var l=Math.floor(e),c=n*(1-r),d=n*(1-(e-l)*r),F=n*(1-(1-e+l)*r),O=l%6;return{r:255*[n,d,c,c,F,n][O],g:255*[F,n,n,d,c,c][O],b:255*[c,c,F,n,n,d][O],a}},et=function(t){return{h:J(t.h),s:b(t.s,0,100),l:b(t.l,0,100),a:b(t.a)}},rt=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},nt=function(t){return tt((r=(e=t).s,{h:e.h,s:(r*=((n=e.l)<50?n:100-n)/100)>0?2*r/(n+r)*100:0,v:n+r,a:e.a}));var e,r,n},D=function(t){return{h:(e=Z(t)).h,s:(a=(200-(r=e.s))*(n=e.v)/100)>0&&a<200?r*n/100/(a<=100?a:200-a)*100:0,l:a/2,a:e.a};var e,r,n,a},qt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Jt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,it={string:[[function(t){var e=Ut.exec(t);return e?(t=e[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?h(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?h(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=Qt.exec(t)||Zt.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:Q({r:Number(e[1])/(e[2]?100/255:1),g:Number(e[3])/(e[4]?100/255:1),b:Number(e[5])/(e[6]?100/255:1),a:e[7]===void 0?1:Number(e[7])/(e[8]?100:1)}):null},"rgb"],[function(t){var e=qt.exec(t)||Jt.exec(t);if(!e)return null;var r,n,a=et({h:(r=e[1],n=e[2],n===void 0&&(n="deg"),Number(r)*(Yt[n]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return nt(a)},"hsl"]],object:[[function(t){var e=t.r,r=t.g,n=t.b,a=t.a,l=a===void 0?1:a;return S(e)&&S(r)&&S(n)?Q({r:Number(e),g:Number(r),b:Number(n),a:Number(l)}):null},"rgb"],[function(t){var e=t.h,r=t.s,n=t.l,a=t.a,l=a===void 0?1:a;if(!S(e)||!S(r)||!S(n))return null;var c=et({h:Number(e),s:Number(r),l:Number(n),a:Number(l)});return nt(c)},"hsl"],[function(t){var e=t.h,r=t.s,n=t.v,a=t.a,l=a===void 0?1:a;if(!S(e)||!S(r)||!S(n))return null;var c=function(d){return{h:J(d.h),s:b(d.s,0,100),v:b(d.v,0,100),a:b(d.a)}}({h:Number(e),s:Number(r),v:Number(n),a:Number(l)});return tt(c)},"hsv"]]},ot=function(t,e){for(var r=0;r<e.length;r++){var n=e[r][0](t);if(n)return[n,e[r][1]]}return[null,void 0]},te=function(t){return typeof t=="string"?ot(t.trim(),it.string):typeof t=="object"&&t!==null?ot(t,it.object):[null,void 0]},j=function(t,e){var r=D(t);return{h:r.h,s:b(r.s+100*e,0,100),l:r.l,a:r.a}},P=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},at=function(t,e){var r=D(t);return{h:r.h,s:r.s,l:b(r.l+100*e,0,100),a:r.a}},ut=function(){function t(e){this.parsed=te(e)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return h(P(this.rgba),2)},t.prototype.isDark=function(){return P(this.rgba)<.5},t.prototype.isLight=function(){return P(this.rgba)>=.5},t.prototype.toHex=function(){return e=W(this.rgba),r=e.r,n=e.g,a=e.b,c=(l=e.a)<1?E(h(255*l)):"","#"+E(r)+E(n)+E(a)+c;var e,r,n,a,l,c},t.prototype.toRgb=function(){return W(this.rgba)},t.prototype.toRgbString=function(){return e=W(this.rgba),r=e.r,n=e.g,a=e.b,(l=e.a)<1?"rgba("+r+", "+n+", "+a+", "+l+")":"rgb("+r+", "+n+", "+a+")";var e,r,n,a,l},t.prototype.toHsl=function(){return rt(D(this.rgba))},t.prototype.toHslString=function(){return e=rt(D(this.rgba)),r=e.h,n=e.s,a=e.l,(l=e.a)<1?"hsla("+r+", "+n+"%, "+a+"%, "+l+")":"hsl("+r+", "+n+"%, "+a+"%)";var e,r,n,a,l},t.prototype.toHsv=function(){return e=Z(this.rgba),{h:h(e.h),s:h(e.s),v:h(e.v),a:h(e.a,3)};var e},t.prototype.invert=function(){return y({r:255-(e=this.rgba).r,g:255-e.g,b:255-e.b,a:e.a});var e},t.prototype.saturate=function(e){return e===void 0&&(e=.1),y(j(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),y(j(this.rgba,-e))},t.prototype.grayscale=function(){return y(j(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),y(at(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),y(at(this.rgba,-e))},t.prototype.rotate=function(e){return e===void 0&&(e=15),this.hue(this.hue()+e)},t.prototype.alpha=function(e){return typeof e=="number"?y({r:(r=this.rgba).r,g:r.g,b:r.b,a:e}):h(this.rgba.a,3);var r},t.prototype.hue=function(e){var r=D(this.rgba);return typeof e=="number"?y({h:e,s:r.s,l:r.l,a:r.a}):h(r.h)},t.prototype.isEqual=function(e){return this.toHex()===y(e).toHex()},t}(),y=function(t){return t instanceof ut?t:new ut(t)};function f(t){return t==null||t==="none"}function C(t,e=0,r=10**e){return Math.round(r*t)/r+0}function w(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(n=>w(n,e)):t;const r={};for(const n in t){const a=t[n];a!=null&&(e?r[n]=w(a,e):r[n]=a)}return r}function M(t){let e;return typeof t=="number"?e={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:e=t,y(e)}function ee(t){return{r:C(t.r),g:C(t.g),b:C(t.b),a:C(t.a,3)}}function V(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function lt(t){return M(t).isValid()}function v(t,e=!1){const r=M(t);if(!r.isValid()){if(typeof t=="string")return t;const d=`Failed to normalizeColor ${t}`;if(e)throw new Error(d);return console.warn(d),G}const{r:n,g:a,b:l,a:c}=ee(r.rgba);return`#${V(n)}${V(a)}${V(l)}${V(C(c*255))}`}var T=T||{};T.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let e="";function r(i){const u=new Error(`${e}: ${i}`);throw u.source=e,u}function n(){const i=a();return e.length>0&&r("Invalid input not EOF"),i}function a(){return x(l)}function l(){return c("linear-gradient",t.linearGradient,F)||c("repeating-linear-gradient",t.repeatingLinearGradient,F)||c("radial-gradient",t.radialGradient,Bt)||c("repeating-radial-gradient",t.repeatingRadialGradient,Bt)}function c(i,u,s){return d(u,m=>{const z=s();return z&&(g(t.comma)||r("Missing comma before color stops")),{type:i,orientation:z,colorStops:x(ce)}})}function d(i,u){const s=g(i);if(s){g(t.startCall)||r("Missing (");const m=u(s);return g(t.endCall)||r("Missing )"),m}}function F(){const i=O();if(i)return i;const u=p("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:ae()}function O(){return p("directional",t.sideOrCorner,1)}function ae(){return p("angular",t.angleValue,1)||p("angular",t.radianValue,1)}function Bt(){let i,u=Kt(),s;return u&&(i=[],i.push(u),s=e,g(t.comma)&&(u=Kt(),u?i.push(u):e=s)),i}function Kt(){let i=ue()||le();if(i)i.at=Y();else{const u=X();if(u){i=u;const s=Y();s&&(i.at=s)}else{const s=Y();if(s)i={type:"default-radial",at:s};else{const m=U();m&&(i={type:"default-radial",at:m})}}}return i}function ue(){const i=p("shape",/^(circle)/i,0);return i&&(i.style=Xt()||X()),i}function le(){const i=p("shape",/^(ellipse)/i,0);return i&&(i.style=U()||H()||X()),i}function X(){return p("extent-keyword",t.extentKeywords,1)}function Y(){if(p("position",/^at/,0)){const i=U();return i||r("Missing positioning value"),i}}function U(){const i=se();if(i.x||i.y)return{type:"position",value:i}}function se(){return{x:H(),y:H()}}function x(i){let u=i();const s=[];if(u)for(s.push(u);g(t.comma);)u=i(),u?s.push(u):r("One extra comma");return s}function ce(){const i=fe();return i||r("Expected color definition"),i.length=H(),i}function fe(){return ge()||be()||pe()||ve()||he()||me()||de()}function de(){return p("literal",t.literalColor,0)}function ge(){return p("hex",t.hexColor,1)}function he(){return d(t.rgbColor,()=>({type:"rgb",value:x(L)}))}function ve(){return d(t.rgbaColor,()=>({type:"rgba",value:x(L)}))}function me(){return d(t.varColor,()=>({type:"var",value:ye()}))}function pe(){return d(t.hslColor,()=>{g(t.percentageValue)&&r("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const u=L();g(t.comma);let s=g(t.percentageValue);const m=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const z=s?s[1]:null;return(!m||!z)&&r("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,m,z]}})}function be(){return d(t.hslaColor,()=>{const i=L();g(t.comma);let u=g(t.percentageValue);const s=u?u[1]:null;g(t.comma),u=g(t.percentageValue);const m=u?u[1]:null;g(t.comma);const z=L();return(!s||!m)&&r("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[i,s,m,z]}})}function ye(){return g(t.variableName)[1]}function L(){return g(t.number)[1]}function H(){return p("%",t.percentageValue,1)||Se()||Ce()||Xt()}function Se(){return p("position-keyword",t.positionKeywords,1)}function Ce(){return d(t.calcValue,()=>{let i=1,u=0;for(;i>0&&u<e.length;){const m=e.charAt(u);m==="("?i++:m===")"&&i--,u++}i>0&&r("Missing closing parenthesis in calc() expression");const s=e.substring(0,u-1);return q(u-1),{type:"calc",value:s}})}function Xt(){return p("px",t.pixelValue,1)||p("em",t.emValue,1)}function p(i,u,s){const m=g(u);if(m)return{type:i,value:m[s]}}function g(i){let u,s;return s=/^\s+/.exec(e),s&&q(s[0].length),u=i.exec(e),u&&q(u[0].length),u}function q(i){e=e.substr(i)}return function(i){return e=i.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),n()}}();const st=T.parse.bind(T);var A=A||{};A.stringify=function(){var t={"visit_linear-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-linear-gradient":function(e){return t.visit_gradient(e)},"visit_radial-gradient":function(e){return t.visit_gradient(e)},"visit_repeating-radial-gradient":function(e){return t.visit_gradient(e)},visit_gradient:function(e){var r=t.visit(e.orientation);return r&&(r+=", "),e.type+"("+r+t.visit(e.colorStops)+")"},visit_shape:function(e){var r=e.value,n=t.visit(e.at),a=t.visit(e.style);return a&&(r+=" "+a),n&&(r+=" at "+n),r},"visit_default-radial":function(e){var r="",n=t.visit(e.at);return n&&(r+=n),r},"visit_extent-keyword":function(e){var r=e.value,n=t.visit(e.at);return n&&(r+=" at "+n),r},"visit_position-keyword":function(e){return e.value},visit_position:function(e){return t.visit(e.value.x)+" "+t.visit(e.value.y)},"visit_%":function(e){return e.value+"%"},visit_em:function(e){return e.value+"em"},visit_px:function(e){return e.value+"px"},visit_calc:function(e){return"calc("+e.value+")"},visit_literal:function(e){return t.visit_color(e.value,e)},visit_hex:function(e){return t.visit_color("#"+e.value,e)},visit_rgb:function(e){return t.visit_color("rgb("+e.value.join(", ")+")",e)},visit_rgba:function(e){return t.visit_color("rgba("+e.value.join(", ")+")",e)},visit_hsl:function(e){return t.visit_color("hsl("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%)",e)},visit_hsla:function(e){return t.visit_color("hsla("+e.value[0]+", "+e.value[1]+"%, "+e.value[2]+"%, "+e.value[3]+")",e)},visit_var:function(e){return t.visit_color("var("+e.value+")",e)},visit_color:function(e,r){var n=e,a=t.visit(r.length);return a&&(n+=" "+a),n},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var r="",n=e.length;return e.forEach(function(a,l){r+=t.visit(a),l<n-1&&(r+=", ")}),r},visit_object:function(e){return e.width&&e.height?t.visit(e.width)+" "+t.visit(e.height):""},visit:function(e){if(!e)return"";if(e instanceof Array)return t.visit_array(e);if(typeof e=="object"&&!e.type)return t.visit_object(e);if(e.type){var r=t["visit_"+e.type];if(r)return r(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const re=A.stringify.bind(A);function ct(t){const e=t.length-1;return t.map((r,n)=>{var d;const a=r.value;let l=C(n/e,3),c="#00000000";switch(r.type){case"rgb":c=v({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0)});break;case"rgba":c=v({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0),a:Number(a[3]??0)});break;case"literal":c=v(r.value);break;case"hex":c=v(`#${r.value}`);break}switch((d=r.length)==null?void 0:d.type){case"%":l=Number(r.length.value)/100;break}return{offset:l,color:c}})}function ft(t){var r;let e=0;switch((r=t.orientation)==null?void 0:r.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:ct(t.colorStops)}}function dt(t){var e;return(e=t.orientation)==null||e.map(r=>{switch(r==null?void 0:r.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:ct(t.colorStops)}}function I(t){return t.startsWith("linear-gradient")||t.startsWith("radial-gradient")}function gt(t){return st(t).map(e=>{switch(e==null?void 0:e.type){case"linear-gradient":return ft(e);case"repeating-linear-gradient":return{...ft(e),repeat:!0};case"radial-gradient":return dt(e);case"repeating-radial-gradient":return{...dt(e),repeat:!0};default:return}}).filter(Boolean)}function ht(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:v(e.color)}}function vt(t){let e;typeof t=="string"?e={image:t}:e=t;const{type:r,...n}=gt(e.image)[0]??{};switch(r){case"radial-gradient":return{radialGradient:n};case"linear-gradient":return{linearGradient:n}}return{}}function mt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function pt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:f(e.foregroundColor)?void 0:v(e.foregroundColor),backgroundColor:f(e.backgroundColor)?void 0:v(e.backgroundColor)}}function bt(t){return!f(t.color)}function yt(t){return typeof t=="string"?lt(t):bt(t)}function St(t){return!f(t.image)&&I(t.image)}function Ct(t){return typeof t=="string"?I(t):St(t)}function wt(t){return!f(t.image)&&!I(t.image)}function zt(t){return typeof t=="string"?!I(t):wt(t)}function kt(t){return!f(t.preset)}function _t(t){return typeof t=="string"?!1:kt(t)}function _(t){if(yt(t))return ht(t);if(Ct(t))return vt(t);if(zt(t))return mt(t);if(_t(t))return pt(t);throw new Error("Unknown fill property object")}function Nt(t){return typeof t=="string"?{..._(t),fillWithShape:!1}:{..._(t),fillWithShape:!!t.fillWithShape}}function R(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function $(t){return{...R(),...w({...t,color:f(t.color)?G:v(t.color)})}}function Ft(){return{...R(),scaleX:1,scaleY:1}}function Dt(t){return{...Ft(),...$(t)}}function ne(t){return t}function Gt(t){return w({...t,softEdge:f(t.softEdge)?void 0:t.softEdge,outerShadow:f(t.outerShadow)?void 0:Dt(t.outerShadow),innerShadow:f(t.innerShadow)?void 0:$(t.innerShadow)})}function It(t){return typeof t=="string"?{..._(t),fillWithShape:!1}:{..._(t),fillWithShape:!!t.fillWithShape}}function Ot(t){return typeof t=="string"?{color:v(t)}:{...t,color:f(t.color)?void 0:v(t.color)}}function Lt(t){return typeof t=="string"?{color:v(t)}:{...t,color:f(t.color)?G:v(t.color)}}function Et(){return{boxShadow:"none"}}function Vt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(e=>typeof e=="string"?{data:e}:e)}:t}function Tt(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function At(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function xt(){return{...Tt(),...At(),...Et(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Ht(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function Wt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function jt(){return{...Ht(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Pt(){return{...Wt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function Mt(){return{...Pt(),...jt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function N(t){return w({...t,color:f(t.color)?void 0:v(t.color),backgroundColor:f(t.backgroundColor)?void 0:v(t.backgroundColor),borderColor:f(t.borderColor)?void 0:v(t.borderColor),outlineColor:f(t.outlineColor)?void 0:v(t.outlineColor),shadowColor:f(t.shadowColor)?void 0:v(t.shadowColor)})}function ie(){return{...xt(),...Mt()}}function B(t=""){return(Array.isArray(t)?t:[t]).map(r=>typeof r=="string"?{fragments:[{content:r}]}:"content"in r?{fragments:[N(r)]}:"fragments"in r?{...N(r),fragments:r.fragments.map(n=>N(n))}:Array.isArray(r)?{fragments:r.map(n=>typeof n=="string"?{content:n}:N(n))}:{fragments:[]})}function Rt(t){return typeof t=="string"?{content:[{fragments:[{content:t}]}]}:"content"in t?{...t,content:B(t.content)}:{content:B(t)}}function $t(t){return typeof t=="string"?{src:t}:t}function K(t){var e;return w({...t,style:f(t.style)?void 0:N(t.style),text:f(t.text)?void 0:Rt(t.text),background:f(t.background)?void 0:Nt(t.background),shape:f(t.shape)?void 0:Vt(t.shape),fill:f(t.fill)?void 0:_(t.fill),outline:f(t.outline)?void 0:Ot(t.outline),foreground:f(t.foreground)?void 0:It(t.foreground),shadow:f(t.shadow)?void 0:Lt(t.shadow),video:f(t.video)?void 0:$t(t.video),audio:f(t.audio)?void 0:k(t.audio),effect:f(t.effect)?void 0:Gt(t.effect),children:(e=t.children)==null?void 0:e.map(r=>K(r))})}function oe(t){return K(t)}o.clearUndef=w,o.defaultColor=G,o.getDefaultElementStyle=xt,o.getDefaultHighlightStyle=Ht,o.getDefaultInnerShadow=R,o.getDefaultLayoutStyle=Tt,o.getDefaultListStyleStyle=Wt,o.getDefaultOuterShadow=Ft,o.getDefaultShadowStyle=Et,o.getDefaultStyle=ie,o.getDefaultTextInlineStyle=jt,o.getDefaultTextLineStyle=Pt,o.getDefaultTextStyle=Mt,o.getDefaultTransformStyle=At,o.isColor=lt,o.isColorFill=yt,o.isColorFillObject=bt,o.isGradient=I,o.isGradientFill=Ct,o.isGradientFillObject=St,o.isImageFill=zt,o.isImageFillObject=wt,o.isNone=f,o.isPresetFill=_t,o.isPresetFillObject=kt,o.normalizeAudio=k,o.normalizeBackground=Nt,o.normalizeColor=v,o.normalizeColorFill=ht,o.normalizeDocument=oe,o.normalizeEffect=Gt,o.normalizeElement=K,o.normalizeFill=_,o.normalizeForeground=It,o.normalizeGradient=gt,o.normalizeGradientFill=vt,o.normalizeImageFill=mt,o.normalizeInnerShadow=$,o.normalizeOuterShadow=Dt,o.normalizeOutline=Ot,o.normalizePresetFill=pt,o.normalizeShadow=Lt,o.normalizeShape=Vt,o.normalizeSoftEdge=ne,o.normalizeStyle=N,o.normalizeText=Rt,o.normalizeTextContent=B,o.normalizeVideo=$t,o.parseColor=M,o.parseGradient=st,o.round=C,o.stringifyGradient=re,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
|
1
|
+
(function(o,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(o=typeof globalThis<"u"?globalThis:o||self,_(o.modernIdoc={}))})(this,function(o){"use strict";function _(t){return typeof t=="string"?{src:t}:t}var Ut={grad:.9,turn:360,rad:360/(2*Math.PI)},S=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},h=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=Math.pow(10,n)),Math.round(e*t)/e+0},b=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=1),t>e?e:t>n?t:n},Q=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},Z=function(t){return{r:b(t.r,0,255),g:b(t.g,0,255),b:b(t.b,0,255),a:b(t.a)}},j=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},qt=/^#([0-9a-f]{3,8})$/i,L=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},tt=function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=Math.max(n,e,r),c=l-Math.min(n,e,r),d=c?l===n?(e-r)/c:l===e?2+(r-n)/c:4+(n-e)/c:0;return{h:60*(d<0?d+6:d),s:l?c/l*100:0,v:l/255*100,a}},nt=function(t){var n=t.h,e=t.s,r=t.v,a=t.a;n=n/360*6,e/=100,r/=100;var l=Math.floor(n),c=r*(1-e),d=r*(1-(n-l)*e),F=r*(1-(1-n+l)*e),O=l%6;return{r:255*[r,d,c,c,F,r][O],g:255*[F,r,r,d,c,c][O],b:255*[c,c,F,r,r,d][O],a}},et=function(t){return{h:Q(t.h),s:b(t.s,0,100),l:b(t.l,0,100),a:b(t.a)}},rt=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},it=function(t){return nt((e=(n=t).s,{h:n.h,s:(e*=((r=n.l)<50?r:100-r)/100)>0?2*e/(r+e)*100:0,v:r+e,a:n.a}));var n,e,r},G=function(t){return{h:(n=tt(t)).h,s:(a=(200-(e=n.s))*(r=n.v)/100)>0&&a<200?e*r/100/(a<=100?a:200-a)*100:0,l:a/2,a:n.a};var n,e,r,a},Jt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Qt=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,Zt=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,tn=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ot={string:[[function(t){var n=qt.exec(t);return n?(t=n[1]).length<=4?{r:parseInt(t[0]+t[0],16),g:parseInt(t[1]+t[1],16),b:parseInt(t[2]+t[2],16),a:t.length===4?h(parseInt(t[3]+t[3],16)/255,2):1}:t.length===6||t.length===8?{r:parseInt(t.substr(0,2),16),g:parseInt(t.substr(2,2),16),b:parseInt(t.substr(4,2),16),a:t.length===8?h(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var n=Zt.exec(t)||tn.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:Z({r:Number(n[1])/(n[2]?100/255:1),g:Number(n[3])/(n[4]?100/255:1),b:Number(n[5])/(n[6]?100/255:1),a:n[7]===void 0?1:Number(n[7])/(n[8]?100:1)}):null},"rgb"],[function(t){var n=Jt.exec(t)||Qt.exec(t);if(!n)return null;var e,r,a=et({h:(e=n[1],r=n[2],r===void 0&&(r="deg"),Number(e)*(Ut[r]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return it(a)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,r=t.b,a=t.a,l=a===void 0?1:a;return S(n)&&S(e)&&S(r)?Z({r:Number(n),g:Number(e),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var n=t.h,e=t.s,r=t.l,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=et({h:Number(n),s:Number(e),l:Number(r),a:Number(l)});return it(c)},"hsl"],[function(t){var n=t.h,e=t.s,r=t.v,a=t.a,l=a===void 0?1:a;if(!S(n)||!S(e)||!S(r))return null;var c=function(d){return{h:Q(d.h),s:b(d.s,0,100),v:b(d.v,0,100),a:b(d.a)}}({h:Number(n),s:Number(e),v:Number(r),a:Number(l)});return nt(c)},"hsv"]]},at=function(t,n){for(var e=0;e<n.length;e++){var r=n[e][0](t);if(r)return[r,n[e][1]]}return[null,void 0]},nn=function(t){return typeof t=="string"?at(t.trim(),ot.string):typeof t=="object"&&t!==null?at(t,ot.object):[null,void 0]},M=function(t,n){var e=G(t);return{h:e.h,s:b(e.s+100*n,0,100),l:e.l,a:e.a}},R=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},ut=function(t,n){var e=G(t);return{h:e.h,s:e.s,l:b(e.l+100*n,0,100),a:e.a}},lt=function(){function t(n){this.parsed=nn(n)[0],this.rgba=this.parsed||{r:0,g:0,b:0,a:1}}return t.prototype.isValid=function(){return this.parsed!==null},t.prototype.brightness=function(){return h(R(this.rgba),2)},t.prototype.isDark=function(){return R(this.rgba)<.5},t.prototype.isLight=function(){return R(this.rgba)>=.5},t.prototype.toHex=function(){return n=j(this.rgba),e=n.r,r=n.g,a=n.b,c=(l=n.a)<1?L(h(255*l)):"","#"+L(e)+L(r)+L(a)+c;var n,e,r,a,l,c},t.prototype.toRgb=function(){return j(this.rgba)},t.prototype.toRgbString=function(){return n=j(this.rgba),e=n.r,r=n.g,a=n.b,(l=n.a)<1?"rgba("+e+", "+r+", "+a+", "+l+")":"rgb("+e+", "+r+", "+a+")";var n,e,r,a,l},t.prototype.toHsl=function(){return rt(G(this.rgba))},t.prototype.toHslString=function(){return n=rt(G(this.rgba)),e=n.h,r=n.s,a=n.l,(l=n.a)<1?"hsla("+e+", "+r+"%, "+a+"%, "+l+")":"hsl("+e+", "+r+"%, "+a+"%)";var n,e,r,a,l},t.prototype.toHsv=function(){return n=tt(this.rgba),{h:h(n.h),s:h(n.s),v:h(n.v),a:h(n.a,3)};var n},t.prototype.invert=function(){return y({r:255-(n=this.rgba).r,g:255-n.g,b:255-n.b,a:n.a});var n},t.prototype.saturate=function(n){return n===void 0&&(n=.1),y(M(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),y(M(this.rgba,-n))},t.prototype.grayscale=function(){return y(M(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),y(ut(this.rgba,-n))},t.prototype.rotate=function(n){return n===void 0&&(n=15),this.hue(this.hue()+n)},t.prototype.alpha=function(n){return typeof n=="number"?y({r:(e=this.rgba).r,g:e.g,b:e.b,a:n}):h(this.rgba.a,3);var e},t.prototype.hue=function(n){var e=G(this.rgba);return typeof n=="number"?y({h:n,s:e.s,l:e.l,a:e.a}):h(e.h)},t.prototype.isEqual=function(n){return this.toHex()===y(n).toHex()},t}(),y=function(t){return t instanceof lt?t:new lt(t)};function f(t){return t==null||t==="none"}function w(t,n=0,e=10**n){return Math.round(e*t)/e+0}function z(t,n=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return n?t.map(r=>z(r,n)):t;const e={};for(const r in t){const a=t[r];a!=null&&(n?e[r]=z(a,n):e[r]=a)}return e}function V(t,n){const e={};return n.forEach(r=>{r in t&&(e[r]=t[r])}),e}function $(t){let n;return typeof t=="number"?n={r:t>>24&255,g:t>>16&255,b:t>>8&255,a:(t&255)/255}:n=t,y(n)}function en(t){return{r:w(t.r),g:w(t.g),b:w(t.b),a:w(t.a,3)}}function T(t){const n=t.toString(16);return n.length<2?`0${n}`:n}const D="#000000FF";function st(t){return $(t).isValid()}function m(t,n=!1){const e=$(t);if(!e.isValid()){if(typeof t=="string")return t;const d=`Failed to normalizeColor ${t}`;if(n)throw new Error(d);return console.warn(d),D}const{r,g:a,b:l,a:c}=en(e.rgba);return`#${T(r)}${T(a)}${T(l)}${T(w(c*255))}`}var A=A||{};A.parse=function(){const t={linearGradient:/^(-(webkit|o|ms|moz)-)?(linear-gradient)/i,repeatingLinearGradient:/^(-(webkit|o|ms|moz)-)?(repeating-linear-gradient)/i,radialGradient:/^(-(webkit|o|ms|moz)-)?(radial-gradient)/i,repeatingRadialGradient:/^(-(webkit|o|ms|moz)-)?(repeating-radial-gradient)/i,sideOrCorner:/^to (left (top|bottom)|right (top|bottom)|top (left|right)|bottom (left|right)|left|right|top|bottom)/i,extentKeywords:/^(closest-side|closest-corner|farthest-side|farthest-corner|contain|cover)/,positionKeywords:/^(left|center|right|top|bottom)/i,pixelValue:/^(-?((\d*\.\d+)|(\d+\.?)))px/,percentageValue:/^(-?((\d*\.\d+)|(\d+\.?)))%/,emValue:/^(-?((\d*\.\d+)|(\d+\.?)))em/,angleValue:/^(-?((\d*\.\d+)|(\d+\.?)))deg/,radianValue:/^(-?((\d*\.\d+)|(\d+\.?)))rad/,startCall:/^\(/,endCall:/^\)/,comma:/^,/,hexColor:/^#([0-9a-f]+)/i,literalColor:/^([a-z]+)/i,rgbColor:/^rgb/i,rgbaColor:/^rgba/i,varColor:/^var/i,calcValue:/^calc/i,variableName:/^(--[a-z0-9-,\s#]+)/i,number:/^((\d*\.\d+)|(\d+\.?))/,hslColor:/^hsl/i,hslaColor:/^hsla/i};let n="";function e(i){const u=new Error(`${n}: ${i}`);throw u.source=n,u}function r(){const i=a();return n.length>0&&e("Invalid input not EOF"),i}function a(){return x(l)}function l(){return c("linear-gradient",t.linearGradient,F)||c("repeating-linear-gradient",t.repeatingLinearGradient,F)||c("radial-gradient",t.radialGradient,Kt)||c("repeating-radial-gradient",t.repeatingRadialGradient,Kt)}function c(i,u,s){return d(u,v=>{const k=s();return k&&(g(t.comma)||e("Missing comma before color stops")),{type:i,orientation:k,colorStops:x(dn)}})}function d(i,u){const s=g(i);if(s){g(t.startCall)||e("Missing (");const v=u(s);return g(t.endCall)||e("Missing )"),v}}function F(){const i=O();if(i)return i;const u=p("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:ln()}function O(){return p("directional",t.sideOrCorner,1)}function ln(){return p("angular",t.angleValue,1)||p("angular",t.radianValue,1)}function Kt(){let i,u=Xt(),s;return u&&(i=[],i.push(u),s=n,g(t.comma)&&(u=Xt(),u?i.push(u):n=s)),i}function Xt(){let i=sn()||cn();if(i)i.at=U();else{const u=Y();if(u){i=u;const s=U();s&&(i.at=s)}else{const s=U();if(s)i={type:"default-radial",at:s};else{const v=q();v&&(i={type:"default-radial",at:v})}}}return i}function sn(){const i=p("shape",/^(circle)/i,0);return i&&(i.style=Yt()||Y()),i}function cn(){const i=p("shape",/^(ellipse)/i,0);return i&&(i.style=q()||P()||Y()),i}function Y(){return p("extent-keyword",t.extentKeywords,1)}function U(){if(p("position",/^at/,0)){const i=q();return i||e("Missing positioning value"),i}}function q(){const i=fn();if(i.x||i.y)return{type:"position",value:i}}function fn(){return{x:P(),y:P()}}function x(i){let u=i();const s=[];if(u)for(s.push(u);g(t.comma);)u=i(),u?s.push(u):e("One extra comma");return s}function dn(){const i=gn();return i||e("Expected color definition"),i.length=P(),i}function gn(){return vn()||Sn()||yn()||pn()||mn()||bn()||hn()}function hn(){return p("literal",t.literalColor,0)}function vn(){return p("hex",t.hexColor,1)}function mn(){return d(t.rgbColor,()=>({type:"rgb",value:x(E)}))}function pn(){return d(t.rgbaColor,()=>({type:"rgba",value:x(E)}))}function bn(){return d(t.varColor,()=>({type:"var",value:Cn()}))}function yn(){return d(t.hslColor,()=>{g(t.percentageValue)&&e("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const u=E();g(t.comma);let s=g(t.percentageValue);const v=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const k=s?s[1]:null;return(!v||!k)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,v,k]}})}function Sn(){return d(t.hslaColor,()=>{const i=E();g(t.comma);let u=g(t.percentageValue);const s=u?u[1]:null;g(t.comma),u=g(t.percentageValue);const v=u?u[1]:null;g(t.comma);const k=E();return(!s||!v)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[i,s,v,k]}})}function Cn(){return g(t.variableName)[1]}function E(){return g(t.number)[1]}function P(){return p("%",t.percentageValue,1)||wn()||zn()||Yt()}function wn(){return p("position-keyword",t.positionKeywords,1)}function zn(){return d(t.calcValue,()=>{let i=1,u=0;for(;i>0&&u<n.length;){const v=n.charAt(u);v==="("?i++:v===")"&&i--,u++}i>0&&e("Missing closing parenthesis in calc() expression");const s=n.substring(0,u-1);return J(u-1),{type:"calc",value:s}})}function Yt(){return p("px",t.pixelValue,1)||p("em",t.emValue,1)}function p(i,u,s){const v=g(u);if(v)return{type:i,value:v[s]}}function g(i){let u,s;return s=/^\s+/.exec(n),s&&J(s[0].length),u=i.exec(n),u&&J(u[0].length),u}function J(i){n=n.substr(i)}return function(i){return n=i.toString().trim(),n.endsWith(";")&&(n=n.slice(0,-1)),r()}}();const ct=A.parse.bind(A);var H=H||{};H.stringify=function(){var t={"visit_linear-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-linear-gradient":function(n){return t.visit_gradient(n)},"visit_radial-gradient":function(n){return t.visit_gradient(n)},"visit_repeating-radial-gradient":function(n){return t.visit_gradient(n)},visit_gradient:function(n){var e=t.visit(n.orientation);return e&&(e+=", "),n.type+"("+e+t.visit(n.colorStops)+")"},visit_shape:function(n){var e=n.value,r=t.visit(n.at),a=t.visit(n.style);return a&&(e+=" "+a),r&&(e+=" at "+r),e},"visit_default-radial":function(n){var e="",r=t.visit(n.at);return r&&(e+=r),e},"visit_extent-keyword":function(n){var e=n.value,r=t.visit(n.at);return r&&(e+=" at "+r),e},"visit_position-keyword":function(n){return n.value},visit_position:function(n){return t.visit(n.value.x)+" "+t.visit(n.value.y)},"visit_%":function(n){return n.value+"%"},visit_em:function(n){return n.value+"em"},visit_px:function(n){return n.value+"px"},visit_calc:function(n){return"calc("+n.value+")"},visit_literal:function(n){return t.visit_color(n.value,n)},visit_hex:function(n){return t.visit_color("#"+n.value,n)},visit_rgb:function(n){return t.visit_color("rgb("+n.value.join(", ")+")",n)},visit_rgba:function(n){return t.visit_color("rgba("+n.value.join(", ")+")",n)},visit_hsl:function(n){return t.visit_color("hsl("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%)",n)},visit_hsla:function(n){return t.visit_color("hsla("+n.value[0]+", "+n.value[1]+"%, "+n.value[2]+"%, "+n.value[3]+")",n)},visit_var:function(n){return t.visit_color("var("+n.value+")",n)},visit_color:function(n,e){var r=n,a=t.visit(e.length);return a&&(r+=" "+a),r},visit_angular:function(n){return n.value+"deg"},visit_directional:function(n){return"to "+n.value},visit_array:function(n){var e="",r=n.length;return n.forEach(function(a,l){e+=t.visit(a),l<r-1&&(e+=", ")}),e},visit_object:function(n){return n.width&&n.height?t.visit(n.width)+" "+t.visit(n.height):""},visit:function(n){if(!n)return"";if(n instanceof Array)return t.visit_array(n);if(typeof n=="object"&&!n.type)return t.visit_object(n);if(n.type){var e=t["visit_"+n.type];if(e)return e(n);throw Error("Missing visitor visit_"+n.type)}else throw Error("Invalid node.")}};return function(n){return t.visit(n)}}();const rn=H.stringify.bind(H);function ft(t){const n=t.length-1;return t.map((e,r)=>{var d;const a=e.value;let l=w(r/n,3),c="#00000000";switch(e.type){case"rgb":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0)});break;case"rgba":c=m({r:Number(a[0]??0),g:Number(a[1]??0),b:Number(a[2]??0),a:Number(a[3]??0)});break;case"literal":c=m(e.value);break;case"hex":c=m(`#${e.value}`);break}switch((d=e.length)==null?void 0:d.type){case"%":l=Number(e.length.value)/100;break}return{offset:l,color:c}})}function dt(t){var e;let n=0;switch((e=t.orientation)==null?void 0:e.type){case"angular":n=Number(t.orientation.value);break}return{type:"linear-gradient",angle:n,stops:ft(t.colorStops)}}function gt(t){var n;return(n=t.orientation)==null||n.map(e=>{switch(e==null?void 0:e.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:ft(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function ht(t){return ct(t).map(n=>{switch(n==null?void 0:n.type){case"linear-gradient":return dt(n);case"repeating-linear-gradient":return{...dt(n),repeat:!0};case"radial-gradient":return gt(n);case"repeating-radial-gradient":return{...gt(n),repeat:!0};default:return}}).filter(Boolean)}function vt(t){let n;return typeof t=="string"?n={color:t}:n=t,{color:m(n.color)}}function mt(t){let n;if(typeof t=="string"?n={image:t}:n=t,n.image){const{type:e,...r}=ht(n.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return n}function pt(t){let n;return typeof t=="string"?n={image:t}:n=t,n}function bt(t){let n;return typeof t=="string"?n={preset:t}:n=t,{preset:n.preset,foregroundColor:f(n.foregroundColor)?void 0:m(n.foregroundColor),backgroundColor:f(n.backgroundColor)?void 0:m(n.backgroundColor)}}function yt(t){return!f(t.color)}function St(t){return typeof t=="string"?st(t):yt(t)}function Ct(t){return!f(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function wt(t){return typeof t=="string"?I(t):Ct(t)}function zt(t){return!f(t.image)&&!I(t.image)}function kt(t){return typeof t=="string"?!I(t):zt(t)}function _t(t){return!f(t.preset)}function Nt(t){return typeof t=="string"?!1:_t(t)}function C(t){if(St(t))return vt(t);if(wt(t))return mt(t);if(kt(t))return pt(t);if(Nt(t))return bt(t);throw new Error("Unknown fill property object")}function Ft(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function W(){return{color:D,offsetX:0,offsetY:0,blurRadius:1}}function B(t){return{...W(),...z({...t,color:f(t.color)?D:m(t.color)})}}function Gt(){return{...W(),scaleX:1,scaleY:1}}function Dt(t){return{...Gt(),...B(t)}}function on(t){return t}function It(t){return z({...t,softEdge:f(t.softEdge)?void 0:t.softEdge,outerShadow:f(t.outerShadow)?void 0:Dt(t.outerShadow),innerShadow:f(t.innerShadow)?void 0:B(t.innerShadow)})}function Ot(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["fillWithShape"])}}function Et(t){return typeof t=="string"?{...C(t)}:{...C(t),...V(t,["width","style","headEnd","tailEnd"])}}function Lt(t){return typeof t=="string"?{color:m(t)}:{...t,color:f(t.color)?D:m(t.color)}}function Vt(){return{boxShadow:"none"}}function Tt(t){return typeof t=="string"?t.startsWith("<svg")?{svg:t}:{paths:[{data:t}]}:Array.isArray(t)?{paths:t.map(n=>typeof n=="string"?{data:n}:n)}:t}function At(){return{overflow:"visible",direction:void 0,display:void 0,boxSizing:void 0,width:void 0,height:void 0,maxHeight:void 0,maxWidth:void 0,minHeight:void 0,minWidth:void 0,position:void 0,left:0,top:0,right:void 0,bottom:void 0,borderTop:void 0,borderLeft:void 0,borderRight:void 0,borderBottom:void 0,borderWidth:0,border:void 0,flex:void 0,flexBasis:void 0,flexDirection:void 0,flexGrow:void 0,flexShrink:void 0,flexWrap:void 0,justifyContent:void 0,gap:void 0,alignContent:void 0,alignItems:void 0,alignSelf:void 0,marginTop:void 0,marginLeft:void 0,marginRight:void 0,marginBottom:void 0,margin:void 0,paddingTop:void 0,paddingLeft:void 0,paddingRight:void 0,paddingBottom:void 0,padding:void 0}}function Ht(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function xt(){return{...At(),...Ht(),...Vt(),backgroundImage:"none",backgroundSize:"auto, auto",backgroundColor:"none",backgroundColormap:"none",borderRadius:0,borderColor:"none",borderStyle:"solid",outlineWidth:0,outlineOffset:0,outlineColor:"rgb(0, 0, 0)",outlineStyle:"none",visibility:"visible",filter:"none",opacity:1,pointerEvents:"auto",maskImage:"none"}}function Pt(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function jt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Mt(){return{...Pt(),color:"rgb(0, 0, 0)",verticalAlign:"baseline",letterSpacing:0,wordSpacing:0,fontSize:14,fontWeight:"normal",fontFamily:"",fontStyle:"normal",fontKerning:"normal",textTransform:"none",textOrientation:"mixed",textDecoration:"none"}}function Rt(){return{...jt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function $t(){return{...Rt(),...Mt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function N(t){return z({...t,color:f(t.color)?void 0:m(t.color),backgroundColor:f(t.backgroundColor)?void 0:m(t.backgroundColor),borderColor:f(t.borderColor)?void 0:m(t.borderColor),outlineColor:f(t.outlineColor)?void 0:m(t.outlineColor),shadowColor:f(t.shadowColor)?void 0:m(t.shadowColor)})}function an(){return{...xt(),...$t()}}function K(t=""){return(Array.isArray(t)?t:[t]).map(e=>typeof e=="string"?{fragments:[{content:e}]}:"content"in e?{fragments:[N(e)]}:"fragments"in e?{...N(e),fragments:e.fragments.map(r=>N(r))}:Array.isArray(e)?{fragments:e.map(r=>typeof r=="string"?{content:r}:N(r))}:{fragments:[]})}function Wt(t){return typeof t=="string"?{content:[{fragments:[{content:t}]}]}:"content"in t?{...t,content:K(t.content)}:{content:K(t)}}function Bt(t){return typeof t=="string"?{src:t}:t}function X(t){var n;return z({...t,style:f(t.style)?void 0:N(t.style),text:f(t.text)?void 0:Wt(t.text),background:f(t.background)?void 0:Ft(t.background),shape:f(t.shape)?void 0:Tt(t.shape),fill:f(t.fill)?void 0:C(t.fill),outline:f(t.outline)?void 0:Et(t.outline),foreground:f(t.foreground)?void 0:Ot(t.foreground),shadow:f(t.shadow)?void 0:Lt(t.shadow),video:f(t.video)?void 0:Bt(t.video),audio:f(t.audio)?void 0:_(t.audio),effect:f(t.effect)?void 0:It(t.effect),children:(n=t.children)==null?void 0:n.map(e=>X(e))})}function un(t){return X(t)}o.clearUndef=z,o.defaultColor=D,o.getDefaultElementStyle=xt,o.getDefaultHighlightStyle=Pt,o.getDefaultInnerShadow=W,o.getDefaultLayoutStyle=At,o.getDefaultListStyleStyle=jt,o.getDefaultOuterShadow=Gt,o.getDefaultShadowStyle=Vt,o.getDefaultStyle=an,o.getDefaultTextInlineStyle=Mt,o.getDefaultTextLineStyle=Rt,o.getDefaultTextStyle=$t,o.getDefaultTransformStyle=Ht,o.isColor=st,o.isColorFill=St,o.isColorFillObject=yt,o.isGradient=I,o.isGradientFill=wt,o.isGradientFillObject=Ct,o.isImageFill=kt,o.isImageFillObject=zt,o.isNone=f,o.isPresetFill=Nt,o.isPresetFillObject=_t,o.normalizeAudio=_,o.normalizeBackground=Ft,o.normalizeColor=m,o.normalizeColorFill=vt,o.normalizeDocument=un,o.normalizeEffect=It,o.normalizeElement=X,o.normalizeFill=C,o.normalizeForeground=Ot,o.normalizeGradient=ht,o.normalizeGradientFill=mt,o.normalizeImageFill=pt,o.normalizeInnerShadow=B,o.normalizeOuterShadow=Dt,o.normalizeOutline=Et,o.normalizePresetFill=bt,o.normalizeShadow=Lt,o.normalizeShape=Tt,o.normalizeSoftEdge=on,o.normalizeStyle=N,o.normalizeText=Wt,o.normalizeTextContent=K,o.normalizeVideo=Bt,o.parseColor=$,o.parseGradient=ct,o.pick=V,o.round=w,o.stringifyGradient=rn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
|
package/dist/index.mjs
CHANGED
|
@@ -39,6 +39,15 @@ function clearUndef(obj, deep = false) {
|
|
|
39
39
|
}
|
|
40
40
|
return newObj;
|
|
41
41
|
}
|
|
42
|
+
function pick(obj, keys) {
|
|
43
|
+
const result = {};
|
|
44
|
+
keys.forEach((key) => {
|
|
45
|
+
if (key in obj) {
|
|
46
|
+
result[key] = obj[key];
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
42
51
|
|
|
43
52
|
function parseColor(color) {
|
|
44
53
|
let input;
|
|
@@ -670,7 +679,7 @@ function parseRadialGradientNode(node) {
|
|
|
670
679
|
};
|
|
671
680
|
}
|
|
672
681
|
function isGradient(cssText) {
|
|
673
|
-
return cssText.startsWith("linear-gradient") || cssText.startsWith("radial-gradient");
|
|
682
|
+
return cssText.startsWith("linear-gradient(") || cssText.startsWith("radial-gradient(");
|
|
674
683
|
}
|
|
675
684
|
function normalizeGradient(cssText) {
|
|
676
685
|
return parseGradient(cssText).map((node) => {
|
|
@@ -708,18 +717,20 @@ function normalizeGradientFill(fill) {
|
|
|
708
717
|
} else {
|
|
709
718
|
obj = fill;
|
|
710
719
|
}
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
720
|
+
if (obj.image) {
|
|
721
|
+
const { type, ...props } = normalizeGradient(obj.image)[0] ?? {};
|
|
722
|
+
switch (type) {
|
|
723
|
+
case "radial-gradient":
|
|
724
|
+
return {
|
|
725
|
+
radialGradient: props
|
|
726
|
+
};
|
|
727
|
+
case "linear-gradient":
|
|
728
|
+
return {
|
|
729
|
+
linearGradient: props
|
|
730
|
+
};
|
|
731
|
+
}
|
|
721
732
|
}
|
|
722
|
-
return
|
|
733
|
+
return obj;
|
|
723
734
|
}
|
|
724
735
|
|
|
725
736
|
function normalizeImageFill(fill) {
|
|
@@ -753,7 +764,7 @@ function isColorFill(fill) {
|
|
|
753
764
|
return typeof fill === "string" ? isColor(fill) : isColorFillObject(fill);
|
|
754
765
|
}
|
|
755
766
|
function isGradientFillObject(fill) {
|
|
756
|
-
return !isNone(fill.image) && isGradient(fill.image);
|
|
767
|
+
return !isNone(fill.image) && isGradient(fill.image) || Boolean(fill.linearGradient) || Boolean(fill.radialGradient);
|
|
757
768
|
}
|
|
758
769
|
function isGradientFill(fill) {
|
|
759
770
|
return typeof fill === "string" ? isGradient(fill) : isGradientFillObject(fill);
|
|
@@ -786,13 +797,12 @@ function normalizeFill(fill) {
|
|
|
786
797
|
function normalizeBackground(background) {
|
|
787
798
|
if (typeof background === "string") {
|
|
788
799
|
return {
|
|
789
|
-
...normalizeFill(background)
|
|
790
|
-
fillWithShape: false
|
|
800
|
+
...normalizeFill(background)
|
|
791
801
|
};
|
|
792
802
|
} else {
|
|
793
803
|
return {
|
|
794
804
|
...normalizeFill(background),
|
|
795
|
-
|
|
805
|
+
...pick(background, ["fillWithShape"])
|
|
796
806
|
};
|
|
797
807
|
}
|
|
798
808
|
}
|
|
@@ -845,13 +855,12 @@ function normalizeEffect(effect) {
|
|
|
845
855
|
function normalizeForeground(foreground) {
|
|
846
856
|
if (typeof foreground === "string") {
|
|
847
857
|
return {
|
|
848
|
-
...normalizeFill(foreground)
|
|
849
|
-
fillWithShape: false
|
|
858
|
+
...normalizeFill(foreground)
|
|
850
859
|
};
|
|
851
860
|
} else {
|
|
852
861
|
return {
|
|
853
862
|
...normalizeFill(foreground),
|
|
854
|
-
|
|
863
|
+
...pick(foreground, ["fillWithShape"])
|
|
855
864
|
};
|
|
856
865
|
}
|
|
857
866
|
}
|
|
@@ -859,12 +868,12 @@ function normalizeForeground(foreground) {
|
|
|
859
868
|
function normalizeOutline(outline) {
|
|
860
869
|
if (typeof outline === "string") {
|
|
861
870
|
return {
|
|
862
|
-
|
|
871
|
+
...normalizeFill(outline)
|
|
863
872
|
};
|
|
864
873
|
} else {
|
|
865
874
|
return {
|
|
866
|
-
...outline,
|
|
867
|
-
|
|
875
|
+
...normalizeFill(outline),
|
|
876
|
+
...pick(outline, ["width", "style", "headEnd", "tailEnd"])
|
|
868
877
|
};
|
|
869
878
|
}
|
|
870
879
|
}
|
|
@@ -1184,4 +1193,4 @@ function normalizeDocument(doc) {
|
|
|
1184
1193
|
return normalizeElement(doc);
|
|
1185
1194
|
}
|
|
1186
1195
|
|
|
1187
|
-
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, round, stringifyGradient };
|
|
1196
|
+
export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeColor, normalizeColorFill, normalizeDocument, normalizeEffect, normalizeElement, normalizeFill, normalizeForeground, normalizeGradient, normalizeGradientFill, normalizeImageFill, normalizeInnerShadow, normalizeOuterShadow, normalizeOutline, normalizePresetFill, normalizeShadow, normalizeShape, normalizeSoftEdge, normalizeStyle, normalizeText, normalizeTextContent, normalizeVideo, parseColor, parseGradient, pick, round, stringifyGradient };
|