@codexo/exojs-aseprite 0.15.2 → 0.16.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +10 -24
- package/dist/esm/AsepriteData.d.ts +22 -6
- package/dist/esm/AsepriteData.d.ts.map +1 -0
- package/dist/esm/AsepriteData.js +4 -7
- package/dist/esm/AsepriteData.js.map +1 -1
- package/dist/esm/AsepriteSheet.d.ts +25 -11
- package/dist/esm/AsepriteSheet.d.ts.map +1 -0
- package/dist/esm/AsepriteSheet.js +212 -225
- package/dist/esm/AsepriteSheet.js.map +1 -1
- package/dist/esm/asepriteExtension.d.ts +5 -4
- package/dist/esm/asepriteExtension.d.ts.map +1 -0
- package/dist/esm/asepriteExtension.js +16 -16
- package/dist/esm/asepriteExtension.js.map +1 -1
- package/dist/esm/asepriteType.d.ts +28 -0
- package/dist/esm/asepriteType.d.ts.map +1 -0
- package/dist/esm/asepriteType.js +83 -0
- package/dist/esm/asepriteType.js.map +1 -0
- package/dist/esm/index.d.ts +1 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +6 -5
- package/dist/esm/public.d.ts +3 -1
- package/dist/esm/public.d.ts.map +1 -0
- package/package.json +7 -14
- package/dist/esm/asepriteBinding.d.ts +0 -27
- package/dist/esm/asepriteBinding.js +0 -106
- package/dist/esm/asepriteBinding.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/register.d.ts +0 -1
- package/dist/esm/register.js +0 -15
- package/dist/esm/register.js.map +0 -1
package/README.md
CHANGED
|
@@ -12,13 +12,15 @@ npm install @codexo/exojs @codexo/exojs-aseprite
|
|
|
12
12
|
`@codexo/exojs` is a peer dependency. This package has no other runtime dependencies.
|
|
13
13
|
|
|
14
14
|
> Export your sprite sheet from Aseprite as a **JSON + PNG** pair (`File → Export Sprite Sheet`,
|
|
15
|
-
>
|
|
15
|
+
> _Output → JSON Data_). Either array or hash frame mode works; frame tags become animation clips.
|
|
16
16
|
|
|
17
17
|
## What this package provides
|
|
18
18
|
|
|
19
|
-
- `AsepriteSheet` — parsed sprite sheet; the result of
|
|
19
|
+
- `AsepriteSheet` — parsed sprite sheet; the result of
|
|
20
|
+
`loader.load(Asset.type('asepriteSheet', url))`. Exposes
|
|
20
21
|
the underlying `spritesheet`, a `clips` map (one `AnimatedSpriteClipDefinition` per frame tag),
|
|
21
|
-
and `createAnimatedSprite()` for a ready-to-play
|
|
22
|
+
the `slices` and `layers` metadata maps, and `createAnimatedSprite()` for a ready-to-play
|
|
23
|
+
`AnimatedSprite`
|
|
22
24
|
- `asepriteExtension` — extension descriptor registering the Aseprite asset binding
|
|
23
25
|
- `asepriteBinding` — the underlying `AssetBinding` (advanced/custom wiring)
|
|
24
26
|
- `AsepriteFormatError` — typed error thrown on malformed Aseprite JSON
|
|
@@ -31,37 +33,21 @@ Register the extension, load an Aseprite JSON export, and create an animated spr
|
|
|
31
33
|
fetches the JSON, resolves and loads the packed texture, and builds one clip per frame tag:
|
|
32
34
|
|
|
33
35
|
```ts
|
|
34
|
-
import { Application } from '@codexo/exojs';
|
|
36
|
+
import { Application, Asset } from '@codexo/exojs';
|
|
35
37
|
import { AsepriteSheet, asepriteExtension } from '@codexo/exojs-aseprite';
|
|
36
38
|
|
|
37
39
|
const app = new Application({ extensions: [asepriteExtension] });
|
|
38
40
|
|
|
39
|
-
const sheet = await app.loader.load(
|
|
41
|
+
const sheet = await app.loader.load(Asset.type('asepriteSheet', 'sprites/hero.aseprite.json'));
|
|
40
42
|
|
|
41
43
|
const sprite = sheet.createAnimatedSprite();
|
|
42
44
|
sprite.play('run'); // 'run' is an Aseprite frame-tag name
|
|
43
|
-
app.
|
|
45
|
+
app.scenes.root.addChild(sprite);
|
|
44
46
|
```
|
|
45
47
|
|
|
46
48
|
Clip frame rate is derived from each frame's Aseprite `duration` (falling back to 12 fps). Frame
|
|
47
49
|
indices in a tag are resolved against the ordered frame array; out-of-range indices are skipped.
|
|
48
50
|
|
|
49
|
-
## `/register` convenience entry
|
|
50
|
-
|
|
51
|
-
Importing `/register` registers `asepriteExtension` in the global `ExtensionRegistry`, so
|
|
52
|
-
subsequently created Applications that use global defaults pick it up automatically:
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
// Side effect: registers asepriteExtension in the global ExtensionRegistry.
|
|
56
|
-
import '@codexo/exojs-aseprite/register';
|
|
57
|
-
|
|
58
|
-
// All named exports are also re-exported from /register:
|
|
59
|
-
import { AsepriteSheet, asepriteExtension } from '@codexo/exojs-aseprite/register';
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
This is the only side-effectful entry — importing the package root (`@codexo/exojs-aseprite`) does
|
|
63
|
-
**not** register anything.
|
|
64
|
-
|
|
65
51
|
## Texture ownership
|
|
66
52
|
|
|
67
53
|
The packed texture is loaded via the Loader and stays in the Loader cache. `AsepriteSheet.destroy()`
|
|
@@ -70,8 +56,8 @@ releases the parsed sprite sheet; the Loader handles texture lifecycle and dedup
|
|
|
70
56
|
## Core compatibility
|
|
71
57
|
|
|
72
58
|
| `@codexo/exojs-aseprite` | `@codexo/exojs` |
|
|
73
|
-
|
|
74
|
-
| 0.14.x
|
|
59
|
+
| ------------------------ | --------------- |
|
|
60
|
+
| 0.14.x | 0.14.x |
|
|
75
61
|
|
|
76
62
|
## Links
|
|
77
63
|
|
|
@@ -41,11 +41,26 @@ export interface AsepriteFrameTag {
|
|
|
41
41
|
*/
|
|
42
42
|
readonly repeat?: string;
|
|
43
43
|
}
|
|
44
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* A single layer entry in the Aseprite JSON metadata (`meta.layers`).
|
|
46
|
+
*
|
|
47
|
+
* Only `name` is guaranteed. `opacity` and `blendMode` describe an image
|
|
48
|
+
* layer's compositing and can both be absent (a group layer has neither), and
|
|
49
|
+
* `color`/`data` carry the layer's editor user data when it was set. `group`
|
|
50
|
+
* names the enclosing group layer and is absent at the top level, so the flat
|
|
51
|
+
* array encodes the layer tree by parent name.
|
|
52
|
+
*/
|
|
45
53
|
export interface AsepriteLayer {
|
|
46
|
-
readonly blendMode
|
|
54
|
+
readonly blendMode?: string;
|
|
55
|
+
/** Layer colour tag from the editor, as `#RRGGBBAA`. */
|
|
56
|
+
readonly color?: string;
|
|
57
|
+
/** Free-form user data attached to the layer in the editor. */
|
|
58
|
+
readonly data?: string;
|
|
59
|
+
/** Name of the enclosing group layer; absent for a top-level layer. */
|
|
60
|
+
readonly group?: string;
|
|
47
61
|
readonly name: string;
|
|
48
|
-
|
|
62
|
+
/** Layer opacity in `[0, 255]` (Aseprite's own scale, not `[0, 1]`). */
|
|
63
|
+
readonly opacity?: number;
|
|
49
64
|
}
|
|
50
65
|
/** Bounds of a named slice at a specific frame. */
|
|
51
66
|
export interface AsepriteSliceKey {
|
|
@@ -71,12 +86,12 @@ export interface AsepriteMeta {
|
|
|
71
86
|
readonly slices?: readonly AsepriteSlice[];
|
|
72
87
|
readonly version: string;
|
|
73
88
|
}
|
|
74
|
-
/** Aseprite JSON export in array mode
|
|
89
|
+
/** Aseprite JSON export in array mode - frames is an ordered array. */
|
|
75
90
|
export interface AsepriteArrayData {
|
|
76
91
|
readonly frames: readonly AsepriteFrameData[];
|
|
77
92
|
readonly meta: AsepriteMeta;
|
|
78
93
|
}
|
|
79
|
-
/** Aseprite JSON export in hash mode
|
|
94
|
+
/** Aseprite JSON export in hash mode - frames is an object keyed by frame name. */
|
|
80
95
|
export interface AsepriteHashData {
|
|
81
96
|
readonly frames: Readonly<Record<string, AsepriteFrameData>>;
|
|
82
97
|
readonly meta: AsepriteMeta;
|
|
@@ -88,4 +103,5 @@ export interface AsepriteHashData {
|
|
|
88
103
|
*/
|
|
89
104
|
export type AsepriteData = AsepriteArrayData | AsepriteHashData;
|
|
90
105
|
/** Returns `true` when `data` is in array mode (frames is an array). */
|
|
91
|
-
export declare
|
|
106
|
+
export declare const isAsepriteArrayData: (data: AsepriteData) => data is AsepriteArrayData;
|
|
107
|
+
//# sourceMappingURL=AsepriteData.d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IAC3C,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B;AAED,uEAAuE;AACvE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,MAAM,EAAE,SAAS,iBAAiB,EAAE,CAAC;IAC9C,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED,mFAAmF;AACnF,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC,CAAC;IAC7D,QAAQ,CAAC,IAAI,EAAE,YAAY,CAAC;CAC7B;AAED;;;;GAIG;AACH,MAAM,MAAM,YAAY,GAAG,iBAAiB,GAAG,gBAAgB,CAAC;AAEhE,wEAAwE;AACxE,eAAO,MAAM,mBAAmB,GAAI,MAAM,YAAY,KAAG,IAAI,IAAI,iBAA+C,CAAC"}
|
package/dist/esm/AsepriteData.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
// Supports both array mode (frames is an ordered array) and hash mode
|
|
3
|
-
// (frames is an object keyed by frame name / filename).
|
|
1
|
+
//#region src/AsepriteData.ts
|
|
4
2
|
/** Returns `true` when `data` is in array mode (frames is an array). */
|
|
5
|
-
|
|
6
|
-
return Array.isArray(data.frames);
|
|
7
|
-
}
|
|
3
|
+
const isAsepriteArrayData = (data) => Array.isArray(data.frames);
|
|
8
4
|
|
|
5
|
+
//#endregion
|
|
9
6
|
export { isAsepriteArrayData };
|
|
10
|
-
//# sourceMappingURL=AsepriteData.js.map
|
|
7
|
+
//# sourceMappingURL=AsepriteData.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AsepriteData.js","sources":["
|
|
1
|
+
{"version":3,"file":"AsepriteData.js","names":[],"sources":["../../src/AsepriteData.ts"],"sourcesContent":["// TypeScript types for the Aseprite JSON sprite sheet export format.\n// Supports both array mode (frames is an ordered array) and hash mode\n// (frames is an object keyed by frame name / filename).\n\n/** Playback direction of an Aseprite frame tag animation. */\nexport type AsepriteDirection = 'forward' | 'pingpong' | 'pingpong_reverse' | 'reverse';\n\n/** Pixel region rectangle used throughout the Aseprite JSON format. */\nexport interface AsepriteRect {\n readonly h: number;\n readonly w: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** Width/height size descriptor used in Aseprite metadata. */\nexport interface AsepriteSize {\n readonly h: number;\n readonly w: number;\n}\n\n/** A single animation frame in the Aseprite JSON export. */\nexport interface AsepriteFrameData {\n /** Display duration of this frame in milliseconds. */\n readonly duration: number;\n /** Pixel region of this frame within the packed sprite sheet texture. */\n readonly frame: AsepriteRect;\n readonly rotated: boolean;\n readonly sourceSize: AsepriteSize;\n readonly spriteSourceSize: AsepriteRect;\n readonly trimmed: boolean;\n}\n\n/**\n * A named animation range defined via Aseprite frame tags.\n * `from` and `to` are inclusive zero-based frame indices.\n */\nexport interface AsepriteFrameTag {\n readonly color?: string;\n readonly direction: AsepriteDirection;\n /** Inclusive end frame index. */\n readonly to: number;\n /** Inclusive start frame index. */\n readonly from: number;\n readonly name: string;\n /**\n * Number of times the tag plays before stopping, as a numeric string\n * (e.g. `\"1\"`, `\"2\"`). Absent means the tag loops indefinitely.\n */\n readonly repeat?: string;\n}\n\n/**\n * A single layer entry in the Aseprite JSON metadata (`meta.layers`).\n *\n * Only `name` is guaranteed. `opacity` and `blendMode` describe an image\n * layer's compositing and can both be absent (a group layer has neither), and\n * `color`/`data` carry the layer's editor user data when it was set. `group`\n * names the enclosing group layer and is absent at the top level, so the flat\n * array encodes the layer tree by parent name.\n */\nexport interface AsepriteLayer {\n readonly blendMode?: string;\n /** Layer colour tag from the editor, as `#RRGGBBAA`. */\n readonly color?: string;\n /** Free-form user data attached to the layer in the editor. */\n readonly data?: string;\n /** Name of the enclosing group layer; absent for a top-level layer. */\n readonly group?: string;\n readonly name: string;\n /** Layer opacity in `[0, 255]` (Aseprite's own scale, not `[0, 1]`). */\n readonly opacity?: number;\n}\n\n/** Bounds of a named slice at a specific frame. */\nexport interface AsepriteSliceKey {\n readonly bounds: AsepriteRect;\n readonly frame: number;\n}\n\n/** A named slice defined in the Aseprite editor. */\nexport interface AsepriteSlice {\n readonly color?: string;\n readonly keys: readonly AsepriteSliceKey[];\n readonly name: string;\n}\n\n/** Metadata block of an Aseprite JSON export. */\nexport interface AsepriteMeta {\n readonly app: string;\n readonly format: string;\n readonly frameTags?: readonly AsepriteFrameTag[];\n /** Relative path to the exported sprite sheet image. */\n readonly image: string;\n readonly layers?: readonly AsepriteLayer[];\n readonly scale: string;\n readonly size: AsepriteSize;\n readonly slices?: readonly AsepriteSlice[];\n readonly version: string;\n}\n\n/** Aseprite JSON export in array mode - frames is an ordered array. */\nexport interface AsepriteArrayData {\n readonly frames: readonly AsepriteFrameData[];\n readonly meta: AsepriteMeta;\n}\n\n/** Aseprite JSON export in hash mode - frames is an object keyed by frame name. */\nexport interface AsepriteHashData {\n readonly frames: Readonly<Record<string, AsepriteFrameData>>;\n readonly meta: AsepriteMeta;\n}\n\n/**\n * Union of both Aseprite JSON export formats.\n *\n * Use {@link isAsepriteArrayData} to discriminate between array and hash mode.\n */\nexport type AsepriteData = AsepriteArrayData | AsepriteHashData;\n\n/** Returns `true` when `data` is in array mode (frames is an array). */\nexport const isAsepriteArrayData = (data: AsepriteData): data is AsepriteArrayData => Array.isArray(data.frames);\n"],"mappings":";;AAyHA,MAAa,uBAAuB,SAAkD,MAAM,QAAQ,KAAK,MAAM"}
|
|
@@ -1,20 +1,21 @@
|
|
|
1
1
|
import { AnimatedSprite, type AnimatedSpriteClipDefinition, Spritesheet, type Texture } from '@codexo/exojs';
|
|
2
|
-
import { type AsepriteData, type AsepriteSlice } from './AsepriteData';
|
|
2
|
+
import { type AsepriteData, type AsepriteLayer, type AsepriteSlice } from './AsepriteData';
|
|
3
3
|
/**
|
|
4
4
|
* Parsed representation of an Aseprite JSON sprite sheet export.
|
|
5
5
|
*
|
|
6
6
|
* `AsepriteSheet.parse(data, texture)` converts the raw JSON document into:
|
|
7
7
|
* - A {@link Spritesheet} whose frames correspond to the Aseprite frame array
|
|
8
|
-
* (keyed by zero-based index string: `"0"`, `"1"`,
|
|
8
|
+
* (keyed by zero-based index string: `"0"`, `"1"`, ...).
|
|
9
9
|
* - A `clips` map of {@link AnimatedSpriteClipDefinition} entries built from
|
|
10
10
|
* `meta.frameTags`, one per named tag.
|
|
11
|
+
* - The `slices` and `layers` metadata maps, carried through verbatim.
|
|
11
12
|
*
|
|
12
13
|
* Call {@link createAnimatedSprite} to obtain a ready-to-use
|
|
13
14
|
* {@link AnimatedSprite} with all clips pre-registered.
|
|
14
15
|
*
|
|
15
16
|
* @example
|
|
16
17
|
* ```ts
|
|
17
|
-
* const sheet = await loader.load(
|
|
18
|
+
* const sheet = await loader.load(Asset.type('asepriteSheet', 'hero.aseprite.json'));
|
|
18
19
|
* const sprite = sheet.createAnimatedSprite();
|
|
19
20
|
* sprite.play('run');
|
|
20
21
|
* scene.addChild(sprite);
|
|
@@ -31,19 +32,31 @@ export declare class AsepriteSheet {
|
|
|
31
32
|
readonly clips: ReadonlyMap<string, AnimatedSpriteClipDefinition>;
|
|
32
33
|
/**
|
|
33
34
|
* Named slices from the Aseprite `meta.slices` metadata, keyed by slice
|
|
34
|
-
* name. Slices describe editor-defined regions
|
|
35
|
-
* borders, UI anchor points
|
|
35
|
+
* name. Slices describe editor-defined regions - hitboxes, nine-patch
|
|
36
|
+
* borders, UI anchor points - that aren't part of the frame/animation
|
|
36
37
|
* data itself. Each {@link AsepriteSlice} carries one {@link AsepriteSliceKey}
|
|
37
38
|
* per frame at which its bounds change; consumers resolve the applicable
|
|
38
39
|
* key for a given frame index themselves.
|
|
39
40
|
*/
|
|
40
41
|
readonly slices: ReadonlyMap<string, AsepriteSlice>;
|
|
41
42
|
/**
|
|
42
|
-
*
|
|
43
|
+
* Layers from the Aseprite `meta.layers` metadata, keyed by layer name and
|
|
44
|
+
* in export order (bottom-most first). Aseprite packs the sheet already
|
|
45
|
+
* composited, so these are descriptive rather than renderable: they tell a
|
|
46
|
+
* consumer which layers went into a frame and how - opacity, blend mode,
|
|
47
|
+
* editor user data - and {@link AsepriteLayer.group} names the enclosing
|
|
48
|
+
* group layer, so the flat map still encodes the layer tree.
|
|
49
|
+
*
|
|
50
|
+
* Empty when the export carries no `meta.layers` block. Layer names are
|
|
51
|
+
* unique within an Aseprite document, so keying by name loses nothing.
|
|
52
|
+
*/
|
|
53
|
+
readonly layers: ReadonlyMap<string, AsepriteLayer>;
|
|
54
|
+
/**
|
|
55
|
+
* @internal - use {@link AsepriteSheet.parse} to create instances.
|
|
43
56
|
* The public modifier is required for the Loader's `AssetConstructor` token
|
|
44
57
|
* contract; users should call `parse()` instead of constructing directly.
|
|
45
58
|
*/
|
|
46
|
-
constructor(spritesheet: Spritesheet, clips: ReadonlyMap<string, AnimatedSpriteClipDefinition>, slices: ReadonlyMap<string, AsepriteSlice>);
|
|
59
|
+
constructor(spritesheet: Spritesheet, clips: ReadonlyMap<string, AnimatedSpriteClipDefinition>, slices: ReadonlyMap<string, AsepriteSlice>, layers?: ReadonlyMap<string, AsepriteLayer>);
|
|
47
60
|
/**
|
|
48
61
|
* Parse a raw {@link AsepriteData} document and the already-loaded
|
|
49
62
|
* {@link Texture} into an {@link AsepriteSheet}.
|
|
@@ -53,21 +66,21 @@ export declare class AsepriteSheet {
|
|
|
53
66
|
* indices are silently skipped.
|
|
54
67
|
*
|
|
55
68
|
* A tag's `direction` determines the expanded frame sequence fed into the
|
|
56
|
-
* clip
|
|
69
|
+
* clip - `forward` and `reverse` play the `[from, to]` range in order or
|
|
57
70
|
* in reverse, while `pingpong`/`pingpong_reverse` append a backward pass
|
|
58
71
|
* (excluding both endpoints) so the bounce plays back correctly on the
|
|
59
72
|
* engine's forward-only {@link AnimatedSprite} playback. The tag's
|
|
60
73
|
* `repeat` field maps directly onto {@link AnimatedSpriteClipDefinition.repeat}:
|
|
61
74
|
* absent means the clip loops indefinitely (`repeat: -1`); a numeric
|
|
62
|
-
* string (`"1"`, `"2"`,
|
|
75
|
+
* string (`"1"`, `"2"`, ...) means it plays exactly that many full cycles
|
|
63
76
|
* before stopping.
|
|
64
77
|
*
|
|
65
78
|
* Each clip's `frameDurations` carries the real per-frame `duration` from
|
|
66
79
|
* the export (falling back to the tag's average when a frame's duration is
|
|
67
80
|
* non-positive), so uneven hold-frames survive into playback instead of
|
|
68
81
|
* being flattened to a uniform fps. `frameOffsets` carries each frame's
|
|
69
|
-
* `spriteSourceSize` `{x,y}`
|
|
70
|
-
* untrimmed canvas
|
|
82
|
+
* `spriteSourceSize` `{x,y}` - its trimmed content's offset within the
|
|
83
|
+
* untrimmed canvas - whenever any frame in the tag is trimmed, so frames
|
|
71
84
|
* trimmed by different amounts stay anchored instead of jittering; it's
|
|
72
85
|
* omitted entirely for tags with no trimmed frames.
|
|
73
86
|
*/
|
|
@@ -83,3 +96,4 @@ export declare class AsepriteSheet {
|
|
|
83
96
|
/** Destroy the underlying {@link Spritesheet} and release its frame resources. */
|
|
84
97
|
destroy(): void;
|
|
85
98
|
}
|
|
99
|
+
//# sourceMappingURL=AsepriteSheet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AsepriteSheet.d.ts","sourceRoot":"","sources":["../../src/AsepriteSheet.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,KAAK,4BAA4B,EAAE,WAAW,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7G,OAAO,EAAE,KAAK,YAAY,EAAiD,KAAK,aAAa,EAAE,KAAK,aAAa,EAAuB,MAAM,gBAAgB,CAAC;AA2G/J;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,qBAAa,aAAa;IACxB,iFAAiF;IACjF,SAAgB,WAAW,EAAE,WAAW,CAAC;IAEzC;;;;OAIG;IACH,SAAgB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;IAEzE;;;;;;;OAOG;IACH,SAAgB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE3D;;;;;;;;;;OAUG;IACH,SAAgB,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,CAAC;IAE3D;;;;OAIG;gBAED,WAAW,EAAE,WAAW,EACxB,KAAK,EAAE,WAAW,CAAC,MAAM,EAAE,4BAA4B,CAAC,EACxD,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAC,EAC1C,MAAM,GAAE,WAAW,CAAC,MAAM,EAAE,aAAa,CAAa;IAQxD;;;;;;;;;;;;;;;;;;;;;;;;;;OA0BG;WACW,KAAK,CAAC,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,OAAO,GAAG,aAAa;IAgFxE;;;;;;OAMG;IACI,oBAAoB,IAAI,cAAc;IAU7C,kFAAkF;IAC3E,OAAO,IAAI,IAAI;CAGvB"}
|