modern-idoc 0.7.2 → 0.7.4

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
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  const colord = require('colord');
4
+ const nanoid$1 = require('nanoid');
4
5
 
5
6
  function normalizeAudio(audio) {
6
7
  if (typeof audio === "string") {
@@ -945,13 +946,27 @@ function defineProperty(target, key, declaration = {}) {
945
946
  getDeclarations(
946
947
  typeof target === "function" ? target : target.constructor
947
948
  ).set(key, declaration);
949
+ const prototype = target.prototype;
950
+ const rawDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
948
951
  const descriptor = getPropertyDescriptor(key, declaration);
949
- Object.defineProperty(target.prototype, key, {
952
+ let isFirst = true;
953
+ function get() {
954
+ let result = descriptor.get.call(this);
955
+ if (isFirst) {
956
+ isFirst = false;
957
+ if (result === void 0 && rawDescriptor) {
958
+ result = rawDescriptor.get?.call(this) ?? rawDescriptor.value;
959
+ descriptor.set.call(this, result);
960
+ }
961
+ }
962
+ return result;
963
+ }
964
+ Object.defineProperty(prototype, key, {
950
965
  get() {
951
- return descriptor.get.call(this);
966
+ return get.call(this);
952
967
  },
953
968
  set(newValue) {
954
- const oldValue = descriptor.get?.call(this);
969
+ const oldValue = get.call(this);
955
970
  descriptor.set.call(this, newValue);
956
971
  this.onUpdateProperty?.(key, newValue, oldValue, declaration);
957
972
  },
@@ -959,7 +974,15 @@ function defineProperty(target, key, declaration = {}) {
959
974
  enumerable: true
960
975
  });
961
976
  }
962
- function property(declaration = {}) {
977
+ function property(declaration) {
978
+ return function(target, key) {
979
+ if (typeof key !== "string") {
980
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
981
+ }
982
+ defineProperty(target.constructor, key, declaration);
983
+ };
984
+ }
985
+ function property2(declaration = {}) {
963
986
  return function(_, context) {
964
987
  const key = context.name;
965
988
  if (typeof key !== "string") {
@@ -1042,6 +1065,11 @@ function normalizeForeground(foreground) {
1042
1065
  }
1043
1066
  }
1044
1067
 
1068
+ const nanoid = () => {
1069
+ return nanoid$1.nanoid(10);
1070
+ };
1071
+ const idGenerator = nanoid;
1072
+
1045
1073
  function normalizeOutline(outline) {
1046
1074
  if (typeof outline === "string") {
1047
1075
  return {
@@ -1416,6 +1444,7 @@ function normalizeVideo(video) {
1416
1444
  function normalizeElement(element) {
1417
1445
  return clearUndef({
1418
1446
  ...element,
1447
+ id: element.id ?? idGenerator(),
1419
1448
  style: isNone(element.style) ? void 0 : normalizeStyle(element.style),
1420
1449
  text: isNone(element.text) ? void 0 : normalizeText(element.text),
1421
1450
  background: isNone(element.background) ? void 0 : normalizeBackground(element.background),
@@ -1456,6 +1485,7 @@ exports.getNestedValue = getNestedValue;
1456
1485
  exports.getObjectValueByPath = getObjectValueByPath;
1457
1486
  exports.getPropertyDescriptor = getPropertyDescriptor;
1458
1487
  exports.hasCRLF = hasCRLF;
1488
+ exports.idGenerator = idGenerator;
1459
1489
  exports.isCRLF = isCRLF;
1460
1490
  exports.isColor = isColor;
1461
1491
  exports.isColorFill = isColorFill;
@@ -1469,6 +1499,7 @@ exports.isImageFillObject = isImageFillObject;
1469
1499
  exports.isNone = isNone;
1470
1500
  exports.isPresetFill = isPresetFill;
1471
1501
  exports.isPresetFillObject = isPresetFillObject;
1502
+ exports.nanoid = nanoid;
1472
1503
  exports.normalizeAudio = normalizeAudio;
1473
1504
  exports.normalizeBackground = normalizeBackground;
1474
1505
  exports.normalizeCRLF = normalizeCRLF;
@@ -1497,6 +1528,7 @@ exports.parseColor = parseColor;
1497
1528
  exports.parseGradient = parseGradient;
1498
1529
  exports.pick = pick;
1499
1530
  exports.property = property;
1531
+ exports.property2 = property2;
1500
1532
  exports.round = round;
1501
1533
  exports.setNestedValue = setNestedValue;
1502
1534
  exports.setObjectValueByPath = setObjectValueByPath;
package/dist/index.d.cts CHANGED
@@ -321,11 +321,11 @@ interface PropertyDeclaration {
321
321
  alias?: string;
322
322
  }
323
323
  interface ReactiveObject {
324
- getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
- setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
324
+ getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
326
326
  onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
327
  }
328
- interface ReactiveObjectGetterSetterContext {
328
+ interface ReactiveObjectPropertyAccessorContext {
329
329
  declaration: PropertyDeclaration;
330
330
  internalKey: symbol;
331
331
  }
@@ -335,7 +335,8 @@ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string,
335
335
  set: (v: any) => void;
336
336
  };
337
337
  declare function defineProperty<V, T extends ReactiveObject>(target: any, key: string, declaration?: PropertyDeclaration): void;
338
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
338
+ declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
339
+ declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
339
340
 
340
341
  interface NormalizedInnerShadow {
341
342
  color: NormalizedColor;
@@ -715,6 +716,7 @@ type Video = string | NormalizedVideo;
715
716
  declare function normalizeVideo(video: Video): NormalizedVideo | undefined;
716
717
 
717
718
  interface Element<T = Meta> extends Node<T> {
719
+ id?: string;
718
720
  style?: WithNone<Style>;
719
721
  text?: WithNone<Text>;
720
722
  background?: WithNone<Background>;
@@ -729,6 +731,7 @@ interface Element<T = Meta> extends Node<T> {
729
731
  children?: Element[];
730
732
  }
731
733
  type NormalizedElement<T = Meta> = Node<T> & {
734
+ id: string;
732
735
  style?: Partial<NormalizedStyle>;
733
736
  text?: NormalizedText;
734
737
  background?: NormalizedBackground;
@@ -752,6 +755,10 @@ interface NormalizedDocument extends NormalizedElement {
752
755
  }
753
756
  declare function normalizeDocument(doc: Document): NormalizedDocument;
754
757
 
758
+ type IdGenerator = () => string;
759
+ declare const nanoid: IdGenerator;
760
+ declare const idGenerator: IdGenerator;
761
+
755
762
  declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
756
763
  declare function round(number: number, digits?: number, base?: number): number;
757
764
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
@@ -785,5 +792,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
785
792
  set(key: K, value: V): this;
786
793
  }
787
794
 
788
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, 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, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
789
- 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectGetterSetterContext, 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 };
795
+ export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, nanoid, 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, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
796
+ 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, IdGenerator, 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, 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
@@ -321,11 +321,11 @@ interface PropertyDeclaration {
321
321
  alias?: string;
322
322
  }
323
323
  interface ReactiveObject {
324
- getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
- setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
324
+ getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
326
326
  onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
327
  }
328
- interface ReactiveObjectGetterSetterContext {
328
+ interface ReactiveObjectPropertyAccessorContext {
329
329
  declaration: PropertyDeclaration;
330
330
  internalKey: symbol;
331
331
  }
@@ -335,7 +335,8 @@ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string,
335
335
  set: (v: any) => void;
336
336
  };
337
337
  declare function defineProperty<V, T extends ReactiveObject>(target: any, key: string, declaration?: PropertyDeclaration): void;
338
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
338
+ declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
339
+ declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
339
340
 
340
341
  interface NormalizedInnerShadow {
341
342
  color: NormalizedColor;
@@ -715,6 +716,7 @@ type Video = string | NormalizedVideo;
715
716
  declare function normalizeVideo(video: Video): NormalizedVideo | undefined;
716
717
 
717
718
  interface Element<T = Meta> extends Node<T> {
719
+ id?: string;
718
720
  style?: WithNone<Style>;
719
721
  text?: WithNone<Text>;
720
722
  background?: WithNone<Background>;
@@ -729,6 +731,7 @@ interface Element<T = Meta> extends Node<T> {
729
731
  children?: Element[];
730
732
  }
731
733
  type NormalizedElement<T = Meta> = Node<T> & {
734
+ id: string;
732
735
  style?: Partial<NormalizedStyle>;
733
736
  text?: NormalizedText;
734
737
  background?: NormalizedBackground;
@@ -752,6 +755,10 @@ interface NormalizedDocument extends NormalizedElement {
752
755
  }
753
756
  declare function normalizeDocument(doc: Document): NormalizedDocument;
754
757
 
758
+ type IdGenerator = () => string;
759
+ declare const nanoid: IdGenerator;
760
+ declare const idGenerator: IdGenerator;
761
+
755
762
  declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
756
763
  declare function round(number: number, digits?: number, base?: number): number;
757
764
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
@@ -785,5 +792,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
785
792
  set(key: K, value: V): this;
786
793
  }
787
794
 
788
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, 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, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
789
- 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectGetterSetterContext, 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 };
795
+ export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, nanoid, 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, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
796
+ 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, IdGenerator, 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, 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
@@ -321,11 +321,11 @@ interface PropertyDeclaration {
321
321
  alias?: string;
322
322
  }
323
323
  interface ReactiveObject {
324
- getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
- setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
324
+ getter?: (key: string, context: ReactiveObjectPropertyAccessorContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectPropertyAccessorContext) => void;
326
326
  onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
327
  }
328
- interface ReactiveObjectGetterSetterContext {
328
+ interface ReactiveObjectPropertyAccessorContext {
329
329
  declaration: PropertyDeclaration;
330
330
  internalKey: symbol;
331
331
  }
@@ -335,7 +335,8 @@ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string,
335
335
  set: (v: any) => void;
336
336
  };
337
337
  declare function defineProperty<V, T extends ReactiveObject>(target: any, key: string, declaration?: PropertyDeclaration): void;
338
- declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
338
+ declare function property<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): PropertyDecorator;
339
+ declare function property2<V, T extends ReactiveObject>(declaration?: PropertyDeclaration): (_: ClassAccessorDecoratorTarget<T, V>, context: ClassAccessorDecoratorContext) => ClassAccessorDecoratorResult<T, V>;
339
340
 
340
341
  interface NormalizedInnerShadow {
341
342
  color: NormalizedColor;
@@ -715,6 +716,7 @@ type Video = string | NormalizedVideo;
715
716
  declare function normalizeVideo(video: Video): NormalizedVideo | undefined;
716
717
 
717
718
  interface Element<T = Meta> extends Node<T> {
719
+ id?: string;
718
720
  style?: WithNone<Style>;
719
721
  text?: WithNone<Text>;
720
722
  background?: WithNone<Background>;
@@ -729,6 +731,7 @@ interface Element<T = Meta> extends Node<T> {
729
731
  children?: Element[];
730
732
  }
731
733
  type NormalizedElement<T = Meta> = Node<T> & {
734
+ id: string;
732
735
  style?: Partial<NormalizedStyle>;
733
736
  text?: NormalizedText;
734
737
  background?: NormalizedBackground;
@@ -752,6 +755,10 @@ interface NormalizedDocument extends NormalizedElement {
752
755
  }
753
756
  declare function normalizeDocument(doc: Document): NormalizedDocument;
754
757
 
758
+ type IdGenerator = () => string;
759
+ declare const nanoid: IdGenerator;
760
+ declare const idGenerator: IdGenerator;
761
+
755
762
  declare function isNone<T>(value: T): value is Extract<T, null | undefined | 'none'>;
756
763
  declare function round(number: number, digits?: number, base?: number): number;
757
764
  declare function clearUndef<T>(obj: T, deep?: boolean): T;
@@ -785,5 +792,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
785
792
  set(key: K, value: V): this;
786
793
  }
787
794
 
788
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, 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, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
789
- 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectGetterSetterContext, 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 };
795
+ export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, nanoid, 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, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
796
+ 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, IdGenerator, 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, PropertyDeclaration, PxNode, RadialGradient, RadialGradientNode, RadialGradientWithType, ReactiveObject, ReactiveObjectPropertyAccessorContext, 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,2 +1,2 @@
1
- (function(o,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(o=typeof globalThis<"u"?globalThis:o||self,E(o.modernIdoc={}))})(this,function(o){"use strict";function E(t){return typeof t=="string"?{src:t}:t}var se={grad:.9,turn:360,rad:360/(2*Math.PI)},_=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},v=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},S=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},lt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},st=function(t){return{r:S(t.r,0,255),g:S(t.g,0,255),b:S(t.b,0,255),a:S(t.a)}},K=function(t){return{r:v(t.r),g:v(t.g),b:v(t.b),a:v(t.a,3)}},ce=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},ct=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=Math.max(e,n,r),c=l-Math.min(e,n,r),u=c?l===e?(n-r)/c:l===n?2+(r-e)/c:4+(e-n)/c:0;return{h:60*(u<0?u+6:u),s:l?c/l*100:0,v:l/255*100,a:i}},ft=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var l=Math.floor(e),c=r*(1-n),u=r*(1-(e-l)*n),g=r*(1-(1-e+l)*n),y=l%6;return{r:255*[r,u,c,c,g,r][y],g:255*[g,r,r,u,c,c][y],b:255*[c,c,g,r,r,u][y],a:i}},dt=function(t){return{h:lt(t.h),s:S(t.s,0,100),l:S(t.l,0,100),a:S(t.a)}},gt=function(t){return{h:v(t.h),s:v(t.s),l:v(t.l),a:v(t.a,3)}},ht=function(t){return ft((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},L=function(t){return{h:(e=ct(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},fe=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,de=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ge=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vt={string:[[function(t){var e=ce.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?v(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?v(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ge.exec(t)||he.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:st({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=fe.exec(t)||de.exec(t);if(!e)return null;var n,r,i=dt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(se[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ht(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=i===void 0?1:i;return _(e)&&_(n)&&_(r)?st({r:Number(e),g:Number(n),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,l=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var c=dt({h:Number(e),s:Number(n),l:Number(r),a:Number(l)});return ht(c)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,l=i===void 0?1:i;if(!_(e)||!_(n)||!_(r))return null;var c=function(u){return{h:lt(u.h),s:S(u.s,0,100),v:S(u.v,0,100),a:S(u.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(l)});return ft(c)},"hsv"]]},mt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},ve=function(t){return typeof t=="string"?mt(t.trim(),vt.string):typeof t=="object"&&t!==null?mt(t,vt.object):[null,void 0]},X=function(t,e){var n=L(t);return{h:n.h,s:S(n.s+100*e,0,100),l:n.l,a:n.a}},Y=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},pt=function(t,e){var n=L(t);return{h:n.h,s:n.s,l:S(n.l+100*e,0,100),a:n.a}},yt=function(){function t(e){this.parsed=ve(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 v(Y(this.rgba),2)},t.prototype.isDark=function(){return Y(this.rgba)<.5},t.prototype.isLight=function(){return Y(this.rgba)>=.5},t.prototype.toHex=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,c=(l=e.a)<1?A(v(255*l)):"","#"+A(n)+A(r)+A(i)+c;var e,n,r,i,l,c},t.prototype.toRgb=function(){return K(this.rgba)},t.prototype.toRgbString=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,(l=e.a)<1?"rgba("+n+", "+r+", "+i+", "+l+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,l},t.prototype.toHsl=function(){return gt(L(this.rgba))},t.prototype.toHslString=function(){return e=gt(L(this.rgba)),n=e.h,r=e.s,i=e.l,(l=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+l+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,l},t.prototype.toHsv=function(){return e=ct(this.rgba),{h:v(e.h),s:v(e.s),v:v(e.v),a:v(e.a,3)};var e},t.prototype.invert=function(){return w({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),w(X(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(X(this.rgba,-e))},t.prototype.grayscale=function(){return w(X(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(pt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(pt(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"?w({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):v(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=L(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):v(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t}(),w=function(t){return t instanceof yt?t:new yt(t)};function d(t){return t==null||t==="none"}function N(t,e=0,n=10**e){return Math.round(n*t)/n+0}function O(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>O(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=O(i,e):n[r]=i)}return n}function T(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function bt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function St(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function Ct(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n))}function wt(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),St(t,e.split("."),n)}class me{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function U(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,w(e)}function pe(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function M(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function zt(t){return U(t).isValid()}function p(t,e=!1){const n=U(t);if(!n.isValid()){if(typeof t=="string")return t;const u=`Failed to normalizeColor ${t}`;if(e)throw new Error(u);return console.warn(u),G}const{r,g:i,b:l,a:c}=pe(n.rgba);return`#${M(r)}${M(i)}${M(l)}${M(N(c*255))}`}var $=$||{};$.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 n(a){const s=new Error(`${e}: ${a}`);throw s.source=e,s}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return j(l)}function l(){return c("linear-gradient",t.linearGradient,g)||c("repeating-linear-gradient",t.repeatingLinearGradient,g)||c("radial-gradient",t.radialGradient,z)||c("repeating-radial-gradient",t.repeatingRadialGradient,z)}function c(a,s,f){return u(s,m=>{const R=f();return R&&(h(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:j(ke)}})}function u(a,s){const f=h(a);if(f){h(t.startCall)||n("Missing (");const m=s(f);return h(t.endCall)||n("Missing )"),m}}function g(){const a=y();if(a)return a;const s=b("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:C()}function y(){return b("directional",t.sideOrCorner,1)}function C(){return b("angular",t.angleValue,1)||b("angular",t.radianValue,1)}function z(){let a,s=D(),f;return s&&(a=[],a.push(s),f=e,h(t.comma)&&(s=D(),s?a.push(s):e=f)),a}function D(){let a=rt()||Re();if(a)a.at=ot();else{const s=it();if(s){a=s;const f=ot();f&&(a.at=f)}else{const f=ot();if(f)a={type:"default-radial",at:f};else{const m=at();m&&(a={type:"default-radial",at:m})}}}return a}function rt(){const a=b("shape",/^(circle)/i,0);return a&&(a.style=le()||it()),a}function Re(){const a=b("shape",/^(ellipse)/i,0);return a&&(a.style=at()||x()||it()),a}function it(){return b("extent-keyword",t.extentKeywords,1)}function ot(){if(b("position",/^at/,0)){const a=at();return a||n("Missing positioning value"),a}}function at(){const a=Ee();if(a.x||a.y)return{type:"position",value:a}}function Ee(){return{x:x(),y:x()}}function j(a){let s=a();const f=[];if(s)for(f.push(s);h(t.comma);)s=a(),s?f.push(s):n("One extra comma");return f}function ke(){const a=De();return a||n("Expected color definition"),a.length=x(),a}function De(){return Ge()||Te()||Ae()||Pe()||Ie()||Ve()||Le()}function Le(){return b("literal",t.literalColor,0)}function Ge(){return b("hex",t.hexColor,1)}function Ie(){return u(t.rgbColor,()=>({type:"rgb",value:j(V)}))}function Pe(){return u(t.rgbaColor,()=>({type:"rgba",value:j(V)}))}function Ve(){return u(t.varColor,()=>({type:"var",value:Me()}))}function Ae(){return u(t.hslColor,()=>{h(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=V();h(t.comma);let f=h(t.percentageValue);const m=f?f[1]:null;h(t.comma),f=h(t.percentageValue);const R=f?f[1]:null;return(!m||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,m,R]}})}function Te(){return u(t.hslaColor,()=>{const a=V();h(t.comma);let s=h(t.percentageValue);const f=s?s[1]:null;h(t.comma),s=h(t.percentageValue);const m=s?s[1]:null;h(t.comma);const R=V();return(!f||!m)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,m,R]}})}function Me(){return h(t.variableName)[1]}function V(){return h(t.number)[1]}function x(){return b("%",t.percentageValue,1)||$e()||He()||le()}function $e(){return b("position-keyword",t.positionKeywords,1)}function He(){return u(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<e.length;){const m=e.charAt(s);m==="("?a++:m===")"&&a--,s++}a>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,s-1);return ut(s-1),{type:"calc",value:f}})}function le(){return b("px",t.pixelValue,1)||b("em",t.emValue,1)}function b(a,s,f){const m=h(s);if(m)return{type:a,value:m[f]}}function h(a){let s,f;return f=/^\s+/.exec(e),f&&ut(f[0].length),s=a.exec(e),s&&ut(s[0].length),s}function ut(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const _t=$.parse.bind($);var H=H||{};H.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 n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"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,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,l){n+=t.visit(i),l<r-1&&(n+=", ")}),n},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 n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const ye=H.stringify.bind(H);function Ft(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let l=N(r/e,3),c="#00000000";switch(n.type){case"rgb":c=p({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":c=p({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":c=p(n.value);break;case"hex":c=p(`#${n.value}`);break}switch(n.length?.type){case"%":l=Number(n.length.value)/100;break}return{offset:l,color:c}})}function Nt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Ft(t.colorStops)}}function Ot(t){return t.orientation?.map(e=>{switch(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 Rt(t){return _t(t).map(e=>{switch(e?.type){case"linear-gradient":return Nt(e);case"repeating-linear-gradient":return{...Nt(e),repeat:!0};case"radial-gradient":return Ot(e);case"repeating-radial-gradient":return{...Ot(e),repeat:!0};default:return}}).filter(Boolean)}function Et(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:p(e.color)}}function kt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Rt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function Dt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Lt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:d(e.foregroundColor)?void 0:p(e.foregroundColor),backgroundColor:d(e.backgroundColor)?void 0:p(e.backgroundColor)}}function Gt(t){return!d(t.color)}function It(t){return typeof t=="string"?zt(t):Gt(t)}function Pt(t){return!d(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):Pt(t)}function At(t){return!d(t.image)&&!I(t.image)}function Tt(t){return typeof t=="string"?!I(t):At(t)}function Mt(t){return!d(t.preset)}function $t(t){return typeof t=="string"?!1:Mt(t)}function F(t){return It(t)?Et(t):Vt(t)?kt(t):Tt(t)?Dt(t):$t(t)?Lt(t):{}}function Ht(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["fillWithShape"])}}const q=Symbol("properties");function W(t){const e=Object.getPrototypeOf(t);let n;return e&&Object.hasOwn(e,q)?n=e[q]:(n=new Map(e?W(e):void 0),e&&(e[q]=n)),n}function Z(t,e={}){const n=Symbol.for(t),{fallback:r,alias:i}=e,l={declaration:e,internalKey:n},c=()=>typeof r=="function"?r():r;return{get(){let u;return i&&i!==t?u=Ct(this,i):typeof this.getter<"u"?u=this.getter(t,l):u=this[n],u??c()},set(u){i&&i!==t?wt(this,i,u):typeof this.setter<"u"?this.setter(t,u,l):this[n]=u}}}function be(t,e,n={}){W(typeof t=="function"?t:t.constructor).set(e,n);const r=Z(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){const l=r.get?.call(this);r.set.call(this,i),this.onUpdateProperty?.(e,i,l,n)},configurable:!0,enumerable:!0})}function Se(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=Z(r,t);return{init(l){return W(this.constructor).set(r,t),i.set.call(this,l),l},get(){return i.get.call(this)},set(l){const c=i.get?.call(this);i.set.call(this,l),this.onUpdateProperty?.(r,l,c,t)}}}}function J(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function Q(t){return{...J(),...O({...t,color:d(t.color)?G:p(t.color)})}}function Wt(){return{...J(),scaleX:1,scaleY:1}}function Bt(t){return{...Wt(),...Q(t)}}function Ce(t){return t}function jt(t){return O({...t,softEdge:d(t.softEdge)?void 0:t.softEdge,outerShadow:d(t.outerShadow)?void 0:Bt(t.outerShadow),innerShadow:d(t.innerShadow)?void 0:Q(t.innerShadow)})}function xt(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["fillWithShape"])}}function Kt(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["width","style","headEnd","tailEnd"])}}function Xt(t){return typeof t=="string"?{color:p(t)}:{...t,color:d(t.color)?G:p(t.color)}}function Yt(){return{boxShadow:"none"}}function Ut(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 qt(){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 Zt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function Jt(){return{...qt(),...Zt(),...Yt(),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 Qt(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function te(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ee(){return{...Qt(),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 ne(){return{...te(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function re(){return{...ne(),...ee(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function k(t){return O({...t,color:d(t.color)?void 0:p(t.color),backgroundColor:d(t.backgroundColor)?void 0:p(t.backgroundColor),borderColor:d(t.borderColor)?void 0:p(t.borderColor),outlineColor:d(t.outlineColor)?void 0:p(t.outlineColor),shadowColor:d(t.shadowColor)?void 0:p(t.shadowColor)})}function we(){return{...Jt(),...re()}}const tt=/\r\n|\n\r|\n|\r/,ze=new RegExp(`${tt.source}|<br\\/>`,"g"),_e=new RegExp(`^(${tt.source})$`),B=`
2
- `;function Fe(t){return tt.test(t)}function et(t){return _e.test(t)}function ie(t){return t.replace(ze,B)}function oe(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function P(t){const e=[];function n(){return e[e.length-1]}function r(u={}){let g=e[e.length-1];return g?.fragments.length===0?(g={...u,fragments:[]},e[e.length-1]=g):(g={...u,fragments:[]},e.push(g)),g}function i(u="",g={}){Array.from(u).forEach(y=>{if(et(y)){const{fragments:C,...z}=n()||r();C.length||C.push({...g,content:B}),r(z)}else{const C=n()||r(),z=C.fragments[C.fragments.length-1];if(z){const{content:D,...rt}=z;if(oe(g,rt)){z.content=`${D}${y}`;return}}C.fragments.push({...g,content:y})}})}(Array.isArray(t)?t:[t]).forEach(u=>{if(typeof u=="string")r(),i(u);else if("content"in u){const{content:g,...y}=u;r(k(y)),i(g)}else if("fragments"in u){const{fragments:g,...y}=u;r(k(y)),g.forEach(C=>{const{content:z,...D}=C;i(z,k(D))})}else Array.isArray(u)?(r(),u.forEach(g=>{if(typeof g=="string")i(g);else{const{content:y,...C}=g;i(y,k(C))}})):console.warn("Failed to parse text content",u)});const c=n();return c&&!c.fragments.length&&c.fragments.push({content:B}),e}function ae(t){return typeof t=="string"?{content:P(t)}:"content"in t?{...t,content:P(t.content)}:{content:P(t)}}function Ne(t){return P(t).map(e=>{const n=ie(e.fragments.flatMap(r=>r.content).join(""));return et(n)?"":n}).join(B)}function ue(t){return typeof t=="string"?{src:t}:t}function nt(t){return O({...t,style:d(t.style)?void 0:k(t.style),text:d(t.text)?void 0:ae(t.text),background:d(t.background)?void 0:Ht(t.background),shape:d(t.shape)?void 0:Ut(t.shape),fill:d(t.fill)?void 0:F(t.fill),outline:d(t.outline)?void 0:Kt(t.outline),foreground:d(t.foreground)?void 0:xt(t.foreground),shadow:d(t.shadow)?void 0:Xt(t.shadow),video:d(t.video)?void 0:ue(t.video),audio:d(t.audio)?void 0:E(t.audio),effect:d(t.effect)?void 0:jt(t.effect),children:t.children?.map(e=>nt(e))})}function Oe(t){return nt(t)}o.RawWeakMap=me,o.clearUndef=O,o.defaultColor=G,o.defineProperty=be,o.getDeclarations=W,o.getDefaultElementStyle=Jt,o.getDefaultHighlightStyle=Qt,o.getDefaultInnerShadow=J,o.getDefaultLayoutStyle=qt,o.getDefaultListStyleStyle=te,o.getDefaultOuterShadow=Wt,o.getDefaultShadowStyle=Yt,o.getDefaultStyle=we,o.getDefaultTextInlineStyle=ee,o.getDefaultTextLineStyle=ne,o.getDefaultTextStyle=re,o.getDefaultTransformStyle=Zt,o.getNestedValue=bt,o.getObjectValueByPath=Ct,o.getPropertyDescriptor=Z,o.hasCRLF=Fe,o.isCRLF=et,o.isColor=zt,o.isColorFill=It,o.isColorFillObject=Gt,o.isEqualStyle=oe,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=Pt,o.isImageFill=Tt,o.isImageFillObject=At,o.isNone=d,o.isPresetFill=$t,o.isPresetFillObject=Mt,o.normalizeAudio=E,o.normalizeBackground=Ht,o.normalizeCRLF=ie,o.normalizeColor=p,o.normalizeColorFill=Et,o.normalizeDocument=Oe,o.normalizeEffect=jt,o.normalizeElement=nt,o.normalizeFill=F,o.normalizeForeground=xt,o.normalizeGradient=Rt,o.normalizeGradientFill=kt,o.normalizeImageFill=Dt,o.normalizeInnerShadow=Q,o.normalizeOuterShadow=Bt,o.normalizeOutline=Kt,o.normalizePresetFill=Lt,o.normalizeShadow=Xt,o.normalizeShape=Ut,o.normalizeSoftEdge=Ce,o.normalizeStyle=k,o.normalizeText=ae,o.normalizeTextContent=P,o.normalizeVideo=ue,o.parseColor=U,o.parseGradient=_t,o.pick=T,o.property=Se,o.round=N,o.setNestedValue=St,o.setObjectValueByPath=wt,o.stringifyGradient=ye,o.textContentToString=Ne,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,E){typeof exports=="object"&&typeof module<"u"?E(exports):typeof define=="function"&&define.amd?define(["exports"],E):(o=typeof globalThis<"u"?globalThis:o||self,E(o.modernIdoc={}))})(this,function(o){"use strict";function E(t){return typeof t=="string"?{src:t}:t}var de={grad:.9,turn:360,rad:360/(2*Math.PI)},z=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},v=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},S=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},lt=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},st=function(t){return{r:S(t.r,0,255),g:S(t.g,0,255),b:S(t.b,0,255),a:S(t.a)}},K=function(t){return{r:v(t.r),g:v(t.g),b:v(t.b),a:v(t.a,3)}},ge=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},ct=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=Math.max(e,n,r),c=l-Math.min(e,n,r),u=c?l===e?(n-r)/c:l===n?2+(r-e)/c:4+(e-n)/c:0;return{h:60*(u<0?u+6:u),s:l?c/l*100:0,v:l/255*100,a:i}},ft=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var l=Math.floor(e),c=r*(1-n),u=r*(1-(e-l)*n),d=r*(1-(1-e+l)*n),p=l%6;return{r:255*[r,u,c,c,d,r][p],g:255*[d,r,r,u,c,c][p],b:255*[c,c,d,r,r,u][p],a:i}},dt=function(t){return{h:lt(t.h),s:S(t.s,0,100),l:S(t.l,0,100),a:S(t.a)}},gt=function(t){return{h:v(t.h),s:v(t.s),l:v(t.l),a:v(t.a,3)}},ht=function(t){return ft((n=(e=t).s,{h:e.h,s:(n*=((r=e.l)<50?r:100-r)/100)>0?2*n/(r+n)*100:0,v:r+n,a:e.a}));var e,n,r},L=function(t){return{h:(e=ct(t)).h,s:(i=(200-(n=e.s))*(r=e.v)/100)>0&&i<200?n*r/100/(i<=100?i:200-i)*100:0,l:i/2,a:e.a};var e,n,r,i},he=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,pe=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*,\s*([+-]?\d*\.?\d+)(%)?\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,me=/^rgba?\(\s*([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s+([+-]?\d*\.?\d+)(%)?\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,vt={string:[[function(t){var e=ge.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?v(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?v(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=pe.exec(t)||me.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:st({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=he.exec(t)||ve.exec(t);if(!e)return null;var n,r,i=dt({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(de[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return ht(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,l=i===void 0?1:i;return z(e)&&z(n)&&z(r)?st({r:Number(e),g:Number(n),b:Number(r),a:Number(l)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,l=i===void 0?1:i;if(!z(e)||!z(n)||!z(r))return null;var c=dt({h:Number(e),s:Number(n),l:Number(r),a:Number(l)});return ht(c)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,l=i===void 0?1:i;if(!z(e)||!z(n)||!z(r))return null;var c=function(u){return{h:lt(u.h),s:S(u.s,0,100),v:S(u.v,0,100),a:S(u.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(l)});return ft(c)},"hsv"]]},pt=function(t,e){for(var n=0;n<e.length;n++){var r=e[n][0](t);if(r)return[r,e[n][1]]}return[null,void 0]},ye=function(t){return typeof t=="string"?pt(t.trim(),vt.string):typeof t=="object"&&t!==null?pt(t,vt.object):[null,void 0]},U=function(t,e){var n=L(t);return{h:n.h,s:S(n.s+100*e,0,100),l:n.l,a:n.a}},X=function(t){return(299*t.r+587*t.g+114*t.b)/1e3/255},mt=function(t,e){var n=L(t);return{h:n.h,s:n.s,l:S(n.l+100*e,0,100),a:n.a}},yt=function(){function t(e){this.parsed=ye(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 v(X(this.rgba),2)},t.prototype.isDark=function(){return X(this.rgba)<.5},t.prototype.isLight=function(){return X(this.rgba)>=.5},t.prototype.toHex=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,c=(l=e.a)<1?A(v(255*l)):"","#"+A(n)+A(r)+A(i)+c;var e,n,r,i,l,c},t.prototype.toRgb=function(){return K(this.rgba)},t.prototype.toRgbString=function(){return e=K(this.rgba),n=e.r,r=e.g,i=e.b,(l=e.a)<1?"rgba("+n+", "+r+", "+i+", "+l+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,l},t.prototype.toHsl=function(){return gt(L(this.rgba))},t.prototype.toHslString=function(){return e=gt(L(this.rgba)),n=e.h,r=e.s,i=e.l,(l=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+l+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,l},t.prototype.toHsv=function(){return e=ct(this.rgba),{h:v(e.h),s:v(e.s),v:v(e.v),a:v(e.a,3)};var e},t.prototype.invert=function(){return w({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),w(U(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(U(this.rgba,-e))},t.prototype.grayscale=function(){return w(U(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(mt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(mt(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"?w({r:(n=this.rgba).r,g:n.g,b:n.b,a:e}):v(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=L(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):v(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t}(),w=function(t){return t instanceof yt?t:new yt(t)};function g(t){return t==null||t==="none"}function N(t,e=0,n=10**e){return Math.round(n*t)/n+0}function O(t,e=!1){if(typeof t!="object"||!t)return t;if(Array.isArray(t))return e?t.map(r=>O(r,e)):t;const n={};for(const r in t){const i=t[r];i!=null&&(e?n[r]=O(i,e):n[r]=i)}return n}function T(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function bt(t,e,n){const r=e.length-1;if(r<0)return t===void 0?n:t;for(let i=0;i<r;i++){if(t==null)return n;t=t[e[i]]}return t==null||t[e[r]]===void 0?n:t[e[r]]}function St(t,e,n){const r=e.length-1;for(let i=0;i<r;i++)typeof t[e[i]]!="object"&&(t[e[i]]={}),t=t[e[i]];t[e[r]]=n}function Ct(t,e,n){return t==null||!e||typeof e!="string"?n:t[e]!==void 0?t[e]:(e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n))}function wt(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),St(t,e.split("."),n)}class be{_map=new WeakMap;_toRaw(e){if(e&&typeof e=="object"){const n=e.__v_raw;n&&(e=this._toRaw(n))}return e}delete(e){return this._map.delete(this._toRaw(e))}get(e){return this._map.get(this._toRaw(e))}has(e){return this._map.has(this._toRaw(e))}set(e,n){return this._map.set(this._toRaw(e),this._toRaw(n)),this}}function Y(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,w(e)}function Se(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function M(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const G="#000000FF";function _t(t){return Y(t).isValid()}function y(t,e=!1){const n=Y(t);if(!n.isValid()){if(typeof t=="string")return t;const u=`Failed to normalizeColor ${t}`;if(e)throw new Error(u);return console.warn(u),G}const{r,g:i,b:l,a:c}=Se(n.rgba);return`#${M(r)}${M(i)}${M(l)}${M(N(c*255))}`}var $=$||{};$.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 n(a){const s=new Error(`${e}: ${a}`);throw s.source=e,s}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return B(l)}function l(){return c("linear-gradient",t.linearGradient,d)||c("repeating-linear-gradient",t.repeatingLinearGradient,d)||c("radial-gradient",t.radialGradient,_)||c("repeating-radial-gradient",t.repeatingRadialGradient,_)}function c(a,s,f){return u(s,m=>{const R=f();return R&&(h(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:B(Pe)}})}function u(a,s){const f=h(a);if(f){h(t.startCall)||n("Missing (");const m=s(f);return h(t.endCall)||n("Missing )"),m}}function d(){const a=p();if(a)return a;const s=b("position-keyword",t.positionKeywords,1);return s?{type:"directional",value:s.value}:C()}function p(){return b("directional",t.sideOrCorner,1)}function C(){return b("angular",t.angleValue,1)||b("angular",t.radianValue,1)}function _(){let a,s=k(),f;return s&&(a=[],a.push(s),f=e,h(t.comma)&&(s=k(),s?a.push(s):e=f)),a}function k(){let a=rt()||Ge();if(a)a.at=ot();else{const s=it();if(s){a=s;const f=ot();f&&(a.at=f)}else{const f=ot();if(f)a={type:"default-radial",at:f};else{const m=at();m&&(a={type:"default-radial",at:m})}}}return a}function rt(){const a=b("shape",/^(circle)/i,0);return a&&(a.style=fe()||it()),a}function Ge(){const a=b("shape",/^(ellipse)/i,0);return a&&(a.style=at()||x()||it()),a}function it(){return b("extent-keyword",t.extentKeywords,1)}function ot(){if(b("position",/^at/,0)){const a=at();return a||n("Missing positioning value"),a}}function at(){const a=Ie();if(a.x||a.y)return{type:"position",value:a}}function Ie(){return{x:x(),y:x()}}function B(a){let s=a();const f=[];if(s)for(f.push(s);h(t.comma);)s=a(),s?f.push(s):n("One extra comma");return f}function Pe(){const a=Ve();return a||n("Expected color definition"),a.length=x(),a}function Ve(){return Te()||je()||We()||$e()||Me()||He()||Ae()}function Ae(){return b("literal",t.literalColor,0)}function Te(){return b("hex",t.hexColor,1)}function Me(){return u(t.rgbColor,()=>({type:"rgb",value:B(V)}))}function $e(){return u(t.rgbaColor,()=>({type:"rgba",value:B(V)}))}function He(){return u(t.varColor,()=>({type:"var",value:Be()}))}function We(){return u(t.hslColor,()=>{h(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const s=V();h(t.comma);let f=h(t.percentageValue);const m=f?f[1]:null;h(t.comma),f=h(t.percentageValue);const R=f?f[1]:null;return(!m||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[s,m,R]}})}function je(){return u(t.hslaColor,()=>{const a=V();h(t.comma);let s=h(t.percentageValue);const f=s?s[1]:null;h(t.comma),s=h(t.percentageValue);const m=s?s[1]:null;h(t.comma);const R=V();return(!f||!m)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,m,R]}})}function Be(){return h(t.variableName)[1]}function V(){return h(t.number)[1]}function x(){return b("%",t.percentageValue,1)||xe()||Ke()||fe()}function xe(){return b("position-keyword",t.positionKeywords,1)}function Ke(){return u(t.calcValue,()=>{let a=1,s=0;for(;a>0&&s<e.length;){const m=e.charAt(s);m==="("?a++:m===")"&&a--,s++}a>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,s-1);return ut(s-1),{type:"calc",value:f}})}function fe(){return b("px",t.pixelValue,1)||b("em",t.emValue,1)}function b(a,s,f){const m=h(s);if(m)return{type:a,value:m[f]}}function h(a){let s,f;return f=/^\s+/.exec(e),f&&ut(f[0].length),s=a.exec(e),s&&ut(s[0].length),s}function ut(a){e=e.substr(a)}return function(a){return e=a.toString().trim(),e.endsWith(";")&&(e=e.slice(0,-1)),r()}}();const zt=$.parse.bind($);var H=H||{};H.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 n=t.visit(e.orientation);return n&&(n+=", "),e.type+"("+n+t.visit(e.colorStops)+")"},visit_shape:function(e){var n=e.value,r=t.visit(e.at),i=t.visit(e.style);return i&&(n+=" "+i),r&&(n+=" at "+r),n},"visit_default-radial":function(e){var n="",r=t.visit(e.at);return r&&(n+=r),n},"visit_extent-keyword":function(e){var n=e.value,r=t.visit(e.at);return r&&(n+=" at "+r),n},"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,n){var r=e,i=t.visit(n.length);return i&&(r+=" "+i),r},visit_angular:function(e){return e.value+"deg"},visit_directional:function(e){return"to "+e.value},visit_array:function(e){var n="",r=e.length;return e.forEach(function(i,l){n+=t.visit(i),l<r-1&&(n+=", ")}),n},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 n=t["visit_"+e.type];if(n)return n(e);throw Error("Missing visitor visit_"+e.type)}else throw Error("Invalid node.")}};return function(e){return t.visit(e)}}();const Ce=H.stringify.bind(H);function Ft(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let l=N(r/e,3),c="#00000000";switch(n.type){case"rgb":c=y({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":c=y({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":c=y(n.value);break;case"hex":c=y(`#${n.value}`);break}switch(n.length?.type){case"%":l=Number(n.length.value)/100;break}return{offset:l,color:c}})}function Nt(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:Ft(t.colorStops)}}function Ot(t){return t.orientation?.map(e=>{switch(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 Rt(t){return zt(t).map(e=>{switch(e?.type){case"linear-gradient":return Nt(e);case"repeating-linear-gradient":return{...Nt(e),repeat:!0};case"radial-gradient":return Ot(e);case"repeating-radial-gradient":return{...Ot(e),repeat:!0};default:return}}).filter(Boolean)}function Et(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:y(e.color)}}function Dt(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Rt(e.image)[0]??{};switch(n){case"radial-gradient":return{radialGradient:r};case"linear-gradient":return{linearGradient:r}}}return e}function kt(t){let e;return typeof t=="string"?e={image:t}:e=t,e}function Lt(t){let e;return typeof t=="string"?e={preset:t}:e=t,{preset:e.preset,foregroundColor:g(e.foregroundColor)?void 0:y(e.foregroundColor),backgroundColor:g(e.backgroundColor)?void 0:y(e.backgroundColor)}}function Gt(t){return!g(t.color)}function It(t){return typeof t=="string"?_t(t):Gt(t)}function Pt(t){return!g(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):Pt(t)}function At(t){return!g(t.image)&&!I(t.image)}function Tt(t){return typeof t=="string"?!I(t):At(t)}function Mt(t){return!g(t.preset)}function $t(t){return typeof t=="string"?!1:Mt(t)}function F(t){return It(t)?Et(t):Vt(t)?Dt(t):Tt(t)?kt(t):$t(t)?Lt(t):{}}function Ht(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["fillWithShape"])}}const q=Symbol("properties");function W(t){const e=Object.getPrototypeOf(t);let n;return e&&Object.hasOwn(e,q)?n=e[q]:(n=new Map(e?W(e):void 0),e&&(e[q]=n)),n}function Z(t,e={}){const n=Symbol.for(t),{fallback:r,alias:i}=e,l={declaration:e,internalKey:n},c=()=>typeof r=="function"?r():r;return{get(){let u;return i&&i!==t?u=Ct(this,i):typeof this.getter<"u"?u=this.getter(t,l):u=this[n],u??c()},set(u){i&&i!==t?wt(this,i,u):typeof this.setter<"u"?this.setter(t,u,l):this[n]=u}}}function Wt(t,e,n={}){W(typeof t=="function"?t:t.constructor).set(e,n);const r=t.prototype,i=Object.getOwnPropertyDescriptor(r,e),l=Z(e,n);let c=!0;function u(){let d=l.get.call(this);return c&&(c=!1,d===void 0&&i&&(d=i.get?.call(this)??i.value,l.set.call(this,d))),d}Object.defineProperty(r,e,{get(){return u.call(this)},set(d){const p=u.call(this);l.set.call(this,d),this.onUpdateProperty?.(e,d,p,n)},configurable:!0,enumerable:!0})}function we(t){return function(e,n){if(typeof n!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");Wt(e.constructor,n,t)}}function _e(t={}){return function(e,n){const r=n.name;if(typeof r!="string")throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");const i=Z(r,t);return{init(l){return W(this.constructor).set(r,t),i.set.call(this,l),l},get(){return i.get.call(this)},set(l){const c=i.get?.call(this);i.set.call(this,l),this.onUpdateProperty?.(r,l,c,t)}}}}function J(){return{color:G,offsetX:0,offsetY:0,blurRadius:1}}function Q(t){return{...J(),...O({...t,color:g(t.color)?G:y(t.color)})}}function jt(){return{...J(),scaleX:1,scaleY:1}}function Bt(t){return{...jt(),...Q(t)}}function ze(t){return t}function xt(t){return O({...t,softEdge:g(t.softEdge)?void 0:t.softEdge,outerShadow:g(t.outerShadow)?void 0:Bt(t.outerShadow),innerShadow:g(t.innerShadow)?void 0:Q(t.innerShadow)})}function Kt(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["fillWithShape"])}}const Fe="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let Ne=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=Fe[n[t]&63];return e};const Ut=()=>Ne(10),Xt=Ut;function Yt(t){return typeof t=="string"?{...F(t)}:{...F(t),...T(t,["width","style","headEnd","tailEnd"])}}function qt(t){return typeof t=="string"?{color:y(t)}:{...t,color:g(t.color)?G:y(t.color)}}function Zt(){return{boxShadow:"none"}}function Jt(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 Qt(){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 te(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function ee(){return{...Qt(),...te(),...Zt(),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 ne(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function re(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function ie(){return{...ne(),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 oe(){return{...re(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function ae(){return{...oe(),...ie(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return O({...t,color:g(t.color)?void 0:y(t.color),backgroundColor:g(t.backgroundColor)?void 0:y(t.backgroundColor),borderColor:g(t.borderColor)?void 0:y(t.borderColor),outlineColor:g(t.outlineColor)?void 0:y(t.outlineColor),shadowColor:g(t.shadowColor)?void 0:y(t.shadowColor)})}function Oe(){return{...ee(),...ae()}}const tt=/\r\n|\n\r|\n|\r/,Re=new RegExp(`${tt.source}|<br\\/>`,"g"),Ee=new RegExp(`^(${tt.source})$`),j=`
2
+ `;function De(t){return tt.test(t)}function et(t){return Ee.test(t)}function ue(t){return t.replace(Re,j)}function le(t,e){const n=Array.from(new Set([...Object.keys(t),...Object.keys(e)]));return!n.length||n.every(r=>t[r]===e[r])}function P(t){const e=[];function n(){return e[e.length-1]}function r(u={}){let d=e[e.length-1];return d?.fragments.length===0?(d={...u,fragments:[]},e[e.length-1]=d):(d={...u,fragments:[]},e.push(d)),d}function i(u="",d={}){Array.from(u).forEach(p=>{if(et(p)){const{fragments:C,..._}=n()||r();C.length||C.push({...d,content:j}),r(_)}else{const C=n()||r(),_=C.fragments[C.fragments.length-1];if(_){const{content:k,...rt}=_;if(le(d,rt)){_.content=`${k}${p}`;return}}C.fragments.push({...d,content:p})}})}(Array.isArray(t)?t:[t]).forEach(u=>{if(typeof u=="string")r(),i(u);else if("content"in u){const{content:d,...p}=u;r(D(p)),i(d)}else if("fragments"in u){const{fragments:d,...p}=u;r(D(p)),d.forEach(C=>{const{content:_,...k}=C;i(_,D(k))})}else Array.isArray(u)?(r(),u.forEach(d=>{if(typeof d=="string")i(d);else{const{content:p,...C}=d;i(p,D(C))}})):console.warn("Failed to parse text content",u)});const c=n();return c&&!c.fragments.length&&c.fragments.push({content:j}),e}function se(t){return typeof t=="string"?{content:P(t)}:"content"in t?{...t,content:P(t.content)}:{content:P(t)}}function ke(t){return P(t).map(e=>{const n=ue(e.fragments.flatMap(r=>r.content).join(""));return et(n)?"":n}).join(j)}function ce(t){return typeof t=="string"?{src:t}:t}function nt(t){return O({...t,id:t.id??Xt(),style:g(t.style)?void 0:D(t.style),text:g(t.text)?void 0:se(t.text),background:g(t.background)?void 0:Ht(t.background),shape:g(t.shape)?void 0:Jt(t.shape),fill:g(t.fill)?void 0:F(t.fill),outline:g(t.outline)?void 0:Yt(t.outline),foreground:g(t.foreground)?void 0:Kt(t.foreground),shadow:g(t.shadow)?void 0:qt(t.shadow),video:g(t.video)?void 0:ce(t.video),audio:g(t.audio)?void 0:E(t.audio),effect:g(t.effect)?void 0:xt(t.effect),children:t.children?.map(e=>nt(e))})}function Le(t){return nt(t)}o.RawWeakMap=be,o.clearUndef=O,o.defaultColor=G,o.defineProperty=Wt,o.getDeclarations=W,o.getDefaultElementStyle=ee,o.getDefaultHighlightStyle=ne,o.getDefaultInnerShadow=J,o.getDefaultLayoutStyle=Qt,o.getDefaultListStyleStyle=re,o.getDefaultOuterShadow=jt,o.getDefaultShadowStyle=Zt,o.getDefaultStyle=Oe,o.getDefaultTextInlineStyle=ie,o.getDefaultTextLineStyle=oe,o.getDefaultTextStyle=ae,o.getDefaultTransformStyle=te,o.getNestedValue=bt,o.getObjectValueByPath=Ct,o.getPropertyDescriptor=Z,o.hasCRLF=De,o.idGenerator=Xt,o.isCRLF=et,o.isColor=_t,o.isColorFill=It,o.isColorFillObject=Gt,o.isEqualStyle=le,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=Pt,o.isImageFill=Tt,o.isImageFillObject=At,o.isNone=g,o.isPresetFill=$t,o.isPresetFillObject=Mt,o.nanoid=Ut,o.normalizeAudio=E,o.normalizeBackground=Ht,o.normalizeCRLF=ue,o.normalizeColor=y,o.normalizeColorFill=Et,o.normalizeDocument=Le,o.normalizeEffect=xt,o.normalizeElement=nt,o.normalizeFill=F,o.normalizeForeground=Kt,o.normalizeGradient=Rt,o.normalizeGradientFill=Dt,o.normalizeImageFill=kt,o.normalizeInnerShadow=Q,o.normalizeOuterShadow=Bt,o.normalizeOutline=Yt,o.normalizePresetFill=Lt,o.normalizeShadow=qt,o.normalizeShape=Jt,o.normalizeSoftEdge=ze,o.normalizeStyle=D,o.normalizeText=se,o.normalizeTextContent=P,o.normalizeVideo=ce,o.parseColor=Y,o.parseGradient=zt,o.pick=T,o.property=we,o.property2=_e,o.round=N,o.setNestedValue=St,o.setObjectValueByPath=wt,o.stringifyGradient=Ce,o.textContentToString=ke,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
package/dist/index.mjs CHANGED
@@ -1,4 +1,5 @@
1
1
  import { colord } from 'colord';
2
+ import { nanoid as nanoid$1 } from 'nanoid';
2
3
 
3
4
  function normalizeAudio(audio) {
4
5
  if (typeof audio === "string") {
@@ -943,13 +944,27 @@ function defineProperty(target, key, declaration = {}) {
943
944
  getDeclarations(
944
945
  typeof target === "function" ? target : target.constructor
945
946
  ).set(key, declaration);
947
+ const prototype = target.prototype;
948
+ const rawDescriptor = Object.getOwnPropertyDescriptor(prototype, key);
946
949
  const descriptor = getPropertyDescriptor(key, declaration);
947
- Object.defineProperty(target.prototype, key, {
950
+ let isFirst = true;
951
+ function get() {
952
+ let result = descriptor.get.call(this);
953
+ if (isFirst) {
954
+ isFirst = false;
955
+ if (result === void 0 && rawDescriptor) {
956
+ result = rawDescriptor.get?.call(this) ?? rawDescriptor.value;
957
+ descriptor.set.call(this, result);
958
+ }
959
+ }
960
+ return result;
961
+ }
962
+ Object.defineProperty(prototype, key, {
948
963
  get() {
949
- return descriptor.get.call(this);
964
+ return get.call(this);
950
965
  },
951
966
  set(newValue) {
952
- const oldValue = descriptor.get?.call(this);
967
+ const oldValue = get.call(this);
953
968
  descriptor.set.call(this, newValue);
954
969
  this.onUpdateProperty?.(key, newValue, oldValue, declaration);
955
970
  },
@@ -957,7 +972,15 @@ function defineProperty(target, key, declaration = {}) {
957
972
  enumerable: true
958
973
  });
959
974
  }
960
- function property(declaration = {}) {
975
+ function property(declaration) {
976
+ return function(target, key) {
977
+ if (typeof key !== "string") {
978
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
979
+ }
980
+ defineProperty(target.constructor, key, declaration);
981
+ };
982
+ }
983
+ function property2(declaration = {}) {
961
984
  return function(_, context) {
962
985
  const key = context.name;
963
986
  if (typeof key !== "string") {
@@ -1040,6 +1063,11 @@ function normalizeForeground(foreground) {
1040
1063
  }
1041
1064
  }
1042
1065
 
1066
+ const nanoid = () => {
1067
+ return nanoid$1(10);
1068
+ };
1069
+ const idGenerator = nanoid;
1070
+
1043
1071
  function normalizeOutline(outline) {
1044
1072
  if (typeof outline === "string") {
1045
1073
  return {
@@ -1414,6 +1442,7 @@ function normalizeVideo(video) {
1414
1442
  function normalizeElement(element) {
1415
1443
  return clearUndef({
1416
1444
  ...element,
1445
+ id: element.id ?? idGenerator(),
1417
1446
  style: isNone(element.style) ? void 0 : normalizeStyle(element.style),
1418
1447
  text: isNone(element.text) ? void 0 : normalizeText(element.text),
1419
1448
  background: isNone(element.background) ? void 0 : normalizeBackground(element.background),
@@ -1433,4 +1462,4 @@ function normalizeDocument(doc) {
1433
1462
  return normalizeElement(doc);
1434
1463
  }
1435
1464
 
1436
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, 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, property, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
1465
+ export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, getPropertyDescriptor, hasCRLF, idGenerator, isCRLF, isColor, isColorFill, isColorFillObject, isEqualStyle, isGradient, isGradientFill, isGradientFillObject, isImageFill, isImageFillObject, isNone, isPresetFill, isPresetFillObject, nanoid, 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, property, property2, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.7.2",
4
+ "version": "0.7.4",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",
@@ -54,7 +54,8 @@
54
54
  "prepare": "simple-git-hooks"
55
55
  },
56
56
  "dependencies": {
57
- "colord": "^2.9.3"
57
+ "colord": "^2.9.3",
58
+ "nanoid": "^5.1.5"
58
59
  },
59
60
  "devDependencies": {
60
61
  "@antfu/eslint-config": "^4.16.1",