modern-idoc 0.6.10 → 0.6.11

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 CHANGED
@@ -1103,67 +1103,110 @@ function getDefaultStyle() {
1103
1103
  };
1104
1104
  }
1105
1105
 
1106
- function normalizeTextContent(content = "") {
1107
- const list = Array.isArray(content) ? content : [content];
1108
- return list.map((p) => {
1106
+ const CRLF_RE = /\r\n|\n\r|\n|\r/;
1107
+ const NORMALIZE_CRLF_RE = new RegExp(`${CRLF_RE.source}|<br\\/>`, "g");
1108
+ const IS_CRLF_RE = new RegExp(`^(${CRLF_RE.source})$`);
1109
+ const NORMALIZED_CRLF = "\n";
1110
+ function hasCRLF(content) {
1111
+ return CRLF_RE.test(content);
1112
+ }
1113
+ function isCRLF(char) {
1114
+ return IS_CRLF_RE.test(char);
1115
+ }
1116
+ function normalizeCRLF(content) {
1117
+ return content.replace(NORMALIZE_CRLF_RE, NORMALIZED_CRLF);
1118
+ }
1119
+ function normalizeTextContent(value) {
1120
+ const paragraphs = [];
1121
+ function getParagraph() {
1122
+ return paragraphs[paragraphs.length - 1] || addParagraph();
1123
+ }
1124
+ function addParagraph(style) {
1125
+ let paragraph = paragraphs[paragraphs.length - 1];
1126
+ if (paragraph?.fragments.length === 0) {
1127
+ paragraph = { ...style, fragments: [] };
1128
+ paragraphs[paragraphs.length - 1] = paragraph;
1129
+ } else {
1130
+ paragraph = { ...style, fragments: [] };
1131
+ paragraphs.push(paragraph);
1132
+ }
1133
+ return paragraph;
1134
+ }
1135
+ function addFragment(content, style) {
1136
+ Array.from(content).forEach((c) => {
1137
+ if (isCRLF(c)) {
1138
+ const { fragments, ...pStyle } = getParagraph();
1139
+ if (!fragments.length) {
1140
+ fragments.push({ ...style, content: NORMALIZED_CRLF });
1141
+ }
1142
+ addParagraph(pStyle);
1143
+ } else {
1144
+ const paragraph = getParagraph();
1145
+ if (paragraph.fragments[paragraph.fragments.length - 1]) {
1146
+ paragraph.fragments[paragraph.fragments.length - 1].content += c;
1147
+ } else {
1148
+ paragraph.fragments.push({ ...style, content: c });
1149
+ }
1150
+ }
1151
+ });
1152
+ }
1153
+ const list = Array.isArray(value) ? value : [value];
1154
+ list.forEach((p) => {
1109
1155
  if (typeof p === "string") {
1110
- return {
1111
- fragments: [
1112
- { content: p }
1113
- ]
1114
- };
1156
+ addFragment(p);
1115
1157
  } else if ("content" in p) {
1116
- return {
1117
- fragments: [
1118
- normalizeStyle(p)
1119
- ]
1120
- };
1158
+ addFragment(p.content, normalizeStyle(p));
1121
1159
  } else if ("fragments" in p) {
1122
- return {
1123
- ...normalizeStyle(p),
1124
- fragments: p.fragments.map((f) => normalizeStyle(f))
1125
- };
1160
+ addParagraph(normalizeStyle(p));
1161
+ p.fragments.forEach((f) => {
1162
+ addFragment(f.content, normalizeStyle(f));
1163
+ });
1126
1164
  } else if (Array.isArray(p)) {
1127
- return {
1128
- fragments: p.map((f) => {
1129
- if (typeof f === "string") {
1130
- return {
1131
- content: f
1132
- };
1133
- } else {
1134
- return normalizeStyle(f);
1135
- }
1136
- })
1137
- };
1165
+ p.forEach((f) => {
1166
+ if (typeof f === "string") {
1167
+ addFragment(f);
1168
+ } else {
1169
+ addFragment(f.content, normalizeStyle(f));
1170
+ }
1171
+ });
1138
1172
  } else {
1139
- return {
1173
+ paragraphs.push({
1140
1174
  fragments: []
1141
- };
1175
+ });
1142
1176
  }
1143
1177
  });
1178
+ if (!getParagraph().fragments.length) {
1179
+ addFragment(NORMALIZED_CRLF);
1180
+ }
1181
+ return paragraphs;
1144
1182
  }
1145
- function normalizeText(text) {
1146
- if (typeof text === "string") {
1183
+ function normalizeText(value) {
1184
+ if (typeof value === "string") {
1147
1185
  return {
1148
- content: [
1149
- {
1150
- fragments: [
1151
- { content: text }
1152
- ]
1153
- }
1154
- ]
1186
+ content: normalizeTextContent(value)
1155
1187
  };
1156
- } else if ("content" in text) {
1188
+ } else if ("content" in value) {
1157
1189
  return {
1158
- ...text,
1159
- content: normalizeTextContent(text.content)
1190
+ ...value,
1191
+ content: normalizeTextContent(value.content)
1160
1192
  };
1161
1193
  } else {
1162
1194
  return {
1163
- content: normalizeTextContent(text)
1195
+ content: normalizeTextContent(value)
1164
1196
  };
1165
1197
  }
1166
1198
  }
1199
+ function textContentToString(value) {
1200
+ return normalizeTextContent(value).map((p) => {
1201
+ const content = normalizeCRLF(
1202
+ p.fragments.flatMap((f) => f.content).join("")
1203
+ );
1204
+ if (isCRLF(content)) {
1205
+ return "";
1206
+ }
1207
+ return content;
1208
+ }).join(NORMALIZED_CRLF);
1209
+ }
1167
1210
 
1168
1211
  function normalizeVideo(video) {
1169
1212
  if (typeof video === "string") {
@@ -1209,6 +1252,8 @@ exports.getDefaultTextInlineStyle = getDefaultTextInlineStyle;
1209
1252
  exports.getDefaultTextLineStyle = getDefaultTextLineStyle;
1210
1253
  exports.getDefaultTextStyle = getDefaultTextStyle;
1211
1254
  exports.getDefaultTransformStyle = getDefaultTransformStyle;
1255
+ exports.hasCRLF = hasCRLF;
1256
+ exports.isCRLF = isCRLF;
1212
1257
  exports.isColor = isColor;
1213
1258
  exports.isColorFill = isColorFill;
1214
1259
  exports.isColorFillObject = isColorFillObject;
@@ -1222,6 +1267,7 @@ exports.isPresetFill = isPresetFill;
1222
1267
  exports.isPresetFillObject = isPresetFillObject;
1223
1268
  exports.normalizeAudio = normalizeAudio;
1224
1269
  exports.normalizeBackground = normalizeBackground;
1270
+ exports.normalizeCRLF = normalizeCRLF;
1225
1271
  exports.normalizeColor = normalizeColor;
1226
1272
  exports.normalizeColorFill = normalizeColorFill;
1227
1273
  exports.normalizeDocument = normalizeDocument;
@@ -1248,3 +1294,4 @@ exports.parseGradient = parseGradient;
1248
1294
  exports.pick = pick;
1249
1295
  exports.round = round;
1250
1296
  exports.stringifyGradient = stringifyGradient;
1297
+ exports.textContentToString = textContentToString;
package/dist/index.d.cts CHANGED
@@ -659,15 +659,15 @@ type Style = StyleObject;
659
659
  declare function normalizeStyle(style: Style): Partial<NormalizedStyle>;
660
660
  declare function getDefaultStyle(): NormalizedStyle;
661
661
 
662
- interface FragmentContent extends StyleObject {
662
+ interface FragmentObject extends StyleObject {
663
663
  content: string;
664
664
  }
665
- interface ParagraphContent extends StyleObject {
666
- fragments: FragmentContent[];
665
+ interface ParagraphObject extends StyleObject {
666
+ fragments: FragmentObject[];
667
667
  }
668
- type TextContentFlat = string | FragmentContent | ParagraphContent | (string | FragmentContent)[];
669
- type TextContent = string | FragmentContent | ParagraphContent | TextContentFlat[];
670
- type NormalizedTextContent = ParagraphContent[];
668
+ type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
669
+ type TextContent = FlatTextContent | FlatTextContent[];
670
+ type NormalizedTextContent = ParagraphObject[];
671
671
  interface NormalizedText {
672
672
  content: NormalizedTextContent;
673
673
  effects?: StyleObject[];
@@ -677,8 +677,12 @@ interface NormalizedText {
677
677
  type Text = string | TextContent | (NormalizedText & {
678
678
  content: TextContent;
679
679
  }) | NormalizedText;
680
- declare function normalizeTextContent(content?: TextContent): NormalizedTextContent;
681
- declare function normalizeText(text: Text): NormalizedText;
680
+ declare function hasCRLF(content: string): boolean;
681
+ declare function isCRLF(char: string): boolean;
682
+ declare function normalizeCRLF(content: string): string;
683
+ declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
684
+ declare function normalizeText(value: Text): NormalizedText;
685
+ declare function textContentToString(value: TextContent): string;
682
686
 
683
687
  interface NormalizedVideo {
684
688
  src: string;
@@ -729,5 +733,5 @@ declare function round(number: number, digits?: number, base?: number): number;
729
733
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
730
734
  declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
731
735
 
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 };
736
+ export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, 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, textContentToString };
737
+ 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, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, 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, ParagraphObject, 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, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.d.mts CHANGED
@@ -659,15 +659,15 @@ type Style = StyleObject;
659
659
  declare function normalizeStyle(style: Style): Partial<NormalizedStyle>;
660
660
  declare function getDefaultStyle(): NormalizedStyle;
661
661
 
662
- interface FragmentContent extends StyleObject {
662
+ interface FragmentObject extends StyleObject {
663
663
  content: string;
664
664
  }
665
- interface ParagraphContent extends StyleObject {
666
- fragments: FragmentContent[];
665
+ interface ParagraphObject extends StyleObject {
666
+ fragments: FragmentObject[];
667
667
  }
668
- type TextContentFlat = string | FragmentContent | ParagraphContent | (string | FragmentContent)[];
669
- type TextContent = string | FragmentContent | ParagraphContent | TextContentFlat[];
670
- type NormalizedTextContent = ParagraphContent[];
668
+ type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
669
+ type TextContent = FlatTextContent | FlatTextContent[];
670
+ type NormalizedTextContent = ParagraphObject[];
671
671
  interface NormalizedText {
672
672
  content: NormalizedTextContent;
673
673
  effects?: StyleObject[];
@@ -677,8 +677,12 @@ interface NormalizedText {
677
677
  type Text = string | TextContent | (NormalizedText & {
678
678
  content: TextContent;
679
679
  }) | NormalizedText;
680
- declare function normalizeTextContent(content?: TextContent): NormalizedTextContent;
681
- declare function normalizeText(text: Text): NormalizedText;
680
+ declare function hasCRLF(content: string): boolean;
681
+ declare function isCRLF(char: string): boolean;
682
+ declare function normalizeCRLF(content: string): string;
683
+ declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
684
+ declare function normalizeText(value: Text): NormalizedText;
685
+ declare function textContentToString(value: TextContent): string;
682
686
 
683
687
  interface NormalizedVideo {
684
688
  src: string;
@@ -729,5 +733,5 @@ declare function round(number: number, digits?: number, base?: number): number;
729
733
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
730
734
  declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
731
735
 
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 };
736
+ export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, 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, textContentToString };
737
+ 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, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, 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, ParagraphObject, 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, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.d.ts CHANGED
@@ -659,15 +659,15 @@ type Style = StyleObject;
659
659
  declare function normalizeStyle(style: Style): Partial<NormalizedStyle>;
660
660
  declare function getDefaultStyle(): NormalizedStyle;
661
661
 
662
- interface FragmentContent extends StyleObject {
662
+ interface FragmentObject extends StyleObject {
663
663
  content: string;
664
664
  }
665
- interface ParagraphContent extends StyleObject {
666
- fragments: FragmentContent[];
665
+ interface ParagraphObject extends StyleObject {
666
+ fragments: FragmentObject[];
667
667
  }
668
- type TextContentFlat = string | FragmentContent | ParagraphContent | (string | FragmentContent)[];
669
- type TextContent = string | FragmentContent | ParagraphContent | TextContentFlat[];
670
- type NormalizedTextContent = ParagraphContent[];
668
+ type FlatTextContent = string | FragmentObject | ParagraphObject | (string | FragmentObject)[];
669
+ type TextContent = FlatTextContent | FlatTextContent[];
670
+ type NormalizedTextContent = ParagraphObject[];
671
671
  interface NormalizedText {
672
672
  content: NormalizedTextContent;
673
673
  effects?: StyleObject[];
@@ -677,8 +677,12 @@ interface NormalizedText {
677
677
  type Text = string | TextContent | (NormalizedText & {
678
678
  content: TextContent;
679
679
  }) | NormalizedText;
680
- declare function normalizeTextContent(content?: TextContent): NormalizedTextContent;
681
- declare function normalizeText(text: Text): NormalizedText;
680
+ declare function hasCRLF(content: string): boolean;
681
+ declare function isCRLF(char: string): boolean;
682
+ declare function normalizeCRLF(content: string): string;
683
+ declare function normalizeTextContent(value: TextContent): NormalizedTextContent;
684
+ declare function normalizeText(value: Text): NormalizedText;
685
+ declare function textContentToString(value: TextContent): string;
682
686
 
683
687
  interface NormalizedVideo {
684
688
  src: string;
@@ -729,5 +733,5 @@ declare function round(number: number, digits?: number, base?: number): number;
729
733
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
730
734
  declare function pick<T extends object, K extends keyof T>(obj: T, keys: K[]): Pick<T, K>;
731
735
 
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 };
736
+ export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, 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, textContentToString };
737
+ 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, FlatTextContent, FlexDirection, FlexWrap, FontKerning, FontStyle, FontWeight, Foreground, ForegroundObject, FragmentObject, 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, ParagraphObject, 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, TextDecoration, TextOrientation, TextTransform, TextWrap, Uint32Color, VerticalAlign, Video, Visibility, WithNone, WithStyleNone, WritingMode, XyzColor, XyzaColor };
package/dist/index.js CHANGED
@@ -1 +1,2 @@
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)}},M=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]},R=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}},$=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($(this.rgba),2)},t.prototype.isDark=function(){return $(this.rgba)<.5},t.prototype.isLight=function(){return $(this.rgba)>=.5},t.prototype.toHex=function(){return n=M(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 M(this.rgba)},t.prototype.toRgbString=function(){return n=M(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(R(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),y(R(this.rgba,-n))},t.prototype.grayscale=function(){return y(R(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 j(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 j(t).isValid()}function m(t,n=!1){const e=j(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){return St(t)?vt(t):wt(t)?mt(t):kt(t)?pt(t):Nt(t)?bt(t):{}}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 Mt(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function Rt(){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 $t(){return{...Mt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function jt(){return{...$t(),...Rt(),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(),...jt()}}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=Mt,o.getDefaultOuterShadow=Gt,o.getDefaultShadowStyle=Vt,o.getDefaultStyle=an,o.getDefaultTextInlineStyle=Rt,o.getDefaultTextLineStyle=$t,o.getDefaultTextStyle=jt,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=j,o.parseGradient=ct,o.pick=V,o.round=w,o.stringifyGradient=rn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,N){typeof exports=="object"&&typeof module<"u"?N(exports):typeof define=="function"&&define.amd?define(["exports"],N):(o=typeof globalThis<"u"?globalThis:o||self,N(o.modernIdoc={}))})(this,function(o){"use strict";function N(t){return typeof t=="string"?{src:t}:t}var tn={grad:.9,turn:360,rad:360/(2*Math.PI)},w=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},y=function(t,n,e){return n===void 0&&(n=0),e===void 0&&(e=1),t>e?e:t>n?t:n},et=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},rt=function(t){return{r:y(t.r,0,255),g:y(t.g,0,255),b:y(t.b,0,255),a:y(t.a)}},H=function(t){return{r:h(t.r),g:h(t.g),b:h(t.b),a:h(t.a,3)}},nn=/^#([0-9a-f]{3,8})$/i,O=function(t){var n=t.toString(16);return n.length<2?"0"+n:n},it=function(t){var n=t.r,e=t.g,r=t.b,i=t.a,c=Math.max(n,e,r),u=c-Math.min(n,e,r),l=u?c===n?(e-r)/u:c===e?2+(r-n)/u:4+(n-e)/u:0;return{h:60*(l<0?l+6:l),s:c?u/c*100:0,v:c/255*100,a:i}},ot=function(t){var n=t.h,e=t.s,r=t.v,i=t.a;n=n/360*6,e/=100,r/=100;var c=Math.floor(n),u=r*(1-e),l=r*(1-(n-c)*e),S=r*(1-(1-n+c)*e),p=c%6;return{r:255*[r,l,u,u,S,r][p],g:255*[S,r,r,l,u,u][p],b:255*[u,u,S,r,r,l][p],a:i}},at=function(t){return{h:et(t.h),s:y(t.s,0,100),l:y(t.l,0,100),a:y(t.a)}},ut=function(t){return{h:h(t.h),s:h(t.s),l:h(t.l),a:h(t.a,3)}},lt=function(t){return ot((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},L=function(t){return{h:(n=it(t)).h,s:(i=(200-(e=n.s))*(r=n.v)/100)>0&&i<200?e*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:n.a};var n,e,r,i},en=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,rn=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,on=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,an=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,st={string:[[function(t){var n=nn.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=on.exec(t)||an.exec(t);return n?n[2]!==n[4]||n[4]!==n[6]?null:rt({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=en.exec(t)||rn.exec(t);if(!n)return null;var e,r,i=at({h:(e=n[1],r=n[2],r===void 0&&(r="deg"),Number(e)*(tn[r]||1)),s:Number(n[3]),l:Number(n[4]),a:n[5]===void 0?1:Number(n[5])/(n[6]?100:1)});return lt(i)},"hsl"]],object:[[function(t){var n=t.r,e=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return w(n)&&w(e)&&w(r)?rt({r:Number(n),g:Number(e),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var n=t.h,e=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!w(n)||!w(e)||!w(r))return null;var u=at({h:Number(n),s:Number(e),l:Number(r),a:Number(c)});return lt(u)},"hsl"],[function(t){var n=t.h,e=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!w(n)||!w(e)||!w(r))return null;var u=function(l){return{h:et(l.h),s:y(l.s,0,100),v:y(l.v,0,100),a:y(l.a)}}({h:Number(n),s:Number(e),v:Number(r),a:Number(c)});return ot(u)},"hsv"]]},ct=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]},un=function(t){return typeof t=="string"?ct(t.trim(),st.string):typeof t=="object"&&t!==null?ct(t,st.object):[null,void 0]},j=function(t,n){var e=L(t);return{h:e.h,s:y(e.s+100*n,0,100),l:e.l,a:e.a}},W=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},ft=function(t,n){var e=L(t);return{h:e.h,s:e.s,l:y(e.l+100*n,0,100),a:e.a}},dt=function(){function t(n){this.parsed=un(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(W(this.rgba),2)},t.prototype.isDark=function(){return W(this.rgba)<.5},t.prototype.isLight=function(){return W(this.rgba)>=.5},t.prototype.toHex=function(){return n=H(this.rgba),e=n.r,r=n.g,i=n.b,u=(c=n.a)<1?O(h(255*c)):"","#"+O(e)+O(r)+O(i)+u;var n,e,r,i,c,u},t.prototype.toRgb=function(){return H(this.rgba)},t.prototype.toRgbString=function(){return n=H(this.rgba),e=n.r,r=n.g,i=n.b,(c=n.a)<1?"rgba("+e+", "+r+", "+i+", "+c+")":"rgb("+e+", "+r+", "+i+")";var n,e,r,i,c},t.prototype.toHsl=function(){return ut(L(this.rgba))},t.prototype.toHslString=function(){return n=ut(L(this.rgba)),e=n.h,r=n.s,i=n.l,(c=n.a)<1?"hsla("+e+", "+r+"%, "+i+"%, "+c+")":"hsl("+e+", "+r+"%, "+i+"%)";var n,e,r,i,c},t.prototype.toHsv=function(){return n=it(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 C({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),C(j(this.rgba,n))},t.prototype.desaturate=function(n){return n===void 0&&(n=.1),C(j(this.rgba,-n))},t.prototype.grayscale=function(){return C(j(this.rgba,-1))},t.prototype.lighten=function(n){return n===void 0&&(n=.1),C(ft(this.rgba,n))},t.prototype.darken=function(n){return n===void 0&&(n=.1),C(ft(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"?C({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=L(this.rgba);return typeof n=="number"?C({h:n,s:e.s,l:e.l,a:e.a}):h(e.h)},t.prototype.isEqual=function(n){return this.toHex()===C(n).toHex()},t}(),C=function(t){return t instanceof dt?t:new dt(t)};function d(t){return t==null||t==="none"}function _(t,n=0,e=10**n){return Math.round(e*t)/e+0}function F(t,n=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return n?t.map(r=>F(r,n)):t;const e={};for(const r in t){const i=t[r];i!=null&&(n?e[r]=F(i,n):e[r]=i)}return e}function A(t,n){const e={};return n.forEach(r=>{r in t&&(e[r]=t[r])}),e}function B(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,C(n)}function ln(t){return{r:_(t.r),g:_(t.g),b:_(t.b),a:_(t.a,3)}}function T(t){const n=t.toString(16);return n.length<2?`0${n}`:n}const D="#000000FF";function gt(t){return B(t).isValid()}function m(t,n=!1){const e=B(t);if(!e.isValid()){if(typeof t=="string")return t;const l=`Failed to normalizeColor ${t}`;if(n)throw new Error(l);return console.warn(l),D}const{r,g:i,b:c,a:u}=ln(e.rgba);return`#${T(r)}${T(i)}${T(c)}${T(_(u*255))}`}var V=V||{};V.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(a){const s=new Error(`${n}: ${a}`);throw s.source=n,s}function r(){const a=i();return n.length>0&&e("Invalid input not EOF"),a}function i(){return P(c)}function c(){return u("linear-gradient",t.linearGradient,S)||u("repeating-linear-gradient",t.repeatingLinearGradient,S)||u("radial-gradient",t.radialGradient,qt)||u("repeating-radial-gradient",t.repeatingRadialGradient,qt)}function u(a,s,f){return l(s,v=>{const k=f();return k&&(g(t.comma)||e("Missing comma before color stops")),{type:a,orientation:k,colorStops:P(Cn)}})}function l(a,s){const f=g(a);if(f){g(t.startCall)||e("Missing (");const v=s(f);return g(t.endCall)||e("Missing )"),v}}function S(){const a=p();if(a)return a;const s=b("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:q()}function p(){return b("directional",t.sideOrCorner,1)}function q(){return b("angular",t.angleValue,1)||b("angular",t.radianValue,1)}function qt(){let a,s=Jt(),f;return s&&(a=[],a.push(s),f=n,g(t.comma)&&(s=Jt(),s?a.push(s):n=f)),a}function Jt(){let a=pn()||bn();if(a)a.at=Q();else{const s=J();if(s){a=s;const f=Q();f&&(a.at=f)}else{const f=Q();if(f)a={type:"default-radial",at:f};else{const v=tt();v&&(a={type:"default-radial",at:v})}}}return a}function pn(){const a=b("shape",/^(circle)/i,0);return a&&(a.style=Qt()||J()),a}function bn(){const a=b("shape",/^(ellipse)/i,0);return a&&(a.style=tt()||$()||J()),a}function J(){return b("extent-keyword",t.extentKeywords,1)}function Q(){if(b("position",/^at/,0)){const a=tt();return a||e("Missing positioning value"),a}}function tt(){const a=yn();if(a.x||a.y)return{type:"position",value:a}}function yn(){return{x:$(),y:$()}}function P(a){let s=a();const f=[];if(s)for(f.push(s);g(t.comma);)s=a(),s?f.push(s):e("One extra comma");return f}function Cn(){const a=Sn();return a||e("Expected color definition"),a.length=$(),a}function Sn(){return zn()||En()||Nn()||Fn()||_n()||kn()||wn()}function wn(){return b("literal",t.literalColor,0)}function zn(){return b("hex",t.hexColor,1)}function _n(){return l(t.rgbColor,()=>({type:"rgb",value:P(R)}))}function Fn(){return l(t.rgbaColor,()=>({type:"rgba",value:P(R)}))}function kn(){return l(t.varColor,()=>({type:"var",value:Ln()}))}function Nn(){return l(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 s=R();g(t.comma);let f=g(t.percentageValue);const v=f?f[1]:null;g(t.comma),f=g(t.percentageValue);const k=f?f[1]:null;return(!v||!k)&&e("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,v,k]}})}function En(){return l(t.hslaColor,()=>{const a=R();g(t.comma);let s=g(t.percentageValue);const f=s?s[1]:null;g(t.comma),s=g(t.percentageValue);const v=s?s[1]:null;g(t.comma);const k=R();return(!f||!v)&&e("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,v,k]}})}function Ln(){return g(t.variableName)[1]}function R(){return g(t.number)[1]}function $(){return b("%",t.percentageValue,1)||Dn()||Gn()||Qt()}function Dn(){return b("position-keyword",t.positionKeywords,1)}function Gn(){return l(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<n.length;){const v=n.charAt(s);v==="("?a++:v===")"&&a--,s++}a>0&&e("Missing closing parenthesis in calc() expression");const f=n.substring(0,s-1);return nt(s-1),{type:"calc",value:f}})}function Qt(){return b("px",t.pixelValue,1)||b("em",t.emValue,1)}function b(a,s,f){const v=g(s);if(v)return{type:a,value:v[f]}}function g(a){let s,f;return f=/^\s+/.exec(n),f&&nt(f[0].length),s=a.exec(n),s&&nt(s[0].length),s}function nt(a){n=n.substr(a)}return function(a){return n=a.toString().trim(),n.endsWith(";")&&(n=n.slice(0,-1)),r()}}();const ht=V.parse.bind(V);var x=x||{};x.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),i=t.visit(n.style);return i&&(e+=" "+i),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,i=t.visit(e.length);return i&&(r+=" "+i),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(i,c){e+=t.visit(i),c<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 sn=x.stringify.bind(x);function vt(t){const n=t.length-1;return t.map((e,r)=>{var l;const i=e.value;let c=_(r/n,3),u="#00000000";switch(e.type){case"rgb":u=m({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":u=m({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":u=m(e.value);break;case"hex":u=m(`#${e.value}`);break}switch((l=e.length)==null?void 0:l.type){case"%":c=Number(e.length.value)/100;break}return{offset:c,color:u}})}function mt(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:vt(t.colorStops)}}function pt(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:vt(t.colorStops)}}function G(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function bt(t){return ht(t).map(n=>{switch(n==null?void 0:n.type){case"linear-gradient":return mt(n);case"repeating-linear-gradient":return{...mt(n),repeat:!0};case"radial-gradient":return pt(n);case"repeating-radial-gradient":return{...pt(n),repeat:!0};default:return}}).filter(Boolean)}function yt(t){let n;return typeof t=="string"?n={color:t}:n=t,{color:m(n.color)}}function Ct(t){let n;if(typeof t=="string"?n={image:t}:n=t,n.image){const{type:e,...r}=bt(n.image)[0]??{};switch(e){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return n}function St(t){let n;return typeof t=="string"?n={image:t}:n=t,n}function wt(t){let n;return typeof t=="string"?n={preset:t}:n=t,{preset:n.preset,foregroundColor:d(n.foregroundColor)?void 0:m(n.foregroundColor),backgroundColor:d(n.backgroundColor)?void 0:m(n.backgroundColor)}}function zt(t){return!d(t.color)}function _t(t){return typeof t=="string"?gt(t):zt(t)}function Ft(t){return!d(t.image)&&G(t.image)||!!t.linearGradient||!!t.radialGradient}function kt(t){return typeof t=="string"?G(t):Ft(t)}function Nt(t){return!d(t.image)&&!G(t.image)}function Et(t){return typeof t=="string"?!G(t):Nt(t)}function Lt(t){return!d(t.preset)}function Dt(t){return typeof t=="string"?!1:Lt(t)}function z(t){return _t(t)?yt(t):kt(t)?Ct(t):Et(t)?St(t):Dt(t)?wt(t):{}}function Gt(t){return typeof t=="string"?{...z(t)}:{...z(t),...A(t,["fillWithShape"])}}function K(){return{color:D,offsetX:0,offsetY:0,blurRadius:1}}function X(t){return{...K(),...F({...t,color:d(t.color)?D:m(t.color)})}}function It(){return{...K(),scaleX:1,scaleY:1}}function Rt(t){return{...It(),...X(t)}}function cn(t){return t}function Ot(t){return F({...t,softEdge:d(t.softEdge)?void 0:t.softEdge,outerShadow:d(t.outerShadow)?void 0:Rt(t.outerShadow),innerShadow:d(t.innerShadow)?void 0:X(t.innerShadow)})}function At(t){return typeof t=="string"?{...z(t)}:{...z(t),...A(t,["fillWithShape"])}}function Tt(t){return typeof t=="string"?{...z(t)}:{...z(t),...A(t,["width","style","headEnd","tailEnd"])}}function Vt(t){return typeof t=="string"?{color:m(t)}:{...t,color:d(t.color)?D:m(t.color)}}function xt(){return{boxShadow:"none"}}function Mt(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 Pt(){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 $t(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Ht(){return{...Pt(),...$t(),...xt(),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 jt(){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 Bt(){return{...jt(),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 Kt(){return{...Wt(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function Xt(){return{...Kt(),...Bt(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function E(t){return F({...t,color:d(t.color)?void 0:m(t.color),backgroundColor:d(t.backgroundColor)?void 0:m(t.backgroundColor),borderColor:d(t.borderColor)?void 0:m(t.borderColor),outlineColor:d(t.outlineColor)?void 0:m(t.outlineColor),shadowColor:d(t.shadowColor)?void 0:m(t.shadowColor)})}function fn(){return{...Ht(),...Xt()}}const Y=/\r\n|\n\r|\n|\r/,dn=new RegExp(`${Y.source}|<br\\/>`,"g"),gn=new RegExp(`^(${Y.source})$`),M=`
2
+ `;function hn(t){return Y.test(t)}function U(t){return gn.test(t)}function Yt(t){return t.replace(dn,M)}function I(t){const n=[];function e(){return n[n.length-1]||r()}function r(u){let l=n[n.length-1];return(l==null?void 0:l.fragments.length)===0?(l={...u,fragments:[]},n[n.length-1]=l):(l={...u,fragments:[]},n.push(l)),l}function i(u,l){Array.from(u).forEach(S=>{if(U(S)){const{fragments:p,...q}=e();p.length||p.push({...l,content:M}),r(q)}else{const p=e();p.fragments[p.fragments.length-1]?p.fragments[p.fragments.length-1].content+=S:p.fragments.push({...l,content:S})}})}return(Array.isArray(t)?t:[t]).forEach(u=>{typeof u=="string"?i(u):"content"in u?i(u.content,E(u)):"fragments"in u?(r(E(u)),u.fragments.forEach(l=>{i(l.content,E(l))})):Array.isArray(u)?u.forEach(l=>{typeof l=="string"?i(l):i(l.content,E(l))}):n.push({fragments:[]})}),e().fragments.length||i(M),n}function Ut(t){return typeof t=="string"?{content:I(t)}:"content"in t?{...t,content:I(t.content)}:{content:I(t)}}function vn(t){return I(t).map(n=>{const e=Yt(n.fragments.flatMap(r=>r.content).join(""));return U(e)?"":e}).join(M)}function Zt(t){return typeof t=="string"?{src:t}:t}function Z(t){var n;return F({...t,style:d(t.style)?void 0:E(t.style),text:d(t.text)?void 0:Ut(t.text),background:d(t.background)?void 0:Gt(t.background),shape:d(t.shape)?void 0:Mt(t.shape),fill:d(t.fill)?void 0:z(t.fill),outline:d(t.outline)?void 0:Tt(t.outline),foreground:d(t.foreground)?void 0:At(t.foreground),shadow:d(t.shadow)?void 0:Vt(t.shadow),video:d(t.video)?void 0:Zt(t.video),audio:d(t.audio)?void 0:N(t.audio),effect:d(t.effect)?void 0:Ot(t.effect),children:(n=t.children)==null?void 0:n.map(e=>Z(e))})}function mn(t){return Z(t)}o.clearUndef=F,o.defaultColor=D,o.getDefaultElementStyle=Ht,o.getDefaultHighlightStyle=jt,o.getDefaultInnerShadow=K,o.getDefaultLayoutStyle=Pt,o.getDefaultListStyleStyle=Wt,o.getDefaultOuterShadow=It,o.getDefaultShadowStyle=xt,o.getDefaultStyle=fn,o.getDefaultTextInlineStyle=Bt,o.getDefaultTextLineStyle=Kt,o.getDefaultTextStyle=Xt,o.getDefaultTransformStyle=$t,o.hasCRLF=hn,o.isCRLF=U,o.isColor=gt,o.isColorFill=_t,o.isColorFillObject=zt,o.isGradient=G,o.isGradientFill=kt,o.isGradientFillObject=Ft,o.isImageFill=Et,o.isImageFillObject=Nt,o.isNone=d,o.isPresetFill=Dt,o.isPresetFillObject=Lt,o.normalizeAudio=N,o.normalizeBackground=Gt,o.normalizeCRLF=Yt,o.normalizeColor=m,o.normalizeColorFill=yt,o.normalizeDocument=mn,o.normalizeEffect=Ot,o.normalizeElement=Z,o.normalizeFill=z,o.normalizeForeground=At,o.normalizeGradient=bt,o.normalizeGradientFill=Ct,o.normalizeImageFill=St,o.normalizeInnerShadow=X,o.normalizeOuterShadow=Rt,o.normalizeOutline=Tt,o.normalizePresetFill=wt,o.normalizeShadow=Vt,o.normalizeShape=Mt,o.normalizeSoftEdge=cn,o.normalizeStyle=E,o.normalizeText=Ut,o.normalizeTextContent=I,o.normalizeVideo=Zt,o.parseColor=B,o.parseGradient=ht,o.pick=A,o.round=_,o.stringifyGradient=sn,o.textContentToString=vn,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1101,67 +1101,110 @@ function getDefaultStyle() {
1101
1101
  };
1102
1102
  }
1103
1103
 
1104
- function normalizeTextContent(content = "") {
1105
- const list = Array.isArray(content) ? content : [content];
1106
- return list.map((p) => {
1104
+ const CRLF_RE = /\r\n|\n\r|\n|\r/;
1105
+ const NORMALIZE_CRLF_RE = new RegExp(`${CRLF_RE.source}|<br\\/>`, "g");
1106
+ const IS_CRLF_RE = new RegExp(`^(${CRLF_RE.source})$`);
1107
+ const NORMALIZED_CRLF = "\n";
1108
+ function hasCRLF(content) {
1109
+ return CRLF_RE.test(content);
1110
+ }
1111
+ function isCRLF(char) {
1112
+ return IS_CRLF_RE.test(char);
1113
+ }
1114
+ function normalizeCRLF(content) {
1115
+ return content.replace(NORMALIZE_CRLF_RE, NORMALIZED_CRLF);
1116
+ }
1117
+ function normalizeTextContent(value) {
1118
+ const paragraphs = [];
1119
+ function getParagraph() {
1120
+ return paragraphs[paragraphs.length - 1] || addParagraph();
1121
+ }
1122
+ function addParagraph(style) {
1123
+ let paragraph = paragraphs[paragraphs.length - 1];
1124
+ if (paragraph?.fragments.length === 0) {
1125
+ paragraph = { ...style, fragments: [] };
1126
+ paragraphs[paragraphs.length - 1] = paragraph;
1127
+ } else {
1128
+ paragraph = { ...style, fragments: [] };
1129
+ paragraphs.push(paragraph);
1130
+ }
1131
+ return paragraph;
1132
+ }
1133
+ function addFragment(content, style) {
1134
+ Array.from(content).forEach((c) => {
1135
+ if (isCRLF(c)) {
1136
+ const { fragments, ...pStyle } = getParagraph();
1137
+ if (!fragments.length) {
1138
+ fragments.push({ ...style, content: NORMALIZED_CRLF });
1139
+ }
1140
+ addParagraph(pStyle);
1141
+ } else {
1142
+ const paragraph = getParagraph();
1143
+ if (paragraph.fragments[paragraph.fragments.length - 1]) {
1144
+ paragraph.fragments[paragraph.fragments.length - 1].content += c;
1145
+ } else {
1146
+ paragraph.fragments.push({ ...style, content: c });
1147
+ }
1148
+ }
1149
+ });
1150
+ }
1151
+ const list = Array.isArray(value) ? value : [value];
1152
+ list.forEach((p) => {
1107
1153
  if (typeof p === "string") {
1108
- return {
1109
- fragments: [
1110
- { content: p }
1111
- ]
1112
- };
1154
+ addFragment(p);
1113
1155
  } else if ("content" in p) {
1114
- return {
1115
- fragments: [
1116
- normalizeStyle(p)
1117
- ]
1118
- };
1156
+ addFragment(p.content, normalizeStyle(p));
1119
1157
  } else if ("fragments" in p) {
1120
- return {
1121
- ...normalizeStyle(p),
1122
- fragments: p.fragments.map((f) => normalizeStyle(f))
1123
- };
1158
+ addParagraph(normalizeStyle(p));
1159
+ p.fragments.forEach((f) => {
1160
+ addFragment(f.content, normalizeStyle(f));
1161
+ });
1124
1162
  } else if (Array.isArray(p)) {
1125
- return {
1126
- fragments: p.map((f) => {
1127
- if (typeof f === "string") {
1128
- return {
1129
- content: f
1130
- };
1131
- } else {
1132
- return normalizeStyle(f);
1133
- }
1134
- })
1135
- };
1163
+ p.forEach((f) => {
1164
+ if (typeof f === "string") {
1165
+ addFragment(f);
1166
+ } else {
1167
+ addFragment(f.content, normalizeStyle(f));
1168
+ }
1169
+ });
1136
1170
  } else {
1137
- return {
1171
+ paragraphs.push({
1138
1172
  fragments: []
1139
- };
1173
+ });
1140
1174
  }
1141
1175
  });
1176
+ if (!getParagraph().fragments.length) {
1177
+ addFragment(NORMALIZED_CRLF);
1178
+ }
1179
+ return paragraphs;
1142
1180
  }
1143
- function normalizeText(text) {
1144
- if (typeof text === "string") {
1181
+ function normalizeText(value) {
1182
+ if (typeof value === "string") {
1145
1183
  return {
1146
- content: [
1147
- {
1148
- fragments: [
1149
- { content: text }
1150
- ]
1151
- }
1152
- ]
1184
+ content: normalizeTextContent(value)
1153
1185
  };
1154
- } else if ("content" in text) {
1186
+ } else if ("content" in value) {
1155
1187
  return {
1156
- ...text,
1157
- content: normalizeTextContent(text.content)
1188
+ ...value,
1189
+ content: normalizeTextContent(value.content)
1158
1190
  };
1159
1191
  } else {
1160
1192
  return {
1161
- content: normalizeTextContent(text)
1193
+ content: normalizeTextContent(value)
1162
1194
  };
1163
1195
  }
1164
1196
  }
1197
+ function textContentToString(value) {
1198
+ return normalizeTextContent(value).map((p) => {
1199
+ const content = normalizeCRLF(
1200
+ p.fragments.flatMap((f) => f.content).join("")
1201
+ );
1202
+ if (isCRLF(content)) {
1203
+ return "";
1204
+ }
1205
+ return content;
1206
+ }).join(NORMALIZED_CRLF);
1207
+ }
1165
1208
 
1166
1209
  function normalizeVideo(video) {
1167
1210
  if (typeof video === "string") {
@@ -1193,4 +1236,4 @@ function normalizeDocument(doc) {
1193
1236
  return normalizeElement(doc);
1194
1237
  }
1195
1238
 
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 };
1239
+ export { clearUndef, defaultColor, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, normalizeAudio, normalizeBackground, normalizeCRLF, 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, textContentToString };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.6.10",
4
+ "version": "0.6.11",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",