@json-to-office/core-docx 7.2.0 → 7.3.1

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.
Files changed (49) hide show
  1. package/dist/index.js +1565 -471
  2. package/dist/index.js.map +1 -1
  3. package/dist/ir/chartValues.d.ts +18 -0
  4. package/dist/ir/chartValues.d.ts.map +1 -0
  5. package/dist/ir/compiler.d.ts.map +1 -1
  6. package/dist/ir/features.d.ts.map +1 -1
  7. package/dist/ir/theme.d.ts +43 -0
  8. package/dist/ir/theme.d.ts.map +1 -0
  9. package/dist/ir/types.d.ts +39 -3
  10. package/dist/ir/types.d.ts.map +1 -1
  11. package/dist/ir/validation.d.ts +2 -1
  12. package/dist/ir/validation.d.ts.map +1 -1
  13. package/dist/plugin/example/index.js +1562 -468
  14. package/dist/plugin/example/index.js.map +1 -1
  15. package/dist/renderers/chartText.d.ts +43 -0
  16. package/dist/renderers/chartText.d.ts.map +1 -0
  17. package/dist/renderers/docxjs/charts.d.ts +45 -0
  18. package/dist/renderers/docxjs/charts.d.ts.map +1 -0
  19. package/dist/renderers/docxjs/docxSubpath.d.ts +34 -0
  20. package/dist/renderers/docxjs/docxSubpath.d.ts.map +1 -0
  21. package/dist/renderers/docxjs/drawingGroup.d.ts +79 -0
  22. package/dist/renderers/docxjs/drawingGroup.d.ts.map +1 -0
  23. package/dist/renderers/docxjs/drawingGroupRepair.d.ts +36 -0
  24. package/dist/renderers/docxjs/drawingGroupRepair.d.ts.map +1 -0
  25. package/dist/renderers/docxjs/emit.d.ts +10 -2
  26. package/dist/renderers/docxjs/emit.d.ts.map +1 -1
  27. package/dist/renderers/docxjs/index.d.ts +2 -1
  28. package/dist/renderers/docxjs/index.d.ts.map +1 -1
  29. package/dist/renderers/docxjs/presetShapes.d.ts +233 -0
  30. package/dist/renderers/docxjs/presetShapes.d.ts.map +1 -0
  31. package/dist/renderers/office-open/chartLook.d.ts +45 -0
  32. package/dist/renderers/office-open/chartLook.d.ts.map +1 -0
  33. package/dist/renderers/office-open/chartParts.d.ts +29 -15
  34. package/dist/renderers/office-open/chartParts.d.ts.map +1 -1
  35. package/dist/renderers/office-open/emit.d.ts +25 -39
  36. package/dist/renderers/office-open/emit.d.ts.map +1 -1
  37. package/dist/renderers/office-open/index.d.ts +16 -4
  38. package/dist/renderers/office-open/index.d.ts.map +1 -1
  39. package/dist/renderers/office-open/themePart.d.ts +28 -0
  40. package/dist/renderers/office-open/themePart.d.ts.map +1 -0
  41. package/dist/tsconfig.tsbuildinfo +1 -1
  42. package/dist/utils/chartWorkbook.d.ts +2 -1
  43. package/dist/utils/chartWorkbook.d.ts.map +1 -1
  44. package/dist/utils/fixFloatingImageIds.d.ts +17 -9
  45. package/dist/utils/fixFloatingImageIds.d.ts.map +1 -1
  46. package/dist/utils/packageDocument.d.ts.map +1 -1
  47. package/package.json +6 -6
  48. package/dist/renderers/office-open/cellTocs.d.ts +0 -26
  49. package/dist/renderers/office-open/cellTocs.d.ts.map +0 -1
@@ -1,28 +1,42 @@
1
1
  /**
2
- * Packaging a native chart's missing half, for DOCX.
2
+ * A native chart's look and references, for DOCX.
3
3
  *
4
- * The repairs themselves — the cell references that fill an empty `<c:f/>`, the
5
- * series colours, the axis titles, the legend position and `c:externalData` —
6
- * are format-neutral and live in `chart-parts` in
7
- * `@json-to-office/shared/rendering`, which explains why a chart emitted by
8
- * `@office-open` needs repairing at all. A `c:chartSpace` is DrawingML: the
9
- * pptx sibling of this file makes exactly the same edits.
4
+ * What a chart needs beyond its type and data — the cell references, the
5
+ * colours, the axes, the fonts, Office's blanks — is format-neutral and is
6
+ * stated as backend options by `chartLook` in
7
+ * `@json-to-office/shared/rendering`; the pptx sibling of this file does the
8
+ * same. `@office-open/docx` 0.14 hands those options to the chart part whole,
9
+ * and embeds the workbook `c:externalData` points at, with its relationship and
10
+ * content type, from `externalData.data` — see `chartOptions` in `emit.ts`.
10
11
  *
11
- * What is here is only what a Word package spells its own way — `word/charts`,
12
- * `word/embeddings`, the chart's rels part, the content-type override — plus
13
- * adm-zip, which is this core's archive library.
12
+ * What is left here is the IR's side of that — `chartInput` — and the one
13
+ * edit no option carries, applied to the emitted parts: a scatter chart's
14
+ * style (`finishChartXml`).
14
15
  */
15
16
  import type AdmZip from 'adm-zip';
17
+ import type { ChartPartInput } from '@json-to-office/shared/rendering';
16
18
  import type { DocxIrChartRun } from '../../ir/types';
17
19
  /**
18
- * Give every chart in the package its workbook, colours and axis titles.
20
+ * One chart run, in the shared look's vocabulary.
21
+ *
22
+ * The docx component exposes a smaller styling surface than the pptx one, so
23
+ * only the axis titles have an authored prop behind them. The theme's chart
24
+ * text style goes on both: as the chart-wide default the tick labels and
25
+ * legend inherit, and on each axis title, which would otherwise take Word's
26
+ * large bold default. The roles themselves — which text takes the style as
27
+ * is, and which adjusts it — are shared with the docx.js renderer
28
+ * (`../chartText`). Everything else is the look docx.js draws, from
29
+ * `chartLook.ts`: gridlines, ticks, axis lines, gaps, markers and borders.
30
+ */
31
+ export declare function chartInput(chart: DocxIrChartRun): ChartPartInput;
32
+ /**
33
+ * Finish every chart part in the package with what no option says.
19
34
  *
20
35
  * Parts are matched to IR nodes by content rather than by position: the emitter
21
36
  * fills its array while *building* the backend's document object and the
22
37
  * backend numbers its parts while *stringifying* that object, and the two walks
23
- * disagree the moment a chart sits in a header or footer. Pairing by position
24
- * handed charts another chart's workbook, so a recipient choosing "Edit Data"
25
- * saw a different chart's numbers.
38
+ * disagree the moment a chart sits in a header or footer. The match also
39
+ * proves every emitted chart reached the package.
26
40
  */
27
- export declare function spliceChartParts(zip: AdmZip, charts: readonly DocxIrChartRun[]): void;
41
+ export declare function finishChartParts(zip: AdmZip, charts: readonly DocxIrChartRun[]): void;
28
42
  //# sourceMappingURL=chartParts.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"chartParts.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/chartParts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAWlC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAuErD;;;;;;;;;GASG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,IAAI,CAkCN"}
1
+ {"version":3,"file":"chartParts.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/chartParts.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAKlC,OAAO,KAAK,EACV,cAAc,EAEf,MAAM,kCAAkC,CAAC;AAC1C,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,gBAAgB,CAAC;AAIrD;;;;;;;;;;;GAWG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,cAAc,GAAG,cAAc,CA8BhE;AAED;;;;;;;;GAQG;AACH,wBAAgB,gBAAgB,CAC9B,GAAG,EAAE,MAAM,EACX,MAAM,EAAE,SAAS,cAAc,EAAE,GAChC,IAAI,CAyBN"}
@@ -15,8 +15,8 @@
15
15
  /// <reference types="node" />
16
16
  /// <reference types="node" />
17
17
  import type { DocxIrBlock, DocxIrChartRun, DocxIrFloating, DocxIrInline, DocxIrNumbering, DocxIrParagraph, DocxIrParagraphFormatting, DocxIrRunFormatting, DocxIrSection, DocxIrTable } from '../../ir/types';
18
+ import type { DocumentOptions, Floating, ParagraphChild, ParagraphOptions, ParagraphStylePropertiesOptions, PictureOptions, RunStylePropertiesOptions, SectionChild, SectionOptions, TableOptions } from '@office-open/docx';
18
19
  import { emuToPixels } from '../../ir/units';
19
- type Opts = Record<string, unknown>;
20
20
  /**
21
21
  * One prepared image per placement size.
22
22
  *
@@ -32,11 +32,11 @@ type Opts = Record<string, unknown>;
32
32
  */
33
33
  export interface PreparedImage {
34
34
  /** `png`, `jpg`, `svg`, … — the backend's media type tag. */
35
- type: string;
35
+ type: PictureOptions['type'];
36
36
  data: Buffer;
37
37
  /** The raster Word draws when it cannot draw the vector. */
38
38
  fallback?: {
39
- type: string;
39
+ type: RasterType;
40
40
  data: Buffer;
41
41
  };
42
42
  /**
@@ -52,6 +52,8 @@ export interface PreparedImage {
52
52
  fileName: string;
53
53
  fallbackFileName?: string;
54
54
  }
55
+ /** The picture types the backend takes for a raster, as opposed to `svg`. */
56
+ export type RasterType = Exclude<PictureOptions['type'], 'svg'>;
55
57
  export type ImageMediaFactory = (placement: {
56
58
  widthEmu: number;
57
59
  heightEmu: number;
@@ -74,34 +76,10 @@ export interface EmitContext {
74
76
  /**
75
77
  * Charts, in the order they were emitted.
76
78
  *
77
- * The backend numbers `word/charts/chartN.xml` by the order it stringifies
78
- * chart runs, which is document order — the same order this array fills. The
79
- * post-generation splice reads it to match each part with the data the
80
- * backend dropped.
79
+ * A chart's place here names its workbook. The post-generation pass reads
80
+ * it to match each emitted part with its IR node — see `chartParts.ts`.
81
81
  */
82
82
  charts?: DocxIrChartRun[];
83
- /**
84
- * Tables of contents inside table cells, in the order they were emitted.
85
- *
86
- * Required rather than optional like `charts`: a cell's table of contents
87
- * goes out as marker paragraphs that only the post-generation splice takes
88
- * out again, so a context that does not collect them would ship the markers.
89
- * See `cellChildren` and `cellTocs.ts`.
90
- */
91
- cellTocs: CellToc[];
92
- }
93
- /**
94
- * A table of contents in a table cell, as the emitter hands it over.
95
- *
96
- * `start` and `end` are the text of the two marker paragraphs its entries
97
- * stand between in the cell. `alias` and `options` are what the backend's
98
- * `stringifyTableOfContents` takes to write the field around those entries.
99
- */
100
- export interface CellToc {
101
- start: string;
102
- end: string;
103
- alias: string;
104
- options: Opts;
105
83
  }
106
84
  /** A context for content that holds no drawings, and for tests. */
107
85
  export declare function emptyContext(): EmitContext;
@@ -119,7 +97,7 @@ export declare function emptyContext(): EmitContext;
119
97
  * Its fourth, `w:highlightCs`, is not left out by oversight: OOXML defines no
120
98
  * such element, and the compiler never sets a highlight.
121
99
  */
122
- export declare function runProperties(formatting: DocxIrRunFormatting | undefined): Opts;
100
+ export declare function runProperties(formatting: DocxIrRunFormatting | undefined): RunStylePropertiesOptions;
123
101
  /**
124
102
  * Turn inline nodes into paragraph children.
125
103
  *
@@ -127,15 +105,23 @@ export declare function runProperties(formatting: DocxIrRunFormatting | undefine
127
105
  * comes next, which is where the backend puts them — `<w:br/>` is run-inner
128
106
  * content, so it has to ride on a run either way.
129
107
  */
130
- export declare function inlineChildren(children: readonly DocxIrInline[], ctx?: EmitContext): Opts[];
131
- /** An IR anchor as the backend's floating options. */
132
- export declare function floatingOptions(floating: DocxIrFloating): Opts;
133
- export declare function paragraphProperties(formatting: DocxIrParagraphFormatting | undefined): Opts;
134
- export declare function paragraph(block: DocxIrParagraph, ctx?: EmitContext): Opts;
108
+ export declare function inlineChildren(children: readonly DocxIrInline[], ctx?: EmitContext): ParagraphChild[];
109
+ /**
110
+ * An IR anchor as the backend's floating options.
111
+ *
112
+ * `Floating` requires both positions; the IR states only those the document
113
+ * sets, and the backend writes its default for a missing one, so the object is
114
+ * built as the IR has it and asserted whole.
115
+ */
116
+ export declare function floatingOptions(floating: DocxIrFloating): Floating;
117
+ export declare function paragraphProperties(formatting: DocxIrParagraphFormatting | undefined): ParagraphStylePropertiesOptions;
118
+ export declare function paragraph(block: DocxIrParagraph, ctx?: EmitContext): ParagraphOptions;
135
119
  /** One IR block as a tagged section child, which is how the backend takes it. */
136
- export declare function block(value: DocxIrBlock, ctx?: EmitContext): Opts;
137
- export declare function table(value: DocxIrTable, ctx: EmitContext): Opts;
138
- export declare function section(value: DocxIrSection, ctx: EmitContext, closesDocument?: boolean): Opts;
139
- export declare function numberingConfig(numbering: DocxIrNumbering): Opts;
120
+ export declare function block(value: DocxIrBlock, ctx?: EmitContext): SectionChild;
121
+ export declare function table(value: DocxIrTable, ctx: EmitContext): TableOptions;
122
+ export declare function section(value: DocxIrSection, ctx: EmitContext, closesDocument?: boolean): SectionOptions;
123
+ export declare function numberingConfig(numbering: DocxIrNumbering): NumberingConfig;
124
+ /** One abstract numbering, as `NumberingOptions.abstractNumberings` holds it. */
125
+ export type NumberingConfig = NonNullable<DocumentOptions['numbering']>['abstractNumberings'][number];
140
126
  export { emuToPixels };
141
127
  //# sourceMappingURL=emit.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"emit.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/emit.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;;;AAGH,OAAO,KAAK,EACV,WAAW,EAMX,cAAc,EAGd,cAAc,EAId,YAAY,EACZ,eAAe,EACf,eAAe,EACf,yBAAyB,EAGzB,mBAAmB,EACnB,aAAa,EAGb,WAAW,EAKZ,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,WAAW,EAAe,MAAM,gBAAgB,CAAC;AAE1D,KAAK,IAAI,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAEpC;;;;;;;;;;;;GAYG;AACH,MAAM,WAAW,aAAa;IAC5B,6DAA6D;IAC7D,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,4DAA4D;IAC5D,QAAQ,CAAC,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAA;KAAE,CAAC;IAC1C;;;;;;;;;OASG;IACH,QAAQ,EAAE,MAAM,CAAC;IACjB,gBAAgB,CAAC,EAAE,MAAM,CAAC;CAC3B;AAED,MAAM,MAAM,iBAAiB,GAAG,CAAC,SAAS,EAAE;IAC1C,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;CACnB,KAAK,aAAa,CAAC;AAEpB;;;;;;;;;GASG;AACH,MAAM,WAAW,WAAW;IAC1B,qDAAqD;IACrD,QAAQ,EAAE,WAAW,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;IACjD,yDAAyD;IACzD,aAAa,EAAE,MAAM,MAAM,CAAC;IAC5B;;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renderer.
3
3
  *
4
4
  * Selecting it is explicit and opt-in; `docxjs` stays the default. The backend
5
- * is an optional peer dependency, resolved at call time so a missing package
6
- * surfaces as an install hint rather than a module-resolution failure.
5
+ * is a dependency of this package, loaded at call time: only a document that
6
+ * selects this renderer pays for loading it, and a broken install surfaces as
7
+ * an install hint rather than a module-resolution failure.
7
8
  *
8
9
  * The capability set below is deliberately narrow. A feature is listed only
9
10
  * when it has been proven against the real package, never from its README, and
@@ -11,10 +12,21 @@
11
12
  * the pipeline reject the document before any bytes exist, instead of shipping
12
13
  * a file with content quietly missing.
13
14
  */
15
+ import type { DocumentOptions } from '@office-open/docx';
14
16
  import type { DocxIR, DocxIrChartRun } from '../../ir/types';
15
17
  import type { DocxRenderer, DocxRendererId } from '../types';
16
- import { type CellToc } from './emit';
17
18
  export declare const OFFICE_OPEN_DOCX_RENDERER_ID: DocxRendererId;
19
+ /**
20
+ * The `@office-open/docx` release this adapter is built and verified against, and the
21
+ * exact version `package.json` pins (a test holds the two together).
22
+ *
23
+ * The adapter hands the backend its options as data, typed against this
24
+ * release: another one can rename or restructure them with nothing failing
25
+ * until a document comes out with content missing. So a different version
26
+ * installed — an override, a hoisted copy — refuses the renderer by name
27
+ * instead (`RENDERER_BACKEND_VERSION_MISMATCH`).
28
+ */
29
+ export declare const OFFICE_OPEN_VERSION = "0.14.6";
18
30
  export declare function createOfficeOpenDocxRenderer(): Promise<DocxRenderer>;
19
31
  /**
20
32
  * Build the backend's document object for an IR document.
@@ -22,5 +34,5 @@ export declare function createOfficeOpenDocxRenderer(): Promise<DocxRenderer>;
22
34
  * Exported for tests: asserting on this object is far cheaper, and far more
23
35
  * legible, than unzipping a package.
24
36
  */
25
- export declare function buildDocumentOptions(ir: DocxIR, charts?: DocxIrChartRun[], svgRasterFallback?: boolean, cellTocs?: CellToc[]): Promise<Record<string, unknown>>;
37
+ export declare function buildDocumentOptions(ir: DocxIR, charts?: DocxIrChartRun[], svgRasterFallback?: boolean): Promise<DocumentOptions>;
26
38
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAIH,OAAO,KAAK,EACV,MAAM,EAEN,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAKL,KAAK,OAAO,EAGb,MAAM,QAAQ,CAAC;AAGhB,eAAO,MAAM,4BAA4B,EAAE,cAA8B,CAAC;AAkE1E,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,YAAY,CAAC,CAoE1E;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,cAAc,EAAO,EAC7B,iBAAiB,CAAC,EAAE,OAAO,EAC3B,QAAQ,GAAE,OAAO,EAAO,GACvB,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CA+ClC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAOH,OAAO,KAAK,EAEV,eAAe,EAGhB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,KAAK,EACV,MAAM,EAEN,cAAc,EAGf,MAAM,gBAAgB,CAAC;AAYxB,OAAO,KAAK,EAAqB,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAYhF,eAAO,MAAM,4BAA4B,EAAE,cAA8B,CAAC;AAS1E;;;;;;;;;GASG;AACH,eAAO,MAAM,mBAAmB,WAAW,CAAC;AAwE5C,wBAAsB,4BAA4B,IAAI,OAAO,CAAC,YAAY,CAAC,CAmE1E;AAED;;;;;GAKG;AACH,wBAAsB,oBAAoB,CACxC,EAAE,EAAE,MAAM,EACV,MAAM,GAAE,cAAc,EAAO,EAC7B,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,eAAe,CAAC,CAkD1B"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * The document's Word theme, for the `office-open` backend.
3
+ *
4
+ * `@office-open/docx` always writes Office's theme part and takes no option
5
+ * for another: `createThemeXml()` is called with no arguments, and the only
6
+ * hook, `rawParts`, would replace the whole part, which means owning a
7
+ * complete theme document — format scheme included — instead of the backend.
8
+ * So the IR theme is spliced into the part the backend wrote: its name, the
9
+ * scheme colours it sets and the Latin faces of the major and minor fonts,
10
+ * as docx.js writes them from the same IR. Everything else in the part —
11
+ * hlink and folHlink unless set, the format scheme, the empty East Asian and
12
+ * complex-script faces — stays the backend's.
13
+ *
14
+ * Beyond native charts, whose lines follow Text 1 on both backends, this
15
+ * backend's own output refers to the theme where docx.js's does not: the
16
+ * built-in styles it adds and the first run of every contents field name theme
17
+ * colours and fonts. Replacing Office's theme with the document's is what
18
+ * makes those follow the document rather than Office.
19
+ *
20
+ * Every edit has to find its element exactly once. A part whose shape
21
+ * changed under a backend upgrade fails the render rather than shipping a
22
+ * theme half Office's and half the document's.
23
+ */
24
+ import type AdmZip from 'adm-zip';
25
+ import type { DocxIrTheme } from '../../ir/types';
26
+ /** Write the IR theme into the theme part the backend wrote. */
27
+ export declare function spliceTheme(zip: AdmZip, theme: DocxIrTheme): void;
28
+ //# sourceMappingURL=themePart.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"themePart.d.ts","sourceRoot":"","sources":["../../../src/renderers/office-open/themePart.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,KAAK,MAAM,MAAM,SAAS,CAAC;AAClC,OAAO,KAAK,EAAE,WAAW,EAAwB,MAAM,gBAAgB,CAAC;AAkExE,gEAAgE;AAChE,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,WAAW,GAAG,IAAI,CAyCjE"}