@lottiefiles/lottie-js
Advanced tools
Comparing version 0.3.7 to 0.3.9
# Changelog | ||
## 0.3.7 | ||
## 0.3.9 | ||
@@ -5,0 +5,0 @@ ### Patch Changes |
/*! | ||
* @lottiefiles/lottie-js - v0.3.7 | ||
* Compiled Wed, 16 Mar 2022 06:55:24 UTC | ||
* @lottiefiles/lottie-js - v0.3.9 | ||
* Compiled Wed, 30 Mar 2022 08:38:45 UTC | ||
* | ||
@@ -35,3 +35,3 @@ * Copyright LottieFiles. All rights reserved. | ||
h: this.height, | ||
i: this.id, | ||
id: this.id, | ||
p: this.data, | ||
@@ -153,2 +153,3 @@ u: this.path, | ||
PropertyType2["POSITION"] = "p"; | ||
PropertyType2["POINTS"] = "pt"; | ||
PropertyType2["ROTATION"] = "r"; | ||
@@ -172,2 +173,3 @@ PropertyType2["ROTATION_X"] = "rx"; | ||
PropertyType2["GRADIENT"] = "gr"; | ||
PropertyType2["EFFECT_VALUE"] = "v"; | ||
})(exports.PropertyType || (exports.PropertyType = {})); | ||
@@ -216,17 +218,33 @@ | ||
class FontList { | ||
constructor() { | ||
this.list = []; | ||
} | ||
fromJSON(json) { | ||
this.list = json.list; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
list: this.list | ||
}; | ||
} | ||
} | ||
(function(EffectType2) { | ||
EffectType2[EffectType2["NONE"] = 0] = "NONE"; | ||
EffectType2[EffectType2["CUSTOM"] = 5] = "CUSTOM"; | ||
EffectType2[EffectType2["PAINT_OVER_TRANSPARENT"] = 7] = "PAINT_OVER_TRANSPARENT"; | ||
EffectType2[EffectType2["TINT"] = 20] = "TINT"; | ||
EffectType2[EffectType2["FILL"] = 21] = "FILL"; | ||
EffectType2[EffectType2["STROKE"] = 22] = "STROKE"; | ||
EffectType2[EffectType2["TRITONE"] = 23] = "TRITONE"; | ||
EffectType2[EffectType2["PRO_LEVELS"] = 24] = "PRO_LEVELS"; | ||
EffectType2[EffectType2["DROP_SHADOW"] = 25] = "DROP_SHADOW"; | ||
EffectType2[EffectType2["RADIAL_WIPE"] = 26] = "RADIAL_WIPE"; | ||
EffectType2[EffectType2["DISPLACEMENT_MAP"] = 27] = "DISPLACEMENT_MAP"; | ||
EffectType2[EffectType2["MATTE3"] = 28] = "MATTE3"; | ||
EffectType2[EffectType2["GAUSSIAN_BLUR"] = 29] = "GAUSSIAN_BLUR"; | ||
EffectType2[EffectType2["MESH_WRAP"] = 31] = "MESH_WRAP"; | ||
EffectType2[EffectType2["WAVY"] = 32] = "WAVY"; | ||
EffectType2[EffectType2["SPHERIZE"] = 33] = "SPHERIZE"; | ||
EffectType2[EffectType2["PUPPET"] = 34] = "PUPPET"; | ||
})(exports.EffectType || (exports.EffectType = {})); | ||
(function(EffectValueType2) { | ||
EffectValueType2[EffectValueType2["SLIDER"] = 0] = "SLIDER"; | ||
EffectValueType2[EffectValueType2["ANGLE"] = 1] = "ANGLE"; | ||
EffectValueType2[EffectValueType2["COLOR"] = 2] = "COLOR"; | ||
EffectValueType2[EffectValueType2["POINT"] = 3] = "POINT"; | ||
EffectValueType2[EffectValueType2["CHECKBOX"] = 4] = "CHECKBOX"; | ||
EffectValueType2[EffectValueType2["IGNORED"] = 6] = "IGNORED"; | ||
EffectValueType2[EffectValueType2["DROPDOWN"] = 7] = "DROPDOWN"; | ||
EffectValueType2[EffectValueType2["LAYER"] = 10] = "LAYER"; | ||
})(exports.EffectValueType || (exports.EffectValueType = {})); | ||
class KeyFrame { | ||
@@ -376,291 +394,2 @@ constructor(frame = 0, value = 0) { | ||
class Transform { | ||
constructor() { | ||
this.anchor = new Property(this, exports.PropertyType.ANCHOR, [new KeyFrame(0, [0, 0])]); | ||
this.opacity = new Property(this, exports.PropertyType.OPACITY, [new KeyFrame(0, 100)]); | ||
this.position = new Property(this, exports.PropertyType.POSITION, [new KeyFrame(0, [0, 0])]); | ||
this.rotation = new Property(this, exports.PropertyType.ROTATION, [new KeyFrame(0, 0)]); | ||
this.scale = new Property(this, exports.PropertyType.SCALE, [new KeyFrame(0, [100, 100])]); | ||
this.skew = new Property(this, exports.PropertyType.SKEW); | ||
this.skewAxis = new Property(this, exports.PropertyType.SKEW_AXIS); | ||
} | ||
fromJSON(json) { | ||
this.rotation = "r" in json ? new Property(this, exports.PropertyType.ROTATION).fromJSON(json.r) : void 0; | ||
"o" in json && this.opacity.fromJSON(json.o); | ||
"p" in json && this.position.fromJSON(json.p); | ||
"a" in json && this.anchor.fromJSON(json.a); | ||
"s" in json && this.scale.fromJSON(json.s); | ||
this.skew = "sk" in json ? new Property(this, exports.PropertyType.SKEW).fromJSON(json.sk) : void 0; | ||
this.skewAxis = "sa" in json ? new Property(this, exports.PropertyType.SKEW_AXIS).fromJSON(json.sa) : void 0; | ||
if ("or" in json) { | ||
this.orientation = new Property(this, exports.PropertyType.ORIENTATION).fromJSON(json.or); | ||
} | ||
if ("rx" in json) { | ||
this.rotationX = new Property(this, exports.PropertyType.ROTATION_X).fromJSON(json.rx); | ||
} | ||
if ("ry" in json) { | ||
this.rotationY = new Property(this, exports.PropertyType.ROTATION_Y).fromJSON(json.ry); | ||
} | ||
if ("rz" in json) { | ||
this.rotationZ = new Property(this, exports.PropertyType.ROTATION_Z).fromJSON(json.rz); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
a: this.anchor, | ||
o: this.opacity, | ||
p: this.position, | ||
r: this.rotation, | ||
s: this.scale, | ||
sk: this.skew, | ||
sa: this.skewAxis, | ||
rx: this.rotationX, | ||
ry: this.rotationY, | ||
rz: this.rotationZ, | ||
or: this.orientation | ||
}; | ||
} | ||
} | ||
class Layer { | ||
constructor(parent) { | ||
this.autoOrient = false; | ||
this.blendMode = exports.BlendMode.NORMAL; | ||
this.classNames = []; | ||
this.height = 0; | ||
this.id = ""; | ||
this.inPoint = 0; | ||
this.is3D = false; | ||
this.name = ""; | ||
this.outPoint = 0; | ||
this.startTime = 0; | ||
this.timeStretch = 1; | ||
this.width = 0; | ||
this.transform = new Transform(); | ||
this.parent = parent; | ||
} | ||
get colors() { | ||
const colors = new Set(); | ||
const registry = useRegistry(); | ||
[...registry.keys()].filter((p) => registry.get(p) === this && p.type === exports.PropertyType.COLOR).forEach((cp) => { | ||
cp.values.forEach((v) => { | ||
colors.add(JSON.stringify(v.value)); | ||
}); | ||
}); | ||
return Array.from(colors).map((c) => JSON.parse(c)); | ||
} | ||
get totalFrames() { | ||
return this.outPoint - this.inPoint; | ||
} | ||
} | ||
class GroupLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.GROUP; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
} | ||
} | ||
class ImageLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.IMAGE; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ty: this.type, | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
refId: this.refId | ||
}; | ||
} | ||
} | ||
class PrecompositionLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.PRECOMPOSITION; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
refId: this.refId, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
} | ||
} | ||
class GradientStop { | ||
@@ -769,2 +498,51 @@ constructor(offset = 0, color = []) { | ||
class Transform { | ||
constructor() { | ||
this.anchor = new Property(this, exports.PropertyType.ANCHOR, [new KeyFrame(0, [0, 0])]); | ||
this.opacity = new Property(this, exports.PropertyType.OPACITY, [new KeyFrame(0, 100)]); | ||
this.position = new Property(this, exports.PropertyType.POSITION, [new KeyFrame(0, [0, 0])]); | ||
this.rotation = new Property(this, exports.PropertyType.ROTATION, [new KeyFrame(0, 0)]); | ||
this.scale = new Property(this, exports.PropertyType.SCALE, [new KeyFrame(0, [100, 100])]); | ||
this.skew = new Property(this, exports.PropertyType.SKEW); | ||
this.skewAxis = new Property(this, exports.PropertyType.SKEW_AXIS); | ||
} | ||
fromJSON(json) { | ||
this.rotation = "r" in json ? new Property(this, exports.PropertyType.ROTATION).fromJSON(json.r) : void 0; | ||
"o" in json && this.opacity.fromJSON(json.o); | ||
"p" in json && this.position.fromJSON(json.p); | ||
"a" in json && this.anchor.fromJSON(json.a); | ||
"s" in json && this.scale.fromJSON(json.s); | ||
this.skew = "sk" in json ? new Property(this, exports.PropertyType.SKEW).fromJSON(json.sk) : void 0; | ||
this.skewAxis = "sa" in json ? new Property(this, exports.PropertyType.SKEW_AXIS).fromJSON(json.sa) : void 0; | ||
if ("or" in json) { | ||
this.orientation = new Property(this, exports.PropertyType.ORIENTATION).fromJSON(json.or); | ||
} | ||
if ("rx" in json) { | ||
this.rotationX = new Property(this, exports.PropertyType.ROTATION_X).fromJSON(json.rx); | ||
} | ||
if ("ry" in json) { | ||
this.rotationY = new Property(this, exports.PropertyType.ROTATION_Y).fromJSON(json.ry); | ||
} | ||
if ("rz" in json) { | ||
this.rotationZ = new Property(this, exports.PropertyType.ROTATION_Z).fromJSON(json.rz); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
a: this.anchor, | ||
o: this.opacity, | ||
p: this.position, | ||
r: this.rotation, | ||
s: this.scale, | ||
sk: this.skew, | ||
sa: this.skewAxis, | ||
rx: this.rotationX, | ||
ry: this.rotationY, | ||
rz: this.rotationZ, | ||
or: this.orientation | ||
}; | ||
} | ||
} | ||
class Shape { | ||
@@ -775,2 +553,20 @@ constructor(parent) { | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name | ||
}; | ||
} | ||
} | ||
@@ -787,7 +583,3 @@ | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.position.fromJSON(json.p); | ||
@@ -799,13 +591,8 @@ this.size.fromJSON(json.s); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
p: this.position, | ||
s: this.size, | ||
d: this.direction | ||
}; | ||
}); | ||
} | ||
@@ -824,7 +611,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
@@ -837,9 +620,4 @@ this.color.fromJSON(json.c); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -849,3 +627,3 @@ c: this.color, | ||
o: this.opacity | ||
}; | ||
}); | ||
} | ||
@@ -869,7 +647,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
@@ -889,9 +663,4 @@ this.endPoint.fromJSON(json.e); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -906,93 +675,60 @@ e: this.endPoint, | ||
s: this.startPoint | ||
}; | ||
}); | ||
} | ||
} | ||
class GradientStrokeShape extends Shape { | ||
class GroupShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.ShapeType.GRADIENT_STROKE; | ||
this.type = exports.ShapeType.GROUP; | ||
this.blendMode = exports.BlendMode.NORMAL; | ||
this.endPoint = new Property(this, exports.PropertyType.POSITION); | ||
this.gradientColors = new Gradient(); | ||
this.gradientType = exports.GradientFillType.LINEAR; | ||
this.highlightAngle = new Property(this, exports.PropertyType.NUMBER); | ||
this.highlightLength = new Property(this, exports.PropertyType.NUMBER); | ||
this.opacity = new Property(this, exports.PropertyType.OPACITY); | ||
this.startPoint = new Property(this, exports.PropertyType.POSITION); | ||
this.lineCapType = exports.LineCapType.ROUND; | ||
this.lineJoinType = exports.LineJoinType.ROUND; | ||
this.width = new Property(this, exports.PropertyType.STROKE_WIDTH); | ||
this.isHidden = false; | ||
this.numProperties = 0; | ||
this.transform = new Transform(); | ||
this.shapes = []; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
this.opacity.fromJSON(json.o); | ||
this.endPoint.fromJSON(json.e); | ||
this.gradientColors.fromJSON(json.g); | ||
this.gradientType = json.t; | ||
this.startPoint.fromJSON(json.s); | ||
if (this.gradientType === exports.GradientFillType.RADIAL) { | ||
this.highlightAngle.fromJSON(json.a); | ||
this.highlightLength.fromJSON(json.h); | ||
} | ||
this.lineCapType = json.lc in exports.LineCapType ? json.lc : exports.LineCapType.ROUND; | ||
this.lineJoinType = json.lj in exports.LineJoinType ? json.lj : exports.LineJoinType.ROUND; | ||
this.miterLimit = json.ml; | ||
this.width.fromJSON(json.w); | ||
this.contentPropertyIndex = json.cix; | ||
this.propertyIndex = json.ix; | ||
this.numProperties = json.np; | ||
this.shapes = json.it.map((jShape) => { | ||
try { | ||
if (jShape.ty !== "tr") { | ||
const nShape = this.createShape(jShape.ty); | ||
return nShape.fromJSON(jShape); | ||
} else { | ||
this.transform.fromJSON(jShape); | ||
} | ||
} catch (e) { | ||
} | ||
return false; | ||
}).filter(Boolean); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
bm: this.blendMode, | ||
o: this.opacity, | ||
e: this.endPoint, | ||
g: this.gradientColors, | ||
t: this.gradientType, | ||
a: this.highlightAngle, | ||
h: this.highlightLength, | ||
s: this.startPoint, | ||
lc: this.lineCapType, | ||
lj: this.lineJoinType, | ||
ml: this.miterLimit, | ||
w: this.width | ||
}; | ||
createShape(type) { | ||
return createShapeFromType(type, this); | ||
} | ||
} | ||
class MergeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.ShapeType.MERGE; | ||
this.mergeMode = 1; | ||
addShape(shape3) { | ||
if (!(shape3 instanceof Shape)) | ||
shape3 = this.createShape(shape3); | ||
this.shapes.push(shape3); | ||
return shape3; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
this.mergeMode = json.mm; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
mm: this.mergeMode | ||
}; | ||
const json = super.toJSON(); | ||
const shapes = JSON.parse(JSON.stringify(this.shapes)); | ||
shapes.push({ | ||
ty: "tr", | ||
nm: "Transform", | ||
...this.transform.toJSON() | ||
}); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
cix: this.contentPropertyIndex, | ||
it: shapes, | ||
ix: this.propertyIndex, | ||
np: this.numProperties | ||
}); | ||
} | ||
@@ -1008,7 +744,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.itemIndex = json.ind; | ||
@@ -1021,9 +753,4 @@ this.shapeIndex = json.ix; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
ind: this.itemIndex, | ||
@@ -1033,3 +760,3 @@ ix: this.shapeIndex, | ||
ks: this.vertices | ||
}; | ||
}); | ||
} | ||
@@ -1047,7 +774,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.direction = json.d; | ||
@@ -1060,9 +783,4 @@ this.position.fromJSON(json.p); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
d: this.direction, | ||
@@ -1072,59 +790,6 @@ p: this.position, | ||
s: this.size | ||
}; | ||
}); | ||
} | ||
} | ||
class StarShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.ShapeType.STAR; | ||
this.position = new Property(this, exports.PropertyType.POSITION); | ||
this.innerRadius = new Property(this, exports.PropertyType.NUMBER); | ||
this.innerRoundness = new Property(this, exports.PropertyType.NUMBER); | ||
this.outerRadius = new Property(this, exports.PropertyType.NUMBER); | ||
this.outerRoundness = new Property(this, exports.PropertyType.NUMBER); | ||
this.rotation = new Property(this, exports.PropertyType.ROTATION); | ||
this.points = new Property(this, exports.PropertyType.NUMBER); | ||
this.starType = exports.StarType.STAR; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
this.position.fromJSON(json.p); | ||
if (json.sy === 1) { | ||
this.innerRadius.fromJSON(json.ir); | ||
this.innerRoundness.fromJSON(json.is); | ||
} | ||
this.outerRadius.fromJSON(json.or); | ||
this.outerRoundness.fromJSON(json.os); | ||
this.rotation.fromJSON(json.r); | ||
this.points.fromJSON(json.pt); | ||
this.starType = json.sy; | ||
this.direction = json.d; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
p: this.position, | ||
...this.starType === 1 && {ir: this.innerRadius}, | ||
...this.starType === 1 && {is: this.innerRoundness}, | ||
or: this.outerRadius, | ||
os: this.outerRoundness, | ||
r: this.rotation, | ||
pt: this.points, | ||
sy: this.starType, | ||
d: this.direction | ||
}; | ||
} | ||
} | ||
class StrokeShape extends Shape { | ||
@@ -1142,7 +807,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm in exports.BlendMode ? json.bm : exports.BlendMode.NORMAL; | ||
@@ -1158,9 +819,4 @@ this.color.fromJSON(json.c); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -1173,3 +829,3 @@ c: this.color, | ||
w: this.width | ||
}; | ||
}); | ||
} | ||
@@ -1189,7 +845,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm in exports.BlendMode ? json.bm : exports.BlendMode.NORMAL; | ||
@@ -1203,9 +855,4 @@ this.trimEnd.fromJSON(json.e); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -1216,91 +863,56 @@ e: this.trimEnd, | ||
m: this.trimMultipleShapes | ||
}; | ||
}); | ||
} | ||
} | ||
class GroupShape extends Shape { | ||
class GradientStrokeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.ShapeType.GROUP; | ||
this.type = exports.ShapeType.GRADIENT_STROKE; | ||
this.blendMode = exports.BlendMode.NORMAL; | ||
this.isHidden = false; | ||
this.numProperties = 0; | ||
this.transform = new Transform(); | ||
this.shapes = []; | ||
this.endPoint = new Property(this, exports.PropertyType.POSITION); | ||
this.gradientColors = new Gradient(); | ||
this.gradientType = exports.GradientFillType.LINEAR; | ||
this.highlightAngle = new Property(this, exports.PropertyType.NUMBER); | ||
this.highlightLength = new Property(this, exports.PropertyType.NUMBER); | ||
this.opacity = new Property(this, exports.PropertyType.OPACITY); | ||
this.startPoint = new Property(this, exports.PropertyType.POSITION); | ||
this.lineCapType = exports.LineCapType.ROUND; | ||
this.lineJoinType = exports.LineJoinType.ROUND; | ||
this.width = new Property(this, exports.PropertyType.STROKE_WIDTH); | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
this.contentPropertyIndex = json.cix; | ||
this.propertyIndex = json.ix; | ||
this.numProperties = json.np; | ||
this.shapes = json.it.map((jShape) => { | ||
try { | ||
if (jShape.ty !== "tr") { | ||
const nShape = this.createShape(jShape.ty); | ||
return nShape.fromJSON(jShape); | ||
} | ||
this.transform.fromJSON(jShape); | ||
} catch (e) { | ||
} | ||
return false; | ||
}).filter(Boolean); | ||
this.opacity.fromJSON(json.o); | ||
this.endPoint.fromJSON(json.e); | ||
this.gradientColors.fromJSON(json.g); | ||
this.gradientType = json.t; | ||
this.startPoint.fromJSON(json.s); | ||
if (this.gradientType === exports.GradientFillType.RADIAL) { | ||
this.highlightAngle.fromJSON(json.a); | ||
this.highlightLength.fromJSON(json.h); | ||
} | ||
this.lineCapType = json.lc in exports.LineCapType ? json.lc : exports.LineCapType.ROUND; | ||
this.lineJoinType = json.lj in exports.LineJoinType ? json.lj : exports.LineJoinType.ROUND; | ||
this.miterLimit = json.ml; | ||
this.width.fromJSON(json.w); | ||
return this; | ||
} | ||
createShape(type) { | ||
if (type === exports.ShapeType.PATH) { | ||
return new PathShape(this); | ||
} else if (type === exports.ShapeType.GROUP) { | ||
return new GroupShape(this); | ||
} else if (type === exports.ShapeType.FILL) { | ||
return new FillShape(this); | ||
} else if (type === exports.ShapeType.RECTANGLE) { | ||
return new RectangleShape(this); | ||
} else if (type === exports.ShapeType.ELLIPSE) { | ||
return new EllipseShape(this); | ||
} else if (type === exports.ShapeType.STROKE) { | ||
return new StrokeShape(this); | ||
} else if (type === exports.ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(this); | ||
} else if (type === exports.ShapeType.GRADIENT_STROKE) { | ||
return new GradientStrokeShape(this); | ||
} else if (type === exports.ShapeType.TRIM) { | ||
return new TrimShape(this); | ||
} else if (type === exports.ShapeType.MERGE) { | ||
return new MergeShape(this); | ||
} else if (type === exports.ShapeType.STAR) { | ||
return new StarShape(this); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
} | ||
addShape(shape2) { | ||
if (!(shape2 instanceof Shape)) | ||
shape2 = this.createShape(shape2); | ||
this.shapes.push(shape2); | ||
return shape2; | ||
} | ||
toJSON() { | ||
const shapes = JSON.parse(JSON.stringify(this.shapes)); | ||
shapes.push({ | ||
ty: "tr", | ||
nm: "Transform", | ||
...this.transform.toJSON() | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
o: this.opacity, | ||
e: this.endPoint, | ||
g: this.gradientColors, | ||
t: this.gradientType, | ||
a: this.highlightAngle, | ||
h: this.highlightLength, | ||
s: this.startPoint, | ||
lc: this.lineCapType, | ||
lj: this.lineJoinType, | ||
ml: this.miterLimit, | ||
w: this.width | ||
}); | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
bm: this.blendMode, | ||
cix: this.contentPropertyIndex, | ||
it: shapes, | ||
ix: this.propertyIndex, | ||
np: this.numProperties | ||
}; | ||
} | ||
@@ -1327,7 +939,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.copies.fromJSON(json.c); | ||
@@ -1351,9 +959,4 @@ this.composition = json.m; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
m: this.composition, | ||
@@ -1372,6 +975,50 @@ c: this.copies, | ||
} | ||
}; | ||
}); | ||
} | ||
} | ||
class StarShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.ShapeType.STAR; | ||
this.position = new Property(this, exports.PropertyType.POSITION); | ||
this.innerRadius = new Property(this, exports.PropertyType.NUMBER); | ||
this.innerRoundness = new Property(this, exports.PropertyType.NUMBER); | ||
this.outerRadius = new Property(this, exports.PropertyType.NUMBER); | ||
this.outerRoundness = new Property(this, exports.PropertyType.NUMBER); | ||
this.rotation = new Property(this, exports.PropertyType.ROTATION); | ||
this.points = new Property(this, exports.PropertyType.NUMBER); | ||
this.starType = exports.StarType.STAR; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.position.fromJSON(json.p); | ||
if (json.sy === 1) { | ||
this.innerRadius.fromJSON(json.ir); | ||
this.innerRoundness.fromJSON(json.is); | ||
} | ||
this.outerRadius.fromJSON(json.or); | ||
this.outerRoundness.fromJSON(json.os); | ||
this.rotation.fromJSON(json.r); | ||
this.points.fromJSON(json.pt); | ||
this.starType = json.sy; | ||
this.direction = json.d; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
p: this.position, | ||
...this.starType === 1 && {ir: this.innerRadius}, | ||
...this.starType === 1 && {is: this.innerRoundness}, | ||
or: this.outerRadius, | ||
os: this.outerRoundness, | ||
r: this.rotation, | ||
pt: this.points, | ||
sy: this.starType, | ||
d: this.direction | ||
}); | ||
} | ||
} | ||
class RoundedCornersShape extends Shape { | ||
@@ -1384,7 +1031,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.roundness.fromJSON(json.r); | ||
@@ -1394,54 +1037,75 @@ return this; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
r: this.roundness | ||
}; | ||
}); | ||
} | ||
} | ||
class ShapeLayer extends Layer { | ||
class MergeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.SHAPE; | ||
this.shapes = []; | ||
this.type = exports.ShapeType.MERGE; | ||
this.mergeMode = 1; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.mergeMode = json.mm; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
mm: this.mergeMode | ||
}); | ||
} | ||
} | ||
const createShapeFromType = (type, parent) => { | ||
if (type === exports.ShapeType.PATH) { | ||
return new PathShape(parent); | ||
} else if (type === exports.ShapeType.GROUP) { | ||
return new GroupShape(parent); | ||
} else if (type === exports.ShapeType.FILL) { | ||
return new FillShape(parent); | ||
} else if (type === exports.ShapeType.RECTANGLE) { | ||
return new RectangleShape(parent); | ||
} else if (type === exports.ShapeType.ELLIPSE) { | ||
return new EllipseShape(parent); | ||
} else if (type === exports.ShapeType.STROKE) { | ||
return new StrokeShape(parent); | ||
} else if (type === exports.ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(parent); | ||
} else if (type === exports.ShapeType.GRADIENT_STROKE) { | ||
return new GradientStrokeShape(parent); | ||
} else if (type === exports.ShapeType.TRIM) { | ||
return new TrimShape(parent); | ||
} else if (type === exports.ShapeType.MERGE) { | ||
return new MergeShape(parent); | ||
} else if (type === exports.ShapeType.STAR) { | ||
return new StarShape(parent); | ||
} else if (type === exports.ShapeType.ROUNDED_CORNERS) { | ||
return new RoundedCornersShape(parent); | ||
} else if (type === exports.ShapeType.REPEATER) { | ||
return new RepeaterShape(parent); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
}; | ||
class Character { | ||
constructor() { | ||
this.character = ""; | ||
this.fontSize = 0; | ||
this.fontStyle = ""; | ||
this.fontWeight = 0; | ||
this.data = []; | ||
this.fontFamily = ""; | ||
} | ||
createShape(type) { | ||
if (type === exports.ShapeType.PATH) { | ||
return new PathShape(this); | ||
} else if (type === exports.ShapeType.GROUP) { | ||
return new GroupShape(this); | ||
} else if (type === exports.ShapeType.FILL) { | ||
return new FillShape(this); | ||
} else if (type === exports.ShapeType.RECTANGLE) { | ||
return new RectangleShape(this); | ||
} else if (type === exports.ShapeType.ELLIPSE) { | ||
return new EllipseShape(this); | ||
} else if (type === exports.ShapeType.STROKE) { | ||
return new StrokeShape(this); | ||
} else if (type === exports.ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(this); | ||
} else if (type === exports.ShapeType.TRIM) { | ||
return new TrimShape(this); | ||
} else if (type === exports.ShapeType.MERGE) { | ||
return new MergeShape(this); | ||
} else if (type === exports.ShapeType.STAR) { | ||
return new StarShape(this); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
return createShapeFromType(type, this); | ||
} | ||
addShape(shape) { | ||
if (!(shape instanceof Shape)) | ||
shape = this.createShape(shape); | ||
this.shapes.push(shape); | ||
return shape; | ||
} | ||
createShapeFromJSON(json) { | ||
try { | ||
const shape = this.createShape(json.ty); | ||
return shape.fromJSON(json); | ||
const shape2 = this.createShape(json.ty); | ||
return shape2.fromJSON(json); | ||
} catch (e) { | ||
@@ -1452,5 +1116,202 @@ throw new Error(`Unable to create shape from JSON: ${json.ty}`); | ||
fromJSON(json) { | ||
this.character = json.ch; | ||
this.fontSize = json.size; | ||
this.fontStyle = json.style; | ||
this.fontWeight = json.w; | ||
this.fontFamily = json.fFamily; | ||
if ("data" in json && json.data.shapes) { | ||
this.data = json.data.shapes.map((shapeJSON) => this.createShapeFromJSON(shapeJSON)); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
const shapes2 = this.data.map((shape2) => shape2.toJSON()); | ||
return { | ||
ch: this.character, | ||
size: this.fontSize, | ||
style: this.fontStyle, | ||
w: this.fontWeight, | ||
data: {shapes: shapes2.length ? shapes2 : void 0}, | ||
fFamily: this.fontFamily | ||
}; | ||
} | ||
} | ||
class Font { | ||
constructor() { | ||
this.fName = ""; | ||
this.fFamily = ""; | ||
this.fStyle = ""; | ||
this.ascent = 0; | ||
this.fPath = ""; | ||
this.fWeight = ""; | ||
this.origin = -1; | ||
this.fClass = ""; | ||
} | ||
fromJSON(json) { | ||
this.fName = json.fName; | ||
this.fFamily = json.fFamily; | ||
this.fStyle = json.fStyle; | ||
this.ascent = json.ascent; | ||
this.fPath = json.fPath; | ||
this.fWeight = json.fWeight; | ||
this.origin = json.origin; | ||
this.fClass = json.fClass; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
fName: this.fName, | ||
fFamily: this.fFamily, | ||
fStyle: this.fStyle, | ||
ascent: this.ascent, | ||
...!(this.fPath === "") && {fPath: this.fPath}, | ||
...!(this.fWeight === "") && {fWeight: this.fWeight}, | ||
...!(this.origin >= 0) && {origin: this.origin}, | ||
...!(this.fClass === "") && {fClass: this.fClass} | ||
}; | ||
} | ||
} | ||
class FontList { | ||
constructor() { | ||
this.list = []; | ||
} | ||
fromJSON(json) { | ||
this.list = json.list.map((fontJSON) => new Font().fromJSON(fontJSON)); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
list: this.list | ||
}; | ||
} | ||
} | ||
class EffectValue { | ||
constructor(type) { | ||
this.name = ""; | ||
this.index = 0; | ||
this.value = new Property(this, exports.PropertyType.EFFECT_VALUE); | ||
this.type = type; | ||
} | ||
fromJSON(json) { | ||
this.name = json.nm; | ||
this.matchName = json.mn; | ||
this.index = json.ix; | ||
this.value.fromJSON(json.v); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
nm: this.name, | ||
mn: this.matchName, | ||
ix: this.index, | ||
v: this.value | ||
}; | ||
} | ||
} | ||
class Effect { | ||
constructor(type = exports.EffectType.NONE) { | ||
this.name = ""; | ||
this.index = 0; | ||
this.enabled = true; | ||
this.values = []; | ||
this.type = type; | ||
} | ||
fromJSON(json) { | ||
var _a; | ||
this.type = json.ty; | ||
this.name = json.nm; | ||
this.matchName = json.mn; | ||
this.numberOfProperties = json.np; | ||
this.index = json.ix; | ||
this.enabled = (_a = json.en) != null ? _a : true; | ||
this.values = json.ef.map((valueJSON) => new EffectValue(valueJSON.ty).fromJSON(valueJSON)); | ||
return this; | ||
} | ||
toJSON() { | ||
const values = this.values.map((value) => value.toJSON()); | ||
return { | ||
ty: this.type, | ||
nm: this.name, | ||
np: this.numberOfProperties, | ||
mn: this.matchName, | ||
ix: this.index, | ||
ef: values, | ||
en: this.enabled ? 1 : this.enabled | ||
}; | ||
} | ||
} | ||
class Mask { | ||
constructor() { | ||
this.isInverted = false; | ||
this.name = ""; | ||
this.opacity = new Property(this, exports.PropertyType.OPACITY); | ||
this.points = new Property(this, exports.PropertyType.POINTS); | ||
this.mode = exports.MaskMode.Add; | ||
this.expansion = new Property(this, exports.PropertyType.EXPANSION); | ||
} | ||
fromJSON(json) { | ||
this.isInverted = Boolean(json.inv); | ||
this.mode = json.mode; | ||
this.name = json.nm; | ||
this.points.fromJSON(json.pt); | ||
this.opacity.fromJSON(json.o); | ||
this.expansion.fromJSON(json.x); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
inv: this.isInverted, | ||
mode: this.mode, | ||
nm: this.name, | ||
o: this.opacity, | ||
pt: this.points, | ||
x: this.expansion | ||
}; | ||
} | ||
} | ||
class Layer { | ||
constructor(parent) { | ||
this.autoOrient = false; | ||
this.blendMode = exports.BlendMode.NORMAL; | ||
this.classNames = []; | ||
this.height = 0; | ||
this.id = ""; | ||
this.inPoint = 0; | ||
this.is3D = false; | ||
this.name = ""; | ||
this.outPoint = 0; | ||
this.startTime = 0; | ||
this.timeStretch = 1; | ||
this.width = 0; | ||
this.masks = []; | ||
this.effects = []; | ||
this.transform = new Transform(); | ||
this.parent = parent; | ||
} | ||
get colors() { | ||
const colors = new Set(); | ||
const registry = useRegistry(); | ||
[...registry.keys()].filter((p) => registry.get(p) === this && p.type === exports.PropertyType.COLOR).forEach((cp) => { | ||
cp.values.forEach((v) => { | ||
colors.add(JSON.stringify(v.value)); | ||
}); | ||
}); | ||
return Array.from(colors).map((c) => JSON.parse(c)); | ||
} | ||
get hasMask() { | ||
return this.masks.length > 0; | ||
} | ||
get totalFrames() { | ||
return this.outPoint - this.inPoint; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
@@ -1481,3 +1342,8 @@ this.id = json.ln; | ||
} | ||
this.shapes = json.shapes.map((jShape) => this.createShapeFromJSON(jShape)).filter(Boolean); | ||
if ("masksProperties" in json) { | ||
this.masks = json.masksProperties.map((maskJson) => new Mask().fromJSON(maskJson)); | ||
} | ||
if ("ef" in json) { | ||
this.effects = json.ef.map((effectJson) => new Effect().fromJSON(effectJson)); | ||
} | ||
return this; | ||
@@ -1487,27 +1353,28 @@ } | ||
var _a; | ||
const masks2 = this.hasMask ? this.masks.map((mask) => mask.toJSON()) : void 0; | ||
const effects2 = this.effects.length ? this.effects.map((effect) => effect.toJSON()) : void 0; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
shapes: this.shapes.map((shape) => shape.toJSON()), | ||
ln: this.id, | ||
ty: this.type, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ln: this.id, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
sr: this.timeStretch, | ||
ks: this.transform.toJSON(), | ||
ao: this.autoOrient ? 1 : 0, | ||
hasMask: this.hasMask || void 0, | ||
masksProperties: masks2, | ||
ef: effects2, | ||
w: this.width, | ||
h: this.height, | ||
ip: this.inPoint, | ||
op: this.outPoint, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
bm: this.blendMode | ||
}; | ||
@@ -1517,2 +1384,85 @@ } | ||
class GroupLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.GROUP; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
return this; | ||
} | ||
} | ||
class ImageLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.IMAGE; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
refId: this.refId | ||
}); | ||
} | ||
} | ||
class PrecompositionLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.PRECOMPOSITION; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
refId: this.refId | ||
}); | ||
} | ||
} | ||
class ShapeLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = exports.LayerType.SHAPE; | ||
this.shapes = []; | ||
} | ||
createShape(type) { | ||
return createShapeFromType(type, this); | ||
} | ||
addShape(shape2) { | ||
if (!(shape2 instanceof Shape)) | ||
shape2 = this.createShape(shape2); | ||
this.shapes.push(shape2); | ||
return shape2; | ||
} | ||
createShapeFromJSON(json) { | ||
try { | ||
const shape2 = this.createShape(json.ty); | ||
return shape2.fromJSON(json); | ||
} catch (e) { | ||
throw new Error(`Unable to create shape from JSON: ${json.ty}`); | ||
} | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.shapes = json.shapes.map((jShape) => this.createShapeFromJSON(jShape)).filter(Boolean); | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
shapes: this.shapes.map((shape2) => shape2.toJSON()) | ||
}); | ||
} | ||
} | ||
class SolidLayer extends Layer { | ||
@@ -1527,32 +1477,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
super.fromJSON(json); | ||
this.solidColor = json.sc; | ||
@@ -1564,31 +1485,8 @@ this.solidHeight = json.sh; | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
sc: this.solidColor, | ||
sh: this.solidHeight, | ||
sw: this.solidWidth, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
sw: this.solidWidth | ||
}); | ||
} | ||
@@ -1603,32 +1501,3 @@ } | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
super.fromJSON(json); | ||
this.textData = json.t; | ||
@@ -1638,29 +1507,6 @@ return this; | ||
toJSON() { | ||
var _a; | ||
return { | ||
ty: this.type, | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
t: this.textData | ||
}; | ||
}); | ||
} | ||
@@ -1715,3 +1561,3 @@ } | ||
this.keywords = []; | ||
this.generator = "@lottiefiles/lottie-js 0.3.7"; | ||
this.generator = "@lottiefiles/lottie-js 0.3.9"; | ||
this.parent = parent; | ||
@@ -1753,2 +1599,3 @@ } | ||
this.fonts = new FontList(); | ||
this.characters = []; | ||
} | ||
@@ -1923,2 +1770,5 @@ static async fromURL(url) { | ||
} | ||
if ("chars" in json) { | ||
this.characters = json.chars.map((charJSON) => new Character().fromJSON(charJSON)); | ||
} | ||
return this; | ||
@@ -1991,2 +1841,3 @@ } | ||
} | ||
const chars = this.characters.map((char) => char.toJSON()); | ||
return { | ||
@@ -2005,3 +1856,4 @@ assets: this.assets, | ||
w: this.width, | ||
...this.fonts.list.length > 0 && {fonts: this.fonts.toJSON()} | ||
...this.fonts.list.length > 0 && {fonts: this.fonts.toJSON()}, | ||
chars: chars.length > 0 ? chars : void 0 | ||
}; | ||
@@ -2011,27 +1863,2 @@ } | ||
class Mask { | ||
constructor() { | ||
this.isInverted = false; | ||
this.name = ""; | ||
this.mode = exports.MaskMode.Add; | ||
} | ||
fromJSON(json) { | ||
this.isInverted = json.inv; | ||
this.mode = json.mode; | ||
this.name = json.nm; | ||
this.points = json.pt; | ||
this.opacity = json.o; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
inv: this.isInverted, | ||
mode: this.mode, | ||
nm: this.name, | ||
o: this.opacity, | ||
pt: this.points | ||
}; | ||
} | ||
} | ||
exports.Animation = Animation; | ||
@@ -2038,0 +1865,0 @@ exports.Asset = Asset; |
@@ -105,2 +105,3 @@ declare abstract class Asset { | ||
POSITION = "p", | ||
POINTS = "pt", | ||
ROTATION = "r", | ||
@@ -123,3 +124,4 @@ ROTATION_X = "rx", | ||
ORIENTATION = "or", | ||
GRADIENT = "gr" | ||
GRADIENT = "gr", | ||
EFFECT_VALUE = "v" | ||
} | ||
@@ -168,2 +170,33 @@ | ||
declare enum EffectType { | ||
NONE = 0, | ||
CUSTOM = 5, | ||
PAINT_OVER_TRANSPARENT = 7, | ||
TINT = 20, | ||
FILL = 21, | ||
STROKE = 22, | ||
TRITONE = 23, | ||
PRO_LEVELS = 24, | ||
DROP_SHADOW = 25, | ||
RADIAL_WIPE = 26, | ||
DISPLACEMENT_MAP = 27, | ||
MATTE3 = 28, | ||
GAUSSIAN_BLUR = 29, | ||
MESH_WRAP = 31, | ||
WAVY = 32, | ||
SPHERIZE = 33, | ||
PUPPET = 34 | ||
} | ||
declare enum EffectValueType { | ||
SLIDER = 0, | ||
ANGLE = 1, | ||
COLOR = 2, | ||
POINT = 3, | ||
CHECKBOX = 4, | ||
IGNORED = 6, | ||
DROPDOWN = 7, | ||
LAYER = 10 | ||
} | ||
interface Value { | ||
@@ -221,2 +254,29 @@ toJSON(): any; | ||
declare class GradientStop { | ||
offset: number; | ||
color: number[]; | ||
constructor(offset?: number, color?: number[]); | ||
get hasAlpha(): boolean; | ||
get red(): number; | ||
get green(): number; | ||
get blue(): number; | ||
get alpha(): number | undefined; | ||
} | ||
declare class GradientColorsProperty extends Property { | ||
colorCount: number; | ||
private keyframeValue; | ||
keyframeHasAlpha(index: number): boolean; | ||
keframeStops(index: number): GradientStop[]; | ||
setKeyframeStops(index: number, stops: GradientStop[]): void; | ||
addKeyframe(frame: number, stops: GradientStop[]): KeyFrame; | ||
private stopsToArray; | ||
} | ||
declare class Gradient { | ||
gradientColors: GradientColorsProperty; | ||
get colorCount(): number; | ||
set colorCount(count: number); | ||
toJSON(): Record<string, any>; | ||
fromJSON(json: Record<string, any>): Gradient; | ||
} | ||
declare class Transform { | ||
@@ -238,10 +298,42 @@ anchor: Property; | ||
declare class EffectValue { | ||
name: string; | ||
matchName?: string; | ||
index: number; | ||
value: Property; | ||
type: EffectValueType; | ||
constructor(type: EffectValueType); | ||
fromJSON(json: Record<string, any>): EffectValue; | ||
toJSON(): Record<string, any>; | ||
} | ||
declare class Effect { | ||
name: string; | ||
matchName?: string; | ||
numberOfProperties?: number; | ||
index: number; | ||
enabled: boolean; | ||
type: EffectType; | ||
values: EffectValue[]; | ||
constructor(type?: EffectType); | ||
fromJSON(json: Record<string, any>): Effect; | ||
toJSON(): Record<string, any>; | ||
} | ||
declare class Mask { | ||
isInverted: boolean; | ||
name: string; | ||
opacity: Property; | ||
points: Property; | ||
mode: MaskMode; | ||
expansion: Property; | ||
fromJSON(json: Record<string, any>): Mask; | ||
toJSON(): Record<string, any>; | ||
} | ||
declare abstract class Layer { | ||
abstract readonly type: LayerType; | ||
abstract fromJSON(json: Record<string, any>): Layer; | ||
abstract toJSON(key?: string): Record<string, any> | undefined; | ||
autoOrient: boolean; | ||
blendMode: BlendMode; | ||
classNames: string[]; | ||
effects: any; | ||
height: number; | ||
@@ -261,2 +353,4 @@ id: string; | ||
matchName?: string; | ||
masks: Mask[]; | ||
effects: Effect[]; | ||
transform: Transform; | ||
@@ -266,3 +360,6 @@ parent?: any; | ||
get colors(): string[]; | ||
get hasMask(): boolean; | ||
get totalFrames(): number; | ||
fromJSON(json: Record<string, any>): Layer; | ||
toJSON(): Record<string, any>; | ||
} | ||
@@ -273,3 +370,2 @@ | ||
fromJSON(json: Record<string, any>): GroupLayer; | ||
toJSON(): Record<string, any>; | ||
} | ||
@@ -292,33 +388,4 @@ | ||
declare class GradientStop { | ||
offset: number; | ||
color: number[]; | ||
constructor(offset?: number, color?: number[]); | ||
get hasAlpha(): boolean; | ||
get red(): number; | ||
get green(): number; | ||
get blue(): number; | ||
get alpha(): number | undefined; | ||
} | ||
declare class GradientColorsProperty extends Property { | ||
colorCount: number; | ||
private keyframeValue; | ||
keyframeHasAlpha(index: number): boolean; | ||
keframeStops(index: number): GradientStop[]; | ||
setKeyframeStops(index: number, stops: GradientStop[]): void; | ||
addKeyframe(frame: number, stops: GradientStop[]): KeyFrame; | ||
private stopsToArray; | ||
} | ||
declare class Gradient { | ||
gradientColors: GradientColorsProperty; | ||
get colorCount(): number; | ||
set colorCount(count: number); | ||
toJSON(): Record<string, any>; | ||
fromJSON(json: Record<string, any>): Gradient; | ||
} | ||
declare abstract class Shape { | ||
abstract readonly type: ShapeType; | ||
abstract fromJSON(json: Record<string, any>): Shape; | ||
abstract toJSON(): Record<string, any>; | ||
classNames?: string; | ||
@@ -333,2 +400,4 @@ matchName?: string; | ||
constructor(parent: any); | ||
fromJSON(json: Record<string, any>): Shape; | ||
toJSON(): Record<string, any>; | ||
} | ||
@@ -528,4 +597,17 @@ | ||
declare class Character { | ||
character: string; | ||
fontSize: number; | ||
fontStyle: string; | ||
fontWeight: number; | ||
data: Shape[]; | ||
fontFamily: string; | ||
createShape(type: ShapeType): Shape; | ||
createShapeFromJSON(json: Record<string, any>): Shape; | ||
fromJSON(json: Record<string, any>): Character; | ||
toJSON(): Record<string, any>; | ||
} | ||
declare class Font { | ||
fname: string; | ||
fName: string; | ||
fFamily: string; | ||
@@ -582,2 +664,3 @@ fStyle: string; | ||
fonts: FontList; | ||
characters: Character[]; | ||
static fromURL(url: string): Promise<Animation>; | ||
@@ -608,12 +691,2 @@ static isLottie(json: Record<string, any>): boolean; | ||
declare class Mask { | ||
isInverted: boolean; | ||
name: string; | ||
opacity: any; | ||
points: any; | ||
mode: MaskMode; | ||
fromJSON(json: Record<string, any>): Mask; | ||
toJSON(): Record<string, any>; | ||
} | ||
declare function useRegistry(): Map<Property, any>; | ||
@@ -624,2 +697,2 @@ | ||
export { Animation, Asset, AssetType, BlendMode, Color, ColorRgb, ColorRgba, EllipseShape, FillRuleType, FillShape, Gradient, GradientFillShape, GradientFillType, GradientStop, GradientStrokeShape, GradientStrokeType, GroupLayer, GroupShape, ImageAsset, ImageLayer, KeyFrame, Layer, LayerType, LineCapType, LineJoinType, Marker, Mask, MaskMode, MatteMode, MergeShape, Meta, PathShape, PrecompositionAsset, PrecompositionLayer, Property, PropertyType, RectangleShape, RepeaterComposite, RepeaterShape, RoundedCornersShape, Shape, ShapeLayer, ShapeType, SolidLayer, StarShape, StarType, StrokeShape, TextLayer, Transform, TrimMode, TrimShape, Value, hexToRgba, rgbaToHex, useRegistry }; | ||
export { Animation, Asset, AssetType, BlendMode, Color, ColorRgb, ColorRgba, EffectType, EffectValueType, EllipseShape, FillRuleType, FillShape, Gradient, GradientFillShape, GradientFillType, GradientStop, GradientStrokeShape, GradientStrokeType, GroupLayer, GroupShape, ImageAsset, ImageLayer, KeyFrame, Layer, LayerType, LineCapType, LineJoinType, Marker, Mask, MaskMode, MatteMode, MergeShape, Meta, PathShape, PrecompositionAsset, PrecompositionLayer, Property, PropertyType, RectangleShape, RepeaterComposite, RepeaterShape, RoundedCornersShape, Shape, ShapeLayer, ShapeType, SolidLayer, StarShape, StarType, StrokeShape, TextLayer, Transform, TrimMode, TrimShape, Value, hexToRgba, rgbaToHex, useRegistry }; |
/*! | ||
* @lottiefiles/lottie-js - v0.3.7 | ||
* Compiled Wed, 16 Mar 2022 06:55:24 UTC | ||
* @lottiefiles/lottie-js - v0.3.9 | ||
* Compiled Wed, 30 Mar 2022 08:38:45 UTC | ||
* | ||
@@ -27,3 +27,3 @@ * Copyright LottieFiles. All rights reserved. | ||
h: this.height, | ||
i: this.id, | ||
id: this.id, | ||
p: this.data, | ||
@@ -155,2 +155,3 @@ u: this.path, | ||
PropertyType2["POSITION"] = "p"; | ||
PropertyType2["POINTS"] = "pt"; | ||
PropertyType2["ROTATION"] = "r"; | ||
@@ -174,2 +175,3 @@ PropertyType2["ROTATION_X"] = "rx"; | ||
PropertyType2["GRADIENT"] = "gr"; | ||
PropertyType2["EFFECT_VALUE"] = "v"; | ||
})(PropertyType || (PropertyType = {})); | ||
@@ -223,17 +225,35 @@ | ||
class FontList { | ||
constructor() { | ||
this.list = []; | ||
} | ||
fromJSON(json) { | ||
this.list = json.list; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
list: this.list | ||
}; | ||
} | ||
} | ||
var EffectType; | ||
(function(EffectType2) { | ||
EffectType2[EffectType2["NONE"] = 0] = "NONE"; | ||
EffectType2[EffectType2["CUSTOM"] = 5] = "CUSTOM"; | ||
EffectType2[EffectType2["PAINT_OVER_TRANSPARENT"] = 7] = "PAINT_OVER_TRANSPARENT"; | ||
EffectType2[EffectType2["TINT"] = 20] = "TINT"; | ||
EffectType2[EffectType2["FILL"] = 21] = "FILL"; | ||
EffectType2[EffectType2["STROKE"] = 22] = "STROKE"; | ||
EffectType2[EffectType2["TRITONE"] = 23] = "TRITONE"; | ||
EffectType2[EffectType2["PRO_LEVELS"] = 24] = "PRO_LEVELS"; | ||
EffectType2[EffectType2["DROP_SHADOW"] = 25] = "DROP_SHADOW"; | ||
EffectType2[EffectType2["RADIAL_WIPE"] = 26] = "RADIAL_WIPE"; | ||
EffectType2[EffectType2["DISPLACEMENT_MAP"] = 27] = "DISPLACEMENT_MAP"; | ||
EffectType2[EffectType2["MATTE3"] = 28] = "MATTE3"; | ||
EffectType2[EffectType2["GAUSSIAN_BLUR"] = 29] = "GAUSSIAN_BLUR"; | ||
EffectType2[EffectType2["MESH_WRAP"] = 31] = "MESH_WRAP"; | ||
EffectType2[EffectType2["WAVY"] = 32] = "WAVY"; | ||
EffectType2[EffectType2["SPHERIZE"] = 33] = "SPHERIZE"; | ||
EffectType2[EffectType2["PUPPET"] = 34] = "PUPPET"; | ||
})(EffectType || (EffectType = {})); | ||
var EffectValueType; | ||
(function(EffectValueType2) { | ||
EffectValueType2[EffectValueType2["SLIDER"] = 0] = "SLIDER"; | ||
EffectValueType2[EffectValueType2["ANGLE"] = 1] = "ANGLE"; | ||
EffectValueType2[EffectValueType2["COLOR"] = 2] = "COLOR"; | ||
EffectValueType2[EffectValueType2["POINT"] = 3] = "POINT"; | ||
EffectValueType2[EffectValueType2["CHECKBOX"] = 4] = "CHECKBOX"; | ||
EffectValueType2[EffectValueType2["IGNORED"] = 6] = "IGNORED"; | ||
EffectValueType2[EffectValueType2["DROPDOWN"] = 7] = "DROPDOWN"; | ||
EffectValueType2[EffectValueType2["LAYER"] = 10] = "LAYER"; | ||
})(EffectValueType || (EffectValueType = {})); | ||
class KeyFrame { | ||
@@ -383,291 +403,2 @@ constructor(frame = 0, value = 0) { | ||
class Transform { | ||
constructor() { | ||
this.anchor = new Property(this, PropertyType.ANCHOR, [new KeyFrame(0, [0, 0])]); | ||
this.opacity = new Property(this, PropertyType.OPACITY, [new KeyFrame(0, 100)]); | ||
this.position = new Property(this, PropertyType.POSITION, [new KeyFrame(0, [0, 0])]); | ||
this.rotation = new Property(this, PropertyType.ROTATION, [new KeyFrame(0, 0)]); | ||
this.scale = new Property(this, PropertyType.SCALE, [new KeyFrame(0, [100, 100])]); | ||
this.skew = new Property(this, PropertyType.SKEW); | ||
this.skewAxis = new Property(this, PropertyType.SKEW_AXIS); | ||
} | ||
fromJSON(json) { | ||
this.rotation = "r" in json ? new Property(this, PropertyType.ROTATION).fromJSON(json.r) : void 0; | ||
"o" in json && this.opacity.fromJSON(json.o); | ||
"p" in json && this.position.fromJSON(json.p); | ||
"a" in json && this.anchor.fromJSON(json.a); | ||
"s" in json && this.scale.fromJSON(json.s); | ||
this.skew = "sk" in json ? new Property(this, PropertyType.SKEW).fromJSON(json.sk) : void 0; | ||
this.skewAxis = "sa" in json ? new Property(this, PropertyType.SKEW_AXIS).fromJSON(json.sa) : void 0; | ||
if ("or" in json) { | ||
this.orientation = new Property(this, PropertyType.ORIENTATION).fromJSON(json.or); | ||
} | ||
if ("rx" in json) { | ||
this.rotationX = new Property(this, PropertyType.ROTATION_X).fromJSON(json.rx); | ||
} | ||
if ("ry" in json) { | ||
this.rotationY = new Property(this, PropertyType.ROTATION_Y).fromJSON(json.ry); | ||
} | ||
if ("rz" in json) { | ||
this.rotationZ = new Property(this, PropertyType.ROTATION_Z).fromJSON(json.rz); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
a: this.anchor, | ||
o: this.opacity, | ||
p: this.position, | ||
r: this.rotation, | ||
s: this.scale, | ||
sk: this.skew, | ||
sa: this.skewAxis, | ||
rx: this.rotationX, | ||
ry: this.rotationY, | ||
rz: this.rotationZ, | ||
or: this.orientation | ||
}; | ||
} | ||
} | ||
class Layer { | ||
constructor(parent) { | ||
this.autoOrient = false; | ||
this.blendMode = BlendMode.NORMAL; | ||
this.classNames = []; | ||
this.height = 0; | ||
this.id = ""; | ||
this.inPoint = 0; | ||
this.is3D = false; | ||
this.name = ""; | ||
this.outPoint = 0; | ||
this.startTime = 0; | ||
this.timeStretch = 1; | ||
this.width = 0; | ||
this.transform = new Transform(); | ||
this.parent = parent; | ||
} | ||
get colors() { | ||
const colors = new Set(); | ||
const registry = useRegistry(); | ||
[...registry.keys()].filter((p) => registry.get(p) === this && p.type === PropertyType.COLOR).forEach((cp) => { | ||
cp.values.forEach((v) => { | ||
colors.add(JSON.stringify(v.value)); | ||
}); | ||
}); | ||
return Array.from(colors).map((c) => JSON.parse(c)); | ||
} | ||
get totalFrames() { | ||
return this.outPoint - this.inPoint; | ||
} | ||
} | ||
class GroupLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.GROUP; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
} | ||
} | ||
class ImageLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.IMAGE; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ty: this.type, | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
refId: this.refId | ||
}; | ||
} | ||
} | ||
class PrecompositionLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.PRECOMPOSITION; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
refId: this.refId, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
} | ||
} | ||
class GradientStop { | ||
@@ -776,2 +507,51 @@ constructor(offset = 0, color = []) { | ||
class Transform { | ||
constructor() { | ||
this.anchor = new Property(this, PropertyType.ANCHOR, [new KeyFrame(0, [0, 0])]); | ||
this.opacity = new Property(this, PropertyType.OPACITY, [new KeyFrame(0, 100)]); | ||
this.position = new Property(this, PropertyType.POSITION, [new KeyFrame(0, [0, 0])]); | ||
this.rotation = new Property(this, PropertyType.ROTATION, [new KeyFrame(0, 0)]); | ||
this.scale = new Property(this, PropertyType.SCALE, [new KeyFrame(0, [100, 100])]); | ||
this.skew = new Property(this, PropertyType.SKEW); | ||
this.skewAxis = new Property(this, PropertyType.SKEW_AXIS); | ||
} | ||
fromJSON(json) { | ||
this.rotation = "r" in json ? new Property(this, PropertyType.ROTATION).fromJSON(json.r) : void 0; | ||
"o" in json && this.opacity.fromJSON(json.o); | ||
"p" in json && this.position.fromJSON(json.p); | ||
"a" in json && this.anchor.fromJSON(json.a); | ||
"s" in json && this.scale.fromJSON(json.s); | ||
this.skew = "sk" in json ? new Property(this, PropertyType.SKEW).fromJSON(json.sk) : void 0; | ||
this.skewAxis = "sa" in json ? new Property(this, PropertyType.SKEW_AXIS).fromJSON(json.sa) : void 0; | ||
if ("or" in json) { | ||
this.orientation = new Property(this, PropertyType.ORIENTATION).fromJSON(json.or); | ||
} | ||
if ("rx" in json) { | ||
this.rotationX = new Property(this, PropertyType.ROTATION_X).fromJSON(json.rx); | ||
} | ||
if ("ry" in json) { | ||
this.rotationY = new Property(this, PropertyType.ROTATION_Y).fromJSON(json.ry); | ||
} | ||
if ("rz" in json) { | ||
this.rotationZ = new Property(this, PropertyType.ROTATION_Z).fromJSON(json.rz); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
a: this.anchor, | ||
o: this.opacity, | ||
p: this.position, | ||
r: this.rotation, | ||
s: this.scale, | ||
sk: this.skew, | ||
sa: this.skewAxis, | ||
rx: this.rotationX, | ||
ry: this.rotationY, | ||
rz: this.rotationZ, | ||
or: this.orientation | ||
}; | ||
} | ||
} | ||
class Shape { | ||
@@ -782,2 +562,20 @@ constructor(parent) { | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name | ||
}; | ||
} | ||
} | ||
@@ -794,7 +592,3 @@ | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.position.fromJSON(json.p); | ||
@@ -806,13 +600,8 @@ this.size.fromJSON(json.s); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
p: this.position, | ||
s: this.size, | ||
d: this.direction | ||
}; | ||
}); | ||
} | ||
@@ -831,7 +620,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
@@ -844,9 +629,4 @@ this.color.fromJSON(json.c); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -856,3 +636,3 @@ c: this.color, | ||
o: this.opacity | ||
}; | ||
}); | ||
} | ||
@@ -876,7 +656,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
@@ -896,9 +672,4 @@ this.endPoint.fromJSON(json.e); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -913,93 +684,60 @@ e: this.endPoint, | ||
s: this.startPoint | ||
}; | ||
}); | ||
} | ||
} | ||
class GradientStrokeShape extends Shape { | ||
class GroupShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = ShapeType.GRADIENT_STROKE; | ||
this.type = ShapeType.GROUP; | ||
this.blendMode = BlendMode.NORMAL; | ||
this.endPoint = new Property(this, PropertyType.POSITION); | ||
this.gradientColors = new Gradient(); | ||
this.gradientType = GradientFillType.LINEAR; | ||
this.highlightAngle = new Property(this, PropertyType.NUMBER); | ||
this.highlightLength = new Property(this, PropertyType.NUMBER); | ||
this.opacity = new Property(this, PropertyType.OPACITY); | ||
this.startPoint = new Property(this, PropertyType.POSITION); | ||
this.lineCapType = LineCapType.ROUND; | ||
this.lineJoinType = LineJoinType.ROUND; | ||
this.width = new Property(this, PropertyType.STROKE_WIDTH); | ||
this.isHidden = false; | ||
this.numProperties = 0; | ||
this.transform = new Transform(); | ||
this.shapes = []; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
this.opacity.fromJSON(json.o); | ||
this.endPoint.fromJSON(json.e); | ||
this.gradientColors.fromJSON(json.g); | ||
this.gradientType = json.t; | ||
this.startPoint.fromJSON(json.s); | ||
if (this.gradientType === GradientFillType.RADIAL) { | ||
this.highlightAngle.fromJSON(json.a); | ||
this.highlightLength.fromJSON(json.h); | ||
} | ||
this.lineCapType = json.lc in LineCapType ? json.lc : LineCapType.ROUND; | ||
this.lineJoinType = json.lj in LineJoinType ? json.lj : LineJoinType.ROUND; | ||
this.miterLimit = json.ml; | ||
this.width.fromJSON(json.w); | ||
this.contentPropertyIndex = json.cix; | ||
this.propertyIndex = json.ix; | ||
this.numProperties = json.np; | ||
this.shapes = json.it.map((jShape) => { | ||
try { | ||
if (jShape.ty !== "tr") { | ||
const nShape = this.createShape(jShape.ty); | ||
return nShape.fromJSON(jShape); | ||
} else { | ||
this.transform.fromJSON(jShape); | ||
} | ||
} catch (e) { | ||
} | ||
return false; | ||
}).filter(Boolean); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
bm: this.blendMode, | ||
o: this.opacity, | ||
e: this.endPoint, | ||
g: this.gradientColors, | ||
t: this.gradientType, | ||
a: this.highlightAngle, | ||
h: this.highlightLength, | ||
s: this.startPoint, | ||
lc: this.lineCapType, | ||
lj: this.lineJoinType, | ||
ml: this.miterLimit, | ||
w: this.width | ||
}; | ||
createShape(type) { | ||
return createShapeFromType(type, this); | ||
} | ||
} | ||
class MergeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = ShapeType.MERGE; | ||
this.mergeMode = 1; | ||
addShape(shape3) { | ||
if (!(shape3 instanceof Shape)) | ||
shape3 = this.createShape(shape3); | ||
this.shapes.push(shape3); | ||
return shape3; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
this.mergeMode = json.mm; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
mm: this.mergeMode | ||
}; | ||
const json = super.toJSON(); | ||
const shapes = JSON.parse(JSON.stringify(this.shapes)); | ||
shapes.push({ | ||
ty: "tr", | ||
nm: "Transform", | ||
...this.transform.toJSON() | ||
}); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
cix: this.contentPropertyIndex, | ||
it: shapes, | ||
ix: this.propertyIndex, | ||
np: this.numProperties | ||
}); | ||
} | ||
@@ -1015,7 +753,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.itemIndex = json.ind; | ||
@@ -1028,9 +762,4 @@ this.shapeIndex = json.ix; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
ind: this.itemIndex, | ||
@@ -1040,3 +769,3 @@ ix: this.shapeIndex, | ||
ks: this.vertices | ||
}; | ||
}); | ||
} | ||
@@ -1054,7 +783,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.direction = json.d; | ||
@@ -1067,9 +792,4 @@ this.position.fromJSON(json.p); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
d: this.direction, | ||
@@ -1079,59 +799,6 @@ p: this.position, | ||
s: this.size | ||
}; | ||
}); | ||
} | ||
} | ||
class StarShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = ShapeType.STAR; | ||
this.position = new Property(this, PropertyType.POSITION); | ||
this.innerRadius = new Property(this, PropertyType.NUMBER); | ||
this.innerRoundness = new Property(this, PropertyType.NUMBER); | ||
this.outerRadius = new Property(this, PropertyType.NUMBER); | ||
this.outerRoundness = new Property(this, PropertyType.NUMBER); | ||
this.rotation = new Property(this, PropertyType.ROTATION); | ||
this.points = new Property(this, PropertyType.NUMBER); | ||
this.starType = StarType.STAR; | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
this.position.fromJSON(json.p); | ||
if (json.sy === 1) { | ||
this.innerRadius.fromJSON(json.ir); | ||
this.innerRoundness.fromJSON(json.is); | ||
} | ||
this.outerRadius.fromJSON(json.or); | ||
this.outerRoundness.fromJSON(json.os); | ||
this.rotation.fromJSON(json.r); | ||
this.points.fromJSON(json.pt); | ||
this.starType = json.sy; | ||
this.direction = json.d; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
p: this.position, | ||
...this.starType === 1 && {ir: this.innerRadius}, | ||
...this.starType === 1 && {is: this.innerRoundness}, | ||
or: this.outerRadius, | ||
os: this.outerRoundness, | ||
r: this.rotation, | ||
pt: this.points, | ||
sy: this.starType, | ||
d: this.direction | ||
}; | ||
} | ||
} | ||
class StrokeShape extends Shape { | ||
@@ -1149,7 +816,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm in BlendMode ? json.bm : BlendMode.NORMAL; | ||
@@ -1165,9 +828,4 @@ this.color.fromJSON(json.c); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -1180,3 +838,3 @@ c: this.color, | ||
w: this.width | ||
}; | ||
}); | ||
} | ||
@@ -1196,7 +854,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm in BlendMode ? json.bm : BlendMode.NORMAL; | ||
@@ -1210,9 +864,4 @@ this.trimEnd.fromJSON(json.e); | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
@@ -1223,91 +872,56 @@ e: this.trimEnd, | ||
m: this.trimMultipleShapes | ||
}; | ||
}); | ||
} | ||
} | ||
class GroupShape extends Shape { | ||
class GradientStrokeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = ShapeType.GROUP; | ||
this.type = ShapeType.GRADIENT_STROKE; | ||
this.blendMode = BlendMode.NORMAL; | ||
this.isHidden = false; | ||
this.numProperties = 0; | ||
this.transform = new Transform(); | ||
this.shapes = []; | ||
this.endPoint = new Property(this, PropertyType.POSITION); | ||
this.gradientColors = new Gradient(); | ||
this.gradientType = GradientFillType.LINEAR; | ||
this.highlightAngle = new Property(this, PropertyType.NUMBER); | ||
this.highlightLength = new Property(this, PropertyType.NUMBER); | ||
this.opacity = new Property(this, PropertyType.OPACITY); | ||
this.startPoint = new Property(this, PropertyType.POSITION); | ||
this.lineCapType = LineCapType.ROUND; | ||
this.lineJoinType = LineJoinType.ROUND; | ||
this.width = new Property(this, PropertyType.STROKE_WIDTH); | ||
} | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.blendMode = json.bm; | ||
this.contentPropertyIndex = json.cix; | ||
this.propertyIndex = json.ix; | ||
this.numProperties = json.np; | ||
this.shapes = json.it.map((jShape) => { | ||
try { | ||
if (jShape.ty !== "tr") { | ||
const nShape = this.createShape(jShape.ty); | ||
return nShape.fromJSON(jShape); | ||
} | ||
this.transform.fromJSON(jShape); | ||
} catch (e) { | ||
} | ||
return false; | ||
}).filter(Boolean); | ||
this.opacity.fromJSON(json.o); | ||
this.endPoint.fromJSON(json.e); | ||
this.gradientColors.fromJSON(json.g); | ||
this.gradientType = json.t; | ||
this.startPoint.fromJSON(json.s); | ||
if (this.gradientType === GradientFillType.RADIAL) { | ||
this.highlightAngle.fromJSON(json.a); | ||
this.highlightLength.fromJSON(json.h); | ||
} | ||
this.lineCapType = json.lc in LineCapType ? json.lc : LineCapType.ROUND; | ||
this.lineJoinType = json.lj in LineJoinType ? json.lj : LineJoinType.ROUND; | ||
this.miterLimit = json.ml; | ||
this.width.fromJSON(json.w); | ||
return this; | ||
} | ||
createShape(type) { | ||
if (type === ShapeType.PATH) { | ||
return new PathShape(this); | ||
} else if (type === ShapeType.GROUP) { | ||
return new GroupShape(this); | ||
} else if (type === ShapeType.FILL) { | ||
return new FillShape(this); | ||
} else if (type === ShapeType.RECTANGLE) { | ||
return new RectangleShape(this); | ||
} else if (type === ShapeType.ELLIPSE) { | ||
return new EllipseShape(this); | ||
} else if (type === ShapeType.STROKE) { | ||
return new StrokeShape(this); | ||
} else if (type === ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(this); | ||
} else if (type === ShapeType.GRADIENT_STROKE) { | ||
return new GradientStrokeShape(this); | ||
} else if (type === ShapeType.TRIM) { | ||
return new TrimShape(this); | ||
} else if (type === ShapeType.MERGE) { | ||
return new MergeShape(this); | ||
} else if (type === ShapeType.STAR) { | ||
return new StarShape(this); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
} | ||
addShape(shape2) { | ||
if (!(shape2 instanceof Shape)) | ||
shape2 = this.createShape(shape2); | ||
this.shapes.push(shape2); | ||
return shape2; | ||
} | ||
toJSON() { | ||
const shapes = JSON.parse(JSON.stringify(this.shapes)); | ||
shapes.push({ | ||
ty: "tr", | ||
nm: "Transform", | ||
...this.transform.toJSON() | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
bm: this.blendMode, | ||
o: this.opacity, | ||
e: this.endPoint, | ||
g: this.gradientColors, | ||
t: this.gradientType, | ||
a: this.highlightAngle, | ||
h: this.highlightLength, | ||
s: this.startPoint, | ||
lc: this.lineCapType, | ||
lj: this.lineJoinType, | ||
ml: this.miterLimit, | ||
w: this.width | ||
}); | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
bm: this.blendMode, | ||
cix: this.contentPropertyIndex, | ||
it: shapes, | ||
ix: this.propertyIndex, | ||
np: this.numProperties | ||
}; | ||
} | ||
@@ -1334,7 +948,3 @@ } | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.copies.fromJSON(json.c); | ||
@@ -1358,9 +968,4 @@ this.composition = json.m; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
m: this.composition, | ||
@@ -1379,6 +984,50 @@ c: this.copies, | ||
} | ||
}; | ||
}); | ||
} | ||
} | ||
class StarShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = ShapeType.STAR; | ||
this.position = new Property(this, PropertyType.POSITION); | ||
this.innerRadius = new Property(this, PropertyType.NUMBER); | ||
this.innerRoundness = new Property(this, PropertyType.NUMBER); | ||
this.outerRadius = new Property(this, PropertyType.NUMBER); | ||
this.outerRoundness = new Property(this, PropertyType.NUMBER); | ||
this.rotation = new Property(this, PropertyType.ROTATION); | ||
this.points = new Property(this, PropertyType.NUMBER); | ||
this.starType = StarType.STAR; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.position.fromJSON(json.p); | ||
if (json.sy === 1) { | ||
this.innerRadius.fromJSON(json.ir); | ||
this.innerRoundness.fromJSON(json.is); | ||
} | ||
this.outerRadius.fromJSON(json.or); | ||
this.outerRoundness.fromJSON(json.os); | ||
this.rotation.fromJSON(json.r); | ||
this.points.fromJSON(json.pt); | ||
this.starType = json.sy; | ||
this.direction = json.d; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
p: this.position, | ||
...this.starType === 1 && {ir: this.innerRadius}, | ||
...this.starType === 1 && {is: this.innerRoundness}, | ||
or: this.outerRadius, | ||
os: this.outerRoundness, | ||
r: this.rotation, | ||
pt: this.points, | ||
sy: this.starType, | ||
d: this.direction | ||
}); | ||
} | ||
} | ||
class RoundedCornersShape extends Shape { | ||
@@ -1391,7 +1040,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.classNames = json.cl; | ||
this.id = json.ln; | ||
this.isHidden = json.hd; | ||
this.matchName = json.mn; | ||
this.name = json.nm; | ||
super.fromJSON(json); | ||
this.roundness.fromJSON(json.r); | ||
@@ -1401,54 +1046,75 @@ return this; | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
cl: this.classNames, | ||
hd: this.isHidden, | ||
ln: this.id, | ||
mn: this.matchName, | ||
nm: this.name, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
r: this.roundness | ||
}; | ||
}); | ||
} | ||
} | ||
class ShapeLayer extends Layer { | ||
class MergeShape extends Shape { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.SHAPE; | ||
this.shapes = []; | ||
this.type = ShapeType.MERGE; | ||
this.mergeMode = 1; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.mergeMode = json.mm; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
mm: this.mergeMode | ||
}); | ||
} | ||
} | ||
const createShapeFromType = (type, parent) => { | ||
if (type === ShapeType.PATH) { | ||
return new PathShape(parent); | ||
} else if (type === ShapeType.GROUP) { | ||
return new GroupShape(parent); | ||
} else if (type === ShapeType.FILL) { | ||
return new FillShape(parent); | ||
} else if (type === ShapeType.RECTANGLE) { | ||
return new RectangleShape(parent); | ||
} else if (type === ShapeType.ELLIPSE) { | ||
return new EllipseShape(parent); | ||
} else if (type === ShapeType.STROKE) { | ||
return new StrokeShape(parent); | ||
} else if (type === ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(parent); | ||
} else if (type === ShapeType.GRADIENT_STROKE) { | ||
return new GradientStrokeShape(parent); | ||
} else if (type === ShapeType.TRIM) { | ||
return new TrimShape(parent); | ||
} else if (type === ShapeType.MERGE) { | ||
return new MergeShape(parent); | ||
} else if (type === ShapeType.STAR) { | ||
return new StarShape(parent); | ||
} else if (type === ShapeType.ROUNDED_CORNERS) { | ||
return new RoundedCornersShape(parent); | ||
} else if (type === ShapeType.REPEATER) { | ||
return new RepeaterShape(parent); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
}; | ||
class Character { | ||
constructor() { | ||
this.character = ""; | ||
this.fontSize = 0; | ||
this.fontStyle = ""; | ||
this.fontWeight = 0; | ||
this.data = []; | ||
this.fontFamily = ""; | ||
} | ||
createShape(type) { | ||
if (type === ShapeType.PATH) { | ||
return new PathShape(this); | ||
} else if (type === ShapeType.GROUP) { | ||
return new GroupShape(this); | ||
} else if (type === ShapeType.FILL) { | ||
return new FillShape(this); | ||
} else if (type === ShapeType.RECTANGLE) { | ||
return new RectangleShape(this); | ||
} else if (type === ShapeType.ELLIPSE) { | ||
return new EllipseShape(this); | ||
} else if (type === ShapeType.STROKE) { | ||
return new StrokeShape(this); | ||
} else if (type === ShapeType.GRADIENT_FILL) { | ||
return new GradientFillShape(this); | ||
} else if (type === ShapeType.TRIM) { | ||
return new TrimShape(this); | ||
} else if (type === ShapeType.MERGE) { | ||
return new MergeShape(this); | ||
} else if (type === ShapeType.STAR) { | ||
return new StarShape(this); | ||
} | ||
throw new Error(`Invalid or unknown shape type: ${type}`); | ||
return createShapeFromType(type, this); | ||
} | ||
addShape(shape) { | ||
if (!(shape instanceof Shape)) | ||
shape = this.createShape(shape); | ||
this.shapes.push(shape); | ||
return shape; | ||
} | ||
createShapeFromJSON(json) { | ||
try { | ||
const shape = this.createShape(json.ty); | ||
return shape.fromJSON(json); | ||
const shape2 = this.createShape(json.ty); | ||
return shape2.fromJSON(json); | ||
} catch (e) { | ||
@@ -1459,5 +1125,202 @@ throw new Error(`Unable to create shape from JSON: ${json.ty}`); | ||
fromJSON(json) { | ||
this.character = json.ch; | ||
this.fontSize = json.size; | ||
this.fontStyle = json.style; | ||
this.fontWeight = json.w; | ||
this.fontFamily = json.fFamily; | ||
if ("data" in json && json.data.shapes) { | ||
this.data = json.data.shapes.map((shapeJSON) => this.createShapeFromJSON(shapeJSON)); | ||
} | ||
return this; | ||
} | ||
toJSON() { | ||
const shapes2 = this.data.map((shape2) => shape2.toJSON()); | ||
return { | ||
ch: this.character, | ||
size: this.fontSize, | ||
style: this.fontStyle, | ||
w: this.fontWeight, | ||
data: {shapes: shapes2.length ? shapes2 : void 0}, | ||
fFamily: this.fontFamily | ||
}; | ||
} | ||
} | ||
class Font { | ||
constructor() { | ||
this.fName = ""; | ||
this.fFamily = ""; | ||
this.fStyle = ""; | ||
this.ascent = 0; | ||
this.fPath = ""; | ||
this.fWeight = ""; | ||
this.origin = -1; | ||
this.fClass = ""; | ||
} | ||
fromJSON(json) { | ||
this.fName = json.fName; | ||
this.fFamily = json.fFamily; | ||
this.fStyle = json.fStyle; | ||
this.ascent = json.ascent; | ||
this.fPath = json.fPath; | ||
this.fWeight = json.fWeight; | ||
this.origin = json.origin; | ||
this.fClass = json.fClass; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
fName: this.fName, | ||
fFamily: this.fFamily, | ||
fStyle: this.fStyle, | ||
ascent: this.ascent, | ||
...!(this.fPath === "") && {fPath: this.fPath}, | ||
...!(this.fWeight === "") && {fWeight: this.fWeight}, | ||
...!(this.origin >= 0) && {origin: this.origin}, | ||
...!(this.fClass === "") && {fClass: this.fClass} | ||
}; | ||
} | ||
} | ||
class FontList { | ||
constructor() { | ||
this.list = []; | ||
} | ||
fromJSON(json) { | ||
this.list = json.list.map((fontJSON) => new Font().fromJSON(fontJSON)); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
list: this.list | ||
}; | ||
} | ||
} | ||
class EffectValue { | ||
constructor(type) { | ||
this.name = ""; | ||
this.index = 0; | ||
this.value = new Property(this, PropertyType.EFFECT_VALUE); | ||
this.type = type; | ||
} | ||
fromJSON(json) { | ||
this.name = json.nm; | ||
this.matchName = json.mn; | ||
this.index = json.ix; | ||
this.value.fromJSON(json.v); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
ty: this.type, | ||
nm: this.name, | ||
mn: this.matchName, | ||
ix: this.index, | ||
v: this.value | ||
}; | ||
} | ||
} | ||
class Effect { | ||
constructor(type = EffectType.NONE) { | ||
this.name = ""; | ||
this.index = 0; | ||
this.enabled = true; | ||
this.values = []; | ||
this.type = type; | ||
} | ||
fromJSON(json) { | ||
var _a; | ||
this.type = json.ty; | ||
this.name = json.nm; | ||
this.matchName = json.mn; | ||
this.numberOfProperties = json.np; | ||
this.index = json.ix; | ||
this.enabled = (_a = json.en) != null ? _a : true; | ||
this.values = json.ef.map((valueJSON) => new EffectValue(valueJSON.ty).fromJSON(valueJSON)); | ||
return this; | ||
} | ||
toJSON() { | ||
const values = this.values.map((value) => value.toJSON()); | ||
return { | ||
ty: this.type, | ||
nm: this.name, | ||
np: this.numberOfProperties, | ||
mn: this.matchName, | ||
ix: this.index, | ||
ef: values, | ||
en: this.enabled ? 1 : this.enabled | ||
}; | ||
} | ||
} | ||
class Mask { | ||
constructor() { | ||
this.isInverted = false; | ||
this.name = ""; | ||
this.opacity = new Property(this, PropertyType.OPACITY); | ||
this.points = new Property(this, PropertyType.POINTS); | ||
this.mode = MaskMode.Add; | ||
this.expansion = new Property(this, PropertyType.EXPANSION); | ||
} | ||
fromJSON(json) { | ||
this.isInverted = Boolean(json.inv); | ||
this.mode = json.mode; | ||
this.name = json.nm; | ||
this.points.fromJSON(json.pt); | ||
this.opacity.fromJSON(json.o); | ||
this.expansion.fromJSON(json.x); | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
inv: this.isInverted, | ||
mode: this.mode, | ||
nm: this.name, | ||
o: this.opacity, | ||
pt: this.points, | ||
x: this.expansion | ||
}; | ||
} | ||
} | ||
class Layer { | ||
constructor(parent) { | ||
this.autoOrient = false; | ||
this.blendMode = BlendMode.NORMAL; | ||
this.classNames = []; | ||
this.height = 0; | ||
this.id = ""; | ||
this.inPoint = 0; | ||
this.is3D = false; | ||
this.name = ""; | ||
this.outPoint = 0; | ||
this.startTime = 0; | ||
this.timeStretch = 1; | ||
this.width = 0; | ||
this.masks = []; | ||
this.effects = []; | ||
this.transform = new Transform(); | ||
this.parent = parent; | ||
} | ||
get colors() { | ||
const colors = new Set(); | ||
const registry = useRegistry(); | ||
[...registry.keys()].filter((p) => registry.get(p) === this && p.type === PropertyType.COLOR).forEach((cp) => { | ||
cp.values.forEach((v) => { | ||
colors.add(JSON.stringify(v.value)); | ||
}); | ||
}); | ||
return Array.from(colors).map((c) => JSON.parse(c)); | ||
} | ||
get hasMask() { | ||
return this.masks.length > 0; | ||
} | ||
get totalFrames() { | ||
return this.outPoint - this.inPoint; | ||
} | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
@@ -1488,3 +1351,8 @@ this.id = json.ln; | ||
} | ||
this.shapes = json.shapes.map((jShape) => this.createShapeFromJSON(jShape)).filter(Boolean); | ||
if ("masksProperties" in json) { | ||
this.masks = json.masksProperties.map((maskJson) => new Mask().fromJSON(maskJson)); | ||
} | ||
if ("ef" in json) { | ||
this.effects = json.ef.map((effectJson) => new Effect().fromJSON(effectJson)); | ||
} | ||
return this; | ||
@@ -1494,27 +1362,28 @@ } | ||
var _a; | ||
const masks2 = this.hasMask ? this.masks.map((mask) => mask.toJSON()) : void 0; | ||
const effects2 = this.effects.length ? this.effects.map((effect) => effect.toJSON()) : void 0; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
shapes: this.shapes.map((shape) => shape.toJSON()), | ||
ln: this.id, | ||
ty: this.type, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ln: this.id, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
sr: this.timeStretch, | ||
ks: this.transform.toJSON(), | ||
ao: this.autoOrient ? 1 : 0, | ||
hasMask: this.hasMask || void 0, | ||
masksProperties: masks2, | ||
ef: effects2, | ||
w: this.width, | ||
h: this.height, | ||
ip: this.inPoint, | ||
op: this.outPoint, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
bm: this.blendMode | ||
}; | ||
@@ -1524,2 +1393,85 @@ } | ||
class GroupLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.GROUP; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
return this; | ||
} | ||
} | ||
class ImageLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.IMAGE; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
refId: this.refId | ||
}); | ||
} | ||
} | ||
class PrecompositionLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.PRECOMPOSITION; | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.refId = json.refId; | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
refId: this.refId | ||
}); | ||
} | ||
} | ||
class ShapeLayer extends Layer { | ||
constructor() { | ||
super(...arguments); | ||
this.type = LayerType.SHAPE; | ||
this.shapes = []; | ||
} | ||
createShape(type) { | ||
return createShapeFromType(type, this); | ||
} | ||
addShape(shape2) { | ||
if (!(shape2 instanceof Shape)) | ||
shape2 = this.createShape(shape2); | ||
this.shapes.push(shape2); | ||
return shape2; | ||
} | ||
createShapeFromJSON(json) { | ||
try { | ||
const shape2 = this.createShape(json.ty); | ||
return shape2.fromJSON(json); | ||
} catch (e) { | ||
throw new Error(`Unable to create shape from JSON: ${json.ty}`); | ||
} | ||
} | ||
fromJSON(json) { | ||
super.fromJSON(json); | ||
this.shapes = json.shapes.map((jShape) => this.createShapeFromJSON(jShape)).filter(Boolean); | ||
return this; | ||
} | ||
toJSON() { | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
shapes: this.shapes.map((shape2) => shape2.toJSON()) | ||
}); | ||
} | ||
} | ||
class SolidLayer extends Layer { | ||
@@ -1534,32 +1486,3 @@ constructor() { | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
super.fromJSON(json); | ||
this.solidColor = json.sc; | ||
@@ -1571,31 +1494,8 @@ this.solidHeight = json.sh; | ||
toJSON() { | ||
var _a; | ||
return { | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
sc: this.solidColor, | ||
sh: this.solidHeight, | ||
sw: this.solidWidth, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
ty: this.type, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0 | ||
}; | ||
sw: this.solidWidth | ||
}); | ||
} | ||
@@ -1610,32 +1510,3 @@ } | ||
fromJSON(json) { | ||
this.autoOrient = json.ao === 1; | ||
this.blendMode = json.bm; | ||
this.effects = json.ef; | ||
this.height = json.h; | ||
this.id = json.ln; | ||
this.index = json.ind; | ||
this.inPoint = json.ip; | ||
this.is3D = json.ddd; | ||
this.name = json.nm; | ||
this.outPoint = json.op; | ||
this.parent = json.parent; | ||
this.startTime = json.st; | ||
this.timeStretch = json.sr; | ||
this.width = json.w; | ||
if ("cl" in json) { | ||
this.classNames = json.cl.split(" "); | ||
} | ||
if ("tt" in json) { | ||
this.matteMode = json.tt; | ||
} | ||
if ("td" in json) { | ||
this.matteTarget = json.td; | ||
} | ||
if ("hd" in json) { | ||
this.isHidden = json.hd; | ||
} | ||
if ("mn" in json) { | ||
this.matchName = json.mn; | ||
} | ||
this.transform.fromJSON(json.ks); | ||
super.fromJSON(json); | ||
this.textData = json.t; | ||
@@ -1645,29 +1516,6 @@ return this; | ||
toJSON() { | ||
var _a; | ||
return { | ||
ty: this.type, | ||
ao: this.autoOrient ? 1 : 0, | ||
bm: this.blendMode, | ||
cl: this.classNames.length ? this.classNames.join(" ") : void 0, | ||
ddd: this.is3D ? 1 : 0, | ||
ef: this.effects, | ||
h: this.height, | ||
ind: this.index, | ||
ip: this.inPoint, | ||
ks: { | ||
...this.transform.toJSON() | ||
}, | ||
ln: this.id, | ||
nm: this.name, | ||
mn: this.matchName, | ||
op: this.outPoint, | ||
parent: (_a = this.parent) == null ? void 0 : _a.index, | ||
sr: this.timeStretch, | ||
st: this.startTime, | ||
w: this.width, | ||
tt: this.matteMode, | ||
td: this.matteTarget, | ||
hd: this.isHidden !== void 0 ? Number(this.isHidden) : void 0, | ||
const json = super.toJSON(); | ||
return Object.assign(json, { | ||
t: this.textData | ||
}; | ||
}); | ||
} | ||
@@ -1722,3 +1570,3 @@ } | ||
this.keywords = []; | ||
this.generator = "@lottiefiles/lottie-js 0.3.7"; | ||
this.generator = "@lottiefiles/lottie-js 0.3.9"; | ||
this.parent = parent; | ||
@@ -1760,2 +1608,3 @@ } | ||
this.fonts = new FontList(); | ||
this.characters = []; | ||
} | ||
@@ -1930,2 +1779,5 @@ static async fromURL(url) { | ||
} | ||
if ("chars" in json) { | ||
this.characters = json.chars.map((charJSON) => new Character().fromJSON(charJSON)); | ||
} | ||
return this; | ||
@@ -1998,2 +1850,3 @@ } | ||
} | ||
const chars = this.characters.map((char) => char.toJSON()); | ||
return { | ||
@@ -2012,3 +1865,4 @@ assets: this.assets, | ||
w: this.width, | ||
...this.fonts.list.length > 0 && {fonts: this.fonts.toJSON()} | ||
...this.fonts.list.length > 0 && {fonts: this.fonts.toJSON()}, | ||
chars: chars.length > 0 ? chars : void 0 | ||
}; | ||
@@ -2018,28 +1872,3 @@ } | ||
class Mask { | ||
constructor() { | ||
this.isInverted = false; | ||
this.name = ""; | ||
this.mode = MaskMode.Add; | ||
} | ||
fromJSON(json) { | ||
this.isInverted = json.inv; | ||
this.mode = json.mode; | ||
this.name = json.nm; | ||
this.points = json.pt; | ||
this.opacity = json.o; | ||
return this; | ||
} | ||
toJSON() { | ||
return { | ||
inv: this.isInverted, | ||
mode: this.mode, | ||
nm: this.name, | ||
o: this.opacity, | ||
pt: this.points | ||
}; | ||
} | ||
} | ||
export { Animation, Asset, AssetType, BlendMode, Color, ColorRgb, ColorRgba, EllipseShape, FillRuleType, FillShape, Gradient, GradientFillShape, GradientFillType, GradientStop, GradientStrokeShape, GradientStrokeType, GroupLayer, GroupShape, ImageAsset, ImageLayer, KeyFrame, Layer, LayerType, LineCapType, LineJoinType, Marker, Mask, MaskMode, MatteMode, MergeShape, Meta, PathShape, PrecompositionAsset, PrecompositionLayer, Property, PropertyType, RectangleShape, RepeaterComposite, RepeaterShape, RoundedCornersShape, Shape, ShapeLayer, ShapeType, SolidLayer, StarShape, StarType, StrokeShape, TextLayer, Transform, TrimMode, TrimShape, hexToRgba, rgbaToHex, useRegistry }; | ||
export { Animation, Asset, AssetType, BlendMode, Color, ColorRgb, ColorRgba, EffectType, EffectValueType, EllipseShape, FillRuleType, FillShape, Gradient, GradientFillShape, GradientFillType, GradientStop, GradientStrokeShape, GradientStrokeType, GroupLayer, GroupShape, ImageAsset, ImageLayer, KeyFrame, Layer, LayerType, LineCapType, LineJoinType, Marker, Mask, MaskMode, MatteMode, MergeShape, Meta, PathShape, PrecompositionAsset, PrecompositionLayer, Property, PropertyType, RectangleShape, RepeaterComposite, RepeaterShape, RoundedCornersShape, Shape, ShapeLayer, ShapeType, SolidLayer, StarShape, StarType, StrokeShape, TextLayer, Transform, TrimMode, TrimShape, hexToRgba, rgbaToHex, useRegistry }; | ||
//# sourceMappingURL=index.esm.js.map |
/*! | ||
* @lottiefiles/lottie-js - v0.3.7 | ||
* Compiled Wed, 16 Mar 2022 06:55:24 UTC | ||
* @lottiefiles/lottie-js - v0.3.9 | ||
* Compiled Wed, 30 Mar 2022 08:38:45 UTC | ||
* | ||
* Copyright LottieFiles. All rights reserved. | ||
*/(function(i,g){typeof exports=="object"&&typeof module!="undefined"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis!="undefined"?globalThis:i||self,g(i.Lottie={}))})(this,function(i){"use strict";class g{constructor(t){this.parent=t}}class Q extends g{fromJSON(t){return this.data=t.p,this.id=t.id,this.height=t.h,this.path=t.u,this.width=t.w,this}toJSON(){return{h:this.height,i:this.id,p:this.data,u:this.path,w:this.width}}}(function(t){t[t.PRECOMPOSITION=0]="PRECOMPOSITION",t[t.IMAGE=1]="IMAGE"})(i.AssetType||(i.AssetType={}));class x extends g{constructor(){super(...arguments);this.type=i.AssetType.PRECOMPOSITION,this.layers=[],this.id=""}fromJSON(t){return this.id=t.id,this.timeRemap=t.tm,this.layers=this.parent.createLayersFromJSONArray(t.layers),this}toJSON(){return{id:this.id,layers:this.layers.map(t=>t.toJSON()),tm:this.timeRemap}}}var ft=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function ut(t,e,r){return r={path:e,exports:{},require:function(n,l){return yt(n,l??r.path)}},t(r,r.exports),r.exports}function yt(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Ot=ut(function(t,e){var r=function(n){function l(){this.fetch=!1,this.DOMException=n.DOMException}return l.prototype=n,new l}(typeof self!="undefined"?self:ft);(function(n){var l=function(d){var c={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(s){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};function p(s){return s&&DataView.prototype.isPrototypeOf(s)}if(c.arrayBuffer)var T=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(s){return s&&T.indexOf(Object.prototype.toString.call(s))>-1};function P(s){if(typeof s!="string"&&(s=String(s)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(s))throw new TypeError("Invalid character in header field name");return s.toLowerCase()}function lt(s){return typeof s!="string"&&(s=String(s)),s}function W(s){var h={next:function(){var o=s.shift();return{done:o===void 0,value:o}}};return c.iterable&&(h[Symbol.iterator]=function(){return h}),h}function f(s){this.map={},s instanceof f?s.forEach(function(h,o){this.append(o,h)},this):Array.isArray(s)?s.forEach(function(h){this.append(h[0],h[1])},this):s&&Object.getOwnPropertyNames(s).forEach(function(h){this.append(h,s[h])},this)}f.prototype.append=function(s,h){s=P(s),h=lt(h);var o=this.map[s];this.map[s]=o?o+", "+h:h},f.prototype.delete=function(s){delete this.map[P(s)]},f.prototype.get=function(s){return s=P(s),this.has(s)?this.map[s]:null},f.prototype.has=function(s){return this.map.hasOwnProperty(P(s))},f.prototype.set=function(s,h){this.map[P(s)]=lt(h)},f.prototype.forEach=function(s,h){for(var o in this.map)this.map.hasOwnProperty(o)&&s.call(h,this.map[o],o,this)},f.prototype.keys=function(){var s=[];return this.forEach(function(h,o){s.push(o)}),W(s)},f.prototype.values=function(){var s=[];return this.forEach(function(h){s.push(h)}),W(s)},f.prototype.entries=function(){var s=[];return this.forEach(function(h,o){s.push([o,h])}),W(s)},c.iterable&&(f.prototype[Symbol.iterator]=f.prototype.entries);function q(s){if(s.bodyUsed)return Promise.reject(new TypeError("Already read"));s.bodyUsed=!0}function dt(s){return new Promise(function(h,o){s.onload=function(){h(s.result)},s.onerror=function(){o(s.error)}})}function Ct(s){var h=new FileReader,o=dt(h);return h.readAsArrayBuffer(s),o}function Mt(s){var h=new FileReader,o=dt(h);return h.readAsText(s),o}function _t(s){for(var h=new Uint8Array(s),o=new Array(h.length),O=0;O<h.length;O++)o[O]=String.fromCharCode(h[O]);return o.join("")}function mt(s){if(s.slice)return s.slice(0);var h=new Uint8Array(s.byteLength);return h.set(new Uint8Array(s)),h.buffer}function ct(){return this.bodyUsed=!1,this._initBody=function(s){this._bodyInit=s,s?typeof s=="string"?this._bodyText=s:c.blob&&Blob.prototype.isPrototypeOf(s)?this._bodyBlob=s:c.formData&&FormData.prototype.isPrototypeOf(s)?this._bodyFormData=s:c.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)?this._bodyText=s.toString():c.arrayBuffer&&c.blob&&p(s)?(this._bodyArrayBuffer=mt(s.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):c.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(s)||I(s))?this._bodyArrayBuffer=mt(s):this._bodyText=s=Object.prototype.toString.call(s):this._bodyText="",this.headers.get("content-type")||(typeof s=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):c.searchParams&&URLSearchParams.prototype.isPrototypeOf(s)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},c.blob&&(this.blob=function(){var s=q(this);if(s)return s;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?q(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(Ct)}),this.text=function(){var s=q(this);if(s)return s;if(this._bodyBlob)return Mt(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(_t(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},c.formData&&(this.formData=function(){return this.text().then(kt)}),this.json=function(){return this.text().then(JSON.parse)},this}var Ut=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function Ht(s){var h=s.toUpperCase();return Ut.indexOf(h)>-1?h:s}function w(s,h){h=h||{};var o=h.body;if(s instanceof w){if(s.bodyUsed)throw new TypeError("Already read");this.url=s.url,this.credentials=s.credentials,h.headers||(this.headers=new f(s.headers)),this.method=s.method,this.mode=s.mode,this.signal=s.signal,!o&&s._bodyInit!=null&&(o=s._bodyInit,s.bodyUsed=!0)}else this.url=String(s);if(this.credentials=h.credentials||this.credentials||"same-origin",(h.headers||!this.headers)&&(this.headers=new f(h.headers)),this.method=Ht(h.method||this.method||"GET"),this.mode=h.mode||this.mode||null,this.signal=h.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}w.prototype.clone=function(){return new w(this,{body:this._bodyInit})};function kt(s){var h=new FormData;return s.trim().split("&").forEach(function(o){if(o){var O=o.split("="),u=O.shift().replace(/\+/g," "),m=O.join("=").replace(/\+/g," ");h.append(decodeURIComponent(u),decodeURIComponent(m))}}),h}function Gt(s){var h=new f,o=s.replace(/\r?\n[\t ]+/g," ");return o.split(/\r?\n/).forEach(function(O){var u=O.split(":"),m=u.shift().trim();if(m){var D=u.join(":").trim();h.append(m,D)}}),h}ct.call(w.prototype);function S(s,h){h||(h={}),this.type="default",this.status=h.status===void 0?200:h.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in h?h.statusText:"OK",this.headers=new f(h.headers),this.url=h.url||"",this._initBody(s)}ct.call(S.prototype),S.prototype.clone=function(){return new S(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new f(this.headers),url:this.url})},S.error=function(){var s=new S(null,{status:0,statusText:""});return s.type="error",s};var Bt=[301,302,303,307,308];S.redirect=function(s,h){if(Bt.indexOf(h)===-1)throw new RangeError("Invalid status code");return new S(null,{status:h,headers:{location:s}})},d.DOMException=n.DOMException;try{new d.DOMException}catch(s){d.DOMException=function(h,o){this.message=h,this.name=o;var O=Error(h);this.stack=O.stack},d.DOMException.prototype=Object.create(Error.prototype),d.DOMException.prototype.constructor=d.DOMException}function $(s,h){return new Promise(function(o,O){var u=new w(s,h);if(u.signal&&u.signal.aborted)return O(new d.DOMException("Aborted","AbortError"));var m=new XMLHttpRequest;function D(){m.abort()}m.onload=function(){var b={status:m.status,statusText:m.statusText,headers:Gt(m.getAllResponseHeaders()||"")};b.url="responseURL"in m?m.responseURL:b.headers.get("X-Request-URL");var Z="response"in m?m.response:m.responseText;o(new S(Z,b))},m.onerror=function(){O(new TypeError("Network request failed"))},m.ontimeout=function(){O(new TypeError("Network request failed"))},m.onabort=function(){O(new d.DOMException("Aborted","AbortError"))},m.open(u.method,u.url,!0),u.credentials==="include"?m.withCredentials=!0:u.credentials==="omit"&&(m.withCredentials=!1),"responseType"in m&&c.blob&&(m.responseType="blob"),u.headers.forEach(function(b,Z){m.setRequestHeader(Z,b)}),u.signal&&(u.signal.addEventListener("abort",D),m.onreadystatechange=function(){m.readyState===4&&u.signal.removeEventListener("abort",D)}),m.send(typeof u._bodyInit=="undefined"?null:u._bodyInit)})}return $.polyfill=!0,n.fetch||(n.fetch=$,n.Headers=f,n.Request=w,n.Response=S),d.Headers=f,d.Request=w,d.Response=S,d.fetch=$,d}({})})(r),delete r.fetch.polyfill,e=r.fetch,e.default=r.fetch,e.fetch=r.fetch,e.Headers=r.Headers,e.Request=r.Request,e.Response=r.Response,t.exports=e});(function(t){t[t.NORMAL=0]="NORMAL",t[t.MULTIPLY=1]="MULTIPLY",t[t.SCREEN=2]="SCREEN",t[t.OVERLAY=3]="OVERLAY",t[t.DARKEN=4]="DARKEN",t[t.LIGHTEN=5]="LIGHTEN",t[t.COLOR_DODGE=6]="COLOR_DODGE",t[t.COLOR_BURN=7]="COLOR_BURN",t[t.HARD_LIGHT=8]="HARD_LIGHT",t[t.SOFT_LIGHT=9]="SOFT_LIGHT",t[t.DIFFERENCE=10]="DIFFERENCE",t[t.EXCLUSION=11]="EXCLUSION",t[t.HUE=12]="HUE",t[t.SATURATION=13]="SATURATION",t[t.COLOR=14]="COLOR",t[t.LUMINOSITY=15]="LUMINOSITY"})(i.BlendMode||(i.BlendMode={})),function(t){t[t.EVEN_ODD=1]="EVEN_ODD",t[t.NONZERO=2]="NONZERO"}(i.FillRuleType||(i.FillRuleType={})),function(t){t[t.NONE=0]="NONE",t[t.LINEAR=1]="LINEAR",t[t.RADIAL=2]="RADIAL",t[t.ANGULAR=4]="ANGULAR",t[t.REFLECTED=5]="REFLECTED",t[t.DIAMOND=6]="DIAMOND"}(i.GradientFillType||(i.GradientFillType={})),function(t){t[t.LINEAR=1]="LINEAR",t[t.RADIAL=2]="RADIAL"}(i.GradientStrokeType||(i.GradientStrokeType={})),function(t){t[t.PRECOMPOSITION=0]="PRECOMPOSITION",t[t.SOLID=1]="SOLID",t[t.IMAGE=2]="IMAGE",t[t.GROUP=3]="GROUP",t[t.SHAPE=4]="SHAPE",t[t.TEXT=5]="TEXT",t[t.AUDIO=6]="AUDIO",t[t.VIDEO_PLACEHOLDER=7]="VIDEO_PLACEHOLDER",t[t.IMAGE_SEQUENCE=8]="IMAGE_SEQUENCE",t[t.VIDEO=9]="VIDEO",t[t.IMAGE_PLACEHOLDER=10]="IMAGE_PLACEHOLDER",t[t.GUIDE=11]="GUIDE",t[t.ADJUSTMENT=12]="ADJUSTMENT",t[t.CAMERA=13]="CAMERA",t[t.LIGHT=14]="LIGHT"}(i.LayerType||(i.LayerType={})),function(t){t[t.BUTT=1]="BUTT",t[t.ROUND=2]="ROUND",t[t.PROJECTING=3]="PROJECTING"}(i.LineCapType||(i.LineCapType={})),function(t){t[t.MITER=1]="MITER",t[t.ROUND=2]="ROUND",t[t.BEVEL=3]="BEVEL"}(i.LineJoinType||(i.LineJoinType={})),function(t){t.None="n",t.Add="a",t.Subtract="s",t.Intersect="i",t.Lighten="l",t.Darken="d",t.Difference="f"}(i.MaskMode||(i.MaskMode={})),function(t){t.ANCHOR="a",t.OPACITY="o",t.POSITION="p",t.ROTATION="r",t.ROTATION_X="rx",t.ROTATION_Y="ry",t.ROTATION_Z="rz",t.SCALE="s",t.SKEW_AXIS="sa",t.SKEW="sk",t.SHAPE="sh",t.EXPANSION="x",t.FEATHER="f",t.SIZE="sz",t.ROUNDNESS="rd",t.MITER_LIMIT="ml",t.STROKE_WIDTH="sw",t.NUMBER="nu",t.COLOR="cl",t.ORIENTATION="or",t.GRADIENT="gr"}(i.PropertyType||(i.PropertyType={})),function(t){t.ELLIPSE="el",t.FILL="fl",t.GRADIENT_FILL="gf",t.GRADIENT_STROKE="gs",t.GROUP="gr",t.MERGE="mm",t.OFFSET_PATH="op",t.PATH="sh",t.RECTANGLE="rc",t.REPEATER="rp",t.ROUNDED_CORNERS="rd",t.STAR="sr",t.STROKE="st",t.TRIM="tm",t.TWIST="tw"}(i.ShapeType||(i.ShapeType={})),function(t){t[t.SIMULTANEOUSLY=1]="SIMULTANEOUSLY",t[t.INDIVIDUALLY=2]="INDIVIDUALLY"}(i.TrimMode||(i.TrimMode={})),function(t){t[t.ABOVE=1]="ABOVE",t[t.BELOW=2]="BELOW"}(i.RepeaterComposite||(i.RepeaterComposite={})),function(t){t[t.STAR=1]="STAR",t[t.POLYGON=2]="POLYGON"}(i.StarType||(i.StarType={})),function(t){t[t.NORMAL=0]="NORMAL",t[t.ALPHA=1]="ALPHA",t[t.INVERTED_ALPHA=2]="INVERTED_ALPHA",t[t.LUMA=3]="LUMA",t[t.INVERTED_LUMA=4]="INVERTED_LUMA"}(i.MatteMode||(i.MatteMode={}));class pt{constructor(){this.list=[]}fromJSON(t){return this.list=t.list,this}toJSON(){return{list:this.list}}}class N{constructor(t=0,e=0){this.frame=0,this.value=0,this.frameInTangent=[0,0],this.frameOutTangent=[1,1],this.hold=!1,this.frame=t,this.value=e}fromJSON(t,e=void 0){this.frame=t.t,e===void 0?this.value=t.s:this.value=e.fromJSON(t.s);const r="i"in t&&"o"in t,n="ti"in t&&"to"in t;return this.frameInTangent=r?[t.i.x,t.i.y]:void 0,this.frameOutTangent=r?[t.o.x,t.o.y]:void 0,n&&("x"in t.ti&&"y"in t.ti?this.valueInTangent=[t.ti.x,t.ti.y]:this.valueInTangent=t.ti,"x"in t.to&&"y"in t.to?this.valueOutTangent=[t.to.x,t.to.y]:this.valueOutTangent=t.to),this.hold="h"in t&&t.h,this}toJSON(){const t={t:this.frame,s:this.value};return this.hold?t.h=1:this.frameInTangent&&this.frameOutTangent&&(t.i={x:this.frameInTangent[0],y:this.frameInTangent[1]},t.o={x:this.frameOutTangent[0],y:this.frameOutTangent[1]}),this.valueInTangent&&this.valueOutTangent&&(t.ti=this.valueInTangent,t.to=this.valueOutTangent),t}}const Nt=new Map;function R(){return Nt}class J{toJSON(){return this.toRgbArray()}static fromJSON(t){return t.length>3?C.fromJSON(t):t.length==3?A.fromJSON(t):new A(0,0,0)}}class A extends J{constructor(t,e,r){super();this.r=t,this.g=e,this.b=r}toRgbArray(){return[this.r,this.g,this.b]}static fromJSON(t){return new A(t[0],t[1],t[2])}}class C extends A{constructor(t,e,r,n=1){super(t,e,r);this.a=n}toRgbArray(){return[this.r,this.g,this.b,this.a]}static fromJSON(t){return new C(t[0],t[1],t[2],t[3])}}class a{constructor(t,e,r=[]){this.UID=0,this.isAnimated=!1,this.values=[],this._parent=t,this.type=e,this.values=r,this.isAnimated=r.length>1,R().set(this,t)}getParent(){return this._parent}fromJSON(t){this.expression="x"in t?t.x:void 0,this.index=t.ix,this.isAnimated=t.a===1;let e;return this.type==i.PropertyType.COLOR&&(e=J),this.values=this.isAnimated?t.k.map(r=>new N().fromJSON(r,e)):[new N().fromJSON({t:0,s:t.k},e)],this.type===i.PropertyType.COLOR&&(this.maxColors="p"in t?t.p:void 0),this}toJSON(){let t;const e=this.isAnimated!==!1||this.values.length>1;return e?t=this.values:t=this.values.length?this.values[0].value:0,{x:this.expression,ix:this.index,a:e?1:0,k:t,p:this.maxColors}}}class M{constructor(){this.anchor=new a(this,i.PropertyType.ANCHOR,[new N(0,[0,0])]),this.opacity=new a(this,i.PropertyType.OPACITY,[new N(0,100)]),this.position=new a(this,i.PropertyType.POSITION,[new N(0,[0,0])]),this.rotation=new a(this,i.PropertyType.ROTATION,[new N(0,0)]),this.scale=new a(this,i.PropertyType.SCALE,[new N(0,[100,100])]),this.skew=new a(this,i.PropertyType.SKEW),this.skewAxis=new a(this,i.PropertyType.SKEW_AXIS)}fromJSON(t){return this.rotation="r"in t?new a(this,i.PropertyType.ROTATION).fromJSON(t.r):void 0,"o"in t&&this.opacity.fromJSON(t.o),"p"in t&&this.position.fromJSON(t.p),"a"in t&&this.anchor.fromJSON(t.a),"s"in t&&this.scale.fromJSON(t.s),this.skew="sk"in t?new a(this,i.PropertyType.SKEW).fromJSON(t.sk):void 0,this.skewAxis="sa"in t?new a(this,i.PropertyType.SKEW_AXIS).fromJSON(t.sa):void 0,"or"in t&&(this.orientation=new a(this,i.PropertyType.ORIENTATION).fromJSON(t.or)),"rx"in t&&(this.rotationX=new a(this,i.PropertyType.ROTATION_X).fromJSON(t.rx)),"ry"in t&&(this.rotationY=new a(this,i.PropertyType.ROTATION_Y).fromJSON(t.ry)),"rz"in t&&(this.rotationZ=new a(this,i.PropertyType.ROTATION_Z).fromJSON(t.rz)),this}toJSON(){return{a:this.anchor,o:this.opacity,p:this.position,r:this.rotation,s:this.scale,sk:this.skew,sa:this.skewAxis,rx:this.rotationX,ry:this.rotationY,rz:this.rotationZ,or:this.orientation}}}class E{constructor(t){this.autoOrient=!1,this.blendMode=i.BlendMode.NORMAL,this.classNames=[],this.height=0,this.id="",this.inPoint=0,this.is3D=!1,this.name="",this.outPoint=0,this.startTime=0,this.timeStretch=1,this.width=0,this.transform=new M,this.parent=t}get colors(){const t=new Set,e=R();return[...e.keys()].filter(r=>e.get(r)===this&&r.type===i.PropertyType.COLOR).forEach(r=>{r.values.forEach(n=>{t.add(JSON.stringify(n.value))})}),Array.from(t).map(r=>JSON.parse(r))}get totalFrames(){return this.outPoint-this.inPoint}}var St=Object.assign;class j extends E{constructor(){super(...arguments);this.type=i.LayerType.GROUP}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,"cl"in t&&(this.classNames=t.cl.split(" ")),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.transform.fromJSON(t.ks),this}toJSON(){var t;return{ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:St({},this.transform.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,sr:this.timeStretch,st:this.startTime,ty:this.type,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0}}}var Tt=Object.assign;class tt extends E{constructor(){super(...arguments);this.type=i.LayerType.IMAGE}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,"cl"in t&&(this.classNames=t.cl.split(" ")),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.transform.fromJSON(t.ks),this.refId=t.refId,this}toJSON(){var t;return{ty:this.type,ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:Tt({},this.transform.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,sr:this.timeStretch,st:this.startTime,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0,refId:this.refId}}}var gt=Object.assign;class it extends E{constructor(){super(...arguments);this.type=i.LayerType.PRECOMPOSITION}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,"cl"in t&&(this.classNames=t.cl.split(" ")),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.transform.fromJSON(t.ks),this.refId=t.refId,this}toJSON(){var t;return{ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:gt({},this.transform.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,refId:this.refId,sr:this.timeStretch,st:this.startTime,ty:this.type,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0}}}class et{constructor(t=0,e=[]){this.offset=t,this.color=e}get hasAlpha(){return this.color.length>3}get red(){return this.color[0]}get green(){return this.color[1]}get blue(){return this.color[2]}get alpha(){return this.color[3]}}class Et extends a{constructor(){super(...arguments);this.colorCount=0}keyframeValue(t){return t>=this.values.length?[]:this.values[t].value}keyframeHasAlpha(t){return this.keyframeValue(t).length==this.colorCount*6}keframeStops(t){const e=this.keyframeValue(t),r=[],n=this.keyframeHasAlpha(t);for(let l=0;l<this.colorCount;l++){const d=e.slice(l,3);n&&d.push(e[this.colorCount*4+l*2]),r.push(new et(e[l*4],d))}return r}setKeyframeStops(t,e){if(t>=this.values.length)return;e.length>this.colorCount&&(this.colorCount=e.length),this.values[t].value=this.stopsToArray(e)}addKeyframe(t,e){const r=new N(t,this.stopsToArray(e));return e.length>this.colorCount&&(this.colorCount=e.length),this.values.push(r),r}stopsToArray(t){let e=!1;const r=[];for(const n of t)r.push(n.offset),r.push(n.red),r.push(n.green),r.push(n.blue),n.hasAlpha&&(e=!0);if(e)for(const n of t)r.push(n.offset),r.push(n.alpha!==void 0?n.alpha:1);return r}}class _{constructor(){this.gradientColors=new Et(this,i.PropertyType.GRADIENT)}get colorCount(){return this.gradientColors.colorCount}set colorCount(t){this.gradientColors.colorCount=t}toJSON(){return{p:this.colorCount,k:this.gradientColors}}fromJSON(t){return this.gradientColors.fromJSON(t.k),this.colorCount=t.p,this}}class y{constructor(t){this.isHidden=!1,this.parent=t}}class U extends y{constructor(){super(...arguments);this.type=i.ShapeType.ELLIPSE,this.position=new a(this,i.PropertyType.POSITION),this.size=new a(this,i.PropertyType.SIZE),this.direction=1}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.position.fromJSON(t.p),this.size.fromJSON(t.s),this.direction=t.d,this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,p:this.position,s:this.size,d:this.direction}}}class H extends y{constructor(){super(...arguments);this.type=i.ShapeType.FILL,this.blendMode=i.BlendMode.NORMAL,this.color=new a(this,i.PropertyType.COLOR),this.fillRule=i.FillRuleType.EVEN_ODD,this.opacity=new a(this,i.PropertyType.OPACITY,[new N(0,100)])}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm,this.color.fromJSON(t.c),this.fillRule=t.r in i.FillRuleType?t.r:i.FillRuleType.EVEN_ODD,this.opacity.fromJSON(t.o),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,c:this.color,r:this.fillRule,o:this.opacity}}}class k extends y{constructor(){super(...arguments);this.type=i.ShapeType.GRADIENT_FILL,this.blendMode=i.BlendMode.NORMAL,this.endPoint=new a(this,i.PropertyType.POSITION),this.gradientColors=new _,this.gradientType=i.GradientFillType.LINEAR,this.highlightAngle=new a(this,i.PropertyType.NUMBER),this.highlightLength=new a(this,i.PropertyType.NUMBER),this.opacity=new a(this,i.PropertyType.OPACITY),this.startPoint=new a(this,i.PropertyType.POSITION),this.fillRule=i.FillRuleType.EVEN_ODD}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm,this.endPoint.fromJSON(t.e),this.gradientColors.fromJSON(t.g),this.gradientType=t.t,this.opacity.fromJSON(t.o),this.startPoint.fromJSON(t.s),this.fillRule=t.r,this.gradientType===i.GradientFillType.RADIAL&&(this.highlightAngle.fromJSON(t.a),this.highlightLength.fromJSON(t.h)),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,e:this.endPoint,g:this.gradientColors,t:this.gradientType,a:this.highlightAngle,h:this.highlightLength,o:this.opacity,r:this.fillRule,s:this.startPoint}}}class st extends y{constructor(){super(...arguments);this.type=i.ShapeType.GRADIENT_STROKE,this.blendMode=i.BlendMode.NORMAL,this.endPoint=new a(this,i.PropertyType.POSITION),this.gradientColors=new _,this.gradientType=i.GradientFillType.LINEAR,this.highlightAngle=new a(this,i.PropertyType.NUMBER),this.highlightLength=new a(this,i.PropertyType.NUMBER),this.opacity=new a(this,i.PropertyType.OPACITY),this.startPoint=new a(this,i.PropertyType.POSITION),this.lineCapType=i.LineCapType.ROUND,this.lineJoinType=i.LineJoinType.ROUND,this.width=new a(this,i.PropertyType.STROKE_WIDTH)}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm,this.opacity.fromJSON(t.o),this.endPoint.fromJSON(t.e),this.gradientColors.fromJSON(t.g),this.gradientType=t.t,this.startPoint.fromJSON(t.s),this.gradientType===i.GradientFillType.RADIAL&&(this.highlightAngle.fromJSON(t.a),this.highlightLength.fromJSON(t.h)),this.lineCapType=t.lc in i.LineCapType?t.lc:i.LineCapType.ROUND,this.lineJoinType=t.lj in i.LineJoinType?t.lj:i.LineJoinType.ROUND,this.miterLimit=t.ml,this.width.fromJSON(t.w),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,o:this.opacity,e:this.endPoint,g:this.gradientColors,t:this.gradientType,a:this.highlightAngle,h:this.highlightLength,s:this.startPoint,lc:this.lineCapType,lj:this.lineJoinType,ml:this.miterLimit,w:this.width}}}class G extends y{constructor(){super(...arguments);this.type=i.ShapeType.MERGE,this.mergeMode=1}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.mergeMode=t.mm,this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,mm:this.mergeMode}}}class B extends y{constructor(){super(...arguments);this.type=i.ShapeType.PATH,this.vertices=new a(this,i.PropertyType.SHAPE)}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.itemIndex=t.ind,this.shapeIndex=t.ix,this.direction=t.d,this.vertices.fromJSON(t.ks),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,ind:this.itemIndex,ix:this.shapeIndex,d:this.direction,ks:this.vertices}}}class F extends y{constructor(){super(...arguments);this.type=i.ShapeType.RECTANGLE,this.position=new a(this,i.PropertyType.POSITION),this.roundness=new a(this,i.PropertyType.ROUNDNESS),this.size=new a(this,i.PropertyType.SIZE)}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.direction=t.d,this.position.fromJSON(t.p),this.roundness.fromJSON(t.r),this.size.fromJSON(t.s),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,d:this.direction,p:this.position,r:this.roundness,s:this.size}}}var V=Object.assign;class Y extends y{constructor(){super(...arguments);this.type=i.ShapeType.STAR,this.position=new a(this,i.PropertyType.POSITION),this.innerRadius=new a(this,i.PropertyType.NUMBER),this.innerRoundness=new a(this,i.PropertyType.NUMBER),this.outerRadius=new a(this,i.PropertyType.NUMBER),this.outerRoundness=new a(this,i.PropertyType.NUMBER),this.rotation=new a(this,i.PropertyType.ROTATION),this.points=new a(this,i.PropertyType.NUMBER),this.starType=i.StarType.STAR}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.position.fromJSON(t.p),t.sy===1&&(this.innerRadius.fromJSON(t.ir),this.innerRoundness.fromJSON(t.is)),this.outerRadius.fromJSON(t.or),this.outerRoundness.fromJSON(t.os),this.rotation.fromJSON(t.r),this.points.fromJSON(t.pt),this.starType=t.sy,this.direction=t.d,this}toJSON(){return V(V(V({ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,p:this.position},this.starType===1&&{ir:this.innerRadius}),this.starType===1&&{is:this.innerRoundness}),{or:this.outerRadius,os:this.outerRoundness,r:this.rotation,pt:this.points,sy:this.starType,d:this.direction})}}class K extends y{constructor(){super(...arguments);this.type=i.ShapeType.STROKE,this.blendMode=i.BlendMode.NORMAL,this.color=new a(this,i.PropertyType.COLOR),this.lineCapType=i.LineCapType.ROUND,this.lineJoinType=i.LineJoinType.ROUND,this.opacity=new a(this,i.PropertyType.OPACITY,[new N(0,100)]),this.width=new a(this,i.PropertyType.STROKE_WIDTH)}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm in i.BlendMode?t.bm:i.BlendMode.NORMAL,this.color.fromJSON(t.c),this.lineCapType=t.lc in i.LineCapType?t.lc:i.LineCapType.ROUND,this.lineJoinType=t.lj in i.LineJoinType?t.lj:i.LineJoinType.ROUND,this.miterLimit=t.ml,this.opacity.fromJSON(t.o),this.width.fromJSON(t.w),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,c:this.color,lc:this.lineCapType,lj:this.lineJoinType,ml:this.miterLimit,o:this.opacity,w:this.width}}}class z extends y{constructor(){super(...arguments);this.type=i.ShapeType.TRIM,this.blendMode=i.BlendMode.NORMAL,this.trimEnd=new a(this,i.PropertyType.NUMBER),this.trimOffset=new a(this,i.PropertyType.NUMBER),this.trimStart=new a(this,i.PropertyType.NUMBER),this.trimMultipleShapes=i.TrimMode.SIMULTANEOUSLY}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm in i.BlendMode?t.bm:i.BlendMode.NORMAL,this.trimEnd.fromJSON(t.e),this.trimOffset.fromJSON(t.o),this.trimStart.fromJSON(t.s),this.trimMultipleShapes=t.m in i.TrimMode?t.m:i.TrimMode.INDIVIDUALLY,this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,e:this.trimEnd,o:this.trimOffset,s:this.trimStart,m:this.trimMultipleShapes}}}var wt=Object.assign;class v extends y{constructor(){super(...arguments);this.type=i.ShapeType.GROUP,this.blendMode=i.BlendMode.NORMAL,this.isHidden=!1,this.numProperties=0,this.transform=new M,this.shapes=[]}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.blendMode=t.bm,this.contentPropertyIndex=t.cix,this.propertyIndex=t.ix,this.numProperties=t.np,this.shapes=t.it.map(e=>{try{if(e.ty!=="tr"){const r=this.createShape(e.ty);return r.fromJSON(e)}this.transform.fromJSON(e)}catch(r){}return!1}).filter(Boolean),this}createShape(t){if(t===i.ShapeType.PATH)return new B(this);if(t===i.ShapeType.GROUP)return new v(this);if(t===i.ShapeType.FILL)return new H(this);if(t===i.ShapeType.RECTANGLE)return new F(this);if(t===i.ShapeType.ELLIPSE)return new U(this);if(t===i.ShapeType.STROKE)return new K(this);if(t===i.ShapeType.GRADIENT_FILL)return new k(this);if(t===i.ShapeType.GRADIENT_STROKE)return new st(this);if(t===i.ShapeType.TRIM)return new z(this);if(t===i.ShapeType.MERGE)return new G(this);if(t===i.ShapeType.STAR)return new Y(this);throw new Error(`Invalid or unknown shape type: ${t}`)}addShape(t){return t instanceof y||(t=this.createShape(t)),this.shapes.push(t),t}toJSON(){const t=JSON.parse(JSON.stringify(this.shapes));return t.push(wt({ty:"tr",nm:"Transform"},this.transform.toJSON())),{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,bm:this.blendMode,cix:this.contentPropertyIndex,it:t,ix:this.propertyIndex,np:this.numProperties}}}class Rt extends y{constructor(){super(...arguments);this.type=i.ShapeType.REPEATER,this.anchor=new a(this,i.PropertyType.ANCHOR),this.startOpacity=new a(this,i.PropertyType.OPACITY),this.endOpacity=new a(this,i.PropertyType.OPACITY),this.position=new a(this,i.PropertyType.POSITION),this.rotation=new a(this,i.PropertyType.ROTATION),this.scale=new a(this,i.PropertyType.SCALE),this.shapes=[],this.skew=new a(this,i.PropertyType.SKEW),this.skewAxis=new a(this,i.PropertyType.SKEW_AXIS),this.copies=new a(this,i.PropertyType.NUMBER),this.offset=new a(this,i.PropertyType.NUMBER),this.composition=i.RepeaterComposite.ABOVE}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.copies.fromJSON(t.c),this.composition=t.m,this.offset.fromJSON(t.o),this.anchor.fromJSON(t.tr.a),this.startOpacity.fromJSON(t.tr.so),this.endOpacity.fromJSON(t.tr.eo),this.position.fromJSON(t.tr.p),this.rotation.fromJSON(t.tr.r),this.scale.fromJSON(t.tr.s),t.tr.sk&&this.skew.fromJSON(t.tr.sk),t.tr.sa&&this.skewAxis.fromJSON(t.tr.sa),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,m:this.composition,c:this.copies,o:this.offset,tr:{a:this.anchor,so:this.startOpacity,eo:this.endOpacity,p:this.position,r:this.rotation,s:this.scale,sk:this.skew,sa:this.skewAxis}}}}class At extends y{constructor(){super(...arguments);this.type=i.ShapeType.ROUNDED_CORNERS,this.roundness=new a(this,i.PropertyType.NUMBER)}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this.roundness.fromJSON(t.r),this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name,r:this.roundness}}}var It=Object.assign;class L extends E{constructor(){super(...arguments);this.type=i.LayerType.SHAPE,this.shapes=[]}createShape(t){if(t===i.ShapeType.PATH)return new B(this);if(t===i.ShapeType.GROUP)return new v(this);if(t===i.ShapeType.FILL)return new H(this);if(t===i.ShapeType.RECTANGLE)return new F(this);if(t===i.ShapeType.ELLIPSE)return new U(this);if(t===i.ShapeType.STROKE)return new K(this);if(t===i.ShapeType.GRADIENT_FILL)return new k(this);if(t===i.ShapeType.TRIM)return new z(this);if(t===i.ShapeType.MERGE)return new G(this);if(t===i.ShapeType.STAR)return new Y(this);throw new Error(`Invalid or unknown shape type: ${t}`)}addShape(t){return t instanceof y||(t=this.createShape(t)),this.shapes.push(t),t}createShapeFromJSON(t){try{const e=this.createShape(t.ty);return e.fromJSON(t)}catch(e){throw new Error(`Unable to create shape from JSON: ${t.ty}`)}}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,this.classNames="cl"in t?t.cl.split(" "):[],this.transform.fromJSON(t.ks),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.shapes=t.shapes.map(e=>this.createShapeFromJSON(e)).filter(Boolean),this}toJSON(){var t;return{ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:It({},this.transform.toJSON()),shapes:this.shapes.map(e=>e.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,sr:this.timeStretch,st:this.startTime,ty:this.type,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0}}}var Pt=Object.assign;class rt extends E{constructor(){super(...arguments);this.type=i.LayerType.SOLID,this.solidColor="#000000",this.solidHeight=1,this.solidWidth=1}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,"cl"in t&&(this.classNames=t.cl.split(" ")),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.transform.fromJSON(t.ks),this.solidColor=t.sc,this.solidHeight=t.sh,this.solidWidth=t.sw,this}toJSON(){var t;return{ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:Pt({},this.transform.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,sc:this.solidColor,sh:this.solidHeight,sw:this.solidWidth,sr:this.timeStretch,st:this.startTime,ty:this.type,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0}}}var bt=Object.assign;class ht extends E{constructor(){super(...arguments);this.type=i.LayerType.TEXT}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.effects=t.ef,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,"cl"in t&&(this.classNames=t.cl.split(" ")),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),this.transform.fromJSON(t.ks),this.textData=t.t,this}toJSON(){var t;return{ty:this.type,ao:this.autoOrient?1:0,bm:this.blendMode,cl:this.classNames.length?this.classNames.join(" "):void 0,ddd:this.is3D?1:0,ef:this.effects,h:this.height,ind:this.index,ip:this.inPoint,ks:bt({},this.transform.toJSON()),ln:this.id,nm:this.name,mn:this.matchName,op:this.outPoint,parent:(t=this.parent)==null?void 0:t.index,sr:this.timeStretch,st:this.startTime,w:this.width,tt:this.matteMode,td:this.matteTarget,hd:this.isHidden!==void 0?Number(this.isHidden):void 0,t:this.textData}}}class nt{constructor(){this.comment="",this.duration=0,this.time=0}fromJSON(t){return this.comment=t.cm,this.duration=t.dr,this.time=t.tm,this}toJSON(){return{cm:this.comment,dr:this.duration,tm:this.time}}}function at(t){let e=(+t[0]).toString(16),r=(+t[1]).toString(16),n=(+t[2]).toString(16),l=Math.round(+t[3]*255).toString(16);return e.length==1&&(e="0"+e),r.length==1&&(r="0"+r),n.length==1&&(n="0"+n),l.length==1&&(l="0"+l),"#"+e+r+n+l}function Jt(t,e){const r=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),l=parseInt(t.slice(5,7),16);return e?[r/255,n/255,l/255,e]:[r/255,n/255,l/255]}class ot{constructor(t){this.keywords=[],this.generator="@lottiefiles/lottie-js 0.3.7",this.parent=t}fromJSON(t){return this.author=t.a,this.keywords="k"in t?t.k.split(",").map(e=>e.trim()):[t.k],this.generator=t.g,this.description=t.d,this.themeColor=t.tc,this}toJSON(){return{a:this.author,k:this.keywords.length?this.keywords:void 0,g:this.generator,d:this.description,tc:this.themeColor}}}var vt=Object.assign,Lt=(t,e,r)=>new Promise((n,l)=>{var d=T=>{try{p(r.next(T))}catch(I){l(I)}},c=T=>{try{p(r.throw(T))}catch(I){l(I)}},p=T=>T.done?n(T.value):Promise.resolve(T.value).then(d,c);p((r=r.apply(t,e)).next())});class X{constructor(){this.assets=[],this.frameRate=60,this.height=0,this.inPoint=0,this.is3D=!1,this.layers=[],this.markers=[],this.meta=new ot(this),this.name="",this.outPoint=0,this.version="",this.width=0,this.fonts=new pt}static fromURL(t){return Lt(this,null,function*(){if(typeof t!="string")throw new Error("The url value must be a string");let e;try{const n=new URL(t),l=yield Ot(n.toString());e=yield l.json()}catch(n){throw new Error("An error occurred while trying to load the Lottie file from URL")}const r=new X;return r.fromJSON(e)})}static isLottie(t){const e=["v","ip","op","layers","fr","w","h"];return e.every(r=>Object.prototype.hasOwnProperty.call(t,r))}get colors(){const t=new Set;return[...R().keys()].filter(e=>e.type===i.PropertyType.COLOR).forEach(e=>{e.values.forEach(r=>{t.add(JSON.stringify(r.value))})}),Array.from(t).map(e=>J.fromJSON(JSON.parse(e)))}get colorsVerbose(){const t={};return[...R().keys()].filter(e=>e.type===i.PropertyType.COLOR).forEach((e,r)=>{const n=e.getParent(),l=this.parentPath(n),d=l.slice();e.values.forEach(c=>{d.unshift("Frame "+c.frame),d.unshift(r.toString());const p=c.value;t[d.join(".")]=at([Math.round(p[0]*255),Math.round(p[1]*255),Math.round(p[2]*255),p[3]])})}),t}get textLayers(){const t={},e=this.getLayersByType(i.LayerType.TEXT);return e.forEach((r,n)=>{t[n+"."+r.name]=r.textData.d.k[0].s.t}),t}parentPath(t,e=[]){return t.parent===void 0?(e.push(t.name),e):(e.push(t.name),this.parentPath(t.parent,e))}get duration(){return this.totalFrames/this.frameRate}get fileSize(){return new TextEncoder().encode(JSON.stringify(this)).length}get totalFrames(){return this.outPoint-this.inPoint}createAsset(t){if(t===i.AssetType.PRECOMPOSITION)return new x(this);if(t===i.AssetType.IMAGE)return new Q(this);throw new Error(`Invalid or unknown asset type ${t}`)}createAssetFromJSON(t){try{const e=this.createAsset("layers"in t?i.AssetType.PRECOMPOSITION:i.AssetType.IMAGE);return e.fromJSON(t)}catch(e){throw new Error("Unable to create asset from JSON")}}createLayer(t){if(t===i.LayerType.PRECOMPOSITION)return new it(this);if(t===i.LayerType.SHAPE)return new L(this);if(t===i.LayerType.GROUP)return new j(this);if(t===i.LayerType.SOLID)return new rt(this);if(t===i.LayerType.IMAGE)return new tt(this);if(t===i.LayerType.TEXT)return new ht(this);throw new Error(`Invalid or unknown layer type: ${t}`)}createLayerFromJSON(t){try{const e=this.createLayer(t.ty);return e.fromJSON(t)}catch(e){throw console.log(e),new Error(`Unable to create layer type from JSON: ${t.ty}`)}}createLayersFromJSONArray(t){const e=new Map,r=[],n=[];return t.forEach(l=>{const d=this.createLayerFromJSON(l);d&&(l.parent!==void 0&&r.push([d,l.parent]),d.index!==void 0&&e.set(d.index,d),n.push(d))}),r.forEach(([l,d])=>{l.parent=e.get(d)}),n}createMarker(){return new nt}createMarkerFromJSON(t){try{const e=this.createMarker();return e.fromJSON(t)}catch(e){throw console.log(e),new Error("Unable to create marker from JSON")}}fromJSON(t){if(X.isLottie(t)===!1)throw new Error("The given object is not a valid Lottie JSON structure");return this.frameRate=t.fr,this.height=t.h,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.version=t.v,this.width=t.w,this.assets=t.assets.map(e=>this.createAssetFromJSON(e)).filter(Boolean),this.layers=this.createLayersFromJSONArray(t.layers),this.markers=t.markers.map(e=>this.createMarkerFromJSON(e)).filter(Boolean),"meta"in t&&this.meta.fromJSON(t.meta),"fonts"in t&&this.fonts.fromJSON(t.fonts),this}getLayerById(t){if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.find(e=>e.id===t)}getShapeById(t){let e=null;if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.forEach(r=>{r instanceof L&&r.shapes.forEach(n=>{if(n.id===t){e=n;return}})}),e}getShapesByClassName(t){const e=[];if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.forEach(r=>{r instanceof L&&r.shapes.forEach(n=>{var l;if(((l=n.classNames)==null?void 0:l.includes(t))&&e.push(n),n instanceof v){const d=n.shapes;d.forEach(c=>{var p;((p=c.classNames)==null?void 0:p.includes(t))&&e.push(n)})}})}),e}getLayersByClassName(t){if(typeof t!="string")throw new Error("Class name value must be a string");return this.layers.filter(e=>e.classNames.includes(t))}getLayersByType(t){if(t in i.LayerType===!1)throw new Error("Type value must be a valid LayerType value");return this.layers.filter(e=>e.type===t)}toJSON(t){return t?void 0:vt({assets:this.assets,ddd:this.is3D?1:0,fr:this.frameRate,h:this.height,ip:this.inPoint,layers:this.layers.map(e=>e.toJSON()),markers:this.markers.map(e=>e.toJSON()),meta:this.meta,nm:this.name,op:this.outPoint,v:this.version||"5.6.0",w:this.width},this.fonts.list.length>0&&{fonts:this.fonts.toJSON()})}}class Dt{constructor(){this.isInverted=!1,this.name="",this.mode=i.MaskMode.Add}fromJSON(t){return this.isInverted=t.inv,this.mode=t.mode,this.name=t.nm,this.points=t.pt,this.opacity=t.o,this}toJSON(){return{inv:this.isInverted,mode:this.mode,nm:this.name,o:this.opacity,pt:this.points}}}i.Animation=X,i.Asset=g,i.Color=J,i.ColorRgb=A,i.ColorRgba=C,i.EllipseShape=U,i.FillShape=H,i.Gradient=_,i.GradientFillShape=k,i.GradientStop=et,i.GradientStrokeShape=st,i.GroupLayer=j,i.GroupShape=v,i.ImageAsset=Q,i.ImageLayer=tt,i.KeyFrame=N,i.Layer=E,i.Marker=nt,i.Mask=Dt,i.MergeShape=G,i.Meta=ot,i.PathShape=B,i.PrecompositionAsset=x,i.PrecompositionLayer=it,i.Property=a,i.RectangleShape=F,i.RepeaterShape=Rt,i.RoundedCornersShape=At,i.Shape=y,i.ShapeLayer=L,i.SolidLayer=rt,i.StarShape=Y,i.StrokeShape=K,i.TextLayer=ht,i.Transform=M,i.TrimShape=z,i.hexToRgba=Jt,i.rgbaToHex=at,i.useRegistry=R,Object.defineProperty(i,"__esModule",{value:!0})}); | ||
*/(function(i,g){typeof exports=="object"&&typeof module!="undefined"?g(exports):typeof define=="function"&&define.amd?define(["exports"],g):(i=typeof globalThis!="undefined"?globalThis:i||self,g(i.Lottie={}))})(this,function(i){"use strict";class g{constructor(t){this.parent=t}}class V extends g{fromJSON(t){return this.data=t.p,this.id=t.id,this.height=t.h,this.path=t.u,this.width=t.w,this}toJSON(){return{h:this.height,id:this.id,p:this.data,u:this.path,w:this.width}}}(function(t){t[t.PRECOMPOSITION=0]="PRECOMPOSITION",t[t.IMAGE=1]="IMAGE"})(i.AssetType||(i.AssetType={}));class K extends g{constructor(){super(...arguments);this.type=i.AssetType.PRECOMPOSITION,this.layers=[],this.id=""}fromJSON(t){return this.id=t.id,this.timeRemap=t.tm,this.layers=this.parent.createLayersFromJSONArray(t.layers),this}toJSON(){return{id:this.id,layers:this.layers.map(t=>t.toJSON()),tm:this.timeRemap}}}var pt=typeof globalThis!="undefined"?globalThis:typeof window!="undefined"?window:typeof global!="undefined"?global:typeof self!="undefined"?self:{};function Tt(t,e,s){return s={path:e,exports:{},require:function(n,u){return gt(n,u??s.path)}},t(s,s.exports),s.exports}function gt(){throw new Error("Dynamic requires are not currently supported by @rollup/plugin-commonjs")}var Et=Tt(function(t,e){var s=function(n){function u(){this.fetch=!1,this.DOMException=n.DOMException}return u.prototype=n,new u}(typeof self!="undefined"?self:pt);(function(n){var u=function(l){var f={searchParams:"URLSearchParams"in n,iterable:"Symbol"in n&&"iterator"in Symbol,blob:"FileReader"in n&&"Blob"in n&&function(){try{return new Blob,!0}catch(r){return!1}}(),formData:"FormData"in n,arrayBuffer:"ArrayBuffer"in n};function N(r){return r&&DataView.prototype.isPrototypeOf(r)}if(f.arrayBuffer)var T=["[object Int8Array]","[object Uint8Array]","[object Uint8ClampedArray]","[object Int16Array]","[object Uint16Array]","[object Int32Array]","[object Uint32Array]","[object Float32Array]","[object Float64Array]"],I=ArrayBuffer.isView||function(r){return r&&T.indexOf(Object.prototype.toString.call(r))>-1};function P(r){if(typeof r!="string"&&(r=String(r)),/[^a-z0-9\-#$%&'*+.^_`|~]/i.test(r))throw new TypeError("Invalid character in header field name");return r.toLowerCase()}function dt(r){return typeof r!="string"&&(r=String(r)),r}function G(r){var h={next:function(){var o=r.shift();return{done:o===void 0,value:o}}};return f.iterable&&(h[Symbol.iterator]=function(){return h}),h}function m(r){this.map={},r instanceof m?r.forEach(function(h,o){this.append(o,h)},this):Array.isArray(r)?r.forEach(function(h){this.append(h[0],h[1])},this):r&&Object.getOwnPropertyNames(r).forEach(function(h){this.append(h,r[h])},this)}m.prototype.append=function(r,h){r=P(r),h=dt(h);var o=this.map[r];this.map[r]=o?o+", "+h:h},m.prototype.delete=function(r){delete this.map[P(r)]},m.prototype.get=function(r){return r=P(r),this.has(r)?this.map[r]:null},m.prototype.has=function(r){return this.map.hasOwnProperty(P(r))},m.prototype.set=function(r,h){this.map[P(r)]=dt(h)},m.prototype.forEach=function(r,h){for(var o in this.map)this.map.hasOwnProperty(o)&&r.call(h,this.map[o],o,this)},m.prototype.keys=function(){var r=[];return this.forEach(function(h,o){r.push(o)}),G(r)},m.prototype.values=function(){var r=[];return this.forEach(function(h){r.push(h)}),G(r)},m.prototype.entries=function(){var r=[];return this.forEach(function(h,o){r.push([o,h])}),G(r)},f.iterable&&(m.prototype[Symbol.iterator]=m.prototype.entries);function B(r){if(r.bodyUsed)return Promise.reject(new TypeError("Already read"));r.bodyUsed=!0}function St(r){return new Promise(function(h,o){r.onload=function(){h(r.result)},r.onerror=function(){o(r.error)}})}function Ct(r){var h=new FileReader,o=St(h);return h.readAsArrayBuffer(r),o}function _t(r){var h=new FileReader,o=St(h);return h.readAsText(r),o}function Ut(r){for(var h=new Uint8Array(r),o=new Array(h.length),S=0;S<h.length;S++)o[S]=String.fromCharCode(h[S]);return o.join("")}function Nt(r){if(r.slice)return r.slice(0);var h=new Uint8Array(r.byteLength);return h.set(new Uint8Array(r)),h.buffer}function yt(){return this.bodyUsed=!1,this._initBody=function(r){this._bodyInit=r,r?typeof r=="string"?this._bodyText=r:f.blob&&Blob.prototype.isPrototypeOf(r)?this._bodyBlob=r:f.formData&&FormData.prototype.isPrototypeOf(r)?this._bodyFormData=r:f.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)?this._bodyText=r.toString():f.arrayBuffer&&f.blob&&N(r)?(this._bodyArrayBuffer=Nt(r.buffer),this._bodyInit=new Blob([this._bodyArrayBuffer])):f.arrayBuffer&&(ArrayBuffer.prototype.isPrototypeOf(r)||I(r))?this._bodyArrayBuffer=Nt(r):this._bodyText=r=Object.prototype.toString.call(r):this._bodyText="",this.headers.get("content-type")||(typeof r=="string"?this.headers.set("content-type","text/plain;charset=UTF-8"):this._bodyBlob&&this._bodyBlob.type?this.headers.set("content-type",this._bodyBlob.type):f.searchParams&&URLSearchParams.prototype.isPrototypeOf(r)&&this.headers.set("content-type","application/x-www-form-urlencoded;charset=UTF-8"))},f.blob&&(this.blob=function(){var r=B(this);if(r)return r;if(this._bodyBlob)return Promise.resolve(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(new Blob([this._bodyArrayBuffer]));if(this._bodyFormData)throw new Error("could not read FormData body as blob");return Promise.resolve(new Blob([this._bodyText]))},this.arrayBuffer=function(){return this._bodyArrayBuffer?B(this)||Promise.resolve(this._bodyArrayBuffer):this.blob().then(Ct)}),this.text=function(){var r=B(this);if(r)return r;if(this._bodyBlob)return _t(this._bodyBlob);if(this._bodyArrayBuffer)return Promise.resolve(Ut(this._bodyArrayBuffer));if(this._bodyFormData)throw new Error("could not read FormData body as text");return Promise.resolve(this._bodyText)},f.formData&&(this.formData=function(){return this.text().then(Ft)}),this.json=function(){return this.text().then(JSON.parse)},this}var Mt=["DELETE","GET","HEAD","OPTIONS","POST","PUT"];function kt(r){var h=r.toUpperCase();return Mt.indexOf(h)>-1?h:r}function R(r,h){h=h||{};var o=h.body;if(r instanceof R){if(r.bodyUsed)throw new TypeError("Already read");this.url=r.url,this.credentials=r.credentials,h.headers||(this.headers=new m(r.headers)),this.method=r.method,this.mode=r.mode,this.signal=r.signal,!o&&r._bodyInit!=null&&(o=r._bodyInit,r.bodyUsed=!0)}else this.url=String(r);if(this.credentials=h.credentials||this.credentials||"same-origin",(h.headers||!this.headers)&&(this.headers=new m(h.headers)),this.method=kt(h.method||this.method||"GET"),this.mode=h.mode||this.mode||null,this.signal=h.signal||this.signal,this.referrer=null,(this.method==="GET"||this.method==="HEAD")&&o)throw new TypeError("Body not allowed for GET or HEAD requests");this._initBody(o)}R.prototype.clone=function(){return new R(this,{body:this._bodyInit})};function Ft(r){var h=new FormData;return r.trim().split("&").forEach(function(o){if(o){var S=o.split("="),O=S.shift().replace(/\+/g," "),c=S.join("=").replace(/\+/g," ");h.append(decodeURIComponent(O),decodeURIComponent(c))}}),h}function Ht(r){var h=new m,o=r.replace(/\r?\n[\t ]+/g," ");return o.split(/\r?\n/).forEach(function(S){var O=S.split(":"),c=O.shift().trim();if(c){var D=O.join(":").trim();h.append(c,D)}}),h}yt.call(R.prototype);function p(r,h){h||(h={}),this.type="default",this.status=h.status===void 0?200:h.status,this.ok=this.status>=200&&this.status<300,this.statusText="statusText"in h?h.statusText:"OK",this.headers=new m(h.headers),this.url=h.url||"",this._initBody(r)}yt.call(p.prototype),p.prototype.clone=function(){return new p(this._bodyInit,{status:this.status,statusText:this.statusText,headers:new m(this.headers),url:this.url})},p.error=function(){var r=new p(null,{status:0,statusText:""});return r.type="error",r};var Gt=[301,302,303,307,308];p.redirect=function(r,h){if(Gt.indexOf(h)===-1)throw new RangeError("Invalid status code");return new p(null,{status:h,headers:{location:r}})},l.DOMException=n.DOMException;try{new l.DOMException}catch(r){l.DOMException=function(h,o){this.message=h,this.name=o;var S=Error(h);this.stack=S.stack},l.DOMException.prototype=Object.create(Error.prototype),l.DOMException.prototype.constructor=l.DOMException}function W(r,h){return new Promise(function(o,S){var O=new R(r,h);if(O.signal&&O.signal.aborted)return S(new l.DOMException("Aborted","AbortError"));var c=new XMLHttpRequest;function D(){c.abort()}c.onload=function(){var J={status:c.status,statusText:c.statusText,headers:Ht(c.getAllResponseHeaders()||"")};J.url="responseURL"in c?c.responseURL:J.headers.get("X-Request-URL");var Y="response"in c?c.response:c.responseText;o(new p(Y,J))},c.onerror=function(){S(new TypeError("Network request failed"))},c.ontimeout=function(){S(new TypeError("Network request failed"))},c.onabort=function(){S(new l.DOMException("Aborted","AbortError"))},c.open(O.method,O.url,!0),O.credentials==="include"?c.withCredentials=!0:O.credentials==="omit"&&(c.withCredentials=!1),"responseType"in c&&f.blob&&(c.responseType="blob"),O.headers.forEach(function(J,Y){c.setRequestHeader(Y,J)}),O.signal&&(O.signal.addEventListener("abort",D),c.onreadystatechange=function(){c.readyState===4&&O.signal.removeEventListener("abort",D)}),c.send(typeof O._bodyInit=="undefined"?null:O._bodyInit)})}return W.polyfill=!0,n.fetch||(n.fetch=W,n.Headers=m,n.Request=R,n.Response=p),l.Headers=m,l.Request=R,l.Response=p,l.fetch=W,l}({})})(s),delete s.fetch.polyfill,e=s.fetch,e.default=s.fetch,e.fetch=s.fetch,e.Headers=s.Headers,e.Request=s.Request,e.Response=s.Response,t.exports=e});(function(t){t[t.NORMAL=0]="NORMAL",t[t.MULTIPLY=1]="MULTIPLY",t[t.SCREEN=2]="SCREEN",t[t.OVERLAY=3]="OVERLAY",t[t.DARKEN=4]="DARKEN",t[t.LIGHTEN=5]="LIGHTEN",t[t.COLOR_DODGE=6]="COLOR_DODGE",t[t.COLOR_BURN=7]="COLOR_BURN",t[t.HARD_LIGHT=8]="HARD_LIGHT",t[t.SOFT_LIGHT=9]="SOFT_LIGHT",t[t.DIFFERENCE=10]="DIFFERENCE",t[t.EXCLUSION=11]="EXCLUSION",t[t.HUE=12]="HUE",t[t.SATURATION=13]="SATURATION",t[t.COLOR=14]="COLOR",t[t.LUMINOSITY=15]="LUMINOSITY"})(i.BlendMode||(i.BlendMode={})),function(t){t[t.EVEN_ODD=1]="EVEN_ODD",t[t.NONZERO=2]="NONZERO"}(i.FillRuleType||(i.FillRuleType={})),function(t){t[t.NONE=0]="NONE",t[t.LINEAR=1]="LINEAR",t[t.RADIAL=2]="RADIAL",t[t.ANGULAR=4]="ANGULAR",t[t.REFLECTED=5]="REFLECTED",t[t.DIAMOND=6]="DIAMOND"}(i.GradientFillType||(i.GradientFillType={})),function(t){t[t.LINEAR=1]="LINEAR",t[t.RADIAL=2]="RADIAL"}(i.GradientStrokeType||(i.GradientStrokeType={})),function(t){t[t.PRECOMPOSITION=0]="PRECOMPOSITION",t[t.SOLID=1]="SOLID",t[t.IMAGE=2]="IMAGE",t[t.GROUP=3]="GROUP",t[t.SHAPE=4]="SHAPE",t[t.TEXT=5]="TEXT",t[t.AUDIO=6]="AUDIO",t[t.VIDEO_PLACEHOLDER=7]="VIDEO_PLACEHOLDER",t[t.IMAGE_SEQUENCE=8]="IMAGE_SEQUENCE",t[t.VIDEO=9]="VIDEO",t[t.IMAGE_PLACEHOLDER=10]="IMAGE_PLACEHOLDER",t[t.GUIDE=11]="GUIDE",t[t.ADJUSTMENT=12]="ADJUSTMENT",t[t.CAMERA=13]="CAMERA",t[t.LIGHT=14]="LIGHT"}(i.LayerType||(i.LayerType={})),function(t){t[t.BUTT=1]="BUTT",t[t.ROUND=2]="ROUND",t[t.PROJECTING=3]="PROJECTING"}(i.LineCapType||(i.LineCapType={})),function(t){t[t.MITER=1]="MITER",t[t.ROUND=2]="ROUND",t[t.BEVEL=3]="BEVEL"}(i.LineJoinType||(i.LineJoinType={})),function(t){t.None="n",t.Add="a",t.Subtract="s",t.Intersect="i",t.Lighten="l",t.Darken="d",t.Difference="f"}(i.MaskMode||(i.MaskMode={})),function(t){t.ANCHOR="a",t.OPACITY="o",t.POSITION="p",t.POINTS="pt",t.ROTATION="r",t.ROTATION_X="rx",t.ROTATION_Y="ry",t.ROTATION_Z="rz",t.SCALE="s",t.SKEW_AXIS="sa",t.SKEW="sk",t.SHAPE="sh",t.EXPANSION="x",t.FEATHER="f",t.SIZE="sz",t.ROUNDNESS="rd",t.MITER_LIMIT="ml",t.STROKE_WIDTH="sw",t.NUMBER="nu",t.COLOR="cl",t.ORIENTATION="or",t.GRADIENT="gr",t.EFFECT_VALUE="v"}(i.PropertyType||(i.PropertyType={})),function(t){t.ELLIPSE="el",t.FILL="fl",t.GRADIENT_FILL="gf",t.GRADIENT_STROKE="gs",t.GROUP="gr",t.MERGE="mm",t.OFFSET_PATH="op",t.PATH="sh",t.RECTANGLE="rc",t.REPEATER="rp",t.ROUNDED_CORNERS="rd",t.STAR="sr",t.STROKE="st",t.TRIM="tm",t.TWIST="tw"}(i.ShapeType||(i.ShapeType={})),function(t){t[t.SIMULTANEOUSLY=1]="SIMULTANEOUSLY",t[t.INDIVIDUALLY=2]="INDIVIDUALLY"}(i.TrimMode||(i.TrimMode={})),function(t){t[t.ABOVE=1]="ABOVE",t[t.BELOW=2]="BELOW"}(i.RepeaterComposite||(i.RepeaterComposite={})),function(t){t[t.STAR=1]="STAR",t[t.POLYGON=2]="POLYGON"}(i.StarType||(i.StarType={})),function(t){t[t.NORMAL=0]="NORMAL",t[t.ALPHA=1]="ALPHA",t[t.INVERTED_ALPHA=2]="INVERTED_ALPHA",t[t.LUMA=3]="LUMA",t[t.INVERTED_LUMA=4]="INVERTED_LUMA"}(i.MatteMode||(i.MatteMode={})),function(t){t[t.NONE=0]="NONE",t[t.CUSTOM=5]="CUSTOM",t[t.PAINT_OVER_TRANSPARENT=7]="PAINT_OVER_TRANSPARENT",t[t.TINT=20]="TINT",t[t.FILL=21]="FILL",t[t.STROKE=22]="STROKE",t[t.TRITONE=23]="TRITONE",t[t.PRO_LEVELS=24]="PRO_LEVELS",t[t.DROP_SHADOW=25]="DROP_SHADOW",t[t.RADIAL_WIPE=26]="RADIAL_WIPE",t[t.DISPLACEMENT_MAP=27]="DISPLACEMENT_MAP",t[t.MATTE3=28]="MATTE3",t[t.GAUSSIAN_BLUR=29]="GAUSSIAN_BLUR",t[t.MESH_WRAP=31]="MESH_WRAP",t[t.WAVY=32]="WAVY",t[t.SPHERIZE=33]="SPHERIZE",t[t.PUPPET=34]="PUPPET"}(i.EffectType||(i.EffectType={})),function(t){t[t.SLIDER=0]="SLIDER",t[t.ANGLE=1]="ANGLE",t[t.COLOR=2]="COLOR",t[t.POINT=3]="POINT",t[t.CHECKBOX=4]="CHECKBOX",t[t.IGNORED=6]="IGNORED",t[t.DROPDOWN=7]="DROPDOWN",t[t.LAYER=10]="LAYER"}(i.EffectValueType||(i.EffectValueType={}));class y{constructor(t=0,e=0){this.frame=0,this.value=0,this.frameInTangent=[0,0],this.frameOutTangent=[1,1],this.hold=!1,this.frame=t,this.value=e}fromJSON(t,e=void 0){this.frame=t.t,e===void 0?this.value=t.s:this.value=e.fromJSON(t.s);const s="i"in t&&"o"in t,n="ti"in t&&"to"in t;return this.frameInTangent=s?[t.i.x,t.i.y]:void 0,this.frameOutTangent=s?[t.o.x,t.o.y]:void 0,n&&("x"in t.ti&&"y"in t.ti?this.valueInTangent=[t.ti.x,t.ti.y]:this.valueInTangent=t.ti,"x"in t.to&&"y"in t.to?this.valueOutTangent=[t.to.x,t.to.y]:this.valueOutTangent=t.to),this.hold="h"in t&&t.h,this}toJSON(){const t={t:this.frame,s:this.value};return this.hold?t.h=1:this.frameInTangent&&this.frameOutTangent&&(t.i={x:this.frameInTangent[0],y:this.frameInTangent[1]},t.o={x:this.frameOutTangent[0],y:this.frameOutTangent[1]}),this.valueInTangent&&this.valueOutTangent&&(t.ti=this.valueInTangent,t.to=this.valueOutTangent),t}}const Rt=new Map;function A(){return Rt}class L{toJSON(){return this.toRgbArray()}static fromJSON(t){return t.length>3?C.fromJSON(t):t.length==3?w.fromJSON(t):new w(0,0,0)}}class w extends L{constructor(t,e,s){super();this.r=t,this.g=e,this.b=s}toRgbArray(){return[this.r,this.g,this.b]}static fromJSON(t){return new w(t[0],t[1],t[2])}}class C extends w{constructor(t,e,s,n=1){super(t,e,s);this.a=n}toRgbArray(){return[this.r,this.g,this.b,this.a]}static fromJSON(t){return new C(t[0],t[1],t[2],t[3])}}class a{constructor(t,e,s=[]){this.UID=0,this.isAnimated=!1,this.values=[],this._parent=t,this.type=e,this.values=s,this.isAnimated=s.length>1,A().set(this,t)}getParent(){return this._parent}fromJSON(t){this.expression="x"in t?t.x:void 0,this.index=t.ix,this.isAnimated=t.a===1;let e;return this.type==i.PropertyType.COLOR&&(e=L),this.values=this.isAnimated?t.k.map(s=>new y().fromJSON(s,e)):[new y().fromJSON({t:0,s:t.k},e)],this.type===i.PropertyType.COLOR&&(this.maxColors="p"in t?t.p:void 0),this}toJSON(){let t;const e=this.isAnimated!==!1||this.values.length>1;return e?t=this.values:t=this.values.length?this.values[0].value:0,{x:this.expression,ix:this.index,a:e?1:0,k:t,p:this.maxColors}}}class z{constructor(t=0,e=[]){this.offset=t,this.color=e}get hasAlpha(){return this.color.length>3}get red(){return this.color[0]}get green(){return this.color[1]}get blue(){return this.color[2]}get alpha(){return this.color[3]}}class At extends a{constructor(){super(...arguments);this.colorCount=0}keyframeValue(t){return t>=this.values.length?[]:this.values[t].value}keyframeHasAlpha(t){return this.keyframeValue(t).length==this.colorCount*6}keframeStops(t){const e=this.keyframeValue(t),s=[],n=this.keyframeHasAlpha(t);for(let u=0;u<this.colorCount;u++){const l=e.slice(u,3);n&&l.push(e[this.colorCount*4+u*2]),s.push(new z(e[u*4],l))}return s}setKeyframeStops(t,e){if(t>=this.values.length)return;e.length>this.colorCount&&(this.colorCount=e.length),this.values[t].value=this.stopsToArray(e)}addKeyframe(t,e){const s=new y(t,this.stopsToArray(e));return e.length>this.colorCount&&(this.colorCount=e.length),this.values.push(s),s}stopsToArray(t){let e=!1;const s=[];for(const n of t)s.push(n.offset),s.push(n.red),s.push(n.green),s.push(n.blue),n.hasAlpha&&(e=!0);if(e)for(const n of t)s.push(n.offset),s.push(n.alpha!==void 0?n.alpha:1);return s}}class _{constructor(){this.gradientColors=new At(this,i.PropertyType.GRADIENT)}get colorCount(){return this.gradientColors.colorCount}set colorCount(t){this.gradientColors.colorCount=t}toJSON(){return{p:this.colorCount,k:this.gradientColors}}fromJSON(t){return this.gradientColors.fromJSON(t.k),this.colorCount=t.p,this}}class U{constructor(){this.anchor=new a(this,i.PropertyType.ANCHOR,[new y(0,[0,0])]),this.opacity=new a(this,i.PropertyType.OPACITY,[new y(0,100)]),this.position=new a(this,i.PropertyType.POSITION,[new y(0,[0,0])]),this.rotation=new a(this,i.PropertyType.ROTATION,[new y(0,0)]),this.scale=new a(this,i.PropertyType.SCALE,[new y(0,[100,100])]),this.skew=new a(this,i.PropertyType.SKEW),this.skewAxis=new a(this,i.PropertyType.SKEW_AXIS)}fromJSON(t){return this.rotation="r"in t?new a(this,i.PropertyType.ROTATION).fromJSON(t.r):void 0,"o"in t&&this.opacity.fromJSON(t.o),"p"in t&&this.position.fromJSON(t.p),"a"in t&&this.anchor.fromJSON(t.a),"s"in t&&this.scale.fromJSON(t.s),this.skew="sk"in t?new a(this,i.PropertyType.SKEW).fromJSON(t.sk):void 0,this.skewAxis="sa"in t?new a(this,i.PropertyType.SKEW_AXIS).fromJSON(t.sa):void 0,"or"in t&&(this.orientation=new a(this,i.PropertyType.ORIENTATION).fromJSON(t.or)),"rx"in t&&(this.rotationX=new a(this,i.PropertyType.ROTATION_X).fromJSON(t.rx)),"ry"in t&&(this.rotationY=new a(this,i.PropertyType.ROTATION_Y).fromJSON(t.ry)),"rz"in t&&(this.rotationZ=new a(this,i.PropertyType.ROTATION_Z).fromJSON(t.rz)),this}toJSON(){return{a:this.anchor,o:this.opacity,p:this.position,r:this.rotation,s:this.scale,sk:this.skew,sa:this.skewAxis,rx:this.rotationX,ry:this.rotationY,rz:this.rotationZ,or:this.orientation}}}class d{constructor(t){this.isHidden=!1,this.parent=t}fromJSON(t){return this.classNames=t.cl,this.id=t.ln,this.isHidden=t.hd,this.matchName=t.mn,this.name=t.nm,this}toJSON(){return{ty:this.type,cl:this.classNames,hd:this.isHidden,ln:this.id,mn:this.matchName,nm:this.name}}}class X extends d{constructor(){super(...arguments);this.type=i.ShapeType.ELLIPSE,this.position=new a(this,i.PropertyType.POSITION),this.size=new a(this,i.PropertyType.SIZE),this.direction=1}fromJSON(t){return super.fromJSON(t),this.position.fromJSON(t.p),this.size.fromJSON(t.s),this.direction=t.d,this}toJSON(){const t=super.toJSON();return Object.assign(t,{p:this.position,s:this.size,d:this.direction})}}class q extends d{constructor(){super(...arguments);this.type=i.ShapeType.FILL,this.blendMode=i.BlendMode.NORMAL,this.color=new a(this,i.PropertyType.COLOR),this.fillRule=i.FillRuleType.EVEN_ODD,this.opacity=new a(this,i.PropertyType.OPACITY,[new y(0,100)])}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm,this.color.fromJSON(t.c),this.fillRule=t.r in i.FillRuleType?t.r:i.FillRuleType.EVEN_ODD,this.opacity.fromJSON(t.o),this}toJSON(){const t=super.toJSON();return Object.assign(t,{bm:this.blendMode,c:this.color,r:this.fillRule,o:this.opacity})}}class Z extends d{constructor(){super(...arguments);this.type=i.ShapeType.GRADIENT_FILL,this.blendMode=i.BlendMode.NORMAL,this.endPoint=new a(this,i.PropertyType.POSITION),this.gradientColors=new _,this.gradientType=i.GradientFillType.LINEAR,this.highlightAngle=new a(this,i.PropertyType.NUMBER),this.highlightLength=new a(this,i.PropertyType.NUMBER),this.opacity=new a(this,i.PropertyType.OPACITY),this.startPoint=new a(this,i.PropertyType.POSITION),this.fillRule=i.FillRuleType.EVEN_ODD}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm,this.endPoint.fromJSON(t.e),this.gradientColors.fromJSON(t.g),this.gradientType=t.t,this.opacity.fromJSON(t.o),this.startPoint.fromJSON(t.s),this.fillRule=t.r,this.gradientType===i.GradientFillType.RADIAL&&(this.highlightAngle.fromJSON(t.a),this.highlightLength.fromJSON(t.h)),this}toJSON(){const t=super.toJSON();return Object.assign(t,{bm:this.blendMode,e:this.endPoint,g:this.gradientColors,t:this.gradientType,a:this.highlightAngle,h:this.highlightLength,o:this.opacity,r:this.fillRule,s:this.startPoint})}}var wt=Object.assign;class M extends d{constructor(){super(...arguments);this.type=i.ShapeType.GROUP,this.blendMode=i.BlendMode.NORMAL,this.isHidden=!1,this.numProperties=0,this.transform=new U,this.shapes=[]}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm,this.contentPropertyIndex=t.cix,this.propertyIndex=t.ix,this.numProperties=t.np,this.shapes=t.it.map(e=>{try{if(e.ty!=="tr"){const s=this.createShape(e.ty);return s.fromJSON(e)}else this.transform.fromJSON(e)}catch(s){}return!1}).filter(Boolean),this}createShape(t){return F(t,this)}addShape(t){return t instanceof d||(t=this.createShape(t)),this.shapes.push(t),t}toJSON(){const t=super.toJSON(),e=JSON.parse(JSON.stringify(this.shapes));return e.push(wt({ty:"tr",nm:"Transform"},this.transform.toJSON())),Object.assign(t,{bm:this.blendMode,cix:this.contentPropertyIndex,it:e,ix:this.propertyIndex,np:this.numProperties})}}class $ extends d{constructor(){super(...arguments);this.type=i.ShapeType.PATH,this.vertices=new a(this,i.PropertyType.SHAPE)}fromJSON(t){return super.fromJSON(t),this.itemIndex=t.ind,this.shapeIndex=t.ix,this.direction=t.d,this.vertices.fromJSON(t.ks),this}toJSON(){const t=super.toJSON();return Object.assign(t,{ind:this.itemIndex,ix:this.shapeIndex,d:this.direction,ks:this.vertices})}}class Q extends d{constructor(){super(...arguments);this.type=i.ShapeType.RECTANGLE,this.position=new a(this,i.PropertyType.POSITION),this.roundness=new a(this,i.PropertyType.ROUNDNESS),this.size=new a(this,i.PropertyType.SIZE)}fromJSON(t){return super.fromJSON(t),this.direction=t.d,this.position.fromJSON(t.p),this.roundness.fromJSON(t.r),this.size.fromJSON(t.s),this}toJSON(){const t=super.toJSON();return Object.assign(t,{d:this.direction,p:this.position,r:this.roundness,s:this.size})}}class x extends d{constructor(){super(...arguments);this.type=i.ShapeType.STROKE,this.blendMode=i.BlendMode.NORMAL,this.color=new a(this,i.PropertyType.COLOR),this.lineCapType=i.LineCapType.ROUND,this.lineJoinType=i.LineJoinType.ROUND,this.opacity=new a(this,i.PropertyType.OPACITY,[new y(0,100)]),this.width=new a(this,i.PropertyType.STROKE_WIDTH)}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm in i.BlendMode?t.bm:i.BlendMode.NORMAL,this.color.fromJSON(t.c),this.lineCapType=t.lc in i.LineCapType?t.lc:i.LineCapType.ROUND,this.lineJoinType=t.lj in i.LineJoinType?t.lj:i.LineJoinType.ROUND,this.miterLimit=t.ml,this.opacity.fromJSON(t.o),this.width.fromJSON(t.w),this}toJSON(){const t=super.toJSON();return Object.assign(t,{bm:this.blendMode,c:this.color,lc:this.lineCapType,lj:this.lineJoinType,ml:this.miterLimit,o:this.opacity,w:this.width})}}class j extends d{constructor(){super(...arguments);this.type=i.ShapeType.TRIM,this.blendMode=i.BlendMode.NORMAL,this.trimEnd=new a(this,i.PropertyType.NUMBER),this.trimOffset=new a(this,i.PropertyType.NUMBER),this.trimStart=new a(this,i.PropertyType.NUMBER),this.trimMultipleShapes=i.TrimMode.SIMULTANEOUSLY}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm in i.BlendMode?t.bm:i.BlendMode.NORMAL,this.trimEnd.fromJSON(t.e),this.trimOffset.fromJSON(t.o),this.trimStart.fromJSON(t.s),this.trimMultipleShapes=t.m in i.TrimMode?t.m:i.TrimMode.INDIVIDUALLY,this}toJSON(){const t=super.toJSON();return Object.assign(t,{bm:this.blendMode,e:this.trimEnd,o:this.trimOffset,s:this.trimStart,m:this.trimMultipleShapes})}}class tt extends d{constructor(){super(...arguments);this.type=i.ShapeType.GRADIENT_STROKE,this.blendMode=i.BlendMode.NORMAL,this.endPoint=new a(this,i.PropertyType.POSITION),this.gradientColors=new _,this.gradientType=i.GradientFillType.LINEAR,this.highlightAngle=new a(this,i.PropertyType.NUMBER),this.highlightLength=new a(this,i.PropertyType.NUMBER),this.opacity=new a(this,i.PropertyType.OPACITY),this.startPoint=new a(this,i.PropertyType.POSITION),this.lineCapType=i.LineCapType.ROUND,this.lineJoinType=i.LineJoinType.ROUND,this.width=new a(this,i.PropertyType.STROKE_WIDTH)}fromJSON(t){return super.fromJSON(t),this.blendMode=t.bm,this.opacity.fromJSON(t.o),this.endPoint.fromJSON(t.e),this.gradientColors.fromJSON(t.g),this.gradientType=t.t,this.startPoint.fromJSON(t.s),this.gradientType===i.GradientFillType.RADIAL&&(this.highlightAngle.fromJSON(t.a),this.highlightLength.fromJSON(t.h)),this.lineCapType=t.lc in i.LineCapType?t.lc:i.LineCapType.ROUND,this.lineJoinType=t.lj in i.LineJoinType?t.lj:i.LineJoinType.ROUND,this.miterLimit=t.ml,this.width.fromJSON(t.w),this}toJSON(){const t=super.toJSON();return Object.assign(t,{bm:this.blendMode,o:this.opacity,e:this.endPoint,g:this.gradientColors,t:this.gradientType,a:this.highlightAngle,h:this.highlightLength,s:this.startPoint,lc:this.lineCapType,lj:this.lineJoinType,ml:this.miterLimit,w:this.width})}}class it extends d{constructor(){super(...arguments);this.type=i.ShapeType.REPEATER,this.anchor=new a(this,i.PropertyType.ANCHOR),this.startOpacity=new a(this,i.PropertyType.OPACITY),this.endOpacity=new a(this,i.PropertyType.OPACITY),this.position=new a(this,i.PropertyType.POSITION),this.rotation=new a(this,i.PropertyType.ROTATION),this.scale=new a(this,i.PropertyType.SCALE),this.shapes=[],this.skew=new a(this,i.PropertyType.SKEW),this.skewAxis=new a(this,i.PropertyType.SKEW_AXIS),this.copies=new a(this,i.PropertyType.NUMBER),this.offset=new a(this,i.PropertyType.NUMBER),this.composition=i.RepeaterComposite.ABOVE}fromJSON(t){return super.fromJSON(t),this.copies.fromJSON(t.c),this.composition=t.m,this.offset.fromJSON(t.o),this.anchor.fromJSON(t.tr.a),this.startOpacity.fromJSON(t.tr.so),this.endOpacity.fromJSON(t.tr.eo),this.position.fromJSON(t.tr.p),this.rotation.fromJSON(t.tr.r),this.scale.fromJSON(t.tr.s),t.tr.sk&&this.skew.fromJSON(t.tr.sk),t.tr.sa&&this.skewAxis.fromJSON(t.tr.sa),this}toJSON(){const t=super.toJSON();return Object.assign(t,{m:this.composition,c:this.copies,o:this.offset,tr:{a:this.anchor,so:this.startOpacity,eo:this.endOpacity,p:this.position,r:this.rotation,s:this.scale,sk:this.skew,sa:this.skewAxis}})}}var k=Object.assign;class et extends d{constructor(){super(...arguments);this.type=i.ShapeType.STAR,this.position=new a(this,i.PropertyType.POSITION),this.innerRadius=new a(this,i.PropertyType.NUMBER),this.innerRoundness=new a(this,i.PropertyType.NUMBER),this.outerRadius=new a(this,i.PropertyType.NUMBER),this.outerRoundness=new a(this,i.PropertyType.NUMBER),this.rotation=new a(this,i.PropertyType.ROTATION),this.points=new a(this,i.PropertyType.NUMBER),this.starType=i.StarType.STAR}fromJSON(t){return super.fromJSON(t),this.position.fromJSON(t.p),t.sy===1&&(this.innerRadius.fromJSON(t.ir),this.innerRoundness.fromJSON(t.is)),this.outerRadius.fromJSON(t.or),this.outerRoundness.fromJSON(t.os),this.rotation.fromJSON(t.r),this.points.fromJSON(t.pt),this.starType=t.sy,this.direction=t.d,this}toJSON(){const t=super.toJSON();return Object.assign(t,k(k(k({p:this.position},this.starType===1&&{ir:this.innerRadius}),this.starType===1&&{is:this.innerRoundness}),{or:this.outerRadius,os:this.outerRoundness,r:this.rotation,pt:this.points,sy:this.starType,d:this.direction}))}}class rt extends d{constructor(){super(...arguments);this.type=i.ShapeType.ROUNDED_CORNERS,this.roundness=new a(this,i.PropertyType.NUMBER)}fromJSON(t){return super.fromJSON(t),this.roundness.fromJSON(t.r),this}toJSON(){const t=super.toJSON();return Object.assign(t,{r:this.roundness})}}class st extends d{constructor(){super(...arguments);this.type=i.ShapeType.MERGE,this.mergeMode=1}fromJSON(t){return super.fromJSON(t),this.mergeMode=t.mm,this}toJSON(){const t=super.toJSON();return Object.assign(t,{mm:this.mergeMode})}}const F=(t,e)=>{if(t===i.ShapeType.PATH)return new $(e);if(t===i.ShapeType.GROUP)return new M(e);if(t===i.ShapeType.FILL)return new q(e);if(t===i.ShapeType.RECTANGLE)return new Q(e);if(t===i.ShapeType.ELLIPSE)return new X(e);if(t===i.ShapeType.STROKE)return new x(e);if(t===i.ShapeType.GRADIENT_FILL)return new Z(e);if(t===i.ShapeType.GRADIENT_STROKE)return new tt(e);if(t===i.ShapeType.TRIM)return new j(e);if(t===i.ShapeType.MERGE)return new st(e);if(t===i.ShapeType.STAR)return new et(e);if(t===i.ShapeType.ROUNDED_CORNERS)return new rt(e);if(t===i.ShapeType.REPEATER)return new it(e);throw new Error(`Invalid or unknown shape type: ${t}`)};class It{constructor(){this.character="",this.fontSize=0,this.fontStyle="",this.fontWeight=0,this.data=[],this.fontFamily=""}createShape(t){return F(t,this)}createShapeFromJSON(t){try{const e=this.createShape(t.ty);return e.fromJSON(t)}catch(e){throw new Error(`Unable to create shape from JSON: ${t.ty}`)}}fromJSON(t){return this.character=t.ch,this.fontSize=t.size,this.fontStyle=t.style,this.fontWeight=t.w,this.fontFamily=t.fFamily,"data"in t&&t.data.shapes&&(this.data=t.data.shapes.map(e=>this.createShapeFromJSON(e))),this}toJSON(){const t=this.data.map(e=>e.toJSON());return{ch:this.character,size:this.fontSize,style:this.fontStyle,w:this.fontWeight,data:{shapes:t.length?t:void 0},fFamily:this.fontFamily}}}var b=Object.assign;class Pt{constructor(){this.fName="",this.fFamily="",this.fStyle="",this.ascent=0,this.fPath="",this.fWeight="",this.origin=-1,this.fClass=""}fromJSON(t){return this.fName=t.fName,this.fFamily=t.fFamily,this.fStyle=t.fStyle,this.ascent=t.ascent,this.fPath=t.fPath,this.fWeight=t.fWeight,this.origin=t.origin,this.fClass=t.fClass,this}toJSON(){return b(b(b(b({fName:this.fName,fFamily:this.fFamily,fStyle:this.fStyle,ascent:this.ascent},!(this.fPath==="")&&{fPath:this.fPath}),!(this.fWeight==="")&&{fWeight:this.fWeight}),!(this.origin>=0)&&{origin:this.origin}),!(this.fClass==="")&&{fClass:this.fClass})}}class Jt{constructor(){this.list=[]}fromJSON(t){return this.list=t.list.map(e=>new Pt().fromJSON(e)),this}toJSON(){return{list:this.list}}}class Lt{constructor(t){this.name="",this.index=0,this.value=new a(this,i.PropertyType.EFFECT_VALUE),this.type=t}fromJSON(t){return this.name=t.nm,this.matchName=t.mn,this.index=t.ix,this.value.fromJSON(t.v),this}toJSON(){return{ty:this.type,nm:this.name,mn:this.matchName,ix:this.index,v:this.value}}}class bt{constructor(t=i.EffectType.NONE){this.name="",this.index=0,this.enabled=!0,this.values=[],this.type=t}fromJSON(t){var e;return this.type=t.ty,this.name=t.nm,this.matchName=t.mn,this.numberOfProperties=t.np,this.index=t.ix,this.enabled=(e=t.en)!=null?e:!0,this.values=t.ef.map(s=>new Lt(s.ty).fromJSON(s)),this}toJSON(){const t=this.values.map(e=>e.toJSON());return{ty:this.type,nm:this.name,np:this.numberOfProperties,mn:this.matchName,ix:this.index,ef:t,en:this.enabled?1:this.enabled}}}class ht{constructor(){this.isInverted=!1,this.name="",this.opacity=new a(this,i.PropertyType.OPACITY),this.points=new a(this,i.PropertyType.POINTS),this.mode=i.MaskMode.Add,this.expansion=new a(this,i.PropertyType.EXPANSION)}fromJSON(t){return this.isInverted=Boolean(t.inv),this.mode=t.mode,this.name=t.nm,this.points.fromJSON(t.pt),this.opacity.fromJSON(t.o),this.expansion.fromJSON(t.x),this}toJSON(){return{inv:this.isInverted,mode:this.mode,nm:this.name,o:this.opacity,pt:this.points,x:this.expansion}}}class E{constructor(t){this.autoOrient=!1,this.blendMode=i.BlendMode.NORMAL,this.classNames=[],this.height=0,this.id="",this.inPoint=0,this.is3D=!1,this.name="",this.outPoint=0,this.startTime=0,this.timeStretch=1,this.width=0,this.masks=[],this.effects=[],this.transform=new U,this.parent=t}get colors(){const t=new Set,e=A();return[...e.keys()].filter(s=>e.get(s)===this&&s.type===i.PropertyType.COLOR).forEach(s=>{s.values.forEach(n=>{t.add(JSON.stringify(n.value))})}),Array.from(t).map(s=>JSON.parse(s))}get hasMask(){return this.masks.length>0}get totalFrames(){return this.outPoint-this.inPoint}fromJSON(t){return this.autoOrient=t.ao===1,this.blendMode=t.bm,this.height=t.h,this.id=t.ln,this.index=t.ind,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.parent=t.parent,this.startTime=t.st,this.timeStretch=t.sr,this.width=t.w,this.classNames="cl"in t?t.cl.split(" "):[],this.transform.fromJSON(t.ks),"tt"in t&&(this.matteMode=t.tt),"td"in t&&(this.matteTarget=t.td),"hd"in t&&(this.isHidden=t.hd),"mn"in t&&(this.matchName=t.mn),"masksProperties"in t&&(this.masks=t.masksProperties.map(e=>new ht().fromJSON(e))),"ef"in t&&(this.effects=t.ef.map(e=>new bt().fromJSON(e))),this}toJSON(){var t;const e=this.hasMask?this.masks.map(n=>n.toJSON()):void 0,s=this.effects.length?this.effects.map(n=>n.toJSON()):void 0;return{ddd:this.is3D?1:0,ind:this.index,ty:this.type,nm:this.name,mn:this.matchName,tt:this.matteMode,td:this.matteTarget,cl:this.classNames.length?this.classNames.join(" "):void 0,ln:this.id,parent:(t=this.parent)==null?void 0:t.index,hd:this.isHidden!==void 0?Number(this.isHidden):void 0,sr:this.timeStretch,ks:this.transform.toJSON(),ao:this.autoOrient?1:0,hasMask:this.hasMask||void 0,masksProperties:e,ef:s,w:this.width,h:this.height,ip:this.inPoint,op:this.outPoint,st:this.startTime,bm:this.blendMode}}}class nt extends E{constructor(){super(...arguments);this.type=i.LayerType.GROUP}fromJSON(t){return super.fromJSON(t),this}}class at extends E{constructor(){super(...arguments);this.type=i.LayerType.IMAGE}fromJSON(t){return super.fromJSON(t),this.refId=t.refId,this}toJSON(){const t=super.toJSON();return Object.assign(t,{refId:this.refId})}}class ot extends E{constructor(){super(...arguments);this.type=i.LayerType.PRECOMPOSITION}fromJSON(t){return super.fromJSON(t),this.refId=t.refId,this}toJSON(){const t=super.toJSON();return Object.assign(t,{refId:this.refId})}}class v extends E{constructor(){super(...arguments);this.type=i.LayerType.SHAPE,this.shapes=[]}createShape(t){return F(t,this)}addShape(t){return t instanceof d||(t=this.createShape(t)),this.shapes.push(t),t}createShapeFromJSON(t){try{const e=this.createShape(t.ty);return e.fromJSON(t)}catch(e){throw new Error(`Unable to create shape from JSON: ${t.ty}`)}}fromJSON(t){return super.fromJSON(t),this.shapes=t.shapes.map(e=>this.createShapeFromJSON(e)).filter(Boolean),this}toJSON(){const t=super.toJSON();return Object.assign(t,{shapes:this.shapes.map(e=>e.toJSON())})}}class ut extends E{constructor(){super(...arguments);this.type=i.LayerType.SOLID,this.solidColor="#000000",this.solidHeight=1,this.solidWidth=1}fromJSON(t){return super.fromJSON(t),this.solidColor=t.sc,this.solidHeight=t.sh,this.solidWidth=t.sw,this}toJSON(){const t=super.toJSON();return Object.assign(t,{sc:this.solidColor,sh:this.solidHeight,sw:this.solidWidth})}}class lt extends E{constructor(){super(...arguments);this.type=i.LayerType.TEXT}fromJSON(t){return super.fromJSON(t),this.textData=t.t,this}toJSON(){const t=super.toJSON();return Object.assign(t,{t:this.textData})}}class ct{constructor(){this.comment="",this.duration=0,this.time=0}fromJSON(t){return this.comment=t.cm,this.duration=t.dr,this.time=t.tm,this}toJSON(){return{cm:this.comment,dr:this.duration,tm:this.time}}}function ft(t){let e=(+t[0]).toString(16),s=(+t[1]).toString(16),n=(+t[2]).toString(16),u=Math.round(+t[3]*255).toString(16);return e.length==1&&(e="0"+e),s.length==1&&(s="0"+s),n.length==1&&(n="0"+n),u.length==1&&(u="0"+u),"#"+e+s+n+u}function vt(t,e){const s=parseInt(t.slice(1,3),16),n=parseInt(t.slice(3,5),16),u=parseInt(t.slice(5,7),16);return e?[s/255,n/255,u/255,e]:[s/255,n/255,u/255]}class mt{constructor(t){this.keywords=[],this.generator="@lottiefiles/lottie-js 0.3.9",this.parent=t}fromJSON(t){return this.author=t.a,this.keywords="k"in t?t.k.split(",").map(e=>e.trim()):[t.k],this.generator=t.g,this.description=t.d,this.themeColor=t.tc,this}toJSON(){return{a:this.author,k:this.keywords.length?this.keywords:void 0,g:this.generator,d:this.description,tc:this.themeColor}}}var Ot=Object.assign,Dt=(t,e,s)=>new Promise((n,u)=>{var l=T=>{try{N(s.next(T))}catch(I){u(I)}},f=T=>{try{N(s.throw(T))}catch(I){u(I)}},N=T=>T.done?n(T.value):Promise.resolve(T.value).then(l,f);N((s=s.apply(t,e)).next())});class H{constructor(){this.assets=[],this.frameRate=60,this.height=0,this.inPoint=0,this.is3D=!1,this.layers=[],this.markers=[],this.meta=new mt(this),this.name="",this.outPoint=0,this.version="",this.width=0,this.fonts=new Jt,this.characters=[]}static fromURL(t){return Dt(this,null,function*(){if(typeof t!="string")throw new Error("The url value must be a string");let e;try{const n=new URL(t),u=yield Et(n.toString());e=yield u.json()}catch(n){throw new Error("An error occurred while trying to load the Lottie file from URL")}const s=new H;return s.fromJSON(e)})}static isLottie(t){const e=["v","ip","op","layers","fr","w","h"];return e.every(s=>Object.prototype.hasOwnProperty.call(t,s))}get colors(){const t=new Set;return[...A().keys()].filter(e=>e.type===i.PropertyType.COLOR).forEach(e=>{e.values.forEach(s=>{t.add(JSON.stringify(s.value))})}),Array.from(t).map(e=>L.fromJSON(JSON.parse(e)))}get colorsVerbose(){const t={};return[...A().keys()].filter(e=>e.type===i.PropertyType.COLOR).forEach((e,s)=>{const n=e.getParent(),u=this.parentPath(n),l=u.slice();e.values.forEach(f=>{l.unshift("Frame "+f.frame),l.unshift(s.toString());const N=f.value;t[l.join(".")]=ft([Math.round(N[0]*255),Math.round(N[1]*255),Math.round(N[2]*255),N[3]])})}),t}get textLayers(){const t={},e=this.getLayersByType(i.LayerType.TEXT);return e.forEach((s,n)=>{t[n+"."+s.name]=s.textData.d.k[0].s.t}),t}parentPath(t,e=[]){return t.parent===void 0?(e.push(t.name),e):(e.push(t.name),this.parentPath(t.parent,e))}get duration(){return this.totalFrames/this.frameRate}get fileSize(){return new TextEncoder().encode(JSON.stringify(this)).length}get totalFrames(){return this.outPoint-this.inPoint}createAsset(t){if(t===i.AssetType.PRECOMPOSITION)return new K(this);if(t===i.AssetType.IMAGE)return new V(this);throw new Error(`Invalid or unknown asset type ${t}`)}createAssetFromJSON(t){try{const e=this.createAsset("layers"in t?i.AssetType.PRECOMPOSITION:i.AssetType.IMAGE);return e.fromJSON(t)}catch(e){throw new Error("Unable to create asset from JSON")}}createLayer(t){if(t===i.LayerType.PRECOMPOSITION)return new ot(this);if(t===i.LayerType.SHAPE)return new v(this);if(t===i.LayerType.GROUP)return new nt(this);if(t===i.LayerType.SOLID)return new ut(this);if(t===i.LayerType.IMAGE)return new at(this);if(t===i.LayerType.TEXT)return new lt(this);throw new Error(`Invalid or unknown layer type: ${t}`)}createLayerFromJSON(t){try{const e=this.createLayer(t.ty);return e.fromJSON(t)}catch(e){throw console.log(e),new Error(`Unable to create layer type from JSON: ${t.ty}`)}}createLayersFromJSONArray(t){const e=new Map,s=[],n=[];return t.forEach(u=>{const l=this.createLayerFromJSON(u);l&&(u.parent!==void 0&&s.push([l,u.parent]),l.index!==void 0&&e.set(l.index,l),n.push(l))}),s.forEach(([u,l])=>{u.parent=e.get(l)}),n}createMarker(){return new ct}createMarkerFromJSON(t){try{const e=this.createMarker();return e.fromJSON(t)}catch(e){throw console.log(e),new Error("Unable to create marker from JSON")}}fromJSON(t){if(H.isLottie(t)===!1)throw new Error("The given object is not a valid Lottie JSON structure");return this.frameRate=t.fr,this.height=t.h,this.inPoint=t.ip,this.is3D=t.ddd,this.name=t.nm,this.outPoint=t.op,this.version=t.v,this.width=t.w,this.assets=t.assets.map(e=>this.createAssetFromJSON(e)).filter(Boolean),this.layers=this.createLayersFromJSONArray(t.layers),this.markers=t.markers.map(e=>this.createMarkerFromJSON(e)).filter(Boolean),"meta"in t&&this.meta.fromJSON(t.meta),"fonts"in t&&this.fonts.fromJSON(t.fonts),"chars"in t&&(this.characters=t.chars.map(e=>new It().fromJSON(e))),this}getLayerById(t){if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.find(e=>e.id===t)}getShapeById(t){let e=null;if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.forEach(s=>{s instanceof v&&s.shapes.forEach(n=>{if(n.id===t){e=n;return}})}),e}getShapesByClassName(t){const e=[];if(typeof t!="string")throw new Error("ID value must be a string");return this.layers.forEach(s=>{s instanceof v&&s.shapes.forEach(n=>{var u;if(((u=n.classNames)==null?void 0:u.includes(t))&&e.push(n),n instanceof M){const l=n.shapes;l.forEach(f=>{var N;((N=f.classNames)==null?void 0:N.includes(t))&&e.push(n)})}})}),e}getLayersByClassName(t){if(typeof t!="string")throw new Error("Class name value must be a string");return this.layers.filter(e=>e.classNames.includes(t))}getLayersByType(t){if(t in i.LayerType===!1)throw new Error("Type value must be a valid LayerType value");return this.layers.filter(e=>e.type===t)}toJSON(t){if(t)return;const e=this.characters.map(s=>s.toJSON());return Ot(Ot({assets:this.assets,ddd:this.is3D?1:0,fr:this.frameRate,h:this.height,ip:this.inPoint,layers:this.layers.map(s=>s.toJSON()),markers:this.markers.map(s=>s.toJSON()),meta:this.meta,nm:this.name,op:this.outPoint,v:this.version||"5.6.0",w:this.width},this.fonts.list.length>0&&{fonts:this.fonts.toJSON()}),{chars:e.length>0?e:void 0})}}i.Animation=H,i.Asset=g,i.Color=L,i.ColorRgb=w,i.ColorRgba=C,i.EllipseShape=X,i.FillShape=q,i.Gradient=_,i.GradientFillShape=Z,i.GradientStop=z,i.GradientStrokeShape=tt,i.GroupLayer=nt,i.GroupShape=M,i.ImageAsset=V,i.ImageLayer=at,i.KeyFrame=y,i.Layer=E,i.Marker=ct,i.Mask=ht,i.MergeShape=st,i.Meta=mt,i.PathShape=$,i.PrecompositionAsset=K,i.PrecompositionLayer=ot,i.Property=a,i.RectangleShape=Q,i.RepeaterShape=it,i.RoundedCornersShape=rt,i.Shape=d,i.ShapeLayer=v,i.SolidLayer=ut,i.StarShape=et,i.StrokeShape=x,i.TextLayer=lt,i.Transform=U,i.TrimShape=j,i.hexToRgba=vt,i.rgbaToHex=ft,i.useRegistry=A,Object.defineProperty(i,"__esModule",{value:!0})}); | ||
//# sourceMappingURL=index.umd.js.map |
{ | ||
"name": "@lottiefiles/lottie-js", | ||
"version": "0.3.7", | ||
"version": "0.3.9", | ||
"description": "Lottie JSON model for Javascript/Typescript", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
688313
4360