modern-idoc 0.6.20 → 0.7.0

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
@@ -890,88 +890,95 @@ function normalizeBackground(background) {
890
890
  }
891
891
  }
892
892
 
893
- const declarationMap = new RawWeakMap();
894
- function getDeclarations(constructor) {
895
- let declarations = declarationMap.get(constructor);
896
- if (!declarations) {
897
- const superConstructor = Object.getPrototypeOf(constructor);
898
- declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
899
- declarationMap.set(constructor, declarations);
893
+ const propertiesSymbol = Symbol("properties");
894
+ function getDeclarations(target) {
895
+ const proto = Object.getPrototypeOf(target);
896
+ let declarations;
897
+ if (proto && Object.hasOwn(proto, propertiesSymbol)) {
898
+ declarations = proto[propertiesSymbol];
899
+ } else {
900
+ declarations = new Map(proto ? getDeclarations(proto) : void 0);
901
+ if (proto) {
902
+ proto[propertiesSymbol] = declarations;
903
+ }
900
904
  }
901
905
  return declarations;
902
906
  }
903
- function defineProperty(constructor, key, declaration = {}) {
904
- getDeclarations(constructor).set(key, declaration);
907
+ function getPropertyDescriptor(key, declaration = {}) {
908
+ const internalKey = Symbol.for(key);
905
909
  const {
906
- default: _default,
907
- alias,
908
- protected: _protected
910
+ fallback,
911
+ alias
909
912
  } = declaration;
910
- const internalKey = Symbol.for(String(key));
911
- const getDefaultValue = () => typeof _default === "function" ? _default() : _default;
912
- const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
913
+ const ctx = { declaration, internalKey };
914
+ const getFallbackValue = () => {
915
+ return typeof fallback === "function" ? fallback() : fallback;
916
+ };
917
+ const descriptor = {
913
918
  get() {
919
+ let result;
914
920
  if (alias && alias !== key) {
915
- if (typeof alias === "string") {
916
- return getObjectValueByPath(this, alias);
917
- } else {
918
- return this[alias];
919
- }
921
+ result = getObjectValueByPath(this, alias);
920
922
  } else {
921
- if (!_protected && typeof key === "string" && this.offsetGet) {
922
- return this.offsetGet(key);
923
+ if (typeof this.getter !== "undefined") {
924
+ result = this.getter(key, ctx);
923
925
  } else {
924
- return this[internalKey];
926
+ result = this[internalKey];
925
927
  }
926
928
  }
929
+ return result ?? getFallbackValue();
927
930
  },
928
- set(value) {
931
+ set(newValue) {
932
+ const oldValue = descriptor.get?.call(this);
929
933
  if (alias && alias !== key) {
930
- if (typeof alias === "string") {
931
- setObjectValueByPath(this, alias, value);
932
- } else {
933
- this[alias] = value;
934
- }
934
+ setObjectValueByPath(this, alias, newValue);
935
935
  } else {
936
- if (!_protected && typeof key === "string" && this.offsetSet) {
937
- this.offsetSet(key, value);
936
+ if (typeof this.setter !== "undefined") {
937
+ this.setter(key, newValue, ctx);
938
938
  } else {
939
- this[internalKey] = value;
939
+ this[internalKey] = newValue;
940
940
  }
941
941
  }
942
+ this.onUpdateProperty?.(key, newValue, oldValue, declaration);
942
943
  }
943
944
  };
944
- Object.defineProperty(constructor.prototype, key, {
945
+ return descriptor;
946
+ }
947
+ function defineProperty(target, key, declaration = {}) {
948
+ const descriptor = getPropertyDescriptor(key, declaration);
949
+ Object.defineProperty(target.prototype, key, {
945
950
  get() {
946
- let value = descriptor.get?.call(this);
947
- if (value === void 0) {
948
- value = getDefaultValue();
949
- if (value !== void 0) {
950
- descriptor.set?.call(this, value);
951
- }
952
- }
953
- return value;
951
+ return descriptor.get.call(this);
954
952
  },
955
953
  set(newValue) {
956
- let oldValue = descriptor.get?.call(this);
957
- if (oldValue === void 0) {
958
- oldValue = getDefaultValue();
959
- }
960
- descriptor.set?.call(this, newValue);
961
- this.requestUpdate?.(key, newValue, oldValue, declaration);
954
+ descriptor.set.call(this, newValue);
962
955
  },
963
956
  configurable: true,
964
957
  enumerable: true
965
958
  });
966
959
  }
967
- function property(options) {
968
- return function(proto, name) {
969
- defineProperty(proto.constructor, name, options);
960
+ function property(declaration = {}) {
961
+ return function(_, context) {
962
+ const key = context.name;
963
+ if (typeof key !== "string") {
964
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
965
+ }
966
+ const descriptor = getPropertyDescriptor(key, declaration);
967
+ return {
968
+ init(v) {
969
+ getDeclarations(this).set(key, declaration);
970
+ descriptor.set.call(this, v);
971
+ return v;
972
+ },
973
+ get() {
974
+ return descriptor.get.call(this);
975
+ },
976
+ set(newValue) {
977
+ descriptor.set.call(this, newValue);
978
+ }
979
+ };
970
980
  };
971
981
  }
972
- function protectedProperty(options) {
973
- return property({ ...options, protected: true });
974
- }
975
982
 
976
983
  function getDefaultInnerShadow() {
977
984
  return {
@@ -1443,6 +1450,7 @@ exports.getDefaultTextStyle = getDefaultTextStyle;
1443
1450
  exports.getDefaultTransformStyle = getDefaultTransformStyle;
1444
1451
  exports.getNestedValue = getNestedValue;
1445
1452
  exports.getObjectValueByPath = getObjectValueByPath;
1453
+ exports.getPropertyDescriptor = getPropertyDescriptor;
1446
1454
  exports.hasCRLF = hasCRLF;
1447
1455
  exports.isCRLF = isCRLF;
1448
1456
  exports.isColor = isColor;
@@ -1485,7 +1493,6 @@ exports.parseColor = parseColor;
1485
1493
  exports.parseGradient = parseGradient;
1486
1494
  exports.pick = pick;
1487
1495
  exports.property = property;
1488
- exports.protectedProperty = protectedProperty;
1489
1496
  exports.round = round;
1490
1497
  exports.setNestedValue = setNestedValue;
1491
1498
  exports.setObjectValueByPath = setObjectValueByPath;
package/dist/index.d.cts CHANGED
@@ -315,21 +315,27 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
315
315
  type Background = string | BackgroundObject;
316
316
  declare function normalizeBackground(background: Background): NormalizedBackground;
317
317
 
318
- interface Definable {
319
- offsetGet?: (key: string) => any;
320
- offsetSet?: (key: string, value: any) => void;
321
- requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
322
- }
323
318
  interface PropertyDeclaration {
324
- readonly [key: string]: any;
325
- readonly default?: any | (() => any);
326
- readonly alias?: string | symbol;
327
- readonly protected?: boolean;
328
- }
329
- declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
330
- declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
331
- declare function property(options?: PropertyDeclaration): PropertyDecorator;
332
- declare function protectedProperty(options?: Omit<PropertyDeclaration, 'protected'>): PropertyDecorator;
319
+ [key: string]: unknown;
320
+ fallback?: unknown | (() => unknown);
321
+ alias?: string;
322
+ }
323
+ interface ReactiveObject {
324
+ getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
326
+ onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
+ }
328
+ interface ReactiveObjectGetterSetterContext {
329
+ declaration: PropertyDeclaration;
330
+ internalKey: symbol;
331
+ }
332
+ declare function getDeclarations(target: unknown): Map<string, PropertyDeclaration>;
333
+ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
334
+ get: () => any;
335
+ set: (v: any) => void;
336
+ };
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>;
333
339
 
334
340
  interface NormalizedInnerShadow {
335
341
  color: NormalizedColor;
@@ -779,5 +785,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
779
785
  set(key: K, value: V): this;
780
786
  }
781
787
 
782
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, 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, protectedProperty, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
783
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, 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, 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 };
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 };
package/dist/index.d.mts CHANGED
@@ -315,21 +315,27 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
315
315
  type Background = string | BackgroundObject;
316
316
  declare function normalizeBackground(background: Background): NormalizedBackground;
317
317
 
318
- interface Definable {
319
- offsetGet?: (key: string) => any;
320
- offsetSet?: (key: string, value: any) => void;
321
- requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
322
- }
323
318
  interface PropertyDeclaration {
324
- readonly [key: string]: any;
325
- readonly default?: any | (() => any);
326
- readonly alias?: string | symbol;
327
- readonly protected?: boolean;
328
- }
329
- declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
330
- declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
331
- declare function property(options?: PropertyDeclaration): PropertyDecorator;
332
- declare function protectedProperty(options?: Omit<PropertyDeclaration, 'protected'>): PropertyDecorator;
319
+ [key: string]: unknown;
320
+ fallback?: unknown | (() => unknown);
321
+ alias?: string;
322
+ }
323
+ interface ReactiveObject {
324
+ getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
326
+ onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
+ }
328
+ interface ReactiveObjectGetterSetterContext {
329
+ declaration: PropertyDeclaration;
330
+ internalKey: symbol;
331
+ }
332
+ declare function getDeclarations(target: unknown): Map<string, PropertyDeclaration>;
333
+ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
334
+ get: () => any;
335
+ set: (v: any) => void;
336
+ };
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>;
333
339
 
334
340
  interface NormalizedInnerShadow {
335
341
  color: NormalizedColor;
@@ -779,5 +785,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
779
785
  set(key: K, value: V): this;
780
786
  }
781
787
 
782
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, 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, protectedProperty, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
783
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, 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, 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 };
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 };
package/dist/index.d.ts CHANGED
@@ -315,21 +315,27 @@ type BackgroundObject = FillObject & Partial<NormalizedBaseBackground>;
315
315
  type Background = string | BackgroundObject;
316
316
  declare function normalizeBackground(background: Background): NormalizedBackground;
317
317
 
318
- interface Definable {
319
- offsetGet?: (key: string) => any;
320
- offsetSet?: (key: string, value: any) => void;
321
- requestUpdate?: (key: PropertyKey, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
322
- }
323
318
  interface PropertyDeclaration {
324
- readonly [key: string]: any;
325
- readonly default?: any | (() => any);
326
- readonly alias?: string | symbol;
327
- readonly protected?: boolean;
328
- }
329
- declare function getDeclarations(constructor: any): Map<PropertyKey, PropertyDeclaration>;
330
- declare function defineProperty(constructor: any, key: PropertyKey, declaration?: PropertyDeclaration): void;
331
- declare function property(options?: PropertyDeclaration): PropertyDecorator;
332
- declare function protectedProperty(options?: Omit<PropertyDeclaration, 'protected'>): PropertyDecorator;
319
+ [key: string]: unknown;
320
+ fallback?: unknown | (() => unknown);
321
+ alias?: string;
322
+ }
323
+ interface ReactiveObject {
324
+ getter?: (key: string, context: ReactiveObjectGetterSetterContext) => any;
325
+ setter?: (key: string, value: any, context: ReactiveObjectGetterSetterContext) => void;
326
+ onUpdateProperty?: (key: string, newValue: unknown, oldValue: unknown, declaration: PropertyDeclaration) => void;
327
+ }
328
+ interface ReactiveObjectGetterSetterContext {
329
+ declaration: PropertyDeclaration;
330
+ internalKey: symbol;
331
+ }
332
+ declare function getDeclarations(target: unknown): Map<string, PropertyDeclaration>;
333
+ declare function getPropertyDescriptor<V, T extends ReactiveObject>(key: string, declaration?: PropertyDeclaration): {
334
+ get: () => any;
335
+ set: (v: any) => void;
336
+ };
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>;
333
339
 
334
340
  interface NormalizedInnerShadow {
335
341
  color: NormalizedColor;
@@ -779,5 +785,5 @@ declare class RawWeakMap<K extends WeakKey = WeakKey, V = any> {
779
785
  set(key: K, value: V): this;
780
786
  }
781
787
 
782
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, 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, protectedProperty, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
783
- export type { Align, AngularNode, Audio, Background, BackgroundObject, BackgroundSize, BorderStyle, BoxShadow, BoxSizing, CmykColor, CmykaColor, Color, ColorFill, ColorFillObject, ColorStop, ColorStopNode, DefaultRadialNode, Definable, 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, 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 };
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 };
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 fe={grad:.9,turn:360,rad:360/(2*Math.PI)},z=function(t){return typeof t=="string"?t.length>0:typeof t=="number"},m=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=Math.pow(10,e)),Math.round(n*t)/n+0},C=function(t,e,n){return e===void 0&&(e=0),n===void 0&&(n=1),t>n?n:t>e?t:e},at=function(t){return(t=isFinite(t)?t%360:0)>0?t:t+360},ut=function(t){return{r:C(t.r,0,255),g:C(t.g,0,255),b:C(t.b,0,255),a:C(t.a)}},x=function(t){return{r:m(t.r),g:m(t.g),b:m(t.b),a:m(t.a,3)}},de=/^#([0-9a-f]{3,8})$/i,A=function(t){var e=t.toString(16);return e.length<2?"0"+e:e},lt=function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=Math.max(e,n,r),s=c-Math.min(e,n,r),l=s?c===e?(n-r)/s:c===n?2+(r-e)/s:4+(e-n)/s:0;return{h:60*(l<0?l+6:l),s:c?s/c*100:0,v:c/255*100,a:i}},st=function(t){var e=t.h,n=t.s,r=t.v,i=t.a;e=e/360*6,n/=100,r/=100;var c=Math.floor(e),s=r*(1-n),l=r*(1-(e-c)*n),d=r*(1-(1-e+c)*n),g=c%6;return{r:255*[r,l,s,s,d,r][g],g:255*[d,r,r,l,s,s][g],b:255*[s,s,d,r,r,l][g],a:i}},ct=function(t){return{h:at(t.h),s:C(t.s,0,100),l:C(t.l,0,100),a:C(t.a)}},ft=function(t){return{h:m(t.h),s:m(t.s),l:m(t.l),a:m(t.a,3)}},dt=function(t){return st((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},G=function(t){return{h:(e=lt(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},ge=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s*,\s*([+-]?\d*\.?\d+)%\s*,\s*([+-]?\d*\.?\d+)%\s*(?:,\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,he=/^hsla?\(\s*([+-]?\d*\.?\d+)(deg|rad|grad|turn)?\s+([+-]?\d*\.?\d+)%\s+([+-]?\d*\.?\d+)%\s*(?:\/\s*([+-]?\d*\.?\d+)(%)?\s*)?\)$/i,ve=/^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,gt={string:[[function(t){var e=de.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?m(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?m(parseInt(t.substr(6,2),16)/255,2):1}:null:null},"hex"],[function(t){var e=ve.exec(t)||me.exec(t);return e?e[2]!==e[4]||e[4]!==e[6]?null:ut({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=ge.exec(t)||he.exec(t);if(!e)return null;var n,r,i=ct({h:(n=e[1],r=e[2],r===void 0&&(r="deg"),Number(n)*(fe[r]||1)),s:Number(e[3]),l:Number(e[4]),a:e[5]===void 0?1:Number(e[5])/(e[6]?100:1)});return dt(i)},"hsl"]],object:[[function(t){var e=t.r,n=t.g,r=t.b,i=t.a,c=i===void 0?1:i;return z(e)&&z(n)&&z(r)?ut({r:Number(e),g:Number(n),b:Number(r),a:Number(c)}):null},"rgb"],[function(t){var e=t.h,n=t.s,r=t.l,i=t.a,c=i===void 0?1:i;if(!z(e)||!z(n)||!z(r))return null;var s=ct({h:Number(e),s:Number(n),l:Number(r),a:Number(c)});return dt(s)},"hsl"],[function(t){var e=t.h,n=t.s,r=t.v,i=t.a,c=i===void 0?1:i;if(!z(e)||!z(n)||!z(r))return null;var s=function(l){return{h:at(l.h),s:C(l.s,0,100),v:C(l.v,0,100),a:C(l.a)}}({h:Number(e),s:Number(n),v:Number(r),a:Number(c)});return st(s)},"hsv"]]},ht=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]},pe=function(t){return typeof t=="string"?ht(t.trim(),gt.string):typeof t=="object"&&t!==null?ht(t,gt.object):[null,void 0]},K=function(t,e){var n=G(t);return{h:n.h,s:C(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},vt=function(t,e){var n=G(t);return{h:n.h,s:n.s,l:C(n.l+100*e,0,100),a:n.a}},mt=function(){function t(e){this.parsed=pe(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 m(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=x(this.rgba),n=e.r,r=e.g,i=e.b,s=(c=e.a)<1?A(m(255*c)):"","#"+A(n)+A(r)+A(i)+s;var e,n,r,i,c,s},t.prototype.toRgb=function(){return x(this.rgba)},t.prototype.toRgbString=function(){return e=x(this.rgba),n=e.r,r=e.g,i=e.b,(c=e.a)<1?"rgba("+n+", "+r+", "+i+", "+c+")":"rgb("+n+", "+r+", "+i+")";var e,n,r,i,c},t.prototype.toHsl=function(){return ft(G(this.rgba))},t.prototype.toHslString=function(){return e=ft(G(this.rgba)),n=e.h,r=e.s,i=e.l,(c=e.a)<1?"hsla("+n+", "+r+"%, "+i+"%, "+c+")":"hsl("+n+", "+r+"%, "+i+"%)";var e,n,r,i,c},t.prototype.toHsv=function(){return e=lt(this.rgba),{h:m(e.h),s:m(e.s),v:m(e.v),a:m(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(K(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(K(this.rgba,-e))},t.prototype.grayscale=function(){return w(K(this.rgba,-1))},t.prototype.lighten=function(e){return e===void 0&&(e=.1),w(vt(this.rgba,e))},t.prototype.darken=function(e){return e===void 0&&(e=.1),w(vt(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}):m(this.rgba.a,3);var n},t.prototype.hue=function(e){var n=G(this.rgba);return typeof e=="number"?w({h:e,s:n.s,l:n.l,a:n.a}):m(n.h)},t.prototype.isEqual=function(e){return this.toHex()===w(e).toHex()},t}(),w=function(t){return t instanceof mt?t:new mt(t)};function h(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 M(t,e){const n={};return e.forEach(r=>{r in t&&(n[r]=t[r])}),n}function pt(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 bt(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 yt(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(/^\./,""),pt(t,e.split("."),n))}function St(t,e,n){if(!(typeof t!="object"||!e))return e=e.replace(/\[(\w+)\]/g,".$1"),e=e.replace(/^\./,""),bt(t,e.split("."),n)}class Ct{_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 be(t){return{r:N(t.r),g:N(t.g),b:N(t.b),a:N(t.a,3)}}function T(t){const e=t.toString(16);return e.length<2?`0${e}`:e}const k="#000000FF";function wt(t){return Y(t).isValid()}function b(t,e=!1){const n=Y(t);if(!n.isValid()){if(typeof t=="string")return t;const l=`Failed to normalizeColor ${t}`;if(e)throw new Error(l);return console.warn(l),k}const{r,g:i,b:c,a:s}=be(n.rgba);return`#${T(r)}${T(i)}${T(c)}${T(N(s*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 u=new Error(`${e}: ${a}`);throw u.source=e,u}function r(){const a=i();return e.length>0&&n("Invalid input not EOF"),a}function i(){return B(c)}function c(){return s("linear-gradient",t.linearGradient,d)||s("repeating-linear-gradient",t.repeatingLinearGradient,d)||s("radial-gradient",t.radialGradient,_)||s("repeating-radial-gradient",t.repeatingRadialGradient,_)}function s(a,u,f){return l(u,p=>{const R=f();return R&&(v(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:B(De)}})}function l(a,u){const f=v(a);if(f){v(t.startCall)||n("Missing (");const p=u(f);return v(t.endCall)||n("Missing )"),p}}function d(){const a=g();if(a)return a;const u=S("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:y()}function g(){return S("directional",t.sideOrCorner,1)}function y(){return S("angular",t.angleValue,1)||S("angular",t.radianValue,1)}function _(){let a,u=L(),f;return u&&(a=[],a.push(u),f=e,v(t.comma)&&(u=L(),u?a.push(u):e=f)),a}function L(){let a=et()||Re();if(a)a.at=rt();else{const u=nt();if(u){a=u;const f=rt();f&&(a.at=f)}else{const f=rt();if(f)a={type:"default-radial",at:f};else{const p=it();p&&(a={type:"default-radial",at:p})}}}return a}function et(){const a=S("shape",/^(circle)/i,0);return a&&(a.style=ce()||nt()),a}function Re(){const a=S("shape",/^(ellipse)/i,0);return a&&(a.style=it()||j()||nt()),a}function nt(){return S("extent-keyword",t.extentKeywords,1)}function rt(){if(S("position",/^at/,0)){const a=it();return a||n("Missing positioning value"),a}}function it(){const a=Ee();if(a.x||a.y)return{type:"position",value:a}}function Ee(){return{x:j(),y:j()}}function B(a){let u=a();const f=[];if(u)for(f.push(u);v(t.comma);)u=a(),u?f.push(u):n("One extra comma");return f}function De(){const a=Le();return a||n("Expected color definition"),a.length=j(),a}function Le(){return ke()||Me()||Ae()||Ve()||Ie()||Pe()||Ge()}function Ge(){return S("literal",t.literalColor,0)}function ke(){return S("hex",t.hexColor,1)}function Ie(){return l(t.rgbColor,()=>({type:"rgb",value:B(P)}))}function Ve(){return l(t.rgbaColor,()=>({type:"rgba",value:B(P)}))}function Pe(){return l(t.varColor,()=>({type:"var",value:Te()}))}function Ae(){return l(t.hslColor,()=>{v(t.percentageValue)&&n("HSL hue value must be a number in degrees (0-360) or normalized (-360 to 360), not a percentage");const u=P();v(t.comma);let f=v(t.percentageValue);const p=f?f[1]:null;v(t.comma),f=v(t.percentageValue);const R=f?f[1]:null;return(!p||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,p,R]}})}function Me(){return l(t.hslaColor,()=>{const a=P();v(t.comma);let u=v(t.percentageValue);const f=u?u[1]:null;v(t.comma),u=v(t.percentageValue);const p=u?u[1]:null;v(t.comma);const R=P();return(!f||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,f,p,R]}})}function Te(){return v(t.variableName)[1]}function P(){return v(t.number)[1]}function j(){return S("%",t.percentageValue,1)||$e()||He()||ce()}function $e(){return S("position-keyword",t.positionKeywords,1)}function He(){return l(t.calcValue,()=>{let a=1,u=0;for(;a>0&&u<e.length;){const p=e.charAt(u);p==="("?a++:p===")"&&a--,u++}a>0&&n("Missing closing parenthesis in calc() expression");const f=e.substring(0,u-1);return ot(u-1),{type:"calc",value:f}})}function ce(){return S("px",t.pixelValue,1)||S("em",t.emValue,1)}function S(a,u,f){const p=v(u);if(p)return{type:a,value:p[f]}}function v(a){let u,f;return f=/^\s+/.exec(e),f&&ot(f[0].length),u=a.exec(e),u&&ot(u[0].length),u}function ot(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,c){n+=t.visit(i),c<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 zt(t){const e=t.length-1;return t.map((n,r)=>{const i=n.value;let c=N(r/e,3),s="#00000000";switch(n.type){case"rgb":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0)});break;case"rgba":s=b({r:Number(i[0]??0),g:Number(i[1]??0),b:Number(i[2]??0),a:Number(i[3]??0)});break;case"literal":s=b(n.value);break;case"hex":s=b(`#${n.value}`);break}switch(n.length?.type){case"%":c=Number(n.length.value)/100;break}return{offset:c,color:s}})}function Ft(t){let e=0;switch(t.orientation?.type){case"angular":e=Number(t.orientation.value);break}return{type:"linear-gradient",angle:e,stops:zt(t.colorStops)}}function Nt(t){return t.orientation?.map(e=>{switch(e?.type){case"shape":case"default-radial":case"extent-keyword":default:return null}}),{type:"radial-gradient",stops:zt(t.colorStops)}}function I(t){return t.startsWith("linear-gradient(")||t.startsWith("radial-gradient(")}function Ot(t){return _t(t).map(e=>{switch(e?.type){case"linear-gradient":return Ft(e);case"repeating-linear-gradient":return{...Ft(e),repeat:!0};case"radial-gradient":return Nt(e);case"repeating-radial-gradient":return{...Nt(e),repeat:!0};default:return}}).filter(Boolean)}function Rt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:b(e.color)}}function Et(t){let e;if(typeof t=="string"?e={image:t}:e=t,e.image){const{type:n,...r}=Ot(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:h(e.foregroundColor)?void 0:b(e.foregroundColor),backgroundColor:h(e.backgroundColor)?void 0:b(e.backgroundColor)}}function Gt(t){return!h(t.color)}function kt(t){return typeof t=="string"?wt(t):Gt(t)}function It(t){return!h(t.image)&&I(t.image)||!!t.linearGradient||!!t.radialGradient}function Vt(t){return typeof t=="string"?I(t):It(t)}function Pt(t){return!h(t.image)&&!I(t.image)}function At(t){return typeof t=="string"?!I(t):Pt(t)}function Mt(t){return!h(t.preset)}function Tt(t){return typeof t=="string"?!1:Mt(t)}function F(t){return kt(t)?Rt(t):Vt(t)?Et(t):At(t)?Dt(t):Tt(t)?Lt(t):{}}function $t(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}const Ht=new Ct;function q(t){let e=Ht.get(t);if(!e){const n=Object.getPrototypeOf(t);e=new Map(n?q(n):void 0),Ht.set(t,e)}return e}function Wt(t,e,n={}){q(t).set(e,n);const{default:r,alias:i,protected:c}=n,s=Symbol.for(String(e)),l=()=>typeof r=="function"?r():r,d=Object.getOwnPropertyDescriptor(t.prototype,e)||{get(){return i&&i!==e?typeof i=="string"?yt(this,i):this[i]:!c&&typeof e=="string"&&this.offsetGet?this.offsetGet(e):this[s]},set(g){i&&i!==e?typeof i=="string"?St(this,i,g):this[i]=g:!c&&typeof e=="string"&&this.offsetSet?this.offsetSet(e,g):this[s]=g}};Object.defineProperty(t.prototype,e,{get(){let g=d.get?.call(this);return g===void 0&&(g=l(),g!==void 0&&d.set?.call(this,g)),g},set(g){let y=d.get?.call(this);y===void 0&&(y=l()),d.set?.call(this,g),this.requestUpdate?.(e,g,y,n)},configurable:!0,enumerable:!0})}function Bt(t){return function(e,n){Wt(e.constructor,n,t)}}function Se(t){return Bt({...t,protected:!0})}function U(){return{color:k,offsetX:0,offsetY:0,blurRadius:1}}function Z(t){return{...U(),...O({...t,color:h(t.color)?k:b(t.color)})}}function jt(){return{...U(),scaleX:1,scaleY:1}}function xt(t){return{...jt(),...Z(t)}}function Ce(t){return t}function Kt(t){return O({...t,softEdge:h(t.softEdge)?void 0:t.softEdge,outerShadow:h(t.outerShadow)?void 0:xt(t.outerShadow),innerShadow:h(t.innerShadow)?void 0:Z(t.innerShadow)})}function Xt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["fillWithShape"])}}function Yt(t){return typeof t=="string"?{...F(t)}:{...F(t),...M(t,["width","style","headEnd","tailEnd"])}}function qt(t){return typeof t=="string"?{color:b(t)}:{...t,color:h(t.color)?k:b(t.color)}}function Ut(){return{boxShadow:"none"}}function Zt(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 Jt(){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 Qt(){return{rotate:0,scaleX:1,scaleY:1,skewX:0,skewY:0,translateX:0,translateY:0,transform:"none",transformOrigin:"center"}}function te(){return{...Jt(),...Qt(),...Ut(),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 ee(){return{highlight:{},highlightImage:"none",highlightReferImage:"none",highlightColormap:"none",highlightLine:"none",highlightSize:"cover",highlightThickness:"100%"}}function ne(){return{listStyle:{},listStyleType:"none",listStyleImage:"none",listStyleColormap:"none",listStyleSize:"cover",listStylePosition:"outside"}}function re(){return{...ee(),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 ie(){return{...ne(),writingMode:"horizontal-tb",textWrap:"wrap",textAlign:"start",textIndent:0,lineHeight:1.2}}function oe(){return{...ie(),...re(),textStrokeWidth:0,textStrokeColor:"rgb(0, 0, 0)"}}function D(t){return O({...t,color:h(t.color)?void 0:b(t.color),backgroundColor:h(t.backgroundColor)?void 0:b(t.backgroundColor),borderColor:h(t.borderColor)?void 0:b(t.borderColor),outlineColor:h(t.outlineColor)?void 0:b(t.outlineColor),shadowColor:h(t.shadowColor)?void 0:b(t.shadowColor)})}function we(){return{...te(),...oe()}}const J=/\r\n|\n\r|\n|\r/,_e=new RegExp(`${J.source}|<br\\/>`,"g"),ze=new RegExp(`^(${J.source})$`),W=`
2
- `;function Fe(t){return J.test(t)}function Q(t){return ze.test(t)}function ae(t){return t.replace(_e,W)}function ue(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 V(t){const e=[];function n(){return e[e.length-1]}function r(l={}){let d=e[e.length-1];return d?.fragments.length===0?(d={...l,fragments:[]},e[e.length-1]=d):(d={...l,fragments:[]},e.push(d)),d}function i(l="",d={}){Array.from(l).forEach(g=>{if(Q(g)){const{fragments:y,..._}=n()||r();y.length||y.push({...d,content:W}),r(_)}else{const y=n()||r(),_=y.fragments[y.fragments.length-1];if(_){const{content:L,...et}=_;if(ue(d,et)){_.content=`${L}${g}`;return}}y.fragments.push({...d,content:g})}})}(Array.isArray(t)?t:[t]).forEach(l=>{if(typeof l=="string")r(),i(l);else if("content"in l){const{content:d,...g}=l;r(D(g)),i(d)}else if("fragments"in l){const{fragments:d,...g}=l;r(D(g)),d.forEach(y=>{const{content:_,...L}=y;i(_,D(L))})}else Array.isArray(l)?(r(),l.forEach(d=>{if(typeof d=="string")i(d);else{const{content:g,...y}=d;i(g,D(y))}})):console.warn("Failed to parse text content",l)});const s=n();return s&&!s.fragments.length&&s.fragments.push({content:W}),e}function le(t){return typeof t=="string"?{content:V(t)}:"content"in t?{...t,content:V(t.content)}:{content:V(t)}}function Ne(t){return V(t).map(e=>{const n=ae(e.fragments.flatMap(r=>r.content).join(""));return Q(n)?"":n}).join(W)}function se(t){return typeof t=="string"?{src:t}:t}function tt(t){return O({...t,style:h(t.style)?void 0:D(t.style),text:h(t.text)?void 0:le(t.text),background:h(t.background)?void 0:$t(t.background),shape:h(t.shape)?void 0:Zt(t.shape),fill:h(t.fill)?void 0:F(t.fill),outline:h(t.outline)?void 0:Yt(t.outline),foreground:h(t.foreground)?void 0:Xt(t.foreground),shadow:h(t.shadow)?void 0:qt(t.shadow),video:h(t.video)?void 0:se(t.video),audio:h(t.audio)?void 0:E(t.audio),effect:h(t.effect)?void 0:Kt(t.effect),children:t.children?.map(e=>tt(e))})}function Oe(t){return tt(t)}o.RawWeakMap=Ct,o.clearUndef=O,o.defaultColor=k,o.defineProperty=Wt,o.getDeclarations=q,o.getDefaultElementStyle=te,o.getDefaultHighlightStyle=ee,o.getDefaultInnerShadow=U,o.getDefaultLayoutStyle=Jt,o.getDefaultListStyleStyle=ne,o.getDefaultOuterShadow=jt,o.getDefaultShadowStyle=Ut,o.getDefaultStyle=we,o.getDefaultTextInlineStyle=re,o.getDefaultTextLineStyle=ie,o.getDefaultTextStyle=oe,o.getDefaultTransformStyle=Qt,o.getNestedValue=pt,o.getObjectValueByPath=yt,o.hasCRLF=Fe,o.isCRLF=Q,o.isColor=wt,o.isColorFill=kt,o.isColorFillObject=Gt,o.isEqualStyle=ue,o.isGradient=I,o.isGradientFill=Vt,o.isGradientFillObject=It,o.isImageFill=At,o.isImageFillObject=Pt,o.isNone=h,o.isPresetFill=Tt,o.isPresetFillObject=Mt,o.normalizeAudio=E,o.normalizeBackground=$t,o.normalizeCRLF=ae,o.normalizeColor=b,o.normalizeColorFill=Rt,o.normalizeDocument=Oe,o.normalizeEffect=Kt,o.normalizeElement=tt,o.normalizeFill=F,o.normalizeForeground=Xt,o.normalizeGradient=Ot,o.normalizeGradientFill=Et,o.normalizeImageFill=Dt,o.normalizeInnerShadow=Z,o.normalizeOuterShadow=xt,o.normalizeOutline=Yt,o.normalizePresetFill=Lt,o.normalizeShadow=qt,o.normalizeShape=Zt,o.normalizeSoftEdge=Ce,o.normalizeStyle=D,o.normalizeText=le,o.normalizeTextContent=V,o.normalizeVideo=se,o.parseColor=Y,o.parseGradient=_t,o.pick=M,o.property=Bt,o.protectedProperty=Se,o.round=N,o.setNestedValue=bt,o.setObjectValueByPath=St,o.stringifyGradient=ye,o.textContentToString=Ne,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(o,k){typeof exports=="object"&&typeof module<"u"?k(exports):typeof define=="function"&&define.amd?define(["exports"],k):(o=typeof globalThis<"u"?globalThis:o||self,k(o.modernIdoc={}))})(this,function(o){"use strict";function k(t){return typeof t=="string"?{src:t}:t}var 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)}},x=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),s=c?l===e?(n-r)/c:l===n?2+(r-e)/c:4+(e-n)/c:0;return{h:60*(s<0?s+6:s),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),s=r*(1-(e-l)*n),f=r*(1-(1-e+l)*n),m=l%6;return{r:255*[r,s,c,c,f,r][m],g:255*[f,r,r,s,c,c][m],b:255*[c,c,f,r,r,s][m],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(s){return{h:lt(s.h),s:S(s.s,0,100),v:S(s.v,0,100),a:S(s.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]},K=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},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(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=x(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 x(this.rgba)},t.prototype.toRgbString=function(){return e=x(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(K(this.rgba,e))},t.prototype.desaturate=function(e){return e===void 0&&(e=.1),w(K(this.rgba,-e))},t.prototype.grayscale=function(){return w(K(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 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 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 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 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 Y(t).isValid()}function y(t,e=!1){const n=Y(t);if(!n.isValid()){if(typeof t=="string")return t;const s=`Failed to normalizeColor ${t}`;if(e)throw new Error(s);return console.warn(s),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 u=new Error(`${e}: ${a}`);throw u.source=e,u}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,f)||c("repeating-linear-gradient",t.repeatingLinearGradient,f)||c("radial-gradient",t.radialGradient,z)||c("repeating-radial-gradient",t.repeatingRadialGradient,z)}function c(a,u,d){return s(u,p=>{const R=d();return R&&(h(t.comma)||n("Missing comma before color stops")),{type:a,orientation:R,colorStops:B(Ee)}})}function s(a,u){const d=h(a);if(d){h(t.startCall)||n("Missing (");const p=u(d);return h(t.endCall)||n("Missing )"),p}}function f(){const a=m();if(a)return a;const u=b("position-keyword",t.positionKeywords,1);return u?{type:"directional",value:u.value}:C()}function m(){return b("directional",t.sideOrCorner,1)}function C(){return b("angular",t.angleValue,1)||b("angular",t.radianValue,1)}function z(){let a,u=D(),d;return u&&(a=[],a.push(u),d=e,h(t.comma)&&(u=D(),u?a.push(u):e=d)),a}function D(){let a=rt()||Re();if(a)a.at=ot();else{const u=it();if(u){a=u;const d=ot();d&&(a.at=d)}else{const d=ot();if(d)a={type:"default-radial",at:d};else{const p=at();p&&(a={type:"default-radial",at:p})}}}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()||j()||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=ke();if(a.x||a.y)return{type:"position",value:a}}function ke(){return{x:j(),y:j()}}function B(a){let u=a();const d=[];if(u)for(d.push(u);h(t.comma);)u=a(),u?d.push(u):n("One extra comma");return d}function Ee(){const a=De();return a||n("Expected color definition"),a.length=j(),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 s(t.rgbColor,()=>({type:"rgb",value:B(V)}))}function Pe(){return s(t.rgbaColor,()=>({type:"rgba",value:B(V)}))}function Ve(){return s(t.varColor,()=>({type:"var",value:Me()}))}function Ae(){return s(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 u=V();h(t.comma);let d=h(t.percentageValue);const p=d?d[1]:null;h(t.comma),d=h(t.percentageValue);const R=d?d[1]:null;return(!p||!R)&&n("Expected percentage value for saturation and lightness in HSL"),{type:"hsl",value:[u,p,R]}})}function Te(){return s(t.hslaColor,()=>{const a=V();h(t.comma);let u=h(t.percentageValue);const d=u?u[1]:null;h(t.comma),u=h(t.percentageValue);const p=u?u[1]:null;h(t.comma);const R=V();return(!d||!p)&&n("Expected percentage value for saturation and lightness in HSLA"),{type:"hsla",value:[a,d,p,R]}})}function Me(){return h(t.variableName)[1]}function V(){return h(t.number)[1]}function j(){return b("%",t.percentageValue,1)||$e()||He()||le()}function $e(){return b("position-keyword",t.positionKeywords,1)}function He(){return s(t.calcValue,()=>{let a=1,u=0;for(;a>0&&u<e.length;){const p=e.charAt(u);p==="("?a++:p===")"&&a--,u++}a>0&&n("Missing closing parenthesis in calc() expression");const d=e.substring(0,u-1);return ut(u-1),{type:"calc",value:d}})}function le(){return b("px",t.pixelValue,1)||b("em",t.emValue,1)}function b(a,u,d){const p=h(u);if(p)return{type:a,value:p[d]}}function h(a){let u,d;return d=/^\s+/.exec(e),d&&ut(d[0].length),u=a.exec(e),u&&ut(u[0].length),u}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=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 _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 kt(t){let e;return typeof t=="string"?e={color:t}:e=t,{color:y(e.color)}}function Et(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: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"?zt(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)?kt(t):Vt(t)?Et(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 U(t){const e=Object.getPrototypeOf(t);let n;return e&&Object.hasOwn(e,q)?n=e[q]:(n=new Map(e?U(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,s={get(){let f;return i&&i!==t?f=Ct(this,i):typeof this.getter<"u"?f=this.getter(t,l):f=this[n],f??c()},set(f){const m=s.get?.call(this);i&&i!==t?wt(this,i,f):typeof this.setter<"u"?this.setter(t,f,l):this[n]=f,this.onUpdateProperty?.(t,f,m,e)}};return s}function be(t,e,n={}){const r=Z(e,n);Object.defineProperty(t.prototype,e,{get(){return r.get.call(this)},set(i){r.set.call(this,i)},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 U(this).set(r,t),i.set.call(this,l),l},get(){return i.get.call(this)},set(l){i.set.call(this,l)}}}}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 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: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 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:y(t)}:{...t,color:g(t.color)?G:y(t.color)}}function Yt(){return{boxShadow:"none"}}function qt(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 Ut(){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{...Ut(),...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 E(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 we(){return{...Jt(),...re()}}const tt=/\r\n|\n\r|\n|\r/,ze=new RegExp(`${tt.source}|<br\\/>`,"g"),_e=new RegExp(`^(${tt.source})$`),W=`
2
+ `;function Fe(t){return tt.test(t)}function et(t){return _e.test(t)}function ie(t){return t.replace(ze,W)}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(s={}){let f=e[e.length-1];return f?.fragments.length===0?(f={...s,fragments:[]},e[e.length-1]=f):(f={...s,fragments:[]},e.push(f)),f}function i(s="",f={}){Array.from(s).forEach(m=>{if(et(m)){const{fragments:C,...z}=n()||r();C.length||C.push({...f,content:W}),r(z)}else{const C=n()||r(),z=C.fragments[C.fragments.length-1];if(z){const{content:D,...rt}=z;if(oe(f,rt)){z.content=`${D}${m}`;return}}C.fragments.push({...f,content:m})}})}(Array.isArray(t)?t:[t]).forEach(s=>{if(typeof s=="string")r(),i(s);else if("content"in s){const{content:f,...m}=s;r(E(m)),i(f)}else if("fragments"in s){const{fragments:f,...m}=s;r(E(m)),f.forEach(C=>{const{content:z,...D}=C;i(z,E(D))})}else Array.isArray(s)?(r(),s.forEach(f=>{if(typeof f=="string")i(f);else{const{content:m,...C}=f;i(m,E(C))}})):console.warn("Failed to parse text content",s)});const c=n();return c&&!c.fragments.length&&c.fragments.push({content:W}),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(W)}function ue(t){return typeof t=="string"?{src:t}:t}function nt(t){return O({...t,style:g(t.style)?void 0:E(t.style),text:g(t.text)?void 0:ae(t.text),background:g(t.background)?void 0:Ht(t.background),shape:g(t.shape)?void 0:qt(t.shape),fill:g(t.fill)?void 0:F(t.fill),outline:g(t.outline)?void 0:Kt(t.outline),foreground:g(t.foreground)?void 0:xt(t.foreground),shadow:g(t.shadow)?void 0:Xt(t.shadow),video:g(t.video)?void 0:ue(t.video),audio:g(t.audio)?void 0:k(t.audio),effect:g(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=U,o.getDefaultElementStyle=Jt,o.getDefaultHighlightStyle=Qt,o.getDefaultInnerShadow=J,o.getDefaultLayoutStyle=Ut,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=g,o.isPresetFill=$t,o.isPresetFillObject=Mt,o.normalizeAudio=k,o.normalizeBackground=Ht,o.normalizeCRLF=ie,o.normalizeColor=y,o.normalizeColorFill=kt,o.normalizeDocument=Oe,o.normalizeEffect=jt,o.normalizeElement=nt,o.normalizeFill=F,o.normalizeForeground=xt,o.normalizeGradient=Rt,o.normalizeGradientFill=Et,o.normalizeImageFill=Dt,o.normalizeInnerShadow=Q,o.normalizeOuterShadow=Bt,o.normalizeOutline=Kt,o.normalizePresetFill=Lt,o.normalizeShadow=Xt,o.normalizeShape=qt,o.normalizeSoftEdge=Ce,o.normalizeStyle=E,o.normalizeText=ae,o.normalizeTextContent=P,o.normalizeVideo=ue,o.parseColor=Y,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"})});
package/dist/index.mjs CHANGED
@@ -888,88 +888,95 @@ function normalizeBackground(background) {
888
888
  }
889
889
  }
890
890
 
891
- const declarationMap = new RawWeakMap();
892
- function getDeclarations(constructor) {
893
- let declarations = declarationMap.get(constructor);
894
- if (!declarations) {
895
- const superConstructor = Object.getPrototypeOf(constructor);
896
- declarations = new Map(superConstructor ? getDeclarations(superConstructor) : void 0);
897
- declarationMap.set(constructor, declarations);
891
+ const propertiesSymbol = Symbol("properties");
892
+ function getDeclarations(target) {
893
+ const proto = Object.getPrototypeOf(target);
894
+ let declarations;
895
+ if (proto && Object.hasOwn(proto, propertiesSymbol)) {
896
+ declarations = proto[propertiesSymbol];
897
+ } else {
898
+ declarations = new Map(proto ? getDeclarations(proto) : void 0);
899
+ if (proto) {
900
+ proto[propertiesSymbol] = declarations;
901
+ }
898
902
  }
899
903
  return declarations;
900
904
  }
901
- function defineProperty(constructor, key, declaration = {}) {
902
- getDeclarations(constructor).set(key, declaration);
905
+ function getPropertyDescriptor(key, declaration = {}) {
906
+ const internalKey = Symbol.for(key);
903
907
  const {
904
- default: _default,
905
- alias,
906
- protected: _protected
908
+ fallback,
909
+ alias
907
910
  } = declaration;
908
- const internalKey = Symbol.for(String(key));
909
- const getDefaultValue = () => typeof _default === "function" ? _default() : _default;
910
- const descriptor = Object.getOwnPropertyDescriptor(constructor.prototype, key) || {
911
+ const ctx = { declaration, internalKey };
912
+ const getFallbackValue = () => {
913
+ return typeof fallback === "function" ? fallback() : fallback;
914
+ };
915
+ const descriptor = {
911
916
  get() {
917
+ let result;
912
918
  if (alias && alias !== key) {
913
- if (typeof alias === "string") {
914
- return getObjectValueByPath(this, alias);
915
- } else {
916
- return this[alias];
917
- }
919
+ result = getObjectValueByPath(this, alias);
918
920
  } else {
919
- if (!_protected && typeof key === "string" && this.offsetGet) {
920
- return this.offsetGet(key);
921
+ if (typeof this.getter !== "undefined") {
922
+ result = this.getter(key, ctx);
921
923
  } else {
922
- return this[internalKey];
924
+ result = this[internalKey];
923
925
  }
924
926
  }
927
+ return result ?? getFallbackValue();
925
928
  },
926
- set(value) {
929
+ set(newValue) {
930
+ const oldValue = descriptor.get?.call(this);
927
931
  if (alias && alias !== key) {
928
- if (typeof alias === "string") {
929
- setObjectValueByPath(this, alias, value);
930
- } else {
931
- this[alias] = value;
932
- }
932
+ setObjectValueByPath(this, alias, newValue);
933
933
  } else {
934
- if (!_protected && typeof key === "string" && this.offsetSet) {
935
- this.offsetSet(key, value);
934
+ if (typeof this.setter !== "undefined") {
935
+ this.setter(key, newValue, ctx);
936
936
  } else {
937
- this[internalKey] = value;
937
+ this[internalKey] = newValue;
938
938
  }
939
939
  }
940
+ this.onUpdateProperty?.(key, newValue, oldValue, declaration);
940
941
  }
941
942
  };
942
- Object.defineProperty(constructor.prototype, key, {
943
+ return descriptor;
944
+ }
945
+ function defineProperty(target, key, declaration = {}) {
946
+ const descriptor = getPropertyDescriptor(key, declaration);
947
+ Object.defineProperty(target.prototype, key, {
943
948
  get() {
944
- let value = descriptor.get?.call(this);
945
- if (value === void 0) {
946
- value = getDefaultValue();
947
- if (value !== void 0) {
948
- descriptor.set?.call(this, value);
949
- }
950
- }
951
- return value;
949
+ return descriptor.get.call(this);
952
950
  },
953
951
  set(newValue) {
954
- let oldValue = descriptor.get?.call(this);
955
- if (oldValue === void 0) {
956
- oldValue = getDefaultValue();
957
- }
958
- descriptor.set?.call(this, newValue);
959
- this.requestUpdate?.(key, newValue, oldValue, declaration);
952
+ descriptor.set.call(this, newValue);
960
953
  },
961
954
  configurable: true,
962
955
  enumerable: true
963
956
  });
964
957
  }
965
- function property(options) {
966
- return function(proto, name) {
967
- defineProperty(proto.constructor, name, options);
958
+ function property(declaration = {}) {
959
+ return function(_, context) {
960
+ const key = context.name;
961
+ if (typeof key !== "string") {
962
+ throw new TypeError("Failed to @property decorator, prop name cannot be a symbol");
963
+ }
964
+ const descriptor = getPropertyDescriptor(key, declaration);
965
+ return {
966
+ init(v) {
967
+ getDeclarations(this).set(key, declaration);
968
+ descriptor.set.call(this, v);
969
+ return v;
970
+ },
971
+ get() {
972
+ return descriptor.get.call(this);
973
+ },
974
+ set(newValue) {
975
+ descriptor.set.call(this, newValue);
976
+ }
977
+ };
968
978
  };
969
979
  }
970
- function protectedProperty(options) {
971
- return property({ ...options, protected: true });
972
- }
973
980
 
974
981
  function getDefaultInnerShadow() {
975
982
  return {
@@ -1422,4 +1429,4 @@ function normalizeDocument(doc) {
1422
1429
  return normalizeElement(doc);
1423
1430
  }
1424
1431
 
1425
- export { RawWeakMap, clearUndef, defaultColor, defineProperty, getDeclarations, getDefaultElementStyle, getDefaultHighlightStyle, getDefaultInnerShadow, getDefaultLayoutStyle, getDefaultListStyleStyle, getDefaultOuterShadow, getDefaultShadowStyle, getDefaultStyle, getDefaultTextInlineStyle, getDefaultTextLineStyle, getDefaultTextStyle, getDefaultTransformStyle, getNestedValue, getObjectValueByPath, 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, protectedProperty, round, setNestedValue, setObjectValueByPath, stringifyGradient, textContentToString };
1432
+ 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 };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "modern-idoc",
3
3
  "type": "module",
4
- "version": "0.6.20",
4
+ "version": "0.7.0",
5
5
  "packageManager": "pnpm@9.15.1",
6
6
  "description": "Intermediate document for modern codec libs",
7
7
  "author": "wxm",
@@ -58,7 +58,7 @@
58
58
  },
59
59
  "devDependencies": {
60
60
  "@antfu/eslint-config": "^4.16.1",
61
- "@types/node": "^24.0.7",
61
+ "@types/node": "^24.0.8",
62
62
  "bumpp": "^10.2.0",
63
63
  "conventional-changelog-cli": "^5.0.0",
64
64
  "eslint": "^9.30.0",