@allyhub/sdk 0.11.0 → 0.13.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/CHANGELOG.md +16 -0
- package/dist/node_modules/@allyhub/audio/dist/plan.d.ts +3 -0
- package/dist/node_modules/@allyhub/audio/dist/render.js +1 -1
- package/dist/node_modules/@allyhub/audio/package.json +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-file.d.ts +2 -0
- package/dist/node_modules/@allyhub/chart/dist/chart-file.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/chart-xml.js +3 -2
- package/dist/node_modules/@allyhub/chart/dist/chart.d.ts +5 -12
- package/dist/node_modules/@allyhub/chart/dist/chart.js +2 -1
- package/dist/node_modules/@allyhub/chart/dist/color.d.ts +37 -0
- package/dist/node_modules/@allyhub/chart/dist/color.js +2 -0
- package/dist/node_modules/@allyhub/chart/dist/index.d.ts +1 -0
- package/dist/node_modules/@allyhub/chart/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/chart/dist/svg.js +1 -1
- package/dist/node_modules/@allyhub/chart/package.json +1 -1
- package/dist/node_modules/@allyhub/diagnostics/package.json +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.d.ts +130 -0
- package/dist/node_modules/@allyhub/formats/dist/data/deck-code.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.d.ts +3 -1
- package/dist/node_modules/@allyhub/formats/dist/data/gen.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.d.ts +512 -166
- package/dist/node_modules/@allyhub/formats/dist/data/sheet.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/data/slides.d.ts +2523 -136
- package/dist/node_modules/@allyhub/formats/dist/data/slides.js +1 -1
- package/dist/node_modules/@allyhub/formats/dist/schemas.d.ts +931 -87
- package/dist/node_modules/@allyhub/formats/dist/schemas.js +1 -1
- package/dist/node_modules/@allyhub/formats/package.json +1 -1
- package/dist/node_modules/@allyhub/image-draw/package.json +1 -1
- package/dist/node_modules/@allyhub/image-measure/package.json +1 -1
- package/dist/node_modules/@allyhub/image-sdk/package.json +1 -1
- package/dist/node_modules/@allyhub/measure/package.json +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/color.d.ts +11 -0
- package/dist/node_modules/@allyhub/ooxml/dist/color.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/ext.d.ts +43 -0
- package/dist/node_modules/@allyhub/ooxml/dist/ext.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/index.d.ts +2 -1
- package/dist/node_modules/@allyhub/ooxml/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/ooxml/dist/transform.d.ts +13 -0
- package/dist/node_modules/@allyhub/ooxml/dist/transform.js +2 -0
- package/dist/node_modules/@allyhub/ooxml/package.json +5 -1
- package/dist/node_modules/@allyhub/piece/dist/gen.d.ts +4 -4
- package/dist/node_modules/@allyhub/piece/dist/media.d.ts +2 -2
- package/dist/node_modules/@allyhub/piece/package.json +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/account.d.ts +49 -5
- package/dist/node_modules/@allyhub/protocol/dist/account.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/auth.d.ts +56 -0
- package/dist/node_modules/@allyhub/protocol/dist/auth.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/cloud.d.ts +72 -9
- package/dist/node_modules/@allyhub/protocol/dist/cloud.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/editor.d.ts +35 -20
- package/dist/node_modules/@allyhub/protocol/dist/editor.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/errors.d.ts +7 -0
- package/dist/node_modules/@allyhub/protocol/dist/errors.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/events.d.ts +328 -0
- package/dist/node_modules/@allyhub/protocol/dist/events.js +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/frame.d.ts +28 -2
- package/dist/node_modules/@allyhub/protocol/dist/frame.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/index.d.ts +2 -0
- package/dist/node_modules/@allyhub/protocol/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/jobs.d.ts +6 -6
- package/dist/node_modules/@allyhub/protocol/dist/mail.d.ts +2 -2
- package/dist/node_modules/@allyhub/protocol/dist/routes.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.d.ts +69 -6
- package/dist/node_modules/@allyhub/protocol/dist/snapshots.js +1 -1
- package/dist/node_modules/@allyhub/protocol/dist/tools.d.ts +9 -9
- package/dist/node_modules/@allyhub/protocol/package.json +1 -1
- package/dist/node_modules/@allyhub/runtimes/package.json +1 -1
- package/dist/node_modules/@allyhub/scenery/package.json +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/annotations.d.ts +14 -0
- package/dist/node_modules/@allyhub/sheet/dist/annotations.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/index.d.ts +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/rules.d.ts +24 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/styles.d.ts +12 -0
- package/dist/node_modules/@allyhub/sheet/dist/api/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.d.ts +3 -1
- package/dist/node_modules/@allyhub/sheet/dist/api/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.d.ts +28 -1
- package/dist/node_modules/@allyhub/sheet/dist/arrange.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/data-tools.d.ts +42 -0
- package/dist/node_modules/@allyhub/sheet/dist/data-tools.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/edit.d.ts +43 -2
- package/dist/node_modules/@allyhub/sheet/dist/edit.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/fill.d.ts +10 -0
- package/dist/node_modules/@allyhub/sheet/dist/fill.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/filter.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.d.ts +14 -0
- package/dist/node_modules/@allyhub/sheet/dist/formula/rewrite.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/html.js +10 -10
- package/dist/node_modules/@allyhub/sheet/dist/index.d.ts +6 -1
- package/dist/node_modules/@allyhub/sheet/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/outline.d.ts +30 -0
- package/dist/node_modules/@allyhub/sheet/dist/outline.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rich.d.ts +29 -0
- package/dist/node_modules/@allyhub/sheet/dist/rich.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/rules.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-style.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/table-style.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/table-styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.d.ts +5 -1
- package/dist/node_modules/@allyhub/sheet/dist/workbook.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/charts.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/import.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.d.ts +17 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/read.js +2 -2
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.d.ts +56 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/runs.js +2 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.d.ts +6 -0
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/styles.js +1 -1
- package/dist/node_modules/@allyhub/sheet/dist/xlsx/write.js +1 -1
- package/dist/node_modules/@allyhub/sheet/package.json +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/animation.d.ts +117 -21
- package/dist/node_modules/@allyhub/slides-core/dist/animation.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/api.d.ts +181 -30
- package/dist/node_modules/@allyhub/slides-core/dist/api.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/capabilities.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.d.ts +28 -2
- package/dist/node_modules/@allyhub/slides-core/dist/chart-api.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/check.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/enums.d.ts +222 -4
- package/dist/node_modules/@allyhub/slides-core/dist/enums.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/file.d.ts +6 -0
- package/dist/node_modules/@allyhub/slides-core/dist/file.js +3 -3
- package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.d.ts +3 -0
- package/dist/node_modules/@allyhub/slides-core/dist/generated/table-styles.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.d.ts +3 -0
- package/dist/node_modules/@allyhub/slides-core/dist/index.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/merge.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/model.d.ts +98 -10
- package/dist/node_modules/@allyhub/slides-core/dist/numbering.d.ts +6 -0
- package/dist/node_modules/@allyhub/slides-core/dist/numbering.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/office.d.ts +53 -0
- package/dist/node_modules/@allyhub/slides-core/dist/office.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/patterns.d.ts +8 -0
- package/dist/node_modules/@allyhub/slides-core/dist/patterns.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.d.ts +36 -6
- package/dist/node_modules/@allyhub/slides-core/dist/resolve.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/script.d.ts +11 -0
- package/dist/node_modules/@allyhub/slides-core/dist/script.js +2 -2
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.d.ts +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/sdk.js +1 -1
- package/dist/node_modules/@allyhub/slides-core/dist/table-style.d.ts +48 -0
- package/dist/node_modules/@allyhub/slides-core/dist/table-style.js +2 -0
- package/dist/node_modules/@allyhub/slides-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/mix-plan.js +1 -1
- package/dist/node_modules/@allyhub/video-core/dist/timeline.d.ts +4 -0
- package/dist/node_modules/@allyhub/video-core/package.json +1 -1
- package/dist/node_modules/@allyhub/video-sdk/package.json +1 -1
- package/docs/defaults.md +78 -4
- package/docs/image.md +1 -1
- package/docs/pictures.md +1 -1
- package/docs/project.md +1 -1
- package/docs/sheets.md +19 -9
- package/docs/slides.md +30 -16
- package/docs/speech.md +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,14 @@
|
|
|
1
|
-
import type { ArrowSize, Numbering, AnimationEffect, AnimationFile, LineDash, TransitionFile, LineEnd, ShapeGeometry, TextAlign, ThemeColor } from "@allyhub/formats";
|
|
1
|
+
import type { ArrowSize, Numbering, AnimationEffect, AnimationFile, LineCap, LineCompound, LineDash, LineJoin, GradientPath, PatternPreset, TransitionFile, LineEnd, ShapeGeometry, TextAlign, TextOrientation, ThemeColor, ColorName, ColorTransform } from "@allyhub/formats";
|
|
2
2
|
import type { Anchor, AutoSize, FillType, PlaceholderType, ShapeType } from "./enums.js";
|
|
3
|
-
import type { Color, ComponentContext, DeckDef, FontDef, Frame, GradientDef, FreeformPath, GeneratedSlideDef, GeneratorContext, LayoutDef, MasterDef, ParagraphDef, TableCellDef, TableDef, ParagraphFormatDef, PropSpec, RunDef, ShapeDef, TextFrameDef } from "./model.js";
|
|
4
|
-
import type { SheetChartType } from "@allyhub/formats";
|
|
3
|
+
import type { Color, ComponentContext, DeckDef, FontDef, Frame, GradientDef, TileDef, FreeformPath, GeneratedSlideDef, GeneratorContext, LayoutDef, MasterDef, ParagraphDef, TableCellDef, TableDef, ParagraphFormatDef, PropSpec, RunDef, ShapeDef, PlaybackDef, TextFrameDef } from "./model.js";
|
|
4
|
+
import type { Caps, SheetChartType, Strike, Underline } from "@allyhub/formats";
|
|
5
5
|
import { Chart, type CategoryChartData, type XyChartData } from "./chart-api.js";
|
|
6
6
|
import type { ThemeInput } from "./theme.js";
|
|
7
7
|
import { type Length, type LengthValue, type SlideSizeName } from "./units.js";
|
|
8
|
+
/** Throws what the API does not do, naming it. */
|
|
9
|
+
export declare const refuse: (what: string) => never;
|
|
10
|
+
/** Office's colour map: each name its own theme colour, text and background 1 and 2 dark and light 1 and 2. */
|
|
11
|
+
export declare const OFFICE_COLOR_MAP: Readonly<Record<ColorName, ThemeColor>>;
|
|
8
12
|
/** python-pptx's `RGBColor`: called or made with `new`, a colour as `#RRGGBB`. */
|
|
9
13
|
export interface RGBColorMaker {
|
|
10
14
|
(r: number, g: number, b: number): string;
|
|
@@ -22,9 +26,17 @@ export declare class ColorFormat {
|
|
|
22
26
|
private readonly read;
|
|
23
27
|
private readonly write;
|
|
24
28
|
constructor(read: () => Color | undefined, write: (c: Color | undefined) => void);
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
29
|
+
/** A theme colour (MSO_THEME_COLOR): one of its twelve, or text and background 1 and 2 (`tx1`), which the master's colour map makes one of them. */
|
|
30
|
+
get theme_color(): ColorName | undefined;
|
|
31
|
+
/** As python-pptx's: a theme colour changed to another keeps its brightness (and its transforms). */
|
|
32
|
+
set theme_color(c: ColorName | undefined);
|
|
33
|
+
/**
|
|
34
|
+
* DrawingML's transforms of the colour, in order (`{ name: "lumMod",
|
|
35
|
+
* value: 0.75 }`, a share; degrees for hue and hueOff), which python-pptx
|
|
36
|
+
* has no name for; set, they take a brightness's place.
|
|
37
|
+
*/
|
|
38
|
+
get transforms(): readonly ColorTransform[];
|
|
39
|
+
set transforms(v: readonly ColorTransform[]);
|
|
28
40
|
/**
|
|
29
41
|
* Lighter (up to 1, white) or darker (down to -1, black), 0 for neither:
|
|
30
42
|
* PowerPoint's "Lighter 40%" is 0.4, "Darker 25%" -0.25 (`a:lumMod` and
|
|
@@ -41,9 +53,12 @@ export declare class Font {
|
|
|
41
53
|
private readonly def;
|
|
42
54
|
constructor(def: FontDef);
|
|
43
55
|
private _set;
|
|
44
|
-
/** A line through it
|
|
45
|
-
get strike(): boolean | undefined;
|
|
46
|
-
set strike(v: boolean | undefined);
|
|
56
|
+
/** A line through it, PowerPoint's Strikethrough: true, or MSO_TEXT_STRIKE.DOUBLE for Double Strikethrough. */
|
|
57
|
+
get strike(): boolean | Strike | undefined;
|
|
58
|
+
set strike(v: boolean | Strike | "noStrike" | undefined);
|
|
59
|
+
/** Its letters as capitals (MSO_TEXT_CAPS): PowerPoint's All Caps and Small Caps. */
|
|
60
|
+
get caps(): Caps | undefined;
|
|
61
|
+
set caps(v: Caps | undefined);
|
|
47
62
|
/** Raised or lowered, a share of its size: superscript 0.3, subscript -0.25. */
|
|
48
63
|
get baseline(): number | undefined;
|
|
49
64
|
set baseline(v: number | undefined);
|
|
@@ -58,9 +73,9 @@ export declare class Font {
|
|
|
58
73
|
set bold(v: boolean | undefined);
|
|
59
74
|
get italic(): boolean | undefined;
|
|
60
75
|
set italic(v: boolean | undefined);
|
|
61
|
-
/**
|
|
62
|
-
get underline(): boolean | undefined;
|
|
63
|
-
set underline(v: boolean | undefined);
|
|
76
|
+
/** python-pptx's: true a single underline, false none, or an MSO_UNDERLINE style (DOUBLE_LINE, WAVY_LINE…). */
|
|
77
|
+
get underline(): boolean | Underline | undefined;
|
|
78
|
+
set underline(v: boolean | Underline | "none" | undefined);
|
|
64
79
|
/** Space added between letters, a Length (negative tightens): PowerPoint's Character Spacing, which python-pptx has no name for. */
|
|
65
80
|
get spacing(): LengthValue | undefined;
|
|
66
81
|
set spacing(v: Length | undefined);
|
|
@@ -91,10 +106,11 @@ declare abstract class Format {
|
|
|
91
106
|
/** A number of lines (1.5), or a Length (Pt(18)) for a fixed height. */
|
|
92
107
|
get line_spacing(): number | LengthValue | undefined;
|
|
93
108
|
set line_spacing(v: number | undefined);
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
109
|
+
/** A Length (Pt(6)), or a number of lines at the paragraph's size (0.5), PowerPoint's Before in lines. */
|
|
110
|
+
get space_before(): number | LengthValue | undefined;
|
|
111
|
+
set space_before(v: number | undefined);
|
|
112
|
+
get space_after(): number | LengthValue | undefined;
|
|
113
|
+
set space_after(v: number | undefined);
|
|
98
114
|
/** Its runs' default character properties (`a:defRPr`). */
|
|
99
115
|
get font(): Font;
|
|
100
116
|
}
|
|
@@ -122,7 +138,7 @@ export declare class Paragraph extends Format {
|
|
|
122
138
|
export declare class ListLevel extends Format {
|
|
123
139
|
protected readonly fmt: ParagraphFormatDef;
|
|
124
140
|
constructor(def: ParagraphFormatDef);
|
|
125
|
-
/** Counted in place of a bullet (`a:buAutoNum`): "arabicPeriod", "
|
|
141
|
+
/** Counted in place of a bullet (`a:buAutoNum`): any of ECMA-376's 41 schemes, "arabicPeriod", "alphaLcParenR", "circleNumDbPlain", "ea1ChsPeriod"… */
|
|
126
142
|
get numbered(): Numbering | undefined;
|
|
127
143
|
set numbered(v: Numbering | undefined);
|
|
128
144
|
/** Its bullet character, or null for none (`a:buChar`, `a:buNone`). */
|
|
@@ -130,6 +146,15 @@ export declare class ListLevel extends Format {
|
|
|
130
146
|
set bullet(v: string | null | undefined);
|
|
131
147
|
get bullet_font(): string | undefined;
|
|
132
148
|
set bullet_font(v: string | undefined);
|
|
149
|
+
/** Its bullet's or number's colour (`a:buClr`): a colour as the slides file writes one (accent1, #RRGGBB) or a Color; null for its text's (`a:buClrTx`). */
|
|
150
|
+
get bullet_color(): Color | null | undefined;
|
|
151
|
+
set bullet_color(v: Exclude<Color, string> | string | null | undefined);
|
|
152
|
+
/** Its bullet's or number's size, a share of its text's, 0.25 to 4 (`a:buSzPct`); null for its text's. */
|
|
153
|
+
get bullet_size(): number | null | undefined;
|
|
154
|
+
set bullet_size(v: number | null | undefined);
|
|
155
|
+
/** The number its list starts at (`a:buAutoNum@startAt`), 1 to 32767. */
|
|
156
|
+
get start_at(): number | undefined;
|
|
157
|
+
set start_at(v: number | undefined);
|
|
133
158
|
/** Where its lines start (`@marL`). */
|
|
134
159
|
get margin_left(): LengthValue | undefined;
|
|
135
160
|
set margin_left(v: Length | undefined);
|
|
@@ -149,6 +174,11 @@ export type ListStyle = readonly [
|
|
|
149
174
|
ListLevel,
|
|
150
175
|
ListLevel
|
|
151
176
|
];
|
|
177
|
+
/** What placeholders.add takes besides a frame: a name of its own; `orient: "vert"`, a vertical placeholder (`p:ph/@orient`, which PowerPoint matches layouts by; its text_frame.orientation turns its text). */
|
|
178
|
+
export interface PlaceholderOptions {
|
|
179
|
+
name?: string;
|
|
180
|
+
orient?: "vert";
|
|
181
|
+
}
|
|
152
182
|
/** python-pptx's `TextFrame`. */
|
|
153
183
|
export declare class TextFrame {
|
|
154
184
|
private readonly def;
|
|
@@ -172,6 +202,9 @@ export declare class TextFrame {
|
|
|
172
202
|
get list_style(): ListStyle;
|
|
173
203
|
get vertical_anchor(): Anchor | undefined;
|
|
174
204
|
set vertical_anchor(v: Anchor | undefined);
|
|
205
|
+
/** Which way its text runs (MSO_TEXT_ORIENTATION, `a:bodyPr/@vert`): PowerPoint's Text Direction, which python-pptx has no name for. */
|
|
206
|
+
get orientation(): TextOrientation | undefined;
|
|
207
|
+
set orientation(v: TextOrientation | undefined);
|
|
175
208
|
get auto_size(): AutoSize | undefined;
|
|
176
209
|
set auto_size(v: AutoSize | undefined);
|
|
177
210
|
get word_wrap(): boolean | undefined;
|
|
@@ -190,16 +223,54 @@ export declare class FillFormat {
|
|
|
190
223
|
private readonly read;
|
|
191
224
|
private readonly write;
|
|
192
225
|
private readonly start;
|
|
193
|
-
/** The shape it fills: only a shape's has a gradient and a transparency. */
|
|
226
|
+
/** The shape it fills: only a shape's has a gradient, a pattern, a picture and a transparency. */
|
|
194
227
|
private readonly shape;
|
|
195
|
-
|
|
228
|
+
/** The folder of the module that writes the deck: a picture's path is from it. */
|
|
229
|
+
private readonly base;
|
|
230
|
+
constructor(read: () => Color | null | undefined, write: (v: Color | null) => void, start?: Color, shape?: ShapeDef, base?: string);
|
|
231
|
+
/** Its other kinds of fill taken away, as setting one kind does. */
|
|
232
|
+
private _only;
|
|
196
233
|
/** A solid fill; its colour is fore_color. */
|
|
197
234
|
solid(): void;
|
|
198
235
|
/** No fill (python-pptx's `background()`: transparent). */
|
|
199
236
|
background(): void;
|
|
237
|
+
/** A pattern fill (python-pptx's `patterned()`), PATTERN_DEFAULTS' colours until fore_color and back_color say otherwise. */
|
|
238
|
+
patterned(): void;
|
|
239
|
+
/** A pattern fill's preset (MSO_PATTERN_TYPE). */
|
|
240
|
+
get pattern(): PatternPreset;
|
|
241
|
+
set pattern(v: PatternPreset);
|
|
242
|
+
private _pattern;
|
|
243
|
+
/** A pattern fill's background colour (python-pptx's back_color). */
|
|
244
|
+
get back_color(): ColorFormat;
|
|
245
|
+
/**
|
|
246
|
+
* A picture filling the shape, PowerPoint's Picture or Texture Fill: a
|
|
247
|
+
* path from the deck's module's folder, stretched over the shape, or
|
|
248
|
+
* tiled (`{ tile: { scale_x, scale_y, offset_x, offset_y, align } }`, the
|
|
249
|
+
* offsets Lengths, the scales shares of its own size).
|
|
250
|
+
*/
|
|
251
|
+
picture(image_file: string, options?: {
|
|
252
|
+
tile?: Partial<TileDef>;
|
|
253
|
+
transparency?: number;
|
|
254
|
+
}): void;
|
|
200
255
|
private _shape;
|
|
201
256
|
/** A gradient fill, of two of the theme's colours until gradient_stops says otherwise. */
|
|
202
257
|
gradient(): void;
|
|
258
|
+
/** A gradient's kind: "linear" along its angle, or out from its focus, "circle", "rect" or "shape" (PowerPoint's Radial, Rectangular and Path); python-pptx has none. */
|
|
259
|
+
get gradient_path(): "linear" | GradientPath;
|
|
260
|
+
set gradient_path(v: "linear" | GradientPath);
|
|
261
|
+
/** A path gradient's focus, the share in from each side ({ left, top, right, bottom }; the middle, 0.5 each, unless set): PowerPoint's Direction. */
|
|
262
|
+
get gradient_focus(): {
|
|
263
|
+
left: number;
|
|
264
|
+
top: number;
|
|
265
|
+
right: number;
|
|
266
|
+
bottom: number;
|
|
267
|
+
};
|
|
268
|
+
set gradient_focus(v: {
|
|
269
|
+
left: number;
|
|
270
|
+
top: number;
|
|
271
|
+
right: number;
|
|
272
|
+
bottom: number;
|
|
273
|
+
});
|
|
203
274
|
/** A gradient's degrees, clockwise from left to right. python-pptx's run the other way. */
|
|
204
275
|
get gradient_angle(): number;
|
|
205
276
|
set gradient_angle(v: number);
|
|
@@ -220,9 +291,9 @@ export declare class FillFormat {
|
|
|
220
291
|
/** How much of the fill shows through, a share (PowerPoint's Transparency). */
|
|
221
292
|
get transparency(): number;
|
|
222
293
|
set transparency(v: number);
|
|
223
|
-
/** MSO_FILL.SOLID,
|
|
294
|
+
/** MSO_FILL.SOLID, BACKGROUND, GRADIENT, PATTERNED or PICTURE, or undefined while it is inherited. */
|
|
224
295
|
get type(): FillType | undefined;
|
|
225
|
-
/** A solid fill's colour; python-pptx refuses it for another fill: call solid() first. */
|
|
296
|
+
/** A solid fill's colour, or a pattern's foreground; python-pptx refuses it for another fill: call solid() first. */
|
|
226
297
|
get fore_color(): ColorFormat;
|
|
227
298
|
}
|
|
228
299
|
/** python-pptx's `_GradientStop`: one of a gradient's stops. */
|
|
@@ -246,8 +317,13 @@ export declare class GradientStop {
|
|
|
246
317
|
*/
|
|
247
318
|
export declare class ShadowFormat {
|
|
248
319
|
private readonly def;
|
|
249
|
-
|
|
320
|
+
/** A shadow inside the shape (`shape.inner_shadow`), not outside. */
|
|
321
|
+
private readonly inner;
|
|
322
|
+
constructor(def: ShapeDef, inner?: boolean);
|
|
250
323
|
private _shadow;
|
|
324
|
+
/** Whether it is drawn (Office's ShadowFormat.Visible): set, it has the defaults' shadow until changed; cleared, none. */
|
|
325
|
+
get visible(): boolean;
|
|
326
|
+
set visible(v: boolean);
|
|
251
327
|
/** Whether it takes its style's effects; false gives it none of its own (no shadow), as python-pptx's empty effect list does. */
|
|
252
328
|
get inherit(): boolean;
|
|
253
329
|
set inherit(v: boolean);
|
|
@@ -261,6 +337,48 @@ export declare class ShadowFormat {
|
|
|
261
337
|
set transparency(v: number);
|
|
262
338
|
get color(): ColorFormat;
|
|
263
339
|
}
|
|
340
|
+
/** A shape's glow (`shape.glow`, Office's GlowFormat): its colour, its radius, how much of it shows through; python-pptx has none. */
|
|
341
|
+
export declare class GlowFormat {
|
|
342
|
+
private readonly def;
|
|
343
|
+
constructor(def: ShapeDef);
|
|
344
|
+
private _glow;
|
|
345
|
+
/** Whether it glows: set, GLOW_DEFAULTS' glow until changed. */
|
|
346
|
+
get visible(): boolean;
|
|
347
|
+
set visible(v: boolean);
|
|
348
|
+
/** How far it reaches, a Length (`a:glow@rad`); 0 takes it away. */
|
|
349
|
+
get radius(): LengthValue;
|
|
350
|
+
set radius(v: Length);
|
|
351
|
+
get transparency(): number;
|
|
352
|
+
set transparency(v: number);
|
|
353
|
+
get color(): ColorFormat;
|
|
354
|
+
}
|
|
355
|
+
/** A shape's soft edges (`shape.soft_edge`, Office's SoftEdgeFormat): how far in its edges fade; python-pptx has none. */
|
|
356
|
+
export declare class SoftEdgeFormat {
|
|
357
|
+
private readonly def;
|
|
358
|
+
constructor(def: ShapeDef);
|
|
359
|
+
/** A Length (`a:softEdge@rad`); 0 takes them away. */
|
|
360
|
+
get radius(): LengthValue;
|
|
361
|
+
set radius(v: Length);
|
|
362
|
+
}
|
|
363
|
+
/** A shape's reflection (`shape.reflection`, Office's ReflectionFormat): how much shows through where it starts, how much of the shape it shows, how far below and how blurred; python-pptx has none. */
|
|
364
|
+
export declare class ReflectionFormat {
|
|
365
|
+
private readonly def;
|
|
366
|
+
constructor(def: ShapeDef);
|
|
367
|
+
private _reflection;
|
|
368
|
+
/** Whether it has one: set, REFLECTION_DEFAULTS' until changed. */
|
|
369
|
+
get visible(): boolean;
|
|
370
|
+
set visible(v: boolean);
|
|
371
|
+
get transparency(): number;
|
|
372
|
+
set transparency(v: number);
|
|
373
|
+
/** The share of the shape it shows, 0 to 1. */
|
|
374
|
+
get size(): number;
|
|
375
|
+
set size(v: number);
|
|
376
|
+
/** How far below the shape, a Length (Office's Offset). */
|
|
377
|
+
get offset(): LengthValue;
|
|
378
|
+
set offset(v: Length);
|
|
379
|
+
get blur(): LengthValue;
|
|
380
|
+
set blur(v: Length);
|
|
381
|
+
}
|
|
264
382
|
/** python-pptx's `LineFormat`: a shape's outline. */
|
|
265
383
|
export declare class LineFormat {
|
|
266
384
|
private readonly def;
|
|
@@ -273,6 +391,15 @@ export declare class LineFormat {
|
|
|
273
391
|
/** Its dashes (MSO_LINE), or null for its theme's. */
|
|
274
392
|
get dash_style(): LineDash | null;
|
|
275
393
|
set dash_style(v: LineDash | null);
|
|
394
|
+
/** How its ends and dashes end (MSO_LINE_CAP): flat unless set. */
|
|
395
|
+
get cap_type(): LineCap;
|
|
396
|
+
set cap_type(v: LineCap);
|
|
397
|
+
/** How its corners meet (MSO_LINE_JOIN): a miter unless set. */
|
|
398
|
+
get join_type(): LineJoin;
|
|
399
|
+
set join_type(v: LineJoin);
|
|
400
|
+
/** One line, two or three (MSO_LINE_COMPOUND): one unless set. */
|
|
401
|
+
get compound_type(): LineCompound;
|
|
402
|
+
set compound_type(v: LineCompound);
|
|
276
403
|
/** What the end of the line where it starts has (MSO_ARROWHEAD). */
|
|
277
404
|
get begin_arrow(): LineEnd;
|
|
278
405
|
set begin_arrow(v: LineEnd);
|
|
@@ -317,7 +444,9 @@ export declare class Shape {
|
|
|
317
444
|
private readonly def;
|
|
318
445
|
/** The frame it takes while it has none of its own: its master's or its layout's placeholder's. */
|
|
319
446
|
private readonly inherit;
|
|
320
|
-
|
|
447
|
+
/** The folder of the module that writes the deck, a project path: a picture fill's path is from it. */
|
|
448
|
+
private readonly base;
|
|
449
|
+
constructor(def: ShapeDef, inherit?: () => Frame | undefined, base?: string);
|
|
321
450
|
/** The model it writes (this package's). */
|
|
322
451
|
get _def(): ShapeDef;
|
|
323
452
|
private _frame;
|
|
@@ -362,6 +491,11 @@ export declare class Shape {
|
|
|
362
491
|
get fill(): FillFormat;
|
|
363
492
|
get line(): LineFormat;
|
|
364
493
|
get shadow(): ShadowFormat;
|
|
494
|
+
/** A shadow inside it, PowerPoint's Inner shadows (`a:innerShdw`); python-pptx has none. */
|
|
495
|
+
get inner_shadow(): ShadowFormat;
|
|
496
|
+
get glow(): GlowFormat;
|
|
497
|
+
get soft_edge(): SoftEdgeFormat;
|
|
498
|
+
get reflection(): ReflectionFormat;
|
|
365
499
|
/** Its geometry's adjustments: `adjustments[0] = 0.1` sets a rounded rectangle's corner. */
|
|
366
500
|
get adjustments(): Adjustments;
|
|
367
501
|
/** A connector's ends (python-pptx's Connector): refuses another shape. */
|
|
@@ -423,6 +557,7 @@ export declare class GroupShape {
|
|
|
423
557
|
/** The shapes in it; what is added to them is in it. */
|
|
424
558
|
get shapes(): ShapeCollection;
|
|
425
559
|
get shape_type(): ShapeType;
|
|
560
|
+
/** Its own name; a group in a group is named within the outer one. */
|
|
426
561
|
get name(): string;
|
|
427
562
|
set name(v: string);
|
|
428
563
|
get left(): LengthValue;
|
|
@@ -498,6 +633,9 @@ export declare class Table {
|
|
|
498
633
|
iter_cells(): Iterable<Cell>;
|
|
499
634
|
get columns(): Column[];
|
|
500
635
|
get rows(): Row[];
|
|
636
|
+
/** Its style, one of PowerPoint's 74 built-in table styles, by its English name ("Medium Style 2 - Accent 1"); set by its name or its id, null for none. */
|
|
637
|
+
get style(): string | null;
|
|
638
|
+
set style(v: string | null);
|
|
501
639
|
private flag;
|
|
502
640
|
get first_row(): boolean;
|
|
503
641
|
set first_row(v: boolean);
|
|
@@ -545,10 +683,15 @@ export declare class ShapeCollection implements Iterable<Shape> {
|
|
|
545
683
|
/** A video file; its poster is a moment of it, in seconds. */
|
|
546
684
|
add_movie(movie_file: string, left: Length, top: Length, width: Length, height: Length, options?: {
|
|
547
685
|
poster_frame_time?: number;
|
|
686
|
+
playback?: PlaybackDef;
|
|
687
|
+
}): Shape;
|
|
688
|
+
/** A sound (PowerPoint's Insert Audio, which python-pptx has no API for): drawn as its icon in its frame, half an inch unless given. */
|
|
689
|
+
add_audio(audio_file: string, left: Length, top: Length, width?: Length, height?: Length, options?: {
|
|
690
|
+
playback?: PlaybackDef;
|
|
548
691
|
}): Shape;
|
|
549
692
|
/** An autoshape, as python-pptx makes one: filled and outlined in accent 1, its text light 1, centred. */
|
|
550
693
|
add_shape(autoshape_type_id: ShapeGeometry, left: Length, top: Length, width: Length, height: Length): Shape;
|
|
551
|
-
/** A table of equal columns and rows (python-pptx's add_table), in `.table
|
|
694
|
+
/** A table of equal columns and rows (python-pptx's add_table), in `.table`: python-pptx's and PowerPoint's, Medium Style 2 – Accent 1 with a header row and banded rows. */
|
|
552
695
|
add_table(rows: number, cols: number, left: Length, top: Length, width: Length, height: Length): Shape;
|
|
553
696
|
/** A chart (python-pptx's add_chart), in `.chart`; PowerPoint opens it as its own, with its numbers in a workbook. */
|
|
554
697
|
add_chart(chart_type: SheetChartType, x: Length, y: Length, cx: Length, cy: Length, chart_data: CategoryChartData | XyChartData): Shape;
|
|
@@ -590,12 +733,8 @@ export declare class Placeholders implements Iterable<Shape> {
|
|
|
590
733
|
* unless given; its idx is PowerPoint's (a title 0, a date, footer and
|
|
591
734
|
* slide number 10, 11, 12, the rest from 1).
|
|
592
735
|
*/
|
|
593
|
-
add(type: PlaceholderType, options?:
|
|
594
|
-
|
|
595
|
-
}): Shape;
|
|
596
|
-
add(type: PlaceholderType, left: Length, top: Length, width: Length, height: Length, options?: {
|
|
597
|
-
name?: string;
|
|
598
|
-
}): Shape;
|
|
736
|
+
add(type: PlaceholderType, options?: PlaceholderOptions): Shape;
|
|
737
|
+
add(type: PlaceholderType, left: Length, top: Length, width: Length, height: Length, options?: PlaceholderOptions): Shape;
|
|
599
738
|
}
|
|
600
739
|
/** What a master and its layouts share: the deck's folder, its components. */
|
|
601
740
|
interface Context {
|
|
@@ -616,6 +755,9 @@ export declare class SlideLayout {
|
|
|
616
755
|
/** Whether its master's shapes are drawn on its slides (PowerPoint's Hide Background Graphics, turned round). */
|
|
617
756
|
get display_master_shapes(): boolean;
|
|
618
757
|
set display_master_shapes(v: boolean);
|
|
758
|
+
/** Its own colour map over its master's (`p:clrMapOvr`): { bg1: "dk1", tx1: "lt1", … }, which python-pptx has no name for; none (undefined) is its master's. */
|
|
759
|
+
get color_map(): Readonly<Partial<Record<ColorName, ThemeColor>>> | undefined;
|
|
760
|
+
set color_map(v: Readonly<Partial<Record<ColorName, ThemeColor>>> | undefined);
|
|
619
761
|
get background(): Background;
|
|
620
762
|
get placeholders(): Placeholders;
|
|
621
763
|
get shapes(): ShapeCollection;
|
|
@@ -651,6 +793,15 @@ export declare class SlideMaster {
|
|
|
651
793
|
constructor(def: MasterDef, ctx: Context, allLayouts: SlideLayout[]);
|
|
652
794
|
get _def(): MasterDef;
|
|
653
795
|
get name(): string;
|
|
796
|
+
/**
|
|
797
|
+
* Its colour map (`p:clrMap`), which python-pptx has no name for: what
|
|
798
|
+
* text and background 1 and 2 (`tx1`, `bg1`, `tx2`, `bg2`) and the accents
|
|
799
|
+
* and links are of the theme's colours. Office's is dark text on light
|
|
800
|
+
* ({ bg1: "lt1", tx1: "dk1", bg2: "lt2", tx2: "dk2" }); a dark master's
|
|
801
|
+
* the other way round. Set, what it leaves out is Office's.
|
|
802
|
+
*/
|
|
803
|
+
get color_map(): Readonly<Record<ColorName, ThemeColor>>;
|
|
804
|
+
set color_map(v: Readonly<Partial<Record<ColorName, ThemeColor>>>);
|
|
654
805
|
get background(): Background;
|
|
655
806
|
get placeholders(): Placeholders;
|
|
656
807
|
get shapes(): ShapeCollection;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
/*! AllyHub. Copyright (c) 2026 AllyHub, Inc. All rights reserved. Use is subject to LICENSE.md. */
|
|
2
|
-
import{themeColor as
|
|
3
|
-
`)}set text(
|
|
4
|
-
`).map(e=>({runs:D(e),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(t=>new Paragraph(t))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const t={runs:[],level:0};return this.def.paragraphs.push(t),new Paragraph(t)}clear(){const t=this.def.paragraphs[0];this.def.paragraphs=t?[{...t,runs:[]}]:[]}fit_text(t,e=18,s,r){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(e*N),...t===void 0?{}:{name:t},...s===void 0?{}:{bold:s},...r===void 0?{}:{italic:r}}}get list_style(){return O(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(t){this._set("vertical_anchor",t)}get auto_size(){return this.def.auto_size}set auto_size(t){this._set("auto_size",t)}get word_wrap(){return this.def.word_wrap}set word_wrap(t){this._set("word_wrap",t)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(t){this.def.margin_left=t}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(t){this.def.margin_top=t}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(t){this.def.margin_right=t}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(t){this.def.margin_bottom=t}}export class FillFormat{read;write;start;shape;constructor(t,e,s="lt1",r){return this.read=t,this.write=e,this.start=s,this.shape=r,a(this,"FillFormat")}solid(){const t=this.read();this.shape&&Reflect.deleteProperty(this.shape,"gradient"),t==null&&this.write(this.start)}background(){this.shape&&Reflect.deleteProperty(this.shape,"gradient"),this.write(null)}_shape(t){if(!this.shape)throw new TypeError(`Only a shape's fill has ${t}.`);return this.shape}gradient(){this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_angle(){return this._gradient().angle}set gradient_angle(t){this._gradient().angle=t}get gradient_stops(){return this._gradient().stops.map(t=>new GradientStop(t))}set gradient_stops(t){if(t.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=t.map(e=>e instanceof GradientStop?GradientStop.defOf(e):{...e,color:I(e.color,"A gradient stop's colour")})}_gradient(){const{gradient:t}=this._shape("a gradient");if(!t)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return t}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(t){if(!(t>=0&&t<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(t)}.`);this._shape("a transparency").fill_transparency=t}get type(){if(this.shape?.gradient)return"gradient";const t=this.read();return t===void 0?void 0:t===null?"background":"solid"}get fore_color(){const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,e=>{this.write(e??this.start)})}}export class GradientStop{stop;constructor(t){return this.stop=t,a(this,"GradientStop")}static defOf(t){return{...t.stop}}get color(){return new ColorFormat(()=>this.stop.color,t=>{t!==void 0&&(this.stop.color=t)})}get position(){return this.stop.at}set position(t){if(!(t>=0&&t<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(t)}.`);this.stop.at=t}get transparency(){return this.stop.transparency??0}set transparency(t){if(!(t>=0&&t<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(t)}.`);t===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=t}}export class ShadowFormat{def;constructor(t){return this.def=t,a(this,"ShadowFormat")}_shadow(){return this.def.shadow??={...z},this.def.shadow}get inherit(){return this.def.shadow===void 0}set inherit(t){t?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(t){this._shadow().blur=t}get distance(){return l(this._shadow().distance)}set distance(t){this._shadow().distance=t}get angle(){return this._shadow().angle}set angle(t){this._shadow().angle=t}get transparency(){return this._shadow().transparency}set transparency(t){this._shadow().transparency=t}get color(){const t=this._shadow();return new ColorFormat(()=>t.color,e=>{t.color=e??z.color})}}export class LineFormat{def;constructor(t){return this.def=t,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,t=>{this.def.line=t??null})}get fill(){return new FillFormat(()=>this.def.line,t=>{this.def.line=t},"dk1")}get width(){return l(this.def.line_width??0)}set width(t){this.def.line_width=t}get dash_style(){return this.def.line_dash??null}set dash_style(t){t===null?delete this.def.line_dash:this.def.line_dash=x(q,"MSO_LINE","dash_style",t)}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(t){this.def.line_begin=x(j,"MSO_ARROWHEAD","begin_arrow",t)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(t){this.def.line_end=x(j,"MSO_ARROWHEAD","end_arrow",t)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(t){this.def.line_begin_size={...this.def.line_begin_size,w:x($,"MSO_ARROWHEAD_SIZE","begin_arrow_width",t)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(t){this.def.line_begin_size={...this.def.line_begin_size,len:x($,"MSO_ARROWHEAD_SIZE","begin_arrow_length",t)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(t){this.def.line_end_size={...this.def.line_end_size,w:x($,"MSO_ARROWHEAD_SIZE","end_arrow_width",t)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(t){this.def.line_end_size={...this.def.line_end_size,len:x($,"MSO_ARROWHEAD_SIZE","end_arrow_length",t)}}}function x(i,t,e,s){if(Object.values(i).includes(s))return s;throw new Error(`${e}: ${String(s)} is not one of ${t}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(t){return this.holder=t,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,t=>{this.holder.background=t??"lt1"})}}export const adjustmentDefaults=i=>H(i).map(t=>t.value/1e5);export class Adjustments{def;constructor(t){return this.def=t,a(this,"Adjustments",{index:e=>this._values()[e],setIndex:(e,s)=>{this._set(e,Number(s))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(t,e){const s=this._values();if(t<0||t>=s.length)throw new RangeError(`adjustments[${String(t)}]: ${this.def.geometry??"this shape"} has ${String(s.length)}.`);if(!Number.isFinite(e))throw new Error(`adjustments[${String(t)}] = ${String(e)} is not a number.`);s[t]=e,this.def.adjustments=s}}const dt={left:0,top:0,width:0,height:0};export class Shape{def;inherit;constructor(t,e=()=>{}){return this.def=t,this.inherit=e,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??dt}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(t){this.def.name=t}get shape_type(){return this.def.path?"freeform":k(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new Q(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(t){this._own().left=t}get top(){return l(this._frame().top)}set top(t){this._own().top=t}get width(){return l(this._frame().width)}set width(t){this._own().width=t}get height(){return l(this._frame().height)}set height(t){this._own().height=t}get rotation(){return this.def.rotation??0}set rotation(t){if(!Number.isFinite(t))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const e=(Math.trunc(t*6e4)%216e5+216e5)%216e5/6e4;e===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=e}get flip_h(){return this.def.flip?.h===!0}set flip_h(t){this._flip("h",t)}get flip_v(){return this.def.flip?.v===!0}set flip_v(t){this._flip("v",t)}_flip(t,e){const s={...this.def.flip};e?s[t]=!0:Reflect.deleteProperty(s,t),Object.keys(s).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=s}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(t){this.text_frame.text=t}get fill(){return new FillFormat(()=>this.def.fill,t=>{this.def.fill=t},"lt1",this.def)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(t){if(this.def.path||!k(this.def.geometry))throw new Error(`${this.def.name}.${t}: it is not a connector (add_connector makes one).`);return U(this._frame(),this.def.flip,this.def.rotation)}_move(t,e){const s=B(t,e,this.def.rotation);this.def.frame=s.frame,s.flip?this.def.flip=s.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(t){const[e,s]=this._ends("begin_x");this._move([t,e[1]],s)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(t){const[e,s]=this._ends("begin_y");this._move([e[0],t],s)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(t){const[e,s]=this._ends("end_x");this._move(e,[t,s[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(t){const[e,s]=this._ends("end_y");this._move(e,[s[0],t])}begin_connect(t,e){this._connect("begin",t,e)}end_connect(t,e){this._connect("end",t,e)}_connect(t,e,s){const r=`${t}_connect`,[n,o]=this._ends(r);if(!(e instanceof Shape))throw new Error(`${this.def.name}.${r}(): its shape is a Shape.`);const h=e._def,f={frame:e._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},u=Z(f).length;if(!Number.isInteger(s)||s<0||s>=u)throw new Error(`${this.def.name}.${r}(): ${h.name} has connection sites 0 to ${String(u-1)}; ${String(s)} is not one.`);const c=W(f,s)??(t==="begin"?n:o);this.def.connect={...this.def.connect,[t]:{shape:h.name,site:s}},this._move(t==="begin"?c:n,t==="begin"?o:c)}}const lt=i=>typeof i=="number"&&Number.isFinite(i),_=(i,t,e,s)=>{for(const[r,n]of Object.entries({left:i,top:t,width:e,height:s}))if(!lt(n))throw new Error(`${r} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(e<0||s<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(t),width:Math.trunc(e),height:Math.trunc(s)}},ft=new Set(Object.values(P));export class FreeformBuilder{steps;sx;sy;make;constructor(t,e,s){return this.steps=[{op:"move",x:t[0],y:t[1]}],[this.sx,this.sy]=typeof e=="number"?[e,e]:e,this.make=s,a(this,"FreeformBuilder")}add_line_segments(t,e=!0){for(const[s,r]of t)this.steps.push({op:"line",x:s,y:r});return e&&this.steps.push({op:"close"}),this}add_curve_segment(t,e,s,r,n,o){if(![t,e,s,r,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:t,y1:e,x2:s,y2:r,x:n,y:o}),this}move_to(t,e){return this.steps.push({op:"move",x:t,y:e}),this}convert_to_shape(t=0,e=0){this.steps.length<2&&g("convert_to_shape(): a freeform needs a segment.");const s=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),r=s.map(d=>d[0]),n=s.map(d=>d[1]),o=Math.min(...r),h=Math.min(...n),f=Math.max(...r)-o,u=Math.max(...n)-h;f===0&&u===0&&g("convert_to_shape(): a freeform's points are all one point.");const c=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:u,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...c(d.x,d.y)};const m=c(d.x1,d.y1),y=c(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...c(d.x,d.y)}})},_(Math.round(o*this.sx)+t,Math.round(h*this.sy)+e,Math.round(f*this.sx),Math.round(u*this.sy)))}}export class GroupShape{list;_name;make;constructor(t,e,s){return this.list=t,this._name=e,this.make=s,a(this,"GroupShape")}members(){return this.list.filter(t=>t.group===this._name)}box(){const t=this.members().flatMap(r=>r.frame?[r.frame]:[]),e=Math.min(...t.map(r=>r.left)),s=Math.min(...t.map(r=>r.top));return{left:t.length>0?e:0,top:t.length>0?s:0,right:Math.max(0,...t.map(r=>r.left+r.width)),bottom:Math.max(0,...t.map(r=>r.top+r.height))}}get shapes(){return this.make(this._name)}get shape_type(){return K.GROUP}get name(){return this._name}set name(t){for(const e of this.members())e.group=t;this._name=t}get left(){return l(this.box().left)}set left(t){const e=t-this.box().left;for(const s of this.members())s.frame&&(s.frame.left+=e)}get top(){return l(this.box().top)}set top(t){const e=t-this.box().top;for(const s of this.members())s.frame&&(s.frame.top+=e)}get width(){const t=this.box();return l(t.right-t.left)}get height(){const t=this.box();return l(t.bottom-t.top)}}export class Cell{def;table;row;col;constructor(t,e,s,r){return this.def=t,this.table=e,this.row=s,this.col=r,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(t){this.text_frame.text=t}get fill(){return new FillFormat(()=>this.def.fill,t=>{this.def.fill=t})}get borders(){return this.def.borders??{}}set borders(t){this.def.borders=Object.fromEntries(Object.entries(t).map(([e,s])=>[e,{...s,color:I(s.color,`A cell's ${e} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(t){this.def.text.margin_left=t}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(t){this.def.text.margin_right=t}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(t){this.def.text.margin_top=t}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(t){this.def.text.margin_bottom=t}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(t){t===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=t}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(t){const e=[this.row,t.row].sort((f,u)=>f-u),s=[this.col,t.col].sort((f,u)=>f-u),[r=0,n=0]=e,[o=0,h=0]=s;for(let f=r;f<=n;f++)for(let u=o;u<=h;u++){const c=this.table.rows[f]?.cells[u];c&&(f===r&&u===o?(h>o&&(c.span_width=h-o+1),n>r&&(c.span_height=n-r+1)):c.spanned=!0)}}split(){const t=this.span_width,e=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let s=this.row;s<this.row+e;s++)for(let r=this.col;r<this.col+t;r++){const n=this.table.rows[s]?.cells[r];n&&delete n.spanned}}}export class Column{def;at;constructor(t,e){return this.def=t,this.at=e,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(t){this.def.columns[this.at]=t}}export class Row{def;at;constructor(t,e){return this.def=t,this.at=e,a(this,"_Row")}get row(){const t=this.def.rows[this.at];if(!t)throw new Error(`The table has no row ${String(this.at)}.`);return t}get height(){return l(this.row.height)}set height(t){this.row.height=t}}export class Table{def;constructor(t){return this.def=t,a(this,"Table")}cell(t,e){const s=this.def.rows[t]?.cells[e];if(!s)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(s,this.def,t,e)}*iter_cells(){for(let t=0;t<this.def.rows.length;t++)for(let e=0;e<this.def.columns.length;e++)yield this.cell(t,e)}get columns(){return this.def.columns.map((t,e)=>new Column(this.def,e))}get rows(){return this.def.rows.map((t,e)=>new Row(this.def,e))}flag(t){return this.def[t]===!0}get first_row(){return this.flag("first_row")}set first_row(t){this.def.first_row=t}get first_col(){return this.flag("first_col")}set first_col(t){this.def.first_col=t}get last_row(){return this.flag("last_row")}set last_row(t){this.def.last_row=t}get last_col(){return this.flag("last_col")}set last_col(t){this.def.last_col=t}get horz_banding(){return this.flag("horz_banding")}set horz_banding(t){this.def.horz_banding=t}get vert_banding(){return this.flag("vert_banding")}set vert_banding(t){this.def.vert_banding=t}}function ut(i,t,e=[]){const s=new Set([...i,...e].map(n=>n.name));let r=1;for(;s.has(`${t}-${String(r)}`);)r++;return`${t}-${String(r)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(t,e,s,r=()=>{},n=()=>[],o){return this.list=t,this.base=e,this.components=s,this.inherit=r,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(t){return new Shape(t,()=>this.inherit(t))}_at(t){const e=this.list[t];return e?this._wrap(e):void 0}*[Symbol.iterator](){for(const t of this.list)yield this._wrap(t)}get length(){return this.list.length}get(t){const e=this.list.find(s=>s.name===t);return e?this._wrap(e):void 0}get title(){const t=this.list.find(e=>e.placeholder?.type==="title"||e.placeholder?.type==="ctrTitle");return t?this._wrap(t):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(t,e){const s={name:ut(this.list,t,this.under()),...e,...this.group===void 0?{}:{group:this.group}};return this.list.push(s),this._wrap(s)}add_textbox(t,e,s,r){return this._add("textbox",{kind:"textbox",frame:_(t,e,s,r),text:{...S(),...rt}})}add_picture(t,e,s,r,n){return(r===void 0||n===void 0)&&g("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(e,s,r??0,n??0),media:{path:t,base:this.base}})}add_movie(t,e,s,r,n,o={}){return this._add("movie",{kind:"movie",frame:_(e,s,r,n),media:{path:t,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time}}})}add_shape(t,e,s,r,n){ft.has(t)||g(`add_shape(): ${t} is not one of MSO_SHAPE's ${Object.keys(P).join(", ")}`);const o=S();return o.vertical_anchor=p.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:p.alignment}],this._add("shape",{kind:"autoshape",frame:_(e,s,r,n),geometry:t,fill:p.fill,line:p.line,line_width:p.line_width,text:o})}add_table(t,e,s,r,n,o){(t<1||e<1)&&g("add_table(): a table has at least a row and a column.");const h=Math.floor(n/e),f=Math.floor(o/t);return this._add("table",{kind:"table",frame:_(s,r,n,o),table:{columns:Array.from({length:e},()=>h),rows:Array.from({length:t},()=>({height:f,cells:Array.from({length:e},()=>({text:S()}))}))}})}add_chart(t,e,s,r,n,o){return this._add("chart",{kind:"chart",frame:_(e,s,r,n),chart:{type:t,categories:[...o.categories],series:o._series()}})}add_group_shape(){this.group!==void 0&&g("add_group_shape(): a group here holds shapes, not another group.");let t=1;for(;this.list.some(e=>e.group===`group-${String(t)}`);)t++;return new GroupShape(this.list,`group-${String(t)}`,e=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,e))}build_freeform(t=0,e=0,s=1){return new FreeformBuilder([t,e],s,(r,n)=>{const o=S();return o.vertical_anchor=p.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:p.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:r,fill:p.fill,line:p.line,line_width:p.line_width,text:o})})}add_connector(t,e,s,r,n){k(t)||g(`add_connector(): ${t} is not one of MSO_CONNECTOR's ${Object.keys(J).join(", ")}, nor a connector's preset (${V.join(", ")})`);const o=_(Math.min(e,r),Math.min(s,n),Math.abs(r-e),Math.abs(n-s)),h=r<e,f=n<s;return this._add("connector",{kind:"autoshape",frame:o,geometry:t,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:F.line,line_width:F.line_width})}add_component(t,e,s,r,n,o={},h={}){if(!Object.hasOwn(this.components(),t))throw new Error(`add_component(): the presentation has no component ${t}; add it with prs.components.add("${t}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${t} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(t,{kind:"component",frame:_(e,s,r,n),component:{name:t,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(t,e=()=>{}){return this.list=t,this.inherit=e,a(this,"placeholders",{index:s=>this.get(s)})}_wrap(t){return new Shape(t,()=>this.inherit(t))}*[Symbol.iterator](){for(const t of this.list)t.kind==="placeholder"&&(yield this._wrap(t))}get length(){return this.list.filter(t=>t.kind==="placeholder").length}get(t){const e=this.list.find(s=>s.kind==="placeholder"&&(typeof t=="number"?s.placeholder?.idx===t:s.name===t||s.placeholder?.type===t));return e?this._wrap(e):void 0}add(t,e,s,r,n,o={}){const h=typeof e=="object"?e:o,f=typeof e=="object"?void 0:e;Object.values(v).includes(t)||g(`placeholders.add(): ${t} is not one of PP_PLACEHOLDER's ${Object.keys(v).join(", ")}`);const u=this.list.filter(b=>b.kind==="placeholder"),c=new Set(u.map(b=>b.placeholder?.idx));let d=t==="title"||t==="ctrTitle"?0:tt[t]??1;for(c.has(d)&&d===0&&(d=1);c.has(d);)d++;const m=h.name??NAME_OF_TYPE[t];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,s,r,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const R={name:m,kind:"placeholder",placeholder:{type:t,idx:d},...y.length===4?{frame:_(f??0,s??0,r??0,n??0)}:{},text:{paragraphs:[],levels:st(t)}};return this.list.push(R),this._wrap(R)}}export class SlideLayout{def;master;ctx;constructor(t,e,s){return this.def=t,this.master=e,this.ctx=s,a(this,"SlideLayout")}get _def(){return this.def}inherit=t=>t.placeholder?C(this.master._def,t.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(t){t?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(t,e){return this.list=t,this.make=e,a(this,"SlideLayouts",{index:s=>this.list[s]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(t,e){return this.list.find(s=>s.name===t)??e}index(t){const e=this.list.indexOf(t);if(e<0)throw new Error(`${t.name} is not among these layouts.`);return e}add(t,e){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const s=this.make(t);return e?.(s),s}}export class TextStyles{def;constructor(t){return this.def=t,a(this,"text_styles")}get title_style(){return O(this.def.title)}get body_style(){return O(this.def.body)}get other_style(){return O(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(t,e,s){return this.def=t,this.ctx=e,this.allLayouts=s,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,t=>{if(this.allLayouts.some(r=>r.name===t))throw new Error(`Two layouts are "${t}": a layout's name is unique in the deck, as its slides file names it.`);const e={name:t,master:this.def.name,shapes:[]};this.def.layouts.push(e);const s=new SlideLayout(e,this,this.ctx);return this.layouts.push(s),this.allLayouts.push(s),s})}}export class SlideMasters{list;make;constructor(t,e){return this.list=t,this.make=e,a(this,"SlideMasters",{index:s=>this.list[s]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(t){return this.list.indexOf(t)}add(t,e){const s=this.make(t);return e?.(s),s}}export class GeneratedSlide{own;def;layout;constructor(t,e,s){this.def=t,this.layout=e,this.own=e._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:S()}));const r=n=>{const o=e._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?C(e.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,s.base,s.components,r,()=>[...e.slide_master._def.shapes,...e._def.shapes]),this._placeholders=new Placeholders(this.own,r),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const t=this.def;return a({notes_text_frame:a({get text(){return t.notes??""},set text(e){t.notes=e}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(t){t===void 0?delete this.def.transition:this.def.transition=t}get animations(){return new Animations(this.def.animations??=[])}_done(){const t={},e=[];for(const s of this.own)s.kind==="placeholder"&&s.placeholder?(s.text?.paragraphs.some(r=>r.runs.length>0)&&(t[s.placeholder.idx]=s.text.paragraphs),s.frame&&e.push({...s,text:S()})):e.push(s);return{...this.def,shapes:e,text:t}}}export class Animations{list;constructor(t){return this.list=t,a(this,"Animations")}add(t,e,s={}){this.list.push({shape:typeof t=="string"?t:t.name,effect:e,...s})}get length(){return this.list.length}}class ct{gen;constructor(t){return this.gen=t,a(this,"slides")}add_slide(t,e){return this.gen._add(t,e)}}export class Generator{list=[];prs;ctx;constructor(t,e){return this.prs=t,this.ctx=e,a(this,"Generator")}data(t){return this.ctx.data(t)}get slides(){return new ct(this)}_add(t,e){const s=typeof t=="string"?this.prs._layout(t):t;if(!s)throw new Error(`add_slide(): the presentation has no layout ${typeof t=="string"?t:t.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(e))throw new Error(`add_slide(): ${e} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===e))throw new Error(`add_slide(): two slides are ${e}.`);const r=new GeneratedSlide({id:e,layout:s.name,shapes:[],text:{}},s,this.prs._ctx);return this.list.push(r),r}_made(){return this.list.map(t=>t._done())}}const pt=()=>JSON.parse(JSON.stringify(et));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(t,e){return this.def={slide_width:t[0],slide_height:t[1],masters:[],components:{},generators:{}},this._ctx={base:e,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(t){this.def.slide_width=t}get slide_height(){return l(this.def.slide_height)}set slide_height(t){this.def.slide_height=t}get slide_masters(){return new SlideMasters(this.masters,t=>{if(this.masters.some(r=>r.name===t))throw new Error(`Two masters are "${t}".`);const e={name:t,background:"lt1",text_styles:pt(),shapes:[],layouts:[]};this.def.masters.push(e);const s=new SlideMaster(e,this._ctx,this.layouts);return this.masters.push(s),s})}get slide_master(){const t=this.masters[0];if(!t)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return t}get slide_layouts(){const t=this.masters[0];return t?t.slide_layouts:new SlideLayouts([])}get slides(){return g("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return g("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(t){this.def.theme=t}get components(){return a({add:(t,e)=>{if(Object.hasOwn(this.def.components,t))throw new Error(`Two components are "${t}".`);const s=X(t,e);if(!s)throw new Error(`Component ${t} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[t]=s}},"components")}get generators(){return a({add:(t,e)=>{if(Object.hasOwn(this.def.generators,t))throw new Error(`Two generators are "${t}".`);this.def.generators[t]={name:t,make:s=>{const r=new Generator(this,s);return e(r),r._made()}}}},"generators")}_layout(t){return this.layouts.find(e=>e.name===t)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(t,e)=>{const[s,r]=typeof t=="function"?[{},t]:[t,e];if(typeof r!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(s.script!==void 0&&!s.script.includes("{locale}"))throw new Error(`presentation(): script ${s.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof s.size=="string"&&!Object.hasOwn(M,s.size))throw new Error(`presentation(): size ${s.size} is not one of ${Object.keys(M).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:s,build:r,written:{file:i}}};export function evaluateDeck(i){const t=i.options.size??"16:9",e=typeof t=="string"?M[t]:[t.width,t.height],s=i.written.file.split("/").slice(0,-1).join("/"),r=new Presentation(e,s);return i.options.theme&&(r.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(r),r._def}
|
|
2
|
+
import{themeColor as P,themeColorOf as T}from"@allyhub/chart";import{presetAdjustments as te}from"@allyhub/ooxml/geometry";import{connectorBetween as re,connectorEnds as se,siteOn as ie,sitesOf as ne}from"./connect.js";import{framedComponent as oe}from"@allyhub/piece";import{COLOR_TRANSFORMS as F,colorOfFile as ae,GRADIENT_PATHS as z,inGroup as I,THEME_COLORS as A}from"@allyhub/formats";import{MSO_ARROWHEAD as C,MSO_ARROWHEAD_SIZE as S,MSO_CONNECTOR as he,MSO_LINE as de,MSO_LINE_CAP as le,MSO_LINE_COMPOUND as fe,MSO_LINE_JOIN as ce,MSO_PATTERN_TYPE as ue,TILE_ALIGNMENT as pe,MSO_SHAPE as D,MSO_SHAPE_TYPE as _e,MSO_TEXT_ORIENTATION as G,PP_PLACEHOLDER as H}from"./enums.js";import{Chart as ge}from"./chart-api.js";import{AUTOSHAPE_STYLE as g,SHADOW_DEFAULTS as U,LINE_DEFAULTS as x,PATTERN_DEFAULTS as O,TILE_DEFAULTS as B,INNER_SHADOW_DEFAULTS as me,GLOW_DEFAULTS as v,REFLECTION_DEFAULTS as we,PLAYBACK_DEFAULTS as W,CONNECTOR_GEOMETRIES as be,CONNECTOR_STYLE as Y,FOOTER_IDX as ye,isConnectorGeometry as M,OFFICE_TEXT_STYLES as xe,placeholderLevels as Ee,TEXT_INSETS as w,TEXTBOX_FRAME as Se}from"./office.js";import{masterPlaceholder as X}from"./placeholders.js";import{strict as a}from"./strict.js";import{DEFAULT_TABLE_STYLE as Oe,TABLE_STYLES as $e,tableStyleOf as Z}from"./table-style.js";import{EMU_PER_PT as R,SLIDE_SIZES as j,length as l,lengthOr as $}from"./units.js";class ke extends Error{constructor(e){super(`${e} (allyhub slides capabilities lists what the API holds).`),this.name="Unsupported"}}export const refuse=i=>{throw new ke(i)};const Te=/^#?[0-9a-f]{6}$/iu,J=i=>{if(!Te.test(i))throw new Error(`rgb ${i} is not RRGGBB.`);return`#${i.replace("#","").toUpperCase()}`};function N(i,e){if(typeof i!="string")return i;const t=ae(i);if(t===void 0)throw new Error(`${e} is a theme colour (accent1), one lighter or darker (accent1 lighter 40%) or #RRGGBB, not ${i}.`);return t}export const OFFICE_COLOR_MAP={...Object.fromEntries(A.map(i=>[i,i])),tx1:"dk1",bg1:"lt1",tx2:"dk2",bg2:"lt2"};const Ae=["bg1","tx1","bg2","tx2","accent1","accent2","accent3","accent4","accent5","accent6","hlink","folHlink"];function K(i){const e={};for(const[t,r]of Object.entries(i))if(r!==void 0){if(!Ae.includes(t))throw new Error(`A colour map maps bg1, tx1, bg2, tx2, accent1 to accent6, hlink and folHlink, not ${t}.`);if(!A.includes(r))throw new Error(`A colour map's ${t} is one of the theme's colours (${A.join(", ")}), not ${r}.`);e[t]=r}return e}export const RGBColor=Object.assign(function(e,t,r){for(const o of[e,t,r])if(!Number.isInteger(o)||o<0||o>255)throw new Error(`RGBColor(${String(e)}, ${String(t)}, ${String(r)}): each is 0 to 255.`);const s=`#${[e,t,r].map(o=>o.toString(16).padStart(2,"0")).join("").toUpperCase()}`;return new.target===void 0?s:new String(s)},{from_string:i=>J(i)});export class ColorFormat{read;write;constructor(e,t){return this.read=e,this.write=t,a(this,"ColorFormat")}get theme_color(){const e=this.read();return e===void 0?void 0:T(e)}set theme_color(e){const t=this.read();e!==void 0&&typeof t=="object"&&"transforms"in t?this.write(t.transforms.length>0?{theme_color:e,transforms:t.transforms}:e):this.write(e===void 0?void 0:P(e,this.brightness))}get transforms(){const e=this.read();return typeof e=="object"&&"transforms"in e?[...e.transforms??[]]:[]}set transforms(e){const t=this.read();if(t===void 0)throw new TypeError("There is no colour to transform: set theme_color or rgb first.");for(const s of e)if(!F.includes(s.name))throw new Error(`A colour's transform is one of ${F.join(", ")}, not ${s.name}.`);const r=e.map(s=>({name:s.name,value:s.value}));if(typeof t=="object"&&"rgb"in t)this.write(r.length>0?{rgb:t.rgb,transforms:r}:{rgb:t.rgb});else{const s=T(t)??"dk1";this.write(r.length>0?{theme_color:s,transforms:r}:s)}}get brightness(){const e=this.read();return typeof e=="object"&&"brightness"in e?e.brightness:0}set brightness(e){if(!(e>=-1&&e<=1))throw new RangeError(`brightness ${String(e)} is not a number from -1.0 to 1.0.`);const t=this.read();if(t===void 0)throw new TypeError("There is no colour to set the brightness of: set theme_color first.");const r=T(t);if(r!==void 0)this.write(P(r,e));else if(e!==0)throw new TypeError("Only a theme colour has a brightness here, so an RGB colour does not: set theme_color first, or rgb to the colour it makes.")}get rgb(){const e=this.read();return typeof e=="object"&&"rgb"in e?e.rgb:void 0}set rgb(e){this.write(e===void 0?void 0:{rgb:J(e)})}}export class Font{def;constructor(e){return this.def=e,a(this,"Font")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get strike(){const e=this.def.strike;return e==="sngStrike"?!0:e}set strike(e){this._set("strike",e==="noStrike"?!1:e==="sngStrike"?!0:e)}get caps(){return this.def.caps}set caps(e){this._set("caps",e)}get baseline(){return this.def.baseline}set baseline(e){this._set("baseline",e)}get highlight(){return this.def.highlight}set highlight(e){this._set("highlight",e)}get name(){return this.def.name}set name(e){this._set("name",e)}get size(){return $(this.def.size)}set size(e){if(e!==void 0&&e<12700)throw new Error(`A font size is a Length of Pt(1) and over: Pt(${String(e)}) for ${String(e)} points; ${String(e)} alone is ${String(e)} EMU.`);this._set("size",e)}get bold(){return this.def.bold}set bold(e){this._set("bold",e)}get italic(){return this.def.italic}set italic(e){this._set("italic",e)}get underline(){const e=this.def.underline;return e==="sng"?!0:e}set underline(e){this._set("underline",e==="none"?!1:e==="sng"?!0:e)}get spacing(){return $(this.def.spacing)}set spacing(e){this._set("spacing",e)}get color(){return new ColorFormat(()=>this.def.color,e=>{this._set("color",e)})}}export class Hyperlink{def;constructor(e){return this.def=e,a(this,"_Hyperlink")}get address(){return this.def.font?.link}set address(e){this.def.font??={},e===void 0?Reflect.deleteProperty(this.def.font,"link"):this.def.font.link=e}}export class Run{def;constructor(e){return this.def=e,a(this,"_Run")}get text(){return this.def.text}set text(e){this.def.text=e}get font(){return this.def.font??={},new Font(this.def.font)}get hyperlink(){return new Hyperlink(this.def)}}const Me=i=>{if(!Number.isFinite(i)||i<=0)throw new Error(`line_spacing ${String(i)} is not over 0.`);return Number.isInteger(i)&&i>=R?{fixed:i}:{lines:i}},Re=i=>i===void 0?void 0:"lines"in i?i.lines:l(i.fixed),q=i=>{if(!Number.isFinite(i)||i<0)throw new Error(`A paragraph's space ${String(i)} is under 0.`);return i===0||Number.isInteger(i)&&i>=R?i:{lines:i}},Q=i=>i===void 0?void 0:typeof i=="number"?l(i):i.lines,V=i=>i.split(/\n|\v/u).flatMap((e,t)=>[...t>0?[{text:"\v"}]:[],...e===""?[]:[{text:e}]]);class ee{_set(e,t){t===void 0?Reflect.deleteProperty(this.fmt,e):this.fmt[e]=t}get alignment(){return this.fmt.alignment}set alignment(e){this._set("alignment",e)}get line_spacing(){return Re(this.fmt.line_spacing)}set line_spacing(e){this._set("line_spacing",e===void 0?void 0:Me(e))}get space_before(){return Q(this.fmt.space_before)}set space_before(e){this._set("space_before",e===void 0?void 0:q(e))}get space_after(){return Q(this.fmt.space_after)}set space_after(e){this._set("space_after",e===void 0?void 0:q(e))}get font(){return this.fmt.font??={},new Font(this.fmt.font)}}export class Paragraph extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"_Paragraph")}get text(){return this.fmt.runs.map(e=>e.text).join("")}set text(e){this.fmt.runs=V(e)}get runs(){return this.fmt.runs.filter(e=>e.text!=="\v").map(e=>new Run(e))}add_run(){const e={text:""};return this.fmt.runs.push(e),new Run(e)}add_line_break(){this.fmt.runs.push({text:"\v"})}clear(){return this.fmt.runs=[],this}get level(){return this.fmt.level}set level(e){if(!Number.isInteger(e)||e<0||e>8)throw new Error(`level ${String(e)} is not 0 to 8.`);this.fmt.level=e}}export class ListLevel extends ee{fmt;constructor(e){return super(),this.fmt=e,a(this,"ListLevel")}get numbered(){return this.fmt.numbered}set numbered(e){this._set("numbered",e)}get bullet(){return this.fmt.bullet}set bullet(e){this._set("bullet",e)}get bullet_font(){return this.fmt.bullet_font}set bullet_font(e){this._set("bullet_font",e)}get bullet_color(){return this.fmt.bullet_color}set bullet_color(e){this._set("bullet_color",e==null?e:N(e,"bullet_color"))}get bullet_size(){return this.fmt.bullet_size}set bullet_size(e){if(typeof e=="number"&&!(e>=.25&&e<=4))throw new Error(`bullet_size is a share of the text's size, 0.25 to 4, not ${String(e)}.`);this._set("bullet_size",e)}get start_at(){return this.fmt.start_at}set start_at(e){if(e!==void 0&&!(Number.isInteger(e)&&e>=1&&e<=32767))throw new Error(`start_at is a whole number from 1 to 32767, not ${String(e)}.`);this._set("start_at",e)}get margin_left(){return $(this.fmt.margin_left)}set margin_left(e){this._set("margin_left",e)}get indent(){return $(this.fmt.indent)}set indent(e){this._set("indent",e)}}const k=i=>Object.freeze(i.map(e=>new ListLevel(e))),je=()=>Array.from({length:9},()=>({})),E=()=>({paragraphs:[],levels:je()});export class TextFrame{def;constructor(e){return this.def=e,a(this,"TextFrame")}_set(e,t){t===void 0?Reflect.deleteProperty(this.def,e):this.def[e]=t}get text(){return this.def.paragraphs.map(e=>e.runs.map(t=>t.text).join("")).join(`
|
|
3
|
+
`)}set text(e){this.def.paragraphs=e.split(`
|
|
4
|
+
`).map(t=>({runs:V(t),level:0}))}get paragraphs(){return this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0}),this.def.paragraphs.map(e=>new Paragraph(e))}add_paragraph(){this.def.paragraphs.length===0&&this.def.paragraphs.push({runs:[],level:0});const e={runs:[],level:0};return this.def.paragraphs.push(e),new Paragraph(e)}clear(){const e=this.def.paragraphs[0];this.def.paragraphs=e?[{...e,runs:[]}]:[]}fit_text(e,t=18,r,s){this.def.auto_size="text",this.def.word_wrap=!0;for(const n of this.def.paragraphs)for(const o of n.runs)o.font={...o.font,size:Math.trunc(t*R),...e===void 0?{}:{name:e},...r===void 0?{}:{bold:r},...s===void 0?{}:{italic:s}}}get list_style(){return k(this.def.levels)}get vertical_anchor(){return this.def.vertical_anchor}set vertical_anchor(e){this._set("vertical_anchor",e)}get orientation(){return this.def.orientation}set orientation(e){if(e!==void 0&&!Object.values(G).includes(e))throw new Error(`orientation is one of MSO_TEXT_ORIENTATION's ${Object.values(G).join(", ")}, not ${e}.`);this._set("orientation",e)}get auto_size(){return this.def.auto_size}set auto_size(e){this._set("auto_size",e)}get word_wrap(){return this.def.word_wrap}set word_wrap(e){this._set("word_wrap",e)}get margin_left(){return l(this.def.margin_left??w.left)}set margin_left(e){this.def.margin_left=e}get margin_top(){return l(this.def.margin_top??w.top)}set margin_top(e){this.def.margin_top=e}get margin_right(){return l(this.def.margin_right??w.right)}set margin_right(e){this.def.margin_right=e}get margin_bottom(){return l(this.def.margin_bottom??w.bottom)}set margin_bottom(e){this.def.margin_bottom=e}}export class FillFormat{read;write;start;shape;base;constructor(e,t,r="lt1",s,n=""){return this.read=e,this.write=t,this.start=r,this.shape=s,this.base=n,a(this,"FillFormat")}_only(e){if(this.shape)for(const t of["gradient","pattern","picture_fill"])t!==e&&Reflect.deleteProperty(this.shape,t)}solid(){const e=this.read();this._only("solid"),e==null&&this.write(this.start)}background(){this._only("solid"),this.write(null)}patterned(){const e=this._shape("a pattern");this._only("pattern"),e.pattern??={preset:"pct5",fg:O.fg,bg:O.bg}}get pattern(){return this._pattern().preset}set pattern(e){this._pattern().preset=p(ue,"MSO_PATTERN_TYPE","pattern",e)}_pattern(){const{pattern:e}=this._shape("a pattern");if(!e)throw new TypeError("This fill is no pattern: call fill.patterned() first.");return e}get back_color(){const e=this._pattern();return new ColorFormat(()=>e.bg,t=>{e.bg=t??O.bg})}picture(e,t={}){const r=this._shape("a picture");this._only("picture_fill"),r.picture_fill={path:e,base:this.base,...t.tile?{tile:{...B,...t.tile,align:p(pe,"TILE_ALIGNMENT","tile.align",t.tile.align??B.align)}}:{},...t.transparency===void 0?{}:{transparency:t.transparency}}}_shape(e){if(!this.shape)throw new TypeError(`Only a shape's fill has ${e}.`);return this.shape}gradient(){this._only("gradient"),this._shape("a gradient").gradient??={angle:90,stops:[{at:0,color:"accent1"},{at:1,color:"accent2"}]}}get gradient_path(){return this._gradient().path??"linear"}set gradient_path(e){const t=this._gradient();e==="linear"?delete t.path:z.includes(e)?t.path=e:refuse(`gradient_path is "linear", ${z.map(r=>`"${r}"`).join(", ")}, not ${e}.`)}get gradient_focus(){return{...this._gradient().focus??{left:.5,top:.5,right:.5,bottom:.5}}}set gradient_focus(e){this._gradient().focus={...e}}get gradient_angle(){return this._gradient().angle}set gradient_angle(e){this._gradient().angle=e}get gradient_stops(){return this._gradient().stops.map(e=>new GradientStop(e))}set gradient_stops(e){if(e.length<2)throw new Error("A gradient has two stops at least.");this._gradient().stops=e.map(t=>t instanceof GradientStop?GradientStop.defOf(t):{...t,color:N(t.color,"A gradient stop's colour")})}_gradient(){const{gradient:e}=this._shape("a gradient");if(!e)throw new TypeError("This fill is no gradient: call fill.gradient() first.");return e}get transparency(){return this._shape("a transparency").fill_transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);this._shape("a transparency").fill_transparency=e}get type(){if(this.shape?.picture_fill)return"picture";if(this.shape?.pattern)return"patterned";if(this.shape?.gradient)return"gradient";const e=this.read();return e===void 0?void 0:e===null?"background":"solid"}get fore_color(){const e=this.shape?.pattern;if(e)return new ColorFormat(()=>e.fg,r=>{e.fg=r??O.fg});const t=this.read();if(t==null)throw new TypeError("This fill is not solid, so it has no fore_color: call fill.solid() first.");return new ColorFormat(()=>this.read()??void 0,r=>{this.write(r??this.start)})}}export class GradientStop{stop;constructor(e){return this.stop=e,a(this,"GradientStop")}static defOf(e){return{...e.stop}}get color(){return new ColorFormat(()=>this.stop.color,e=>{e!==void 0&&(this.stop.color=e)})}get position(){return this.stop.at}set position(e){if(!(e>=0&&e<=1))throw new Error(`A stop's position is a share, 0 to 1, not ${String(e)}.`);this.stop.at=e}get transparency(){return this.stop.transparency??0}set transparency(e){if(!(e>=0&&e<=1))throw new Error(`A transparency is a share, 0 to 1, not ${String(e)}.`);e===0?Reflect.deleteProperty(this.stop,"transparency"):this.stop.transparency=e}}export class ShadowFormat{def;inner;constructor(e,t=!1){return this.def=e,this.inner=t,a(this,"ShadowFormat")}_shadow(){return this.inner?(this.def.inner_shadow??={...me},this.def.inner_shadow):(this.def.shadow??={...U},this.def.shadow)}get visible(){return this.inner?this.def.inner_shadow!==void 0:this.def.shadow!==void 0&&this.def.shadow!==null}set visible(e){e?this._shadow():this.inner?Reflect.deleteProperty(this.def,"inner_shadow"):this.def.shadow=null}get inherit(){return this.def.shadow===void 0}set inherit(e){e?Reflect.deleteProperty(this.def,"shadow"):this.def.shadow??=null}get blur_radius(){return l(this._shadow().blur)}set blur_radius(e){this._shadow().blur=e}get distance(){return l(this._shadow().distance)}set distance(e){this._shadow().distance=e}get angle(){return this._shadow().angle}set angle(e){this._shadow().angle=e}get transparency(){return this._shadow().transparency}set transparency(e){this._shadow().transparency=e}get color(){const e=this._shadow();return new ColorFormat(()=>e.color,t=>{e.color=t??U.color})}}export class GlowFormat{def;constructor(e){return this.def=e,a(this,"GlowFormat")}_glow(){return this.def.glow??={...v},this.def.glow}get visible(){return this.def.glow!==void 0}set visible(e){e?this._glow():Reflect.deleteProperty(this.def,"glow")}get radius(){return l(this.def.glow?.size??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"glow"):this._glow().size=e}get transparency(){return this._glow().transparency}set transparency(e){this._glow().transparency=e}get color(){const e=this._glow();return new ColorFormat(()=>e.color,t=>{e.color=t??v.color})}}export class SoftEdgeFormat{def;constructor(e){return this.def=e,a(this,"SoftEdgeFormat")}get radius(){return l(this.def.soft_edges??0)}set radius(e){e<=0?Reflect.deleteProperty(this.def,"soft_edges"):this.def.soft_edges=e}}export class ReflectionFormat{def;constructor(e){return this.def=e,a(this,"ReflectionFormat")}_reflection(){return this.def.reflection??={...we},this.def.reflection}get visible(){return this.def.reflection!==void 0}set visible(e){e?this._reflection():Reflect.deleteProperty(this.def,"reflection")}get transparency(){return this._reflection().transparency}set transparency(e){this._reflection().transparency=e}get size(){return this._reflection().size}set size(e){this._reflection().size=e}get offset(){return l(this._reflection().distance)}set offset(e){this._reflection().distance=e}get blur(){return l(this._reflection().blur)}set blur(e){this._reflection().blur=e}}export class LineFormat{def;constructor(e){return this.def=e,a(this,"LineFormat")}get color(){return new ColorFormat(()=>this.def.line??void 0,e=>{this.def.line=e??null})}get fill(){return new FillFormat(()=>this.def.line,e=>{this.def.line=e},"dk1")}get width(){return l(this.def.line_width??0)}set width(e){this.def.line_width=e}get dash_style(){return this.def.line_dash??null}set dash_style(e){e===null?delete this.def.line_dash:this.def.line_dash=p(de,"MSO_LINE","dash_style",e)}get cap_type(){return this.def.line_cap??x.cap}set cap_type(e){const t=p(le,"MSO_LINE_CAP","cap_type",e);t===x.cap?delete this.def.line_cap:this.def.line_cap=t}get join_type(){return this.def.line_join??x.join}set join_type(e){const t=p(ce,"MSO_LINE_JOIN","join_type",e);t===x.join?delete this.def.line_join:this.def.line_join=t}get compound_type(){return this.def.line_compound??x.compound}set compound_type(e){const t=p(fe,"MSO_LINE_COMPOUND","compound_type",e);t===x.compound?delete this.def.line_compound:this.def.line_compound=t}get begin_arrow(){return this.def.line_begin??"none"}set begin_arrow(e){this.def.line_begin=p(C,"MSO_ARROWHEAD","begin_arrow",e)}get end_arrow(){return this.def.line_end??"none"}set end_arrow(e){this.def.line_end=p(C,"MSO_ARROWHEAD","end_arrow",e)}get begin_arrow_width(){return this.def.line_begin_size?.w??"med"}set begin_arrow_width(e){this.def.line_begin_size={...this.def.line_begin_size,w:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_width",e)}}get begin_arrow_length(){return this.def.line_begin_size?.len??"med"}set begin_arrow_length(e){this.def.line_begin_size={...this.def.line_begin_size,len:p(S,"MSO_ARROWHEAD_SIZE","begin_arrow_length",e)}}get end_arrow_width(){return this.def.line_end_size?.w??"med"}set end_arrow_width(e){this.def.line_end_size={...this.def.line_end_size,w:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_width",e)}}get end_arrow_length(){return this.def.line_end_size?.len??"med"}set end_arrow_length(e){this.def.line_end_size={...this.def.line_end_size,len:p(S,"MSO_ARROWHEAD_SIZE","end_arrow_length",e)}}}function p(i,e,t,r){if(Object.values(i).includes(r))return r;throw new Error(`${t}: ${String(r)} is not one of ${e}'s ${Object.keys(i).join(", ")}.`)}export class Background{holder;constructor(e){return this.holder=e,a(this,"_Background")}get fill(){return new FillFormat(()=>this.holder.background,e=>{this.holder.background=e??"bg1"})}}export const adjustmentDefaults=i=>te(i).map(e=>e.value/1e5);export class Adjustments{def;constructor(e){return this.def=e,a(this,"Adjustments",{index:t=>this._values()[t],setIndex:(t,r)=>{this._set(t,Number(r))}})}_values(){return this.def.adjustments??adjustmentDefaults(this.def.geometry??"rect")}get length(){return this._values().length}_set(e,t){const r=this._values();if(e<0||e>=r.length)throw new RangeError(`adjustments[${String(e)}]: ${this.def.geometry??"this shape"} has ${String(r.length)}.`);if(!Number.isFinite(t))throw new Error(`adjustments[${String(e)}] = ${String(t)} is not a number.`);r[e]=t,this.def.adjustments=r}}const Ne={left:0,top:0,width:0,height:0};export class Shape{def;inherit;base;constructor(e,t=()=>{},r=""){return this.def=e,this.inherit=t,this.base=r,a(this,"Shape")}get _def(){return this.def}_frame(){return this.def.frame??this.inherit()??Ne}_own(){return this.def.frame??={...this._frame()},this.def.frame}get name(){return this.def.name}set name(e){this.def.name=e}get shape_type(){return this.def.path?"freeform":this.def.kind==="audio"?"movie":M(this.def.geometry)?"line":this.def.kind}get is_placeholder(){return this.def.kind==="placeholder"}get has_table(){return this.def.table!==void 0}get has_chart(){return this.def.chart!==void 0}get chart(){if(!this.def.chart)throw new Error(`${this.def.name} is not a chart.`);return new ge(this.def.chart)}get table(){if(!this.def.table)throw new Error(`${this.def.name} is not a table.`);return new Table(this.def.table)}get placeholder_format(){if(!this.def.placeholder)throw new Error(`${this.def.name} is not a placeholder.`);return a({...this.def.placeholder},"_PlaceholderFormat")}get left(){return l(this._frame().left)}set left(e){this._own().left=e}get top(){return l(this._frame().top)}set top(e){this._own().top=e}get width(){return l(this._frame().width)}set width(e){this._own().width=e}get height(){return l(this._frame().height)}set height(e){this._own().height=e}get rotation(){return this.def.rotation??0}set rotation(e){if(!Number.isFinite(e))throw new Error(`${this.def.name}: rotation is a number of degrees.`);const t=(Math.trunc(e*6e4)%216e5+216e5)%216e5/6e4;t===0?Reflect.deleteProperty(this.def,"rotation"):this.def.rotation=t}get flip_h(){return this.def.flip?.h===!0}set flip_h(e){this._flip("h",e)}get flip_v(){return this.def.flip?.v===!0}set flip_v(e){this._flip("v",e)}_flip(e,t){const r={...this.def.flip};t?r[e]=!0:Reflect.deleteProperty(r,e),Object.keys(r).length===0?Reflect.deleteProperty(this.def,"flip"):this.def.flip=r}get has_text_frame(){return this.def.text!==void 0}get text_frame(){if(!this.def.text)throw new Error(`${this.def.name} (a ${this.shape_type}) has no text frame: has_text_frame is false.`);return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e},"lt1",this.def,this.base)}get line(){return new LineFormat(this.def)}get shadow(){return new ShadowFormat(this.def)}get inner_shadow(){return new ShadowFormat(this.def,!0)}get glow(){return new GlowFormat(this.def)}get soft_edge(){return new SoftEdgeFormat(this.def)}get reflection(){return new ReflectionFormat(this.def)}get adjustments(){return new Adjustments(this.def)}_ends(e){if(this.def.path||!M(this.def.geometry))throw new Error(`${this.def.name}.${e}: it is not a connector (add_connector makes one).`);return se(this._frame(),this.def.flip,this.def.rotation)}_move(e,t){const r=re(e,t,this.def.rotation);this.def.frame=r.frame,r.flip?this.def.flip=r.flip:Reflect.deleteProperty(this.def,"flip")}get begin_x(){return l(Math.round(this._ends("begin_x")[0][0]))}set begin_x(e){const[t,r]=this._ends("begin_x");this._move([e,t[1]],r)}get begin_y(){return l(Math.round(this._ends("begin_y")[0][1]))}set begin_y(e){const[t,r]=this._ends("begin_y");this._move([t[0],e],r)}get end_x(){return l(Math.round(this._ends("end_x")[1][0]))}set end_x(e){const[t,r]=this._ends("end_x");this._move(t,[e,r[1]])}get end_y(){return l(Math.round(this._ends("end_y")[1][1]))}set end_y(e){const[t,r]=this._ends("end_y");this._move(t,[r[0],e])}begin_connect(e,t){this._connect("begin",e,t)}end_connect(e,t){this._connect("end",e,t)}_connect(e,t,r){const s=`${e}_connect`,[n,o]=this._ends(s);if(!(t instanceof Shape))throw new Error(`${this.def.name}.${s}(): its shape is a Shape.`);const h=t._def,f={frame:t._frame(),geometry:h.geometry,adjustments:h.adjustments,flip:h.flip,rotation:h.rotation,path:h.path},c=ne(f).length;if(!Number.isInteger(r)||r<0||r>=c)throw new Error(`${this.def.name}.${s}(): ${h.name} has connection sites 0 to ${String(c-1)}; ${String(r)} is not one.`);const u=ie(f,r)??(e==="begin"?n:o);this.def.connect={...this.def.connect,[e]:{shape:h.name,site:r}},this._move(e==="begin"?u:n,e==="begin"?o:u)}}const Le=i=>typeof i=="number"&&Number.isFinite(i),_=(i,e,t,r)=>{for(const[s,n]of Object.entries({left:i,top:e,width:t,height:r}))if(!Le(n))throw new Error(`${s} ${String(n)} is not a length (Emu, Inches, Pt, Cm, Mm).`);if(t<0||r<0)throw new Error("A shape's width and height are 0 or more.");return{left:Math.trunc(i),top:Math.trunc(e),width:Math.trunc(t),height:Math.trunc(r)}},Pe=new Set(Object.values(D));export class FreeformBuilder{steps;sx;sy;make;constructor(e,t,r){return this.steps=[{op:"move",x:e[0],y:e[1]}],[this.sx,this.sy]=typeof t=="number"?[t,t]:t,this.make=r,a(this,"FreeformBuilder")}add_line_segments(e,t=!0){for(const[r,s]of e)this.steps.push({op:"line",x:r,y:s});return t&&this.steps.push({op:"close"}),this}add_curve_segment(e,t,r,s,n,o){if(![e,t,r,s,n,o].every(h=>Number.isFinite(h)))throw new Error("add_curve_segment(x1, y1, x2, y2, x, y) takes six numbers in local units: its two control points and the point it ends at.");return this.steps.push({op:"curve",x1:e,y1:t,x2:r,y2:s,x:n,y:o}),this}move_to(e,t){return this.steps.push({op:"move",x:e,y:t}),this}convert_to_shape(e=0,t=0){this.steps.length<2&&refuse("convert_to_shape(): a freeform needs a segment.");const r=this.steps.flatMap(d=>d.op==="close"?[]:d.op==="curve"?[[d.x1,d.y1],[d.x2,d.y2],[d.x,d.y]]:[[d.x,d.y]]),s=r.map(d=>d[0]),n=r.map(d=>d[1]),o=Math.min(...s),h=Math.min(...n),f=Math.max(...s)-o,c=Math.max(...n)-h;f===0&&c===0&&refuse("convert_to_shape(): a freeform's points are all one point.");const u=(d,m)=>({x:d-o,y:m-h});return this.make({w:f,h:c,steps:this.steps.map(d=>{if(d.op==="close")return d;if(d.op!=="curve")return{op:d.op,...u(d.x,d.y)};const m=u(d.x1,d.y1),y=u(d.x2,d.y2);return{op:"curve",x1:m.x,y1:m.y,x2:y.x,y2:y.y,...u(d.x,d.y)}})},_(Math.round(o*this.sx)+e,Math.round(h*this.sy)+t,Math.round(f*this.sx),Math.round(c*this.sy)))}}export class GroupShape{list;_name;make;constructor(e,t,r){return this.list=e,this._name=t,this.make=r,a(this,"GroupShape")}members(){return this.list.filter(e=>I(e.group,this._name))}box(){const e=this.members().flatMap(s=>s.frame?[s.frame]:[]),t=Math.min(...e.map(s=>s.left)),r=Math.min(...e.map(s=>s.top));return{left:e.length>0?t:0,top:e.length>0?r:0,right:Math.max(0,...e.map(s=>s.left+s.width)),bottom:Math.max(0,...e.map(s=>s.top+s.height))}}get shapes(){return this.make(this._name)}get shape_type(){return _e.GROUP}get name(){return this._name.split("/").pop()??this._name}set name(e){const t=this._name.lastIndexOf("/"),r=t<0?e:`${this._name.slice(0,t)}/${e}`;for(const s of this.members())s.group=`${r}${(s.group??"").slice(this._name.length)}`;this._name=r}get left(){return l(this.box().left)}set left(e){const t=e-this.box().left;for(const r of this.members())r.frame&&(r.frame.left+=t)}get top(){return l(this.box().top)}set top(e){const t=e-this.box().top;for(const r of this.members())r.frame&&(r.frame.top+=t)}get width(){const e=this.box();return l(e.right-e.left)}get height(){const e=this.box();return l(e.bottom-e.top)}}export class Cell{def;table;row;col;constructor(e,t,r,s){return this.def=e,this.table=t,this.row=r,this.col=s,a(this,"_Cell")}get text_frame(){return new TextFrame(this.def.text)}get text(){return this.text_frame.text}set text(e){this.text_frame.text=e}get fill(){return new FillFormat(()=>this.def.fill,e=>{this.def.fill=e})}get borders(){return this.def.borders??{}}set borders(e){this.def.borders=Object.fromEntries(Object.entries(e).map(([t,r])=>[t,{...r,color:N(r.color,`A cell's ${t} border`)}]))}get margin_left(){return l(this.def.text.margin_left??w.left)}set margin_left(e){this.def.text.margin_left=e}get margin_right(){return l(this.def.text.margin_right??w.right)}set margin_right(e){this.def.text.margin_right=e}get margin_top(){return l(this.def.text.margin_top??w.top)}set margin_top(e){this.def.text.margin_top=e}get margin_bottom(){return l(this.def.text.margin_bottom??w.bottom)}set margin_bottom(e){this.def.text.margin_bottom=e}get vertical_anchor(){return this.def.text.vertical_anchor}set vertical_anchor(e){e===void 0?delete this.def.text.vertical_anchor:this.def.text.vertical_anchor=e}get is_merge_origin(){return(this.def.span_width??1)>1||(this.def.span_height??1)>1}get is_spanned(){return this.def.spanned===!0}get span_width(){return this.def.span_width??1}get span_height(){return this.def.span_height??1}merge(e){const t=[this.row,e.row].sort((f,c)=>f-c),r=[this.col,e.col].sort((f,c)=>f-c),[s=0,n=0]=t,[o=0,h=0]=r;for(let f=s;f<=n;f++)for(let c=o;c<=h;c++){const u=this.table.rows[f]?.cells[c];u&&(f===s&&c===o?(h>o&&(u.span_width=h-o+1),n>s&&(u.span_height=n-s+1)):u.spanned=!0)}}split(){const e=this.span_width,t=this.span_height;delete this.def.span_width,delete this.def.span_height;for(let r=this.row;r<this.row+t;r++)for(let s=this.col;s<this.col+e;s++){const n=this.table.rows[r]?.cells[s];n&&delete n.spanned}}}export class Column{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Column")}get width(){return l(this.def.columns[this.at]??0)}set width(e){this.def.columns[this.at]=e}}export class Row{def;at;constructor(e,t){return this.def=e,this.at=t,a(this,"_Row")}get row(){const e=this.def.rows[this.at];if(!e)throw new Error(`The table has no row ${String(this.at)}.`);return e}get height(){return l(this.row.height)}set height(e){this.row.height=e}}export class Table{def;constructor(e){return this.def=e,a(this,"Table")}cell(e,t){const r=this.def.rows[e]?.cells[t];if(!r)throw new Error(`cell(): the table has ${String(this.def.rows.length)} rows and ${String(this.def.columns.length)} columns.`);return new Cell(r,this.def,e,t)}*iter_cells(){for(let e=0;e<this.def.rows.length;e++)for(let t=0;t<this.def.columns.length;t++)yield this.cell(e,t)}get columns(){return this.def.columns.map((e,t)=>new Column(this.def,t))}get rows(){return this.def.rows.map((e,t)=>new Row(this.def,t))}get style(){return Z(this.def.style)?.name??null}set style(e){if(e===null){delete this.def.style;return}const t=Z(e)??refuse(`Table.style: ${e} is none of PowerPoint's built-in table styles (${$e.slice(0,3).map(r=>r.name).join(", ")}…).`);this.def.style=t.id}flag(e){return this.def[e]===!0}get first_row(){return this.flag("first_row")}set first_row(e){this.def.first_row=e}get first_col(){return this.flag("first_col")}set first_col(e){this.def.first_col=e}get last_row(){return this.flag("last_row")}set last_row(e){this.def.last_row=e}get last_col(){return this.flag("last_col")}set last_col(e){this.def.last_col=e}get horz_banding(){return this.flag("horz_banding")}set horz_banding(e){this.def.horz_banding=e}get vert_banding(){return this.flag("vert_banding")}set vert_banding(e){this.def.vert_banding=e}}function Fe(i,e,t=[]){const r=new Set([...i,...t].map(n=>n.name));let s=1;for(;r.has(`${e}-${String(s)}`);)s++;return`${e}-${String(s)}`}export class ShapeCollection{list;base;components;inherit;group;under;constructor(e,t,r,s=()=>{},n=()=>[],o){return this.list=e,this.base=t,this.components=r,this.inherit=s,this.under=n,this.group=o,a(this,"SlideShapes",{index:h=>this._at(h)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}_at(e){const t=this.list[e];return t?this._wrap(t):void 0}*[Symbol.iterator](){for(const e of this.list)yield this._wrap(e)}get length(){return this.list.length}get(e){const t=this.list.find(r=>r.name===e);return t?this._wrap(t):void 0}get title(){const e=this.list.find(t=>t.placeholder?.type==="title"||t.placeholder?.type==="ctrTitle");return e?this._wrap(e):void 0}get placeholders(){return new Placeholders(this.list,this.inherit)}_add(e,t){const r={name:Fe(this.list,e,this.under()),...t,...this.group===void 0?{}:{group:this.group}};return this.list.push(r),this._wrap(r)}add_textbox(e,t,r,s){return this._add("textbox",{kind:"textbox",frame:_(e,t,r,s),text:{...E(),...Se}})}add_picture(e,t,r,s,n){return(s===void 0||n===void 0)&&refuse("add_picture() takes a width and a height here: a picture's own size is not read while a deck's code runs"),this._add("picture",{kind:"picture",frame:_(t,r,s??0,n??0),media:{path:e,base:this.base}})}add_movie(e,t,r,s,n,o={}){return this._add("movie",{kind:"movie",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.poster_frame_time===void 0?{}:{poster:o.poster_frame_time},...o.playback?{playback:{...o.playback}}:{}}})}add_audio(e,t,r,s=W.icon,n=W.icon,o={}){return this._add("audio",{kind:"audio",frame:_(t,r,s,n),media:{path:e,base:this.base,...o.playback?{playback:{...o.playback}}:{}}})}add_shape(e,t,r,s,n){Pe.has(e)||refuse(`add_shape(): ${e} is not one of MSO_SHAPE's ${Object.keys(D).join(", ")}`);const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("shape",{kind:"autoshape",frame:_(t,r,s,n),geometry:e,fill:g.fill,line:g.line,line_width:g.line_width,text:o})}add_table(e,t,r,s,n,o){(e<1||t<1)&&refuse("add_table(): a table has at least a row and a column.");const h=Math.floor(n/t),f=Math.floor(o/e);return this._add("table",{kind:"table",frame:_(r,s,n,o),table:{style:Oe,first_row:!0,horz_banding:!0,columns:Array.from({length:t},()=>h),rows:Array.from({length:e},()=>({height:f,cells:Array.from({length:t},()=>({text:E()}))}))}})}add_chart(e,t,r,s,n,o){return this._add("chart",{kind:"chart",frame:_(t,r,s,n),chart:{type:e,categories:[...o.categories],series:o._series()}})}add_group_shape(){const e=this.group===void 0?"":`${this.group}/`;let t=1;for(;this.list.some(r=>I(r.group,`${e}group-${String(t)}`));)t++;return new GroupShape(this.list,`${e}group-${String(t)}`,r=>new ShapeCollection(this.list,this.base,this.components,this.inherit,this.under,r))}build_freeform(e=0,t=0,r=1){return new FreeformBuilder([e,t],r,(s,n)=>{const o=E();return o.vertical_anchor=g.vertical_anchor,o.paragraphs=[{runs:[],level:0,alignment:g.alignment}],this._add("freeform",{kind:"autoshape",frame:n,path:s,fill:g.fill,line:g.line,line_width:g.line_width,text:o})})}add_connector(e,t,r,s,n){M(e)||refuse(`add_connector(): ${e} is not one of MSO_CONNECTOR's ${Object.keys(he).join(", ")}, nor a connector's preset (${be.join(", ")})`);const o=_(Math.min(t,s),Math.min(r,n),Math.abs(s-t),Math.abs(n-r)),h=s<t,f=n<r;return this._add("connector",{kind:"autoshape",frame:o,geometry:e,...h||f?{flip:{...h?{h}:{},...f?{v:f}:{}}}:{},line:Y.line,line_width:Y.line_width})}add_component(e,t,r,s,n,o={},h={}){if(!Object.hasOwn(this.components(),e))throw new Error(`add_component(): the presentation has no component ${e}; add it with prs.components.add("${e}", { … }) first.`);if(h.dur!==void 0&&!(Number.isFinite(h.dur)&&h.dur>0))throw new Error(`add_component(): dur is how long ${e} moves, seconds over 0; it was ${String(h.dur)}.`);return this._add(e,{kind:"component",frame:_(t,r,s,n),component:{name:e,props:o,...h.dur===void 0?{}:{dur:h.dur}}})}}export const NAME_OF_TYPE={title:"title",ctrTitle:"title",subTitle:"subtitle",body:"body",pic:"picture",media:"media",obj:"content",dt:"date",ftr:"footer",sldNum:"slide-number"};export class Placeholders{list;inherit;constructor(e,t=()=>{}){return this.list=e,this.inherit=t,a(this,"placeholders",{index:r=>this.get(r)})}_wrap(e){return new Shape(e,()=>this.inherit(e))}*[Symbol.iterator](){for(const e of this.list)e.kind==="placeholder"&&(yield this._wrap(e))}get length(){return this.list.filter(e=>e.kind==="placeholder").length}get(e){const t=this.list.find(r=>r.kind==="placeholder"&&(typeof e=="number"?r.placeholder?.idx===e:r.name===e||r.placeholder?.type===e));return t?this._wrap(t):void 0}add(e,t,r,s,n,o={}){const h=typeof t=="object"?t:o,f=typeof t=="object"?void 0:t;Object.values(H).includes(e)||refuse(`placeholders.add(): ${e} is not one of PP_PLACEHOLDER's ${Object.keys(H).join(", ")}`);const c=this.list.filter(b=>b.kind==="placeholder"),u=new Set(c.map(b=>b.placeholder?.idx));let d=e==="title"||e==="ctrTitle"?0:ye[e]??1;for(u.has(d)&&d===0&&(d=1);u.has(d);)d++;const m=h.name??NAME_OF_TYPE[e];if(this.list.some(b=>b.name===m))throw new Error(`Two shapes are ${m}: give the placeholder a name ({ name }).`);const y=[f,r,s,n].filter(b=>b!==void 0);if(y.length!==0&&y.length!==4)throw new Error("placeholders.add(type, left, top, width, height): give all four, or none to take the master's frame.");const L={name:m,kind:"placeholder",placeholder:{type:e,idx:d,...h.orient==="vert"?{orient:"vert"}:{}},...y.length===4?{frame:_(f??0,r??0,s??0,n??0)}:{},text:{paragraphs:[],levels:Ee(e)}};return this.list.push(L),this._wrap(L)}}export class SlideLayout{def;master;ctx;constructor(e,t,r){return this.def=e,this.master=t,this.ctx=r,a(this,"SlideLayout")}get _def(){return this.def}inherit=e=>e.placeholder?X(this.master._def,e.placeholder.type)?.frame:void 0;get name(){return this.def.name}get slide_master(){return this.master}get display_master_shapes(){return this.def.display_master_shapes??!0}set display_master_shapes(e){e?delete this.def.display_master_shapes:this.def.display_master_shapes=!1}get color_map(){return this.def.color_map&&{...this.def.color_map}}set color_map(e){e===void 0?delete this.def.color_map:this.def.color_map=K(e)}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes,this.inherit)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components,this.inherit,()=>this.master._def.shapes)}}export class SlideLayouts{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideLayouts",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}get_by_name(e,t){return this.list.find(r=>r.name===e)??t}index(e){const t=this.list.indexOf(e);if(t<0)throw new Error(`${e.name} is not among these layouts.`);return t}add(e,t){if(!this.make)throw new Error("A layout is added to a master: master.slide_layouts.add(name).");const r=this.make(e);return t?.(r),r}}export class TextStyles{def;constructor(e){return this.def=e,a(this,"text_styles")}get title_style(){return k(this.def.title)}get body_style(){return k(this.def.body)}get other_style(){return k(this.def.other)}}export class SlideMaster{def;layouts=[];ctx;allLayouts;constructor(e,t,r){return this.def=e,this.ctx=t,this.allLayouts=r,a(this,"SlideMaster")}get _def(){return this.def}get name(){return this.def.name}get color_map(){return{...OFFICE_COLOR_MAP,...this.def.color_map}}set color_map(e){const t=K(e),r=Object.fromEntries(Object.entries(t).filter(([s,n])=>OFFICE_COLOR_MAP[s]!==n));Object.keys(r).length===0?delete this.def.color_map:this.def.color_map=r}get background(){return new Background(this.def)}get placeholders(){return new Placeholders(this.def.shapes)}get shapes(){return new ShapeCollection(this.def.shapes,this.ctx.base,this.ctx.components)}get text_styles(){return new TextStyles(this.def.text_styles)}get slide_layouts(){return new SlideLayouts(this.layouts,e=>{if(this.allLayouts.some(s=>s.name===e))throw new Error(`Two layouts are "${e}": a layout's name is unique in the deck, as its slides file names it.`);const t={name:e,master:this.def.name,shapes:[]};this.def.layouts.push(t);const r=new SlideLayout(t,this,this.ctx);return this.layouts.push(r),this.allLayouts.push(r),r})}}export class SlideMasters{list;make;constructor(e,t){return this.list=e,this.make=t,a(this,"SlideMasters",{index:r=>this.list[r]})}*[Symbol.iterator](){yield*this.list}get length(){return this.list.length}index(e){return this.list.indexOf(e)}add(e,t){const r=this.make(e);return t?.(r),r}}export class GeneratedSlide{own;def;layout;constructor(e,t,r){this.def=e,this.layout=t,this.own=t._def.shapes.filter(n=>n.kind==="placeholder").map(n=>({name:n.name,kind:"placeholder",...n.placeholder?{placeholder:{...n.placeholder}}:{},text:E()}));const s=n=>{const o=t._def.shapes.find(h=>h.kind==="placeholder"&&h.placeholder?.idx===n.placeholder?.idx);return o?o.frame??(o.placeholder?X(t.slide_master._def,o.placeholder.type)?.frame:void 0):void 0};return this._shapes=new ShapeCollection(this.own,r.base,r.components,s,()=>[...t.slide_master._def.shapes,...t._def.shapes]),this._placeholders=new Placeholders(this.own,s),a(this,"Slide")}_shapes;_placeholders;get shapes(){return this._shapes}get placeholders(){return this._placeholders}get slide_id(){return this.def.id}get slide_layout(){return this.layout}get has_notes_slide(){return this.def.notes!==void 0}get notes_slide(){const e=this.def;return a({notes_text_frame:a({get text(){return e.notes??""},set text(t){e.notes=t}},"TextFrame")},"NotesSlide")}get transition(){return this.def.transition}set transition(e){e===void 0?delete this.def.transition:this.def.transition=e}get animations(){return new Animations(this.def.animations??=[])}_done(){const e={},t=[];for(const r of this.own)r.kind==="placeholder"&&r.placeholder?(r.text?.paragraphs.some(s=>s.runs.length>0)&&(e[r.placeholder.idx]=r.text.paragraphs),r.frame&&t.push({...r,text:E()})):t.push(r);return{...this.def,shapes:t,text:e}}}export class Animations{list;constructor(e){return this.list=e,a(this,"Animations")}add(e,t,r={}){this.list.push({shape:typeof e=="string"?e:e.name,effect:t,...r})}get length(){return this.list.length}}class ze{gen;constructor(e){return this.gen=e,a(this,"slides")}add_slide(e,t){return this.gen._add(e,t)}}export class Generator{list=[];prs;ctx;constructor(e,t){return this.prs=e,this.ctx=t,a(this,"Generator")}data(e){return this.ctx.data(e)}get slides(){return new ze(this)}_add(e,t){const r=typeof e=="string"?this.prs._layout(e):e;if(!r)throw new Error(`add_slide(): the presentation has no layout ${typeof e=="string"?e:e.name}.`);if(!/^[A-Za-z0-9_-]+$/u.test(t))throw new Error(`add_slide(): ${t} is not an id of letters, digits, _ and -.`);if(this.list.some(n=>n.slide_id===t))throw new Error(`add_slide(): two slides are ${t}.`);const s=new GeneratedSlide({id:t,layout:r.name,shapes:[],text:{}},r,this.prs._ctx);return this.list.push(s),s}_made(){return this.list.map(e=>e._done())}}const Ie=()=>JSON.parse(JSON.stringify(xe));export class Presentation{masters=[];layouts=[];def;_ctx;constructor(e,t){return this.def={slide_width:e[0],slide_height:e[1],masters:[],components:{},generators:{}},this._ctx={base:t,components:()=>this.def.components},a(this,"Presentation")}get _def(){return this.def}get slide_width(){return l(this.def.slide_width)}set slide_width(e){this.def.slide_width=e}get slide_height(){return l(this.def.slide_height)}set slide_height(e){this.def.slide_height=e}get slide_masters(){return new SlideMasters(this.masters,e=>{if(this.masters.some(s=>s.name===e))throw new Error(`Two masters are "${e}".`);const t={name:e,background:"bg1",text_styles:Ie(),shapes:[],layouts:[]};this.def.masters.push(t);const r=new SlideMaster(t,this._ctx,this.layouts);return this.masters.push(r),r})}get slide_master(){const e=this.masters[0];if(!e)throw new Error("The presentation has no master yet: prs.slide_masters.add(name) makes one.");return e}get slide_layouts(){const e=this.masters[0];return e?e.slide_layouts:new SlideLayouts([])}get slides(){return refuse("A deck's slides are in the slides file presentation({ slides }) names, in order, each on a layout, and their words in its script; slides made from data are a generator's (prs.generators.add)")}save(){return refuse("A deck is not saved by its code: allyhub render writes its PDF, pictures and PPTX")}get theme(){return this.def.theme??={},this.def.theme}set theme(e){this.def.theme=e}get components(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.components,e))throw new Error(`Two components are "${e}".`);const r=oe(e,t);if(!r)throw new Error(`Component ${e} is not a component: give what defineComponent makes, or { props, layers }.`);this.def.components[e]=r}},"components")}get generators(){return a({add:(e,t)=>{if(Object.hasOwn(this.def.generators,e))throw new Error(`Two generators are "${e}".`);this.def.generators[e]={name:e,make:r=>{const s=new Generator(this,r);return t(s),s._made()}}}},"generators")}_layout(e){return this.layouts.find(t=>t.name===e)}}export const DECK_BRAND="__allyhubDeck";export function isDeck(i){return typeof i=="object"&&i!==null&&DECK_BRAND in i}export const presentationFor=i=>(e,t)=>{const[r,s]=typeof e=="function"?[{},e]:[e,t];if(typeof s!="function")throw new Error(`A deck's module exports one deck: export default presentation({ slides: "./deck.yaml", script: "./deck.{locale}.yaml", size }, (prs) => { … masters, layouts, components … }), its slides and its script named from its folder.`);if(r.script!==void 0&&!r.script.includes("{locale}"))throw new Error(`presentation(): script ${r.script} names one file: write {locale} in its name for each language (./deck.{locale}.yaml).`);if(typeof r.size=="string"&&!Object.hasOwn(j,r.size))throw new Error(`presentation(): size ${r.size} is not one of ${Object.keys(j).join(", ")}, or { width, height } in EMU.`);return{[DECK_BRAND]:!0,kind:"slides",options:r,build:s,written:{file:i}}};export function evaluateDeck(i){const e=i.options.size??"16:9",t=typeof e=="string"?j[e]:[e.width,e.height],r=i.written.file.split("/").slice(0,-1).join("/"),s=new Presentation(t,r);return i.options.theme&&(s.theme=JSON.parse(JSON.stringify(i.options.theme))),i.build(s),s._def}
|