ooxml-core 1.46.0 → 1.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/PptxHandler-JX62VKU4.cjs +14 -0
- package/dist/{PptxHandler-HWEOIHEA.mjs → PptxHandler-NXHZ6ITL.mjs} +2 -2
- package/dist/PptxHandler-SUGLNSZI.mjs +5 -0
- package/dist/{PresentationBuilder-2BCCMZW7.cjs → PresentationBuilder-IK6NIK6T.cjs} +6 -6
- package/dist/{PresentationBuilder-AFD72LIG.mjs → PresentationBuilder-LHQ333UL.mjs} +3 -3
- package/dist/{PresentationBuilder-66RV4F45.mjs → PresentationBuilder-URSPID7L.mjs} +2 -2
- package/dist/{chunk-IBRV3AK3.cjs → chunk-4GPLQEEC.cjs} +1381 -1289
- package/dist/{chunk-E2TTMUKU.mjs → chunk-553WFEHD.mjs} +108 -16
- package/dist/{chunk-H43QQVJU.mjs → chunk-5HNRZOBX.mjs} +1 -1
- package/dist/{chunk-EI6555OK.mjs → chunk-6MU4WKHS.mjs} +1 -1
- package/dist/{chunk-X2DC7XRL.mjs → chunk-7L6ZAA5Y.mjs} +66 -2
- package/dist/{chunk-5TOVSCVT.cjs → chunk-APCA7N6Q.cjs} +3 -3
- package/dist/{chunk-LXVE2VKR.mjs → chunk-DEDK2J57.mjs} +65 -1
- package/dist/{chunk-G6LEU3Y5.mjs → chunk-QHR726W3.mjs} +1 -1
- package/dist/{chunk-QUAFASFC.cjs → chunk-WFN6ZU7N.cjs} +65 -0
- package/dist/{chunk-L6MJGE3Q.mjs → chunk-XVEJS7HN.mjs} +5 -5
- package/dist/{chunk-HH3AYM63.mjs → chunk-Z734BYYR.mjs} +109 -17
- package/dist/pptx/automation/index.cjs +1857 -1682
- package/dist/pptx/automation/index.d.ts +3 -3
- package/dist/pptx/automation/index.mjs +5 -5
- package/dist/pptx/chunks/{index-BPGaFlm5.d.ts → index--HBUyILF.d.ts} +4 -4
- package/dist/pptx/chunks/{index-BPGaFlm5.d.ts.map → index--HBUyILF.d.ts.map} +1 -1
- package/dist/pptx/chunks/{index-DtFoPmk7.d.ts → index-BDVzSboe.d.ts} +23 -2
- package/dist/pptx/chunks/index-BDVzSboe.d.ts.map +1 -0
- package/dist/pptx/chunks/{index-D4-WJQ1r.d.ts → index-Dr3iIPt9.d.ts} +2 -2
- package/dist/pptx/chunks/{index-D4-WJQ1r.d.ts.map → index-Dr3iIPt9.d.ts.map} +1 -1
- package/dist/pptx/cli/index.cjs +301 -126
- package/dist/pptx/cli/index.mjs +4 -4
- package/dist/pptx/converter/index.d.ts +1 -1
- package/dist/pptx/converter/index.mjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.cjs +2 -2
- package/dist/pptx/editor/render/custom-show-operations.mjs +1 -1
- package/dist/pptx/editor/render/find-replace.cjs +15 -15
- package/dist/pptx/editor/render/find-replace.d.ts +1 -1
- package/dist/pptx/editor/render/find-replace.mjs +2 -2
- package/dist/pptx/editor/render/slide-operations.cjs +9 -9
- package/dist/pptx/editor/render/slide-operations.mjs +3 -3
- package/dist/pptx/index.cjs +2254 -2079
- package/dist/pptx/index.d.ts +4 -4
- package/dist/pptx/index.mjs +5 -5
- package/dist/pptx/node/index.d.ts +1 -1
- package/package.json +1 -1
- package/dist/PptxHandler-FZ43IJFP.mjs +0 -5
- package/dist/PptxHandler-XAUKKK36.cjs +0 -14
- package/dist/pptx/chunks/index-DtFoPmk7.d.ts.map +0 -1
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var JSZip = require('jszip');
|
|
4
3
|
var xmldom = require('@xmldom/xmldom');
|
|
5
4
|
require('xpath');
|
|
5
|
+
var JSZip = require('jszip');
|
|
6
6
|
var fastXmlParser = require('fast-xml-parser');
|
|
7
7
|
var mtxDecompressor = require('mtx-decompressor');
|
|
8
8
|
require('fflate');
|
|
@@ -3962,6 +3962,1056 @@ var init_chart_layout_operations = __esm({
|
|
|
3962
3962
|
}
|
|
3963
3963
|
});
|
|
3964
3964
|
|
|
3965
|
+
// xml/namespaces.ts
|
|
3966
|
+
var NS;
|
|
3967
|
+
var init_namespaces = __esm({
|
|
3968
|
+
"xml/namespaces.ts"() {
|
|
3969
|
+
NS = {
|
|
3970
|
+
/** WordprocessingML main. */
|
|
3971
|
+
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
3972
|
+
/** PresentationML main. */
|
|
3973
|
+
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
3974
|
+
/** SpreadsheetML main. */
|
|
3975
|
+
x: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
3976
|
+
/** DrawingML main. */
|
|
3977
|
+
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
3978
|
+
/** DrawingML chart. */
|
|
3979
|
+
c: "http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
3980
|
+
/** Office 2016 extended charts (waterfall, histogram, funnel...; `cx:chartSpace`). */
|
|
3981
|
+
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
3982
|
+
/** Office 2010 chart extensions, including built-in modern chart styles. */
|
|
3983
|
+
c14: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart",
|
|
3984
|
+
/** DrawingML diagram (SmartArt) main. */
|
|
3985
|
+
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
3986
|
+
/** Office 2007+ diagram drawing (`dsp`). */
|
|
3987
|
+
dsp: "http://schemas.microsoft.com/office/drawing/2008/diagram",
|
|
3988
|
+
/** DrawingML Word drawing (`wp:inline`, `wp:anchor`). */
|
|
3989
|
+
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
3990
|
+
/** DrawingML picture. */
|
|
3991
|
+
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
3992
|
+
/** Word 2010 shapes (`wps`). */
|
|
3993
|
+
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
3994
|
+
/** Relationships (`r:id`, `r:embed`). */
|
|
3995
|
+
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
3996
|
+
/** Markup compatibility (`mc:AlternateContent`). */
|
|
3997
|
+
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
3998
|
+
/** OPC relationships part. */
|
|
3999
|
+
rels: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
4000
|
+
/** OPC content types part. */
|
|
4001
|
+
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
4002
|
+
/** Office Math. */
|
|
4003
|
+
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
4004
|
+
/** Core properties. */
|
|
4005
|
+
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
4006
|
+
/** Dublin Core elements. */
|
|
4007
|
+
dc: "http://purl.org/dc/elements/1.1/",
|
|
4008
|
+
/** Legacy VML. */
|
|
4009
|
+
v: "urn:schemas-microsoft-com:vml",
|
|
4010
|
+
/** Office VML extensions. */
|
|
4011
|
+
o: "urn:schemas-microsoft-com:office:office",
|
|
4012
|
+
/** Word VML extensions. */
|
|
4013
|
+
w10: "urn:schemas-microsoft-com:office:word",
|
|
4014
|
+
/** SpreadsheetML drawing (`xdr:wsDr`, cell anchors). */
|
|
4015
|
+
xdr: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
|
|
4016
|
+
/** SpreadsheetML 2009 extensions (`x14:conditionalFormatting`, `x14:dataBar`). */
|
|
4017
|
+
x14: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
4018
|
+
/** SpreadsheetML 2009 attribute extensions (`x14ac:dyDescent`). */
|
|
4019
|
+
x14ac: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
|
|
4020
|
+
/** SpreadsheetML revision ids (`xr:uid`). */
|
|
4021
|
+
xr: "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
|
|
4022
|
+
/** Excel threaded comments and persons. */
|
|
4023
|
+
tc: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
|
|
4024
|
+
/** Legacy VML Excel client data (`x:ClientData`). */
|
|
4025
|
+
xv: "urn:schemas-microsoft-com:office:excel",
|
|
4026
|
+
/** Extended (app) properties. */
|
|
4027
|
+
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
4028
|
+
/** Dublin Core terms (`dcterms:created`). */
|
|
4029
|
+
dcterms: "http://purl.org/dc/terms/",
|
|
4030
|
+
/** Custom document properties (`docProps/custom.xml`). */
|
|
4031
|
+
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
|
4032
|
+
/** Document property variant types (`vt:lpwstr`, `vt:vector`). */
|
|
4033
|
+
vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
4034
|
+
/** XML itself (`xml:space`). */
|
|
4035
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
4036
|
+
};
|
|
4037
|
+
}
|
|
4038
|
+
});
|
|
4039
|
+
function checkXmlLimits(xml, label2, limits = {}) {
|
|
4040
|
+
const maxDepth2 = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
4041
|
+
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
4042
|
+
let depth = 0;
|
|
4043
|
+
let nodes = 0;
|
|
4044
|
+
let at2 = xml.indexOf("<");
|
|
4045
|
+
while (at2 !== -1) {
|
|
4046
|
+
const skip = MARKUP_SKIPS.find(([open2]) => xml.startsWith(open2, at2));
|
|
4047
|
+
if (skip) {
|
|
4048
|
+
const end = xml.indexOf(skip[1], at2 + skip[0].length);
|
|
4049
|
+
if (end === -1) return;
|
|
4050
|
+
at2 = xml.indexOf("<", end + skip[1].length);
|
|
4051
|
+
continue;
|
|
4052
|
+
}
|
|
4053
|
+
TAG_RE.lastIndex = at2;
|
|
4054
|
+
const match = TAG_RE.exec(xml);
|
|
4055
|
+
if (!match) {
|
|
4056
|
+
at2 = xml.indexOf("<", at2 + 1);
|
|
4057
|
+
continue;
|
|
4058
|
+
}
|
|
4059
|
+
const [, closing, , selfClosing] = match;
|
|
4060
|
+
at2 = xml.indexOf("<", at2 + match[0].length);
|
|
4061
|
+
if (closing) {
|
|
4062
|
+
depth--;
|
|
4063
|
+
continue;
|
|
4064
|
+
}
|
|
4065
|
+
nodes++;
|
|
4066
|
+
if (nodes > maxNodes)
|
|
4067
|
+
throw new XmlLimitError(
|
|
4068
|
+
`${label2} XML exceeds the limit of ${maxNodes} elements`,
|
|
4069
|
+
"maxNodes",
|
|
4070
|
+
maxNodes
|
|
4071
|
+
);
|
|
4072
|
+
if (!selfClosing && ++depth > maxDepth2)
|
|
4073
|
+
throw new XmlLimitError(
|
|
4074
|
+
`${label2} XML exceeds the nesting depth limit of ${maxDepth2}`,
|
|
4075
|
+
"maxDepth",
|
|
4076
|
+
maxDepth2
|
|
4077
|
+
);
|
|
4078
|
+
}
|
|
4079
|
+
}
|
|
4080
|
+
function parseXml(xml, options2 = {}) {
|
|
4081
|
+
const label2 = options2.label ?? "OOXML";
|
|
4082
|
+
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
4083
|
+
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
4084
|
+
checkXmlLimits(xml, label2, options2.limits);
|
|
4085
|
+
let parseError = "";
|
|
4086
|
+
let parsed;
|
|
4087
|
+
try {
|
|
4088
|
+
parsed = new xmldom.DOMParser({
|
|
4089
|
+
onError: (level2, message) => {
|
|
4090
|
+
if (level2 !== "warning" || options2.warningsAsErrors) parseError = message;
|
|
4091
|
+
}
|
|
4092
|
+
}).parseFromString(xml, "application/xml");
|
|
4093
|
+
} catch (error62) {
|
|
4094
|
+
throw new Error(
|
|
4095
|
+
`Invalid ${label2} XML: ${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
4096
|
+
{ cause: error62 }
|
|
4097
|
+
);
|
|
4098
|
+
}
|
|
4099
|
+
if (parseError || !parsed.documentElement)
|
|
4100
|
+
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
4101
|
+
if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
|
|
4102
|
+
return parsed;
|
|
4103
|
+
}
|
|
4104
|
+
function named(element2, local, ns, lenient = true) {
|
|
4105
|
+
if (!element2 || element2.localName !== local) return false;
|
|
4106
|
+
return element2.namespaceURI === ns || lenient && !element2.namespaceURI;
|
|
4107
|
+
}
|
|
4108
|
+
function attr(element2, local, ns, prefix) {
|
|
4109
|
+
return element2?.getAttributeNS(ns, local) ?? element2?.getAttribute(`${prefix}:${local}`) ?? void 0;
|
|
4110
|
+
}
|
|
4111
|
+
var DEFAULT_XML_LIMITS, XmlLimitError, TAG_RE, MARKUP_SKIPS, CRLF_DECLARATION, crlfDeclarations, buildXml, isElement, elements, children, first, relAttr;
|
|
4112
|
+
var init_xml = __esm({
|
|
4113
|
+
"xml/xml.ts"() {
|
|
4114
|
+
init_namespaces();
|
|
4115
|
+
DEFAULT_XML_LIMITS = {
|
|
4116
|
+
maxDepth: 512,
|
|
4117
|
+
maxNodes: 5e6
|
|
4118
|
+
};
|
|
4119
|
+
XmlLimitError = class extends Error {
|
|
4120
|
+
code = "xml-limit";
|
|
4121
|
+
/** The limit that was exceeded. */
|
|
4122
|
+
limit;
|
|
4123
|
+
/** Its value: the largest depth or element count allowed. */
|
|
4124
|
+
maximum;
|
|
4125
|
+
constructor(message, limit, maximum) {
|
|
4126
|
+
super(message);
|
|
4127
|
+
this.name = "XmlLimitError";
|
|
4128
|
+
this.limit = limit;
|
|
4129
|
+
this.maximum = maximum;
|
|
4130
|
+
}
|
|
4131
|
+
};
|
|
4132
|
+
TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
|
|
4133
|
+
MARKUP_SKIPS = [
|
|
4134
|
+
["<!--", "-->"],
|
|
4135
|
+
["<![CDATA[", "]]>"],
|
|
4136
|
+
["<?", "?>"]
|
|
4137
|
+
];
|
|
4138
|
+
CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
|
|
4139
|
+
crlfDeclarations = /* @__PURE__ */ new WeakSet();
|
|
4140
|
+
buildXml = (node2) => {
|
|
4141
|
+
const xml = new xmldom.XMLSerializer().serializeToString(node2);
|
|
4142
|
+
return crlfDeclarations.has(node2) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
|
|
4143
|
+
};
|
|
4144
|
+
isElement = (node2) => node2.nodeType === 1;
|
|
4145
|
+
elements = (parent) => Array.from(parent.childNodes).filter(isElement);
|
|
4146
|
+
children = (parent, local, ns, lenient = true) => elements(parent).filter((element2) => named(element2, local, ns, lenient));
|
|
4147
|
+
first = (parent, local, ns, lenient = true) => parent ? children(parent, local, ns, lenient)[0] : void 0;
|
|
4148
|
+
relAttr = (element2, local) => attr(element2, local, NS.r, "r");
|
|
4149
|
+
}
|
|
4150
|
+
});
|
|
4151
|
+
|
|
4152
|
+
// xml/merge-three-way.ts
|
|
4153
|
+
var init_merge_three_way = __esm({
|
|
4154
|
+
"xml/merge-three-way.ts"() {
|
|
4155
|
+
}
|
|
4156
|
+
});
|
|
4157
|
+
|
|
4158
|
+
// xml/lite.ts
|
|
4159
|
+
var init_lite = __esm({
|
|
4160
|
+
"xml/lite.ts"() {
|
|
4161
|
+
}
|
|
4162
|
+
});
|
|
4163
|
+
var init_xpath = __esm({
|
|
4164
|
+
"xml/xpath.ts"() {
|
|
4165
|
+
}
|
|
4166
|
+
});
|
|
4167
|
+
|
|
4168
|
+
// xml/index.ts
|
|
4169
|
+
var init_xml2 = __esm({
|
|
4170
|
+
"xml/index.ts"() {
|
|
4171
|
+
init_namespaces();
|
|
4172
|
+
init_xml();
|
|
4173
|
+
init_merge_three_way();
|
|
4174
|
+
init_lite();
|
|
4175
|
+
init_xpath();
|
|
4176
|
+
}
|
|
4177
|
+
});
|
|
4178
|
+
|
|
4179
|
+
// drawingml/picture-artistic.ts
|
|
4180
|
+
function parseArtisticPictureExtension(node2) {
|
|
4181
|
+
if (node2.namespaceURI !== NS.a || node2.localName !== "extLst") return void 0;
|
|
4182
|
+
const found = [];
|
|
4183
|
+
const unhandled = [];
|
|
4184
|
+
const pending = [node2];
|
|
4185
|
+
while (pending.length) {
|
|
4186
|
+
const item2 = pending.pop();
|
|
4187
|
+
if (item2 !== node2 && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
|
|
4188
|
+
unhandled.push(item2.localName);
|
|
4189
|
+
if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
|
|
4190
|
+
found.push(item2);
|
|
4191
|
+
pending.push(...elements(item2));
|
|
4192
|
+
}
|
|
4193
|
+
if (found.length !== 1) return void 0;
|
|
4194
|
+
const effect = found[0];
|
|
4195
|
+
const key2 = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
|
|
4196
|
+
if (!key2) return void 0;
|
|
4197
|
+
const raw2 = key2 ? effect.getAttribute(key2) : null;
|
|
4198
|
+
const n = raw2 === null ? 0 : Number(raw2);
|
|
4199
|
+
if (!Number.isFinite(n)) return void 0;
|
|
4200
|
+
return {
|
|
4201
|
+
kind: "artistic",
|
|
4202
|
+
name: effect.localName,
|
|
4203
|
+
radius: effect.localName === "artisticBlur" ? n : n / 1e3,
|
|
4204
|
+
baked: true,
|
|
4205
|
+
...unhandled.length ? { unhandled } : {}
|
|
4206
|
+
};
|
|
4207
|
+
}
|
|
4208
|
+
var ARTISTIC_PRIMARY_ATTRIBUTE;
|
|
4209
|
+
var init_picture_artistic = __esm({
|
|
4210
|
+
"drawingml/picture-artistic.ts"() {
|
|
4211
|
+
init_xml2();
|
|
4212
|
+
ARTISTIC_PRIMARY_ATTRIBUTE = {
|
|
4213
|
+
artisticBlur: "radius",
|
|
4214
|
+
artisticCement: "crackSpacing",
|
|
4215
|
+
artisticChalkSketch: "pressure",
|
|
4216
|
+
artisticCrisscrossEtching: "pressure",
|
|
4217
|
+
artisticCutout: "numberOfShades",
|
|
4218
|
+
artisticFilmGrain: "grainSize",
|
|
4219
|
+
artisticGlass: "scaling",
|
|
4220
|
+
artisticGlowDiffused: "intensity",
|
|
4221
|
+
artisticGlowEdges: "smoothness",
|
|
4222
|
+
artisticLightScreen: "gridSize",
|
|
4223
|
+
artisticLineDrawing: "pencilSize",
|
|
4224
|
+
artisticMarker: "size",
|
|
4225
|
+
// Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
|
|
4226
|
+
artisticMosiaicBubbles: "pressure",
|
|
4227
|
+
artisticPaintBrush: "brushSize",
|
|
4228
|
+
artisticPaintStrokes: "intensity",
|
|
4229
|
+
artisticPastelsSmooth: "scaling",
|
|
4230
|
+
artisticPencilGrayscale: "pencilSize",
|
|
4231
|
+
artisticPencilSketch: "pressure",
|
|
4232
|
+
artisticPhotocopy: "detail",
|
|
4233
|
+
artisticPlasticWrap: "smoothness",
|
|
4234
|
+
artisticTexturizer: "scaling",
|
|
4235
|
+
artisticWatercolorSponge: "brushSize"
|
|
4236
|
+
};
|
|
4237
|
+
}
|
|
4238
|
+
});
|
|
4239
|
+
|
|
4240
|
+
// color/contrast.ts
|
|
4241
|
+
var init_contrast = __esm({
|
|
4242
|
+
"color/contrast.ts"() {
|
|
4243
|
+
}
|
|
4244
|
+
});
|
|
4245
|
+
|
|
4246
|
+
// color/unit-rgb.ts
|
|
4247
|
+
var init_unit_rgb = __esm({
|
|
4248
|
+
"color/unit-rgb.ts"() {
|
|
4249
|
+
}
|
|
4250
|
+
});
|
|
4251
|
+
|
|
4252
|
+
// color/sigma-gradient-stops.ts
|
|
4253
|
+
var init_sigma_gradient_stops = __esm({
|
|
4254
|
+
"color/sigma-gradient-stops.ts"() {
|
|
4255
|
+
}
|
|
4256
|
+
});
|
|
4257
|
+
|
|
4258
|
+
// color/hex-rgb.ts
|
|
4259
|
+
var init_hex_rgb = __esm({
|
|
4260
|
+
"color/hex-rgb.ts"() {
|
|
4261
|
+
}
|
|
4262
|
+
});
|
|
4263
|
+
|
|
4264
|
+
// color/theme-palette.ts
|
|
4265
|
+
var init_theme_palette = __esm({
|
|
4266
|
+
"color/theme-palette.ts"() {
|
|
4267
|
+
}
|
|
4268
|
+
});
|
|
4269
|
+
|
|
4270
|
+
// color/straight-alpha-stops.ts
|
|
4271
|
+
var init_straight_alpha_stops = __esm({
|
|
4272
|
+
"color/straight-alpha-stops.ts"() {
|
|
4273
|
+
}
|
|
4274
|
+
});
|
|
4275
|
+
|
|
4276
|
+
// color/office-gradient-stops.ts
|
|
4277
|
+
var init_office_gradient_stops = __esm({
|
|
4278
|
+
"color/office-gradient-stops.ts"() {
|
|
4279
|
+
}
|
|
4280
|
+
});
|
|
4281
|
+
|
|
4282
|
+
// color/index.ts
|
|
4283
|
+
var init_color = __esm({
|
|
4284
|
+
"color/index.ts"() {
|
|
4285
|
+
init_color_primitives();
|
|
4286
|
+
init_color_linear();
|
|
4287
|
+
init_contrast();
|
|
4288
|
+
init_unit_rgb();
|
|
4289
|
+
init_sigma_gradient_stops();
|
|
4290
|
+
init_hex_rgb();
|
|
4291
|
+
init_theme_palette();
|
|
4292
|
+
init_straight_alpha_stops();
|
|
4293
|
+
init_office_gradient_stops();
|
|
4294
|
+
}
|
|
4295
|
+
});
|
|
4296
|
+
|
|
4297
|
+
// drawingml/dom.ts
|
|
4298
|
+
function attributeReader(element2) {
|
|
4299
|
+
return (name) => {
|
|
4300
|
+
if (!element2) return void 0;
|
|
4301
|
+
const direct = element2.getAttribute(name);
|
|
4302
|
+
if (direct !== null) return direct;
|
|
4303
|
+
const attributes3 = element2.attributes;
|
|
4304
|
+
for (let index2 = 0; index2 < attributes3.length; index2++) {
|
|
4305
|
+
const candidate = attributes3.item(index2);
|
|
4306
|
+
if (candidate && candidate.localName === name) return candidate.value;
|
|
4307
|
+
}
|
|
4308
|
+
return void 0;
|
|
4309
|
+
};
|
|
4310
|
+
}
|
|
4311
|
+
function stringAttribute(element2, name) {
|
|
4312
|
+
const value = attributeReader(element2)(name)?.trim();
|
|
4313
|
+
return value ? value : void 0;
|
|
4314
|
+
}
|
|
4315
|
+
function integerAttribute(element2, name) {
|
|
4316
|
+
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
4317
|
+
return Number.isFinite(parsed) ? parsed : void 0;
|
|
4318
|
+
}
|
|
4319
|
+
function booleanAttribute(element2, name) {
|
|
4320
|
+
const value = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
4321
|
+
if (value === "1" || value === "true") return true;
|
|
4322
|
+
if (value === "0" || value === "false") return false;
|
|
4323
|
+
return void 0;
|
|
4324
|
+
}
|
|
4325
|
+
function descendants(root, local) {
|
|
4326
|
+
const result = [];
|
|
4327
|
+
const visit2 = (node2) => {
|
|
4328
|
+
for (const child33 of Array.from(node2.childNodes)) {
|
|
4329
|
+
if (!isElement(child33)) continue;
|
|
4330
|
+
if (child33.localName === local) result.push(child33);
|
|
4331
|
+
visit2(child33);
|
|
4332
|
+
}
|
|
4333
|
+
};
|
|
4334
|
+
visit2(root);
|
|
4335
|
+
return result;
|
|
4336
|
+
}
|
|
4337
|
+
var init_dom = __esm({
|
|
4338
|
+
"drawingml/dom.ts"() {
|
|
4339
|
+
init_xml2();
|
|
4340
|
+
}
|
|
4341
|
+
});
|
|
4342
|
+
|
|
4343
|
+
// drawingml/ordered-color-transforms.ts
|
|
4344
|
+
function orderedColorTransforms(channels, transforms) {
|
|
4345
|
+
let { r, g: g3, b } = channels;
|
|
4346
|
+
let alpha = 1;
|
|
4347
|
+
const wrap2 = (value) => (value % 360 + 360) % 360;
|
|
4348
|
+
for (const transform8 of transforms) {
|
|
4349
|
+
const { name, value } = transform8;
|
|
4350
|
+
const fraction = parseDrawingFraction(value);
|
|
4351
|
+
if (name === "alpha" && fraction !== void 0) alpha = clampUnitInterval(fraction);
|
|
4352
|
+
else if (name === "alphaMod" && fraction !== void 0)
|
|
4353
|
+
alpha = clampUnitInterval(alpha * fraction);
|
|
4354
|
+
else if (name === "alphaOff" && fraction !== void 0)
|
|
4355
|
+
alpha = clampUnitInterval(alpha + fraction);
|
|
4356
|
+
else if (name === "inv") [r, g3, b] = [255 - r, 255 - g3, 255 - b];
|
|
4357
|
+
else if (name === "gray") r = g3 = b = 0.299 * r + 0.587 * g3 + 0.114 * b;
|
|
4358
|
+
else if ((name === "shade" || name === "tint") && fraction !== void 0) {
|
|
4359
|
+
const mix = (channel) => linearToSrgb255(
|
|
4360
|
+
name === "shade" ? srgb255ToLinear(channel) * fraction : 1 - (1 - srgb255ToLinear(channel)) * fraction
|
|
4361
|
+
);
|
|
4362
|
+
[r, g3, b] = [mix(r), mix(g3), mix(b)];
|
|
4363
|
+
} else {
|
|
4364
|
+
const hsl = rgbToHsl(r, g3, b);
|
|
4365
|
+
if (name === "comp") hsl.h = wrap2(hsl.h + 180);
|
|
4366
|
+
else if (name === "hue") {
|
|
4367
|
+
const hue = parseDrawingHueDegrees(value);
|
|
4368
|
+
if (hue !== void 0) hsl.h = wrap2(hue);
|
|
4369
|
+
} else if (name === "hueOff") {
|
|
4370
|
+
const hue = parseDrawingHueDegrees(value);
|
|
4371
|
+
if (hue !== void 0) hsl.h = wrap2(hsl.h + hue);
|
|
4372
|
+
} else if (name === "hueMod" && fraction !== void 0) hsl.h = wrap2(hsl.h * fraction);
|
|
4373
|
+
else if (name === "sat" && fraction !== void 0) hsl.s = clampUnitInterval(fraction);
|
|
4374
|
+
else if (name === "satMod" && fraction !== void 0) hsl.s *= fraction;
|
|
4375
|
+
else if (name === "satOff" && fraction !== void 0)
|
|
4376
|
+
hsl.s = clampUnitInterval(hsl.s + fraction);
|
|
4377
|
+
else if (name === "lum" && fraction !== void 0) hsl.l = clampUnitInterval(fraction);
|
|
4378
|
+
else if (name === "lumMod" && fraction !== void 0)
|
|
4379
|
+
hsl.l = clampUnitInterval(hsl.l * fraction);
|
|
4380
|
+
else if (name === "lumOff" && fraction !== void 0)
|
|
4381
|
+
hsl.l = clampUnitInterval(hsl.l + fraction);
|
|
4382
|
+
else continue;
|
|
4383
|
+
({ r, g: g3, b } = hslToRgb(hsl.h, hsl.s, hsl.l, (channel) => channel, {
|
|
4384
|
+
clampSaturation: false
|
|
4385
|
+
}));
|
|
4386
|
+
}
|
|
4387
|
+
}
|
|
4388
|
+
return { r, g: g3, b, alpha };
|
|
4389
|
+
}
|
|
4390
|
+
var init_ordered_color_transforms = __esm({
|
|
4391
|
+
"drawingml/ordered-color-transforms.ts"() {
|
|
4392
|
+
init_color();
|
|
4393
|
+
init_color_linear();
|
|
4394
|
+
}
|
|
4395
|
+
});
|
|
4396
|
+
|
|
4397
|
+
// drawingml/drawing-color.ts
|
|
4398
|
+
function colorValue(kind, element2) {
|
|
4399
|
+
const attribute7 = (name) => element2.getAttribute(name) ?? "";
|
|
4400
|
+
if (kind === "scrgb") return `${attribute7("r")},${attribute7("g")},${attribute7("b")}`;
|
|
4401
|
+
if (kind === "hsl") return `${attribute7("hue")},${attribute7("sat")},${attribute7("lum")}`;
|
|
4402
|
+
return attribute7("val");
|
|
4403
|
+
}
|
|
4404
|
+
function parseDrawingColorIn(container2) {
|
|
4405
|
+
if (!container2) return void 0;
|
|
4406
|
+
for (const element2 of elements(container2)) {
|
|
4407
|
+
const kind = COLOR_ELEMENTS[element2.localName];
|
|
4408
|
+
if (!kind || element2.namespaceURI && element2.namespaceURI !== NS.a) continue;
|
|
4409
|
+
return parseDrawingColor(element2);
|
|
4410
|
+
}
|
|
4411
|
+
return void 0;
|
|
4412
|
+
}
|
|
4413
|
+
function parseDrawingColor(element2) {
|
|
4414
|
+
const kind = COLOR_ELEMENTS[element2.localName];
|
|
4415
|
+
if (!kind) return void 0;
|
|
4416
|
+
const color3 = {
|
|
4417
|
+
kind,
|
|
4418
|
+
value: colorValue(kind, element2),
|
|
4419
|
+
transforms: elements(element2).map((child33) => ({
|
|
4420
|
+
name: child33.localName,
|
|
4421
|
+
value: child33.getAttribute("val") ?? ""
|
|
4422
|
+
}))
|
|
4423
|
+
};
|
|
4424
|
+
const fallback = kind === "system" ? element2.getAttribute("lastClr") : null;
|
|
4425
|
+
if (fallback) color3.fallback = fallback;
|
|
4426
|
+
return color3;
|
|
4427
|
+
}
|
|
4428
|
+
function parseDrawingColorList(container2) {
|
|
4429
|
+
if (!container2) return [];
|
|
4430
|
+
return elements(container2).flatMap((element2) => {
|
|
4431
|
+
const color3 = parseDrawingColor(element2);
|
|
4432
|
+
return color3 ? [color3] : [];
|
|
4433
|
+
});
|
|
4434
|
+
}
|
|
4435
|
+
function baseHex(color3, theme) {
|
|
4436
|
+
switch (color3.kind) {
|
|
4437
|
+
case "srgb":
|
|
4438
|
+
return /^[0-9a-f]{6}$/i.test(color3.value) ? `#${color3.value.toUpperCase()}` : void 0;
|
|
4439
|
+
case "scheme":
|
|
4440
|
+
return theme?.scheme(color3.value);
|
|
4441
|
+
case "system":
|
|
4442
|
+
return color3.fallback && /^[0-9a-f]{6}$/i.test(color3.fallback) ? `#${color3.fallback.toUpperCase()}` : void 0;
|
|
4443
|
+
case "preset":
|
|
4444
|
+
return PRESET_COLORS[color3.value];
|
|
4445
|
+
case "scrgb": {
|
|
4446
|
+
const [r, g3, b] = color3.value.split(",").map((part) => parseDrawingFraction(part));
|
|
4447
|
+
if (r === void 0 || g3 === void 0 || b === void 0) return void 0;
|
|
4448
|
+
return `#${toHex(scrgbLinearToSrgb8(r))}${toHex(scrgbLinearToSrgb8(g3))}${toHex(scrgbLinearToSrgb8(b))}`;
|
|
4449
|
+
}
|
|
4450
|
+
case "hsl": {
|
|
4451
|
+
const [h2, s, l] = color3.value.split(",");
|
|
4452
|
+
const hue = parseDrawingHueDegrees(h2);
|
|
4453
|
+
const sat = parseDrawingFraction(s);
|
|
4454
|
+
const lum = parseDrawingFraction(l);
|
|
4455
|
+
if (hue === void 0 || sat === void 0 || lum === void 0) return void 0;
|
|
4456
|
+
const { r, g: g3, b } = hslToRgb(hue, sat, lum);
|
|
4457
|
+
return `#${toHex(r)}${toHex(g3)}${toHex(b)}`;
|
|
4458
|
+
}
|
|
4459
|
+
}
|
|
4460
|
+
}
|
|
4461
|
+
function resolveDrawingColor(color3, theme, options2) {
|
|
4462
|
+
const base2 = baseHex(color3, theme);
|
|
4463
|
+
const rgb2 = base2 ? hexToRgbChannels(base2) : null;
|
|
4464
|
+
if (!rgb2) return void 0;
|
|
4465
|
+
if (options2?.transformOrder === "document") {
|
|
4466
|
+
const value = orderedColorTransforms(rgb2, color3.transforms);
|
|
4467
|
+
const round5 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
4468
|
+
return {
|
|
4469
|
+
hex: `#${toHex(round5(value.r))}${toHex(round5(value.g))}${toHex(round5(value.b))}`,
|
|
4470
|
+
alpha: value.alpha,
|
|
4471
|
+
unapplied: [...new Set(color3.transforms.map((transform8) => transform8.name))].filter(
|
|
4472
|
+
(name) => !APPLIED.has(name)
|
|
4473
|
+
)
|
|
4474
|
+
};
|
|
4475
|
+
}
|
|
4476
|
+
let { r, g: g3, b } = rgb2;
|
|
4477
|
+
const find = (name) => color3.transforms.find((entry2) => entry2.name === name)?.value;
|
|
4478
|
+
const has2 = (name) => color3.transforms.some((entry2) => entry2.name === name);
|
|
4479
|
+
if (has2("comp")) {
|
|
4480
|
+
const hsl = rgbToHsl(r, g3, b);
|
|
4481
|
+
({ r, g: g3, b } = hslToRgb((hsl.h + 180) % 360, hsl.s, hsl.l));
|
|
4482
|
+
}
|
|
4483
|
+
if (has2("inv")) [r, g3, b] = [255 - r, 255 - g3, 255 - b];
|
|
4484
|
+
if (has2("gray")) r = g3 = b = Math.round(0.299 * r + 0.587 * g3 + 0.114 * b);
|
|
4485
|
+
const shade = parseDrawingPercent(find("shade"));
|
|
4486
|
+
if (shade !== void 0) {
|
|
4487
|
+
r = linearToSrgb255(srgb255ToLinear(r) * shade);
|
|
4488
|
+
g3 = linearToSrgb255(srgb255ToLinear(g3) * shade);
|
|
4489
|
+
b = linearToSrgb255(srgb255ToLinear(b) * shade);
|
|
4490
|
+
}
|
|
4491
|
+
const tint = parseDrawingPercent(find("tint"));
|
|
4492
|
+
if (tint !== void 0) {
|
|
4493
|
+
r = linearToSrgb255(1 - (1 - srgb255ToLinear(r)) * tint);
|
|
4494
|
+
g3 = linearToSrgb255(1 - (1 - srgb255ToLinear(g3)) * tint);
|
|
4495
|
+
b = linearToSrgb255(1 - (1 - srgb255ToLinear(b)) * tint);
|
|
4496
|
+
}
|
|
4497
|
+
if (["hue", "hueMod", "hueOff", "sat", "satMod", "satOff", "lum", "lumMod", "lumOff"].some(has2)) {
|
|
4498
|
+
const hsl = rgbToHsl(r, g3, b);
|
|
4499
|
+
const wrap2 = (degrees) => (degrees % 360 + 360) % 360;
|
|
4500
|
+
const hueAbs = parseDrawingHueDegrees(find("hue"));
|
|
4501
|
+
if (hueAbs !== void 0) hsl.h = wrap2(hueAbs);
|
|
4502
|
+
const hueMod = parseDrawingFraction(find("hueMod"));
|
|
4503
|
+
if (hueMod !== void 0) hsl.h = wrap2(hsl.h * hueMod);
|
|
4504
|
+
const hueOff = parseDrawingHueDegrees(find("hueOff"));
|
|
4505
|
+
if (hueOff !== void 0) hsl.h = wrap2(hsl.h + hueOff);
|
|
4506
|
+
const satAbs = parseDrawingFraction(find("sat"));
|
|
4507
|
+
if (satAbs !== void 0) hsl.s = clampUnitInterval(satAbs);
|
|
4508
|
+
const satMod = parseDrawingFraction(find("satMod"));
|
|
4509
|
+
if (satMod !== void 0) hsl.s = clampUnitInterval(hsl.s * satMod);
|
|
4510
|
+
const satOff = parseDrawingFraction(find("satOff"));
|
|
4511
|
+
if (satOff !== void 0) hsl.s = clampUnitInterval(hsl.s + satOff);
|
|
4512
|
+
const lumAbs = parseDrawingFraction(find("lum"));
|
|
4513
|
+
if (lumAbs !== void 0) hsl.l = clampUnitInterval(lumAbs);
|
|
4514
|
+
const lumMod = parseDrawingFraction(find("lumMod"));
|
|
4515
|
+
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
4516
|
+
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
4517
|
+
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
4518
|
+
const round5 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
4519
|
+
({ r, g: g3, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round5));
|
|
4520
|
+
}
|
|
4521
|
+
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
4522
|
+
const alphaMod = parseDrawingFraction(find("alphaMod"));
|
|
4523
|
+
if (alphaMod !== void 0) alpha = clampUnitInterval(alpha * alphaMod);
|
|
4524
|
+
const alphaOff = parseDrawingFraction(find("alphaOff"));
|
|
4525
|
+
if (alphaOff !== void 0) alpha = clampUnitInterval(alpha + alphaOff);
|
|
4526
|
+
return {
|
|
4527
|
+
hex: `#${toHex(r)}${toHex(g3)}${toHex(b)}`,
|
|
4528
|
+
alpha,
|
|
4529
|
+
unapplied: [...new Set(color3.transforms.map((entry2) => entry2.name))].filter(
|
|
4530
|
+
(name) => !APPLIED.has(name)
|
|
4531
|
+
)
|
|
4532
|
+
};
|
|
4533
|
+
}
|
|
4534
|
+
var COLOR_ELEMENTS, PRESET_COLORS, APPLIED;
|
|
4535
|
+
var init_drawing_color = __esm({
|
|
4536
|
+
"drawingml/drawing-color.ts"() {
|
|
4537
|
+
init_color();
|
|
4538
|
+
init_color_linear();
|
|
4539
|
+
init_dom();
|
|
4540
|
+
init_ordered_color_transforms();
|
|
4541
|
+
COLOR_ELEMENTS = {
|
|
4542
|
+
srgbClr: "srgb",
|
|
4543
|
+
schemeClr: "scheme",
|
|
4544
|
+
sysClr: "system",
|
|
4545
|
+
prstClr: "preset",
|
|
4546
|
+
scrgbClr: "scrgb",
|
|
4547
|
+
hslClr: "hsl"
|
|
4548
|
+
};
|
|
4549
|
+
PRESET_COLORS = {
|
|
4550
|
+
black: "#000000",
|
|
4551
|
+
white: "#FFFFFF",
|
|
4552
|
+
red: "#FF0000",
|
|
4553
|
+
green: "#008000",
|
|
4554
|
+
blue: "#0000FF",
|
|
4555
|
+
yellow: "#FFFF00",
|
|
4556
|
+
gray: "#808080",
|
|
4557
|
+
grey: "#808080"
|
|
4558
|
+
};
|
|
4559
|
+
APPLIED = /* @__PURE__ */ new Set([
|
|
4560
|
+
"alpha",
|
|
4561
|
+
"alphaMod",
|
|
4562
|
+
"alphaOff",
|
|
4563
|
+
"comp",
|
|
4564
|
+
"inv",
|
|
4565
|
+
"gray",
|
|
4566
|
+
"shade",
|
|
4567
|
+
"tint",
|
|
4568
|
+
"hue",
|
|
4569
|
+
"hueMod",
|
|
4570
|
+
"hueOff",
|
|
4571
|
+
"sat",
|
|
4572
|
+
"satMod",
|
|
4573
|
+
"satOff",
|
|
4574
|
+
"lum",
|
|
4575
|
+
"lumMod",
|
|
4576
|
+
"lumOff"
|
|
4577
|
+
]);
|
|
4578
|
+
}
|
|
4579
|
+
});
|
|
4580
|
+
|
|
4581
|
+
// drawingml/write-color.ts
|
|
4582
|
+
function drawingColorXml(color3) {
|
|
4583
|
+
const local = ELEMENTS[color3.kind];
|
|
4584
|
+
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
4585
|
+
const root = doc.documentElement;
|
|
4586
|
+
if (color3.kind === "scrgb" || color3.kind === "hsl") {
|
|
4587
|
+
const keys = color3.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
4588
|
+
const values = color3.value.split(",");
|
|
4589
|
+
keys.forEach((key2, i2) => root.setAttribute(key2, values[i2] ?? "0"));
|
|
4590
|
+
} else root.setAttribute("val", color3.value);
|
|
4591
|
+
if (color3.fallback !== void 0 && color3.kind === "system")
|
|
4592
|
+
root.setAttribute("lastClr", color3.fallback);
|
|
4593
|
+
for (const transform8 of color3.transforms) {
|
|
4594
|
+
if (!/^[A-Za-z_][\w.-]*$/.test(transform8.name))
|
|
4595
|
+
throw new Error(`Invalid DrawingML transform ${transform8.name}`);
|
|
4596
|
+
const node2 = doc.createElementNS(NS.a, `a:${transform8.name}`);
|
|
4597
|
+
if (transform8.value !== "") node2.setAttribute("val", transform8.value);
|
|
4598
|
+
root.appendChild(node2);
|
|
4599
|
+
}
|
|
4600
|
+
return buildXml(doc);
|
|
4601
|
+
}
|
|
4602
|
+
var ELEMENTS;
|
|
4603
|
+
var init_write_color = __esm({
|
|
4604
|
+
"drawingml/write-color.ts"() {
|
|
4605
|
+
init_xml2();
|
|
4606
|
+
ELEMENTS = {
|
|
4607
|
+
srgb: "srgbClr",
|
|
4608
|
+
scheme: "schemeClr",
|
|
4609
|
+
system: "sysClr",
|
|
4610
|
+
preset: "prstClr",
|
|
4611
|
+
scrgb: "scrgbClr",
|
|
4612
|
+
hsl: "hslClr"
|
|
4613
|
+
};
|
|
4614
|
+
}
|
|
4615
|
+
});
|
|
4616
|
+
|
|
4617
|
+
// drawingml/patch-color.ts
|
|
4618
|
+
function patchDrawingColorIn(container2, color3) {
|
|
4619
|
+
const old = elements(container2).find((node2) => parseDrawingColor(node2));
|
|
4620
|
+
const before = parseDrawingColorIn(container2);
|
|
4621
|
+
if (!old || !before || before.kind !== color3.kind) {
|
|
4622
|
+
const next = container2.ownerDocument.importNode(
|
|
4623
|
+
parseXml(drawingColorXml(color3)).documentElement,
|
|
4624
|
+
true
|
|
4625
|
+
);
|
|
4626
|
+
if (old) container2.replaceChild(next, old);
|
|
4627
|
+
else container2.insertBefore(next, container2.firstChild);
|
|
4628
|
+
return;
|
|
4629
|
+
}
|
|
4630
|
+
if (before.value !== color3.value) {
|
|
4631
|
+
if (color3.kind === "scrgb" || color3.kind === "hsl") {
|
|
4632
|
+
const keys = color3.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
4633
|
+
const values = color3.value.split(",");
|
|
4634
|
+
keys.forEach((key2, index2) => old.setAttribute(key2, values[index2] ?? "0"));
|
|
4635
|
+
} else old.setAttribute("val", color3.value);
|
|
4636
|
+
}
|
|
4637
|
+
if (before.fallback !== color3.fallback && color3.kind === "system") {
|
|
4638
|
+
if (color3.fallback === void 0) old.removeAttribute("lastClr");
|
|
4639
|
+
else old.setAttribute("lastClr", color3.fallback);
|
|
4640
|
+
}
|
|
4641
|
+
const originals = elements(old);
|
|
4642
|
+
color3.transforms.forEach((transform8, index2) => {
|
|
4643
|
+
const source2 = originals[index2];
|
|
4644
|
+
if (source2?.localName === transform8.name) {
|
|
4645
|
+
if (before.transforms[index2]?.value !== transform8.value) {
|
|
4646
|
+
if (transform8.value === "") source2.removeAttribute("val");
|
|
4647
|
+
else source2.setAttribute("val", transform8.value);
|
|
4648
|
+
}
|
|
4649
|
+
return;
|
|
4650
|
+
}
|
|
4651
|
+
if (!/^[A-Za-z_][\w.-]*$/u.test(transform8.name))
|
|
4652
|
+
throw new Error("Invalid DrawingML colour transform");
|
|
4653
|
+
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform8.name}`);
|
|
4654
|
+
if (transform8.value !== "") next.setAttribute("val", transform8.value);
|
|
4655
|
+
if (source2) old.replaceChild(next, source2);
|
|
4656
|
+
else old.appendChild(next);
|
|
4657
|
+
});
|
|
4658
|
+
for (const extra of originals.slice(color3.transforms.length)) old.removeChild(extra);
|
|
4659
|
+
}
|
|
4660
|
+
var init_patch_color = __esm({
|
|
4661
|
+
"drawingml/patch-color.ts"() {
|
|
4662
|
+
init_xml2();
|
|
4663
|
+
init_drawing_color();
|
|
4664
|
+
init_write_color();
|
|
4665
|
+
}
|
|
4666
|
+
});
|
|
4667
|
+
|
|
4668
|
+
// drawingml/picture-standard-effects.ts
|
|
4669
|
+
function parseStandardPictureEffect(node2) {
|
|
4670
|
+
const name = node2.localName;
|
|
4671
|
+
if (![
|
|
4672
|
+
"biLevel",
|
|
4673
|
+
"alphaInv",
|
|
4674
|
+
"alphaCeiling",
|
|
4675
|
+
"alphaFloor",
|
|
4676
|
+
"alphaRepl",
|
|
4677
|
+
"alphaBiLevel",
|
|
4678
|
+
"alphaMod",
|
|
4679
|
+
"duotone",
|
|
4680
|
+
"clrRepl",
|
|
4681
|
+
"clrChange",
|
|
4682
|
+
"hsl",
|
|
4683
|
+
"tint",
|
|
4684
|
+
"blur"
|
|
4685
|
+
].includes(name))
|
|
4686
|
+
return void 0;
|
|
4687
|
+
const values = {};
|
|
4688
|
+
for (const [key2, attribute7] of Object.entries(attrs[name] ?? {})) {
|
|
4689
|
+
const raw2 = node2.getAttribute(attribute7);
|
|
4690
|
+
if (raw2 === null) continue;
|
|
4691
|
+
const percent = raw2.endsWith("%");
|
|
4692
|
+
const n = Number(percent ? raw2.slice(0, -1) : raw2) / (key2 === "hue" ? 6e4 : key2 === "radiusEmu" ? 1 : percent ? 100 : 1e5);
|
|
4693
|
+
if (!Number.isFinite(n) || key2 === "hue" && (n < 0 || n >= 360) || key2 === "threshold" && (n < 0 || n > 1) || key2 === "radiusEmu" && (!Number.isSafeInteger(n) || n < 0) || ["saturation", "luminance", "amount"].includes(key2) && name !== "alphaMod" && (n < (name === "alphaRepl" ? 0 : -1) || n > 1))
|
|
4694
|
+
return void 0;
|
|
4695
|
+
values[key2] = n;
|
|
4696
|
+
}
|
|
4697
|
+
if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
|
|
4698
|
+
return void 0;
|
|
4699
|
+
if (name === "alphaRepl" && values.amount === void 0) return void 0;
|
|
4700
|
+
if (name === "alphaMod") {
|
|
4701
|
+
const cont = first(node2, "cont", NS.a);
|
|
4702
|
+
const nested = cont ? elements(cont) : [];
|
|
4703
|
+
if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
|
|
4704
|
+
const raw2 = nested[0].getAttribute("amt") ?? "100000";
|
|
4705
|
+
const n = Number(raw2.endsWith("%") ? raw2.slice(0, -1) : raw2) / (raw2.endsWith("%") ? 100 : 1e5);
|
|
4706
|
+
if (!Number.isFinite(n) || n < 0) return void 0;
|
|
4707
|
+
values.amount = n;
|
|
4708
|
+
}
|
|
4709
|
+
let colors = [];
|
|
4710
|
+
if (name === "duotone") {
|
|
4711
|
+
const candidates = elements(node2).filter(
|
|
4712
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
4713
|
+
);
|
|
4714
|
+
colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
|
|
4715
|
+
if (colors.length !== 2) return void 0;
|
|
4716
|
+
}
|
|
4717
|
+
if (name === "clrRepl") {
|
|
4718
|
+
const color3 = parseDrawingColorIn(node2);
|
|
4719
|
+
if (!color3) return void 0;
|
|
4720
|
+
colors = [color3];
|
|
4721
|
+
}
|
|
4722
|
+
if (name === "clrChange") {
|
|
4723
|
+
const from = parseDrawingColorIn(first(node2, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node2, "clrTo", NS.a));
|
|
4724
|
+
if (!from || !to) return void 0;
|
|
4725
|
+
colors = [from, to];
|
|
4726
|
+
}
|
|
4727
|
+
if (name === "alphaInv") {
|
|
4728
|
+
const color3 = parseDrawingColorIn(node2);
|
|
4729
|
+
if (color3) colors = [color3];
|
|
4730
|
+
}
|
|
4731
|
+
return {
|
|
4732
|
+
kind: "standard",
|
|
4733
|
+
name,
|
|
4734
|
+
...Object.keys(values).length ? { values } : {},
|
|
4735
|
+
...colors.length ? { colors } : {},
|
|
4736
|
+
...name === "clrChange" && node2.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node2.getAttribute("useA") ?? "") } : {},
|
|
4737
|
+
...name === "blur" && node2.hasAttribute("grow") ? { grow: !["0", "false"].includes(node2.getAttribute("grow") ?? "") } : {}
|
|
4738
|
+
};
|
|
4739
|
+
}
|
|
4740
|
+
function applyStandardPictureEffect(node2, effect) {
|
|
4741
|
+
const doc = node2.ownerDocument, before = parseStandardPictureEffect(node2);
|
|
4742
|
+
for (const [key2, value] of Object.entries(effect.values ?? {})) {
|
|
4743
|
+
if (!Number.isFinite(value) || key2 === "hue" && (value < 0 || value >= 360) || key2 === "threshold" && (value < 0 || value > 1) || key2 === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key2 === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key2) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
|
|
4744
|
+
throw new RangeError("Invalid picture effect values");
|
|
4745
|
+
}
|
|
4746
|
+
const count2 = effect.colors?.length ?? 0;
|
|
4747
|
+
if (["duotone", "clrChange"].includes(effect.name) && count2 !== 2 || effect.name === "clrRepl" && count2 !== 1 || effect.name === "alphaInv" && count2 > 1)
|
|
4748
|
+
throw new RangeError("Invalid picture effect colours");
|
|
4749
|
+
for (const [key2, attribute7] of Object.entries(attrs[effect.name] ?? {})) {
|
|
4750
|
+
const value = effect.values?.[key2];
|
|
4751
|
+
if (value === before?.values?.[key2]) continue;
|
|
4752
|
+
if (value === void 0) node2.removeAttribute(attribute7);
|
|
4753
|
+
else
|
|
4754
|
+
node2.setAttribute(
|
|
4755
|
+
attribute7,
|
|
4756
|
+
String(Math.round(value * (key2 === "hue" ? 6e4 : key2 === "radiusEmu" ? 1 : 1e5)))
|
|
4757
|
+
);
|
|
4758
|
+
}
|
|
4759
|
+
if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
|
|
4760
|
+
const cont = first(node2, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
|
|
4761
|
+
const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
|
|
4762
|
+
fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
|
|
4763
|
+
if (!fix.parentNode) cont.appendChild(fix);
|
|
4764
|
+
if (!cont.parentNode) node2.appendChild(cont);
|
|
4765
|
+
}
|
|
4766
|
+
if (effect.useAlpha !== before?.useAlpha) {
|
|
4767
|
+
if (effect.useAlpha === void 0) node2.removeAttribute("useA");
|
|
4768
|
+
else node2.setAttribute("useA", effect.useAlpha ? "1" : "0");
|
|
4769
|
+
}
|
|
4770
|
+
if (effect.grow !== before?.grow) {
|
|
4771
|
+
if (effect.grow === void 0) node2.removeAttribute("grow");
|
|
4772
|
+
else node2.setAttribute("grow", effect.grow ? "1" : "0");
|
|
4773
|
+
}
|
|
4774
|
+
if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
|
|
4775
|
+
if (effect.name === "duotone") {
|
|
4776
|
+
const old = elements(node2).filter(
|
|
4777
|
+
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
4778
|
+
);
|
|
4779
|
+
for (let i2 = 0; i2 < (effect.colors?.length ?? 0); i2++) {
|
|
4780
|
+
const holder = doc.createElementNS(NS.a, "a:holder");
|
|
4781
|
+
if (old[i2]) holder.appendChild(doc.importNode(old[i2], true));
|
|
4782
|
+
patchDrawingColorIn(holder, effect.colors[i2]);
|
|
4783
|
+
const next = elements(holder)[0];
|
|
4784
|
+
if (old[i2]) node2.replaceChild(next, old[i2]);
|
|
4785
|
+
else node2.insertBefore(next, first(node2, "extLst", NS.a) ?? null);
|
|
4786
|
+
}
|
|
4787
|
+
} else if (effect.name === "clrChange") {
|
|
4788
|
+
for (const [i2, name] of ["clrFrom", "clrTo"].entries()) {
|
|
4789
|
+
const holder = first(node2, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
|
|
4790
|
+
if (effect.colors?.[i2]) patchDrawingColorIn(holder, effect.colors[i2]);
|
|
4791
|
+
if (!holder.parentNode) node2.insertBefore(holder, first(node2, "extLst", NS.a) ?? null);
|
|
4792
|
+
}
|
|
4793
|
+
} else if (effect.colors?.[0]) patchDrawingColorIn(node2, effect.colors[0]);
|
|
4794
|
+
}
|
|
4795
|
+
if (!parseStandardPictureEffect(node2)) throw new RangeError("Invalid picture effect values");
|
|
4796
|
+
}
|
|
4797
|
+
var attrs;
|
|
4798
|
+
var init_picture_standard_effects = __esm({
|
|
4799
|
+
"drawingml/picture-standard-effects.ts"() {
|
|
4800
|
+
init_xml2();
|
|
4801
|
+
init_drawing_color();
|
|
4802
|
+
init_patch_color();
|
|
4803
|
+
attrs = {
|
|
4804
|
+
biLevel: { threshold: "thresh" },
|
|
4805
|
+
alphaRepl: { amount: "a" },
|
|
4806
|
+
alphaBiLevel: { threshold: "thresh" },
|
|
4807
|
+
hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
|
|
4808
|
+
tint: { hue: "hue", amount: "amt" },
|
|
4809
|
+
blur: { radiusEmu: "rad" }
|
|
4810
|
+
};
|
|
4811
|
+
}
|
|
4812
|
+
});
|
|
4813
|
+
|
|
4814
|
+
// drawingml/picture-effects.ts
|
|
4815
|
+
function picturePercentage(value) {
|
|
4816
|
+
const text2 = String(value ?? "").trim();
|
|
4817
|
+
if (!text2) return void 0;
|
|
4818
|
+
const percent = text2.endsWith("%");
|
|
4819
|
+
const n = Number(percent ? text2.slice(0, -1) : text2) / (percent ? 100 : 1e5);
|
|
4820
|
+
return Number.isFinite(n) ? n : void 0;
|
|
4821
|
+
}
|
|
4822
|
+
function readPictureEffect(name, attribute7) {
|
|
4823
|
+
if (name === "grayscl") return { kind: "grayscale" };
|
|
4824
|
+
if (name === "lum") {
|
|
4825
|
+
const brightness = picturePercentage(attribute7("bright"));
|
|
4826
|
+
const contrast = picturePercentage(attribute7("contrast"));
|
|
4827
|
+
for (const [name2, value] of [
|
|
4828
|
+
["bright", brightness],
|
|
4829
|
+
["contrast", contrast]
|
|
4830
|
+
]) {
|
|
4831
|
+
const raw2 = attribute7(name2);
|
|
4832
|
+
if (raw2 !== void 0 && raw2 !== null && (value === void 0 || Math.abs(value) > 1))
|
|
4833
|
+
return void 0;
|
|
4834
|
+
}
|
|
4835
|
+
return {
|
|
4836
|
+
kind: "luminance",
|
|
4837
|
+
...brightness !== void 0 ? { brightness } : {},
|
|
4838
|
+
...contrast !== void 0 ? { contrast } : {}
|
|
4839
|
+
};
|
|
4840
|
+
}
|
|
4841
|
+
if (name === "alphaModFix") {
|
|
4842
|
+
const raw2 = attribute7("amt");
|
|
4843
|
+
const amount = raw2 === void 0 || raw2 === null ? 1 : picturePercentage(raw2);
|
|
4844
|
+
if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
|
|
4845
|
+
}
|
|
4846
|
+
return void 0;
|
|
4847
|
+
}
|
|
4848
|
+
function parsePictureEffects(blip) {
|
|
4849
|
+
if (!blip) return [];
|
|
4850
|
+
return elements(blip).map((node2) => ({
|
|
4851
|
+
...(node2.namespaceURI === NS.a ? readPictureEffect(node2.localName, (name) => node2.getAttribute(name)) ?? parseStandardPictureEffect(node2) ?? parseArtisticPictureExtension(node2) : void 0) ?? { kind: "unsupported", name: node2.localName },
|
|
4852
|
+
sourceXml: buildXml(node2)
|
|
4853
|
+
}));
|
|
4854
|
+
}
|
|
4855
|
+
function applyPictureEffects(blip, effects2) {
|
|
4856
|
+
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects2)) return;
|
|
4857
|
+
const nodes = effects2.map((effect) => {
|
|
4858
|
+
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
|
|
4859
|
+
if (effect.kind === "artistic") {
|
|
4860
|
+
const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
|
|
4861
|
+
if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
|
|
4862
|
+
throw new Error("Artistic authoring requires a host-generated baked picture cache");
|
|
4863
|
+
}
|
|
4864
|
+
const source2 = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
|
|
4865
|
+
if (effect.kind === "unsupported" && !source2)
|
|
4866
|
+
throw new Error("An unsupported picture effect needs source XML");
|
|
4867
|
+
const node2 = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
4868
|
+
if (effect.kind !== "unsupported" && (node2.namespaceURI !== NS.a || node2.localName !== name))
|
|
4869
|
+
throw new Error("Picture effect source does not match its kind");
|
|
4870
|
+
const set3 = (name2, value) => {
|
|
4871
|
+
const original = picturePercentage(node2.getAttribute(name2));
|
|
4872
|
+
if (value === void 0) node2.removeAttribute(name2);
|
|
4873
|
+
else if (value !== original) {
|
|
4874
|
+
if (!Number.isFinite(value)) throw new RangeError("Picture effect must be finite");
|
|
4875
|
+
node2.setAttribute(name2, String(Math.round(value * 1e5)));
|
|
4876
|
+
}
|
|
4877
|
+
};
|
|
4878
|
+
if (effect.kind === "luminance") {
|
|
4879
|
+
if ([effect.brightness, effect.contrast].some(
|
|
4880
|
+
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
4881
|
+
))
|
|
4882
|
+
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
4883
|
+
set3("bright", effect.brightness);
|
|
4884
|
+
set3("contrast", effect.contrast);
|
|
4885
|
+
}
|
|
4886
|
+
if (effect.kind === "alphaModFix") {
|
|
4887
|
+
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
4888
|
+
set3("amt", effect.amount);
|
|
4889
|
+
}
|
|
4890
|
+
if (effect.kind === "standard") applyStandardPictureEffect(node2, effect);
|
|
4891
|
+
return node2;
|
|
4892
|
+
});
|
|
4893
|
+
for (const node2 of elements(blip)) blip.removeChild(node2);
|
|
4894
|
+
for (const node2 of nodes) blip.appendChild(node2);
|
|
4895
|
+
}
|
|
4896
|
+
function patchPictureEffects(source2, patch) {
|
|
4897
|
+
const result = structuredClone(source2);
|
|
4898
|
+
const upsert2 = (kind, update) => {
|
|
4899
|
+
const matches = result.flatMap((effect, index3) => effect.kind === kind ? [index3] : []);
|
|
4900
|
+
if (matches.length > 1) throw new Error(`Ambiguous duplicate picture effect: ${kind}`);
|
|
4901
|
+
const index2 = matches[0];
|
|
4902
|
+
const value = update(index2 === void 0 ? void 0 : result[index2]);
|
|
4903
|
+
if (index2 !== void 0) {
|
|
4904
|
+
if (value) result[index2] = value;
|
|
4905
|
+
else result.splice(index2, 1);
|
|
4906
|
+
} else if (value) {
|
|
4907
|
+
const ext = result.findIndex(
|
|
4908
|
+
(effect) => effect.kind === "unsupported" && effect.name === "extLst"
|
|
4909
|
+
);
|
|
4910
|
+
result.splice(ext < 0 ? result.length : ext, 0, value);
|
|
4911
|
+
}
|
|
4912
|
+
};
|
|
4913
|
+
for (const key2 of ["brightness", "contrast", "alpha"])
|
|
4914
|
+
if (patch[key2] !== void 0 && !Number.isFinite(patch[key2]))
|
|
4915
|
+
throw new RangeError("Picture effect must be finite");
|
|
4916
|
+
if ([patch.brightness, patch.contrast].some((value) => value !== void 0 && Math.abs(value) > 1))
|
|
4917
|
+
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
4918
|
+
if (patch.alpha !== void 0 && patch.alpha < 0)
|
|
4919
|
+
throw new RangeError("Picture alpha must be nonnegative");
|
|
4920
|
+
if (patch.grayscale !== void 0)
|
|
4921
|
+
upsert2(
|
|
4922
|
+
"grayscale",
|
|
4923
|
+
(effect) => patch.grayscale ? effect ?? { kind: "grayscale" } : void 0
|
|
4924
|
+
);
|
|
4925
|
+
if (patch.brightness !== void 0 || patch.contrast !== void 0)
|
|
4926
|
+
upsert2("luminance", (effect) => ({
|
|
4927
|
+
...effect?.kind === "luminance" ? effect : { kind: "luminance" },
|
|
4928
|
+
...patch.brightness !== void 0 ? { brightness: patch.brightness } : {},
|
|
4929
|
+
...patch.contrast !== void 0 ? { contrast: patch.contrast } : {}
|
|
4930
|
+
}));
|
|
4931
|
+
if (patch.alpha !== void 0)
|
|
4932
|
+
upsert2("alphaModFix", (effect) => ({
|
|
4933
|
+
...effect?.kind === "alphaModFix" ? effect : { kind: "alphaModFix" },
|
|
4934
|
+
amount: patch.alpha
|
|
4935
|
+
}));
|
|
4936
|
+
if (patch.standard) {
|
|
4937
|
+
const target = patch.standard;
|
|
4938
|
+
const matches = result.flatMap(
|
|
4939
|
+
(effect, index3) => effect.kind === "standard" && effect.name === target.name || effect.kind === "unsupported" && effect.name === target.name ? [index3] : []
|
|
4940
|
+
);
|
|
4941
|
+
if (matches.length > 1 || matches.some((index3) => result[index3]?.kind === "unsupported"))
|
|
4942
|
+
throw new Error(`Ambiguous or unreadable picture effect: ${target.name}`);
|
|
4943
|
+
const index2 = matches[0], before = index2 === void 0 ? void 0 : result[index2];
|
|
4944
|
+
const next = {
|
|
4945
|
+
...before?.kind === "standard" ? before : {},
|
|
4946
|
+
...target,
|
|
4947
|
+
kind: "standard"
|
|
4948
|
+
};
|
|
4949
|
+
const doc = parseXml(next.sourceXml ?? `<a:${next.name} xmlns:a="${NS.a}"/>`);
|
|
4950
|
+
applyStandardPictureEffect(doc.documentElement, next);
|
|
4951
|
+
if (index2 === void 0) {
|
|
4952
|
+
const ext = result.findIndex(
|
|
4953
|
+
(effect) => effect.kind === "artistic" || effect.kind === "unsupported" && effect.name === "extLst"
|
|
4954
|
+
);
|
|
4955
|
+
result.splice(ext < 0 ? result.length : ext, 0, next);
|
|
4956
|
+
} else result[index2] = next;
|
|
4957
|
+
}
|
|
4958
|
+
return result;
|
|
4959
|
+
}
|
|
4960
|
+
var init_picture_effects = __esm({
|
|
4961
|
+
"drawingml/picture-effects.ts"() {
|
|
4962
|
+
init_picture_artistic();
|
|
4963
|
+
init_picture_standard_effects();
|
|
4964
|
+
init_xml2();
|
|
4965
|
+
}
|
|
4966
|
+
});
|
|
4967
|
+
|
|
4968
|
+
// pptx/core/builders/sdk/picture-effects-input.ts
|
|
4969
|
+
function pictureEffectsFromInput(options2) {
|
|
4970
|
+
const { opacity: opacity2, brightness, contrast } = options2 ?? {};
|
|
4971
|
+
if (opacity2 !== void 0 && !(opacity2 >= 0 && opacity2 <= 1)) {
|
|
4972
|
+
throw new RangeError(`ImageOptions.opacity must be between 0 and 1, got ${opacity2}`);
|
|
4973
|
+
}
|
|
4974
|
+
const patch = {};
|
|
4975
|
+
if (opacity2 !== void 0 && opacity2 < 1) {
|
|
4976
|
+
patch.alpha = opacity2;
|
|
4977
|
+
}
|
|
4978
|
+
if (brightness !== void 0) {
|
|
4979
|
+
patch.brightness = brightness / 100;
|
|
4980
|
+
}
|
|
4981
|
+
if (contrast !== void 0) {
|
|
4982
|
+
patch.contrast = contrast / 100;
|
|
4983
|
+
}
|
|
4984
|
+
if (Object.keys(patch).length === 0) {
|
|
4985
|
+
return void 0;
|
|
4986
|
+
}
|
|
4987
|
+
let patched;
|
|
4988
|
+
try {
|
|
4989
|
+
patched = patchPictureEffects([], patch);
|
|
4990
|
+
} catch (error62) {
|
|
4991
|
+
throw new RangeError(
|
|
4992
|
+
`ImageOptions.brightness and contrast must be finite percentages from -100 to 100 (${String(error62)})`
|
|
4993
|
+
);
|
|
4994
|
+
}
|
|
4995
|
+
let effects2;
|
|
4996
|
+
for (const effect of patched) {
|
|
4997
|
+
effects2 ??= {};
|
|
4998
|
+
if (effect.kind === "alphaModFix") {
|
|
4999
|
+
effects2.alphaModFix = effect.amount * 100;
|
|
5000
|
+
} else if (effect.kind === "luminance") {
|
|
5001
|
+
effects2.lum = {
|
|
5002
|
+
...effect.brightness !== void 0 ? { bright: effect.brightness * 100 } : {},
|
|
5003
|
+
...effect.contrast !== void 0 ? { contrast: effect.contrast * 100 } : {}
|
|
5004
|
+
};
|
|
5005
|
+
}
|
|
5006
|
+
}
|
|
5007
|
+
return effects2;
|
|
5008
|
+
}
|
|
5009
|
+
var init_picture_effects_input = __esm({
|
|
5010
|
+
"pptx/core/builders/sdk/picture-effects-input.ts"() {
|
|
5011
|
+
init_picture_effects();
|
|
5012
|
+
}
|
|
5013
|
+
});
|
|
5014
|
+
|
|
3965
5015
|
// pptx/core/builders/sdk/shape-style-input.ts
|
|
3966
5016
|
function mapFillToShapeStyle(fill3) {
|
|
3967
5017
|
if (!fill3) {
|
|
@@ -4602,12 +5652,13 @@ function createConnectorElement(options2) {
|
|
|
4602
5652
|
function createImageElement(source2, options2) {
|
|
4603
5653
|
const p2 = pos("image", options2);
|
|
4604
5654
|
const isDataUrl = source2.startsWith("data:");
|
|
5655
|
+
const imageEffects = pictureEffectsFromInput(options2);
|
|
4605
5656
|
return {
|
|
4606
5657
|
type: "image",
|
|
4607
5658
|
id: generateId("img"),
|
|
4608
5659
|
...p2,
|
|
4609
5660
|
rotation: options2?.rotation,
|
|
4610
|
-
|
|
5661
|
+
...imageEffects ? { imageEffects } : {},
|
|
4611
5662
|
imagePath: isDataUrl ? void 0 : source2,
|
|
4612
5663
|
imageData: isDataUrl ? source2 : void 0,
|
|
4613
5664
|
altText: options2?.altText,
|
|
@@ -4775,6 +5826,7 @@ var init_ElementFactory = __esm({
|
|
|
4775
5826
|
init_custom_geometry();
|
|
4776
5827
|
init_chart_gradient_input();
|
|
4777
5828
|
init_chart_layout_operations();
|
|
5829
|
+
init_picture_effects_input();
|
|
4778
5830
|
init_table_cell_input();
|
|
4779
5831
|
init_table_merge_input();
|
|
4780
5832
|
init_text_segment_style();
|
|
@@ -5482,6 +6534,698 @@ var init_layout_operations = __esm({
|
|
|
5482
6534
|
}
|
|
5483
6535
|
});
|
|
5484
6536
|
|
|
6537
|
+
// opc/properties/types.ts
|
|
6538
|
+
var CUSTOM_PROPERTIES_FMTID, PROPERTY_CONTENT_TYPES;
|
|
6539
|
+
var init_types3 = __esm({
|
|
6540
|
+
"opc/properties/types.ts"() {
|
|
6541
|
+
CUSTOM_PROPERTIES_FMTID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
|
|
6542
|
+
PROPERTY_CONTENT_TYPES = {
|
|
6543
|
+
core: "application/vnd.openxmlformats-package.core-properties+xml",
|
|
6544
|
+
app: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
|
|
6545
|
+
custom: "application/vnd.openxmlformats-officedocument.custom-properties+xml"
|
|
6546
|
+
};
|
|
6547
|
+
}
|
|
6548
|
+
});
|
|
6549
|
+
|
|
6550
|
+
// opc/properties/patch.ts
|
|
6551
|
+
function tagEnd(xml, from) {
|
|
6552
|
+
let quote = "";
|
|
6553
|
+
for (let i2 = from + 1; i2 < xml.length; i2++) {
|
|
6554
|
+
const ch = xml[i2];
|
|
6555
|
+
if (quote) {
|
|
6556
|
+
if (ch === quote) quote = "";
|
|
6557
|
+
} else if (ch === '"' || ch === "'") quote = ch;
|
|
6558
|
+
else if (ch === ">") return i2 + 1;
|
|
6559
|
+
}
|
|
6560
|
+
throw new Error("Unterminated tag in property part");
|
|
6561
|
+
}
|
|
6562
|
+
function skipMarkup(xml, at2) {
|
|
6563
|
+
if (xml.startsWith("<!--", at2)) return xml.indexOf("-->", at2) + 3;
|
|
6564
|
+
if (xml.startsWith("<![CDATA[", at2)) return xml.indexOf("]]>", at2) + 3;
|
|
6565
|
+
if (xml.startsWith("<?", at2)) return xml.indexOf("?>", at2) + 2;
|
|
6566
|
+
return void 0;
|
|
6567
|
+
}
|
|
6568
|
+
function scan(xml) {
|
|
6569
|
+
let i2 = 0;
|
|
6570
|
+
let rootStart = -1;
|
|
6571
|
+
while (rootStart < 0) {
|
|
6572
|
+
const lt = xml.indexOf("<", i2);
|
|
6573
|
+
if (lt < 0) throw new Error("Property part has no root element");
|
|
6574
|
+
const skipped = skipMarkup(xml, lt);
|
|
6575
|
+
if (skipped !== void 0) i2 = skipped;
|
|
6576
|
+
else rootStart = lt;
|
|
6577
|
+
}
|
|
6578
|
+
const openEnd = tagEnd(xml, rootStart);
|
|
6579
|
+
if (xml[openEnd - 2] === "/") {
|
|
6580
|
+
const root = {
|
|
6581
|
+
start: rootStart,
|
|
6582
|
+
openEnd,
|
|
6583
|
+
closeStart: openEnd,
|
|
6584
|
+
end: openEnd,
|
|
6585
|
+
selfClosing: true
|
|
6586
|
+
};
|
|
6587
|
+
return { root, children: [] };
|
|
6588
|
+
}
|
|
6589
|
+
const children16 = [];
|
|
6590
|
+
let depth = 0;
|
|
6591
|
+
let child33;
|
|
6592
|
+
i2 = openEnd;
|
|
6593
|
+
for (; ; ) {
|
|
6594
|
+
const lt = xml.indexOf("<", i2);
|
|
6595
|
+
if (lt < 0) throw new Error("Property part root is not closed");
|
|
6596
|
+
const skipped = skipMarkup(xml, lt);
|
|
6597
|
+
if (skipped !== void 0) {
|
|
6598
|
+
i2 = skipped;
|
|
6599
|
+
continue;
|
|
6600
|
+
}
|
|
6601
|
+
const end = tagEnd(xml, lt);
|
|
6602
|
+
i2 = end;
|
|
6603
|
+
if (xml[lt + 1] === "/") {
|
|
6604
|
+
if (depth === 0) {
|
|
6605
|
+
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
6606
|
+
return { root, children: children16 };
|
|
6607
|
+
}
|
|
6608
|
+
depth--;
|
|
6609
|
+
if (depth === 0 && child33)
|
|
6610
|
+
children16.push({ ...child33, closeStart: lt, end, selfClosing: false });
|
|
6611
|
+
} else if (xml[end - 2] === "/") {
|
|
6612
|
+
if (depth === 0)
|
|
6613
|
+
children16.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
6614
|
+
} else {
|
|
6615
|
+
if (depth === 0) child33 = { start: lt, openEnd: end };
|
|
6616
|
+
depth++;
|
|
6617
|
+
}
|
|
6618
|
+
}
|
|
6619
|
+
}
|
|
6620
|
+
var XMLNS, escapeText, qualifiedName, PartPatch;
|
|
6621
|
+
var init_patch = __esm({
|
|
6622
|
+
"opc/properties/patch.ts"() {
|
|
6623
|
+
init_xml2();
|
|
6624
|
+
XMLNS = "http://www.w3.org/2000/xmlns/";
|
|
6625
|
+
escapeText = (text2) => text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
6626
|
+
qualifiedName = (xml, span2) => /^<([^\s/>]+)/.exec(xml.slice(span2.start, span2.openEnd))?.[1] ?? "";
|
|
6627
|
+
PartPatch = class {
|
|
6628
|
+
constructor(xml, rootElement) {
|
|
6629
|
+
this.xml = xml;
|
|
6630
|
+
const { root, children: children16 } = scan(xml);
|
|
6631
|
+
const kids = elements(rootElement);
|
|
6632
|
+
if (kids.length !== children16.length) throw new Error("Property part markup is not supported");
|
|
6633
|
+
kids.forEach((kid, index2) => this.spans.set(kid, children16[index2]));
|
|
6634
|
+
this.root = root;
|
|
6635
|
+
for (const attribute7 of Array.from(rootElement.attributes)) {
|
|
6636
|
+
if (attribute7.name === "xmlns") this.defaultNs = attribute7.value;
|
|
6637
|
+
else if (attribute7.namespaceURI === XMLNS || attribute7.name.startsWith("xmlns:"))
|
|
6638
|
+
this.prefixes.set(attribute7.value, attribute7.localName);
|
|
6639
|
+
}
|
|
6640
|
+
}
|
|
6641
|
+
xml;
|
|
6642
|
+
root;
|
|
6643
|
+
spans = /* @__PURE__ */ new Map();
|
|
6644
|
+
edits = [];
|
|
6645
|
+
appended = [];
|
|
6646
|
+
prefixes = /* @__PURE__ */ new Map();
|
|
6647
|
+
defaultNs = null;
|
|
6648
|
+
seq = 0;
|
|
6649
|
+
add(start, end, text2) {
|
|
6650
|
+
this.edits.push({ start, end, text: text2, seq: this.seq++ });
|
|
6651
|
+
}
|
|
6652
|
+
span(element2) {
|
|
6653
|
+
const span2 = this.spans.get(element2);
|
|
6654
|
+
if (!span2) throw new Error("Element is not a child of the patched root");
|
|
6655
|
+
return span2;
|
|
6656
|
+
}
|
|
6657
|
+
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
6658
|
+
prefix(ns, preferred) {
|
|
6659
|
+
const known = this.prefixes.get(ns);
|
|
6660
|
+
if (known !== void 0) return known;
|
|
6661
|
+
const taken = new Set(this.prefixes.values());
|
|
6662
|
+
let prefix = preferred;
|
|
6663
|
+
for (let n = 1; taken.has(prefix); n++) prefix = `${preferred}${n}`;
|
|
6664
|
+
this.prefixes.set(ns, prefix);
|
|
6665
|
+
const at2 = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
6666
|
+
this.add(at2, at2, ` xmlns:${prefix}="${ns}"`);
|
|
6667
|
+
return prefix;
|
|
6668
|
+
}
|
|
6669
|
+
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
6670
|
+
qualify(ns, local, preferred) {
|
|
6671
|
+
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
6672
|
+
}
|
|
6673
|
+
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
6674
|
+
setContent(element2, content2) {
|
|
6675
|
+
const span2 = this.span(element2);
|
|
6676
|
+
if (span2.selfClosing)
|
|
6677
|
+
this.add(span2.openEnd - 2, span2.openEnd, `>${content2}</${qualifiedName(this.xml, span2)}>`);
|
|
6678
|
+
else this.add(span2.openEnd, span2.closeStart, content2);
|
|
6679
|
+
}
|
|
6680
|
+
/** Adds ` name="value"` text to the element's start tag. */
|
|
6681
|
+
addAttribute(element2, attribute7) {
|
|
6682
|
+
const span2 = this.span(element2);
|
|
6683
|
+
const at2 = span2.openEnd - (span2.selfClosing ? 2 : 1);
|
|
6684
|
+
this.add(at2, at2, attribute7);
|
|
6685
|
+
}
|
|
6686
|
+
remove(element2) {
|
|
6687
|
+
const span2 = this.span(element2);
|
|
6688
|
+
this.add(span2.start, span2.end, "");
|
|
6689
|
+
}
|
|
6690
|
+
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
6691
|
+
insert(markup, before) {
|
|
6692
|
+
if (before) {
|
|
6693
|
+
const at2 = this.span(before).start;
|
|
6694
|
+
this.add(at2, at2, markup);
|
|
6695
|
+
} else this.appended.push(markup);
|
|
6696
|
+
}
|
|
6697
|
+
toString() {
|
|
6698
|
+
const edits = [...this.edits];
|
|
6699
|
+
if (this.appended.length) {
|
|
6700
|
+
const text2 = this.appended.join("");
|
|
6701
|
+
const root = this.root;
|
|
6702
|
+
if (root.selfClosing) {
|
|
6703
|
+
const name = qualifiedName(this.xml, root);
|
|
6704
|
+
edits.push({
|
|
6705
|
+
start: root.end - 2,
|
|
6706
|
+
end: root.end,
|
|
6707
|
+
text: `>${text2}</${name}>`,
|
|
6708
|
+
seq: this.seq
|
|
6709
|
+
});
|
|
6710
|
+
} else edits.push({ start: root.closeStart, end: root.closeStart, text: text2, seq: this.seq });
|
|
6711
|
+
}
|
|
6712
|
+
edits.sort((a, b) => a.start - b.start || a.end - a.start - (b.end - b.start) || a.seq - b.seq);
|
|
6713
|
+
let out = "";
|
|
6714
|
+
let at2 = 0;
|
|
6715
|
+
for (const edit of edits) {
|
|
6716
|
+
out += this.xml.slice(at2, edit.start) + edit.text;
|
|
6717
|
+
at2 = Math.max(at2, edit.end);
|
|
6718
|
+
}
|
|
6719
|
+
return out + this.xml.slice(at2);
|
|
6720
|
+
}
|
|
6721
|
+
};
|
|
6722
|
+
}
|
|
6723
|
+
});
|
|
6724
|
+
|
|
6725
|
+
// opc/properties/core.ts
|
|
6726
|
+
function parseCoreProperties(xml) {
|
|
6727
|
+
const out = {};
|
|
6728
|
+
if (!xml) return out;
|
|
6729
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
6730
|
+
for (const [field, prefix] of FIELDS) {
|
|
6731
|
+
const text2 = first(root, field, NS[prefix])?.textContent ?? "";
|
|
6732
|
+
if (text2 !== "") out[field] = text2;
|
|
6733
|
+
}
|
|
6734
|
+
return out;
|
|
6735
|
+
}
|
|
6736
|
+
function writeCoreProperties(props, sourceXml) {
|
|
6737
|
+
const xml = sourceXml ?? EMPTY_CORE;
|
|
6738
|
+
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
6739
|
+
const patch = new PartPatch(xml, root);
|
|
6740
|
+
for (const [field, prefix, isDate] of FIELDS) {
|
|
6741
|
+
const ns = NS[prefix];
|
|
6742
|
+
const value = props[field];
|
|
6743
|
+
const element2 = first(root, field, ns);
|
|
6744
|
+
if (value === void 0 || value === "") {
|
|
6745
|
+
if (element2 && (element2.textContent ?? "") !== "") patch.remove(element2);
|
|
6746
|
+
continue;
|
|
6747
|
+
}
|
|
6748
|
+
if (element2 && element2.textContent === value) continue;
|
|
6749
|
+
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
6750
|
+
if (element2) {
|
|
6751
|
+
if (isDate && !element2.getAttributeNS(XSI, "type")) patch.addAttribute(element2, typed());
|
|
6752
|
+
patch.setContent(element2, escapeText(value));
|
|
6753
|
+
continue;
|
|
6754
|
+
}
|
|
6755
|
+
const name = patch.qualify(ns, field, prefix);
|
|
6756
|
+
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
6757
|
+
}
|
|
6758
|
+
return patch.toString();
|
|
6759
|
+
}
|
|
6760
|
+
var XSI, FIELDS, EMPTY_CORE, formatW3cdtf;
|
|
6761
|
+
var init_core = __esm({
|
|
6762
|
+
"opc/properties/core.ts"() {
|
|
6763
|
+
init_xml2();
|
|
6764
|
+
init_patch();
|
|
6765
|
+
XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
6766
|
+
FIELDS = [
|
|
6767
|
+
["title", "dc", false],
|
|
6768
|
+
["subject", "dc", false],
|
|
6769
|
+
["creator", "dc", false],
|
|
6770
|
+
["keywords", "cp", false],
|
|
6771
|
+
["description", "dc", false],
|
|
6772
|
+
["lastModifiedBy", "cp", false],
|
|
6773
|
+
["created", "dcterms", true],
|
|
6774
|
+
["modified", "dcterms", true],
|
|
6775
|
+
["category", "cp", false],
|
|
6776
|
+
["contentStatus", "cp", false],
|
|
6777
|
+
["revision", "cp", false],
|
|
6778
|
+
["language", "dc", false],
|
|
6779
|
+
["identifier", "dc", false],
|
|
6780
|
+
["lastPrinted", "cp", false],
|
|
6781
|
+
["version", "cp", false]
|
|
6782
|
+
];
|
|
6783
|
+
FIELDS.map(([field]) => field);
|
|
6784
|
+
EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
6785
|
+
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
6786
|
+
formatW3cdtf = (date5) => date5.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
6787
|
+
}
|
|
6788
|
+
});
|
|
6789
|
+
|
|
6790
|
+
// opc/properties/app.ts
|
|
6791
|
+
function namespacesOf(root) {
|
|
6792
|
+
if (root.localName !== "Properties") return void 0;
|
|
6793
|
+
if (root.namespaceURI === NS.extendedProperties) return { app: NS.extendedProperties, vt: NS.vt };
|
|
6794
|
+
if (root.namespaceURI === STRICT_APP_NAMESPACES.extendedProperties)
|
|
6795
|
+
return { app: STRICT_APP_NAMESPACES.extendedProperties, vt: STRICT_APP_NAMESPACES.vt };
|
|
6796
|
+
return void 0;
|
|
6797
|
+
}
|
|
6798
|
+
function vectorItems(element2, vt) {
|
|
6799
|
+
const vector = first(element2, "vector", vt);
|
|
6800
|
+
return vector ? elements(vector) : [];
|
|
6801
|
+
}
|
|
6802
|
+
function readPairs(element2, vt) {
|
|
6803
|
+
const variants = vectorItems(element2, vt).map((variant) => elements(variant)[0]);
|
|
6804
|
+
const out = [];
|
|
6805
|
+
for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
|
|
6806
|
+
const name = variants[i2]?.textContent ?? "";
|
|
6807
|
+
const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
|
|
6808
|
+
out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
|
|
6809
|
+
}
|
|
6810
|
+
return out;
|
|
6811
|
+
}
|
|
6812
|
+
function readField(element2, kind, vt) {
|
|
6813
|
+
const text2 = element2.textContent ?? "";
|
|
6814
|
+
if (kind === "pairs") return readPairs(element2, vt);
|
|
6815
|
+
if (kind === "titles") return vectorItems(element2, vt).map((item2) => item2.textContent ?? "");
|
|
6816
|
+
if (kind === "bool") return text2.trim() === "true" || text2.trim() === "1";
|
|
6817
|
+
if (kind === "int") {
|
|
6818
|
+
const value = Number.parseInt(text2, 10);
|
|
6819
|
+
return Number.isFinite(value) ? value : void 0;
|
|
6820
|
+
}
|
|
6821
|
+
return text2 === "" ? void 0 : text2;
|
|
6822
|
+
}
|
|
6823
|
+
function readKnown(root, ns) {
|
|
6824
|
+
const out = {};
|
|
6825
|
+
for (const [field, local, kind] of FIELDS2) {
|
|
6826
|
+
const element2 = first(root, local, ns.app);
|
|
6827
|
+
if (!element2) continue;
|
|
6828
|
+
const value = readField(element2, kind, ns.vt);
|
|
6829
|
+
if (value !== void 0) out[field] = value;
|
|
6830
|
+
}
|
|
6831
|
+
return out;
|
|
6832
|
+
}
|
|
6833
|
+
function parseAppProperties(xml) {
|
|
6834
|
+
if (!xml) return {};
|
|
6835
|
+
const root = parseXml(xml, { label: "app properties" }).documentElement;
|
|
6836
|
+
const ns = namespacesOf(root);
|
|
6837
|
+
return ns ? readKnown(root, ns) : {};
|
|
6838
|
+
}
|
|
6839
|
+
function content(kind, value, vt) {
|
|
6840
|
+
if (kind === "bool") return value ? "true" : "false";
|
|
6841
|
+
if (kind === "int") return String(Math.trunc(value));
|
|
6842
|
+
if (kind === "text") return escapeText(String(value));
|
|
6843
|
+
const item2 = (local, text2) => `<${vt}:${local}>${escapeText(text2)}</${vt}:${local}>`;
|
|
6844
|
+
const items = kind === "pairs" ? value.flatMap((pair) => [
|
|
6845
|
+
`<${vt}:variant>${item2("lpstr", pair.name)}</${vt}:variant>`,
|
|
6846
|
+
`<${vt}:variant>${item2("i4", String(Math.trunc(pair.count)))}</${vt}:variant>`
|
|
6847
|
+
]) : value.map((title) => item2("lpstr", title));
|
|
6848
|
+
const baseType = kind === "pairs" ? "variant" : "lpstr";
|
|
6849
|
+
return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
|
|
6850
|
+
}
|
|
6851
|
+
function writeAppProperties(props, sourceXml) {
|
|
6852
|
+
const xml = sourceXml ?? EMPTY_APP;
|
|
6853
|
+
const root = parseXml(xml, { label: "app properties" }).documentElement;
|
|
6854
|
+
const ns = namespacesOf(root);
|
|
6855
|
+
if (!ns) throw new Error("app properties root is not an extended-properties element");
|
|
6856
|
+
const patch = new PartPatch(xml, root);
|
|
6857
|
+
const prior = readKnown(root, ns);
|
|
6858
|
+
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
6859
|
+
FIELDS2.forEach(([field, local, kind], index2) => {
|
|
6860
|
+
const value = props[field];
|
|
6861
|
+
const existing = first(root, local, ns.app);
|
|
6862
|
+
if (value === void 0 || kind === "text" && value === "") {
|
|
6863
|
+
if (existing && (existing.textContent ?? "") !== "") patch.remove(existing);
|
|
6864
|
+
return;
|
|
6865
|
+
}
|
|
6866
|
+
if (existing && same(prior[field], value)) return;
|
|
6867
|
+
const vt = kind === "pairs" || kind === "titles" ? patch.prefix(ns.vt, "vt") : "";
|
|
6868
|
+
const body = content(kind, value, vt);
|
|
6869
|
+
if (existing) {
|
|
6870
|
+
patch.setContent(existing, body);
|
|
6871
|
+
return;
|
|
6872
|
+
}
|
|
6873
|
+
const next = FIELDS2.slice(index2 + 1).map(([, name]) => first(root, name, ns.app)).find((node2) => node2 !== void 0);
|
|
6874
|
+
patch.insert(`<${ownPrefix}${local}>${body}</${ownPrefix}${local}>`, next);
|
|
6875
|
+
});
|
|
6876
|
+
return patch.toString();
|
|
6877
|
+
}
|
|
6878
|
+
var FIELDS2, STRICT_APP_NAMESPACES, EMPTY_APP, same;
|
|
6879
|
+
var init_app = __esm({
|
|
6880
|
+
"opc/properties/app.ts"() {
|
|
6881
|
+
init_xml2();
|
|
6882
|
+
init_patch();
|
|
6883
|
+
FIELDS2 = [
|
|
6884
|
+
["template", "Template", "text"],
|
|
6885
|
+
["totalTime", "TotalTime", "int"],
|
|
6886
|
+
["pages", "Pages", "int"],
|
|
6887
|
+
["words", "Words", "int"],
|
|
6888
|
+
["characters", "Characters", "int"],
|
|
6889
|
+
["application", "Application", "text"],
|
|
6890
|
+
["docSecurity", "DocSecurity", "int"],
|
|
6891
|
+
["presentationFormat", "PresentationFormat", "text"],
|
|
6892
|
+
["lines", "Lines", "int"],
|
|
6893
|
+
["paragraphs", "Paragraphs", "int"],
|
|
6894
|
+
["slides", "Slides", "int"],
|
|
6895
|
+
["notes", "Notes", "int"],
|
|
6896
|
+
["hiddenSlides", "HiddenSlides", "int"],
|
|
6897
|
+
["mmClips", "MMClips", "int"],
|
|
6898
|
+
["scaleCrop", "ScaleCrop", "bool"],
|
|
6899
|
+
["headingPairs", "HeadingPairs", "pairs"],
|
|
6900
|
+
["titlesOfParts", "TitlesOfParts", "titles"],
|
|
6901
|
+
["manager", "Manager", "text"],
|
|
6902
|
+
["company", "Company", "text"],
|
|
6903
|
+
["linksUpToDate", "LinksUpToDate", "bool"],
|
|
6904
|
+
["charactersWithSpaces", "CharactersWithSpaces", "int"],
|
|
6905
|
+
["sharedDoc", "SharedDoc", "bool"],
|
|
6906
|
+
["hyperlinkBase", "HyperlinkBase", "text"],
|
|
6907
|
+
["hyperlinksChanged", "HyperlinksChanged", "bool"],
|
|
6908
|
+
["appVersion", "AppVersion", "text"]
|
|
6909
|
+
];
|
|
6910
|
+
STRICT_APP_NAMESPACES = {
|
|
6911
|
+
extendedProperties: "http://purl.oclc.org/ooxml/officeDocument/extendedProperties",
|
|
6912
|
+
vt: "http://purl.oclc.org/ooxml/officeDocument/docPropsVTypes"
|
|
6913
|
+
};
|
|
6914
|
+
EMPTY_APP = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
6915
|
+
<Properties xmlns="${NS.extendedProperties}" xmlns:vt="${NS.vt}"/>`;
|
|
6916
|
+
same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
6917
|
+
}
|
|
6918
|
+
});
|
|
6919
|
+
|
|
6920
|
+
// opc/properties/custom.ts
|
|
6921
|
+
function allocateCustomPropertyIds(properties) {
|
|
6922
|
+
const used = /* @__PURE__ */ new Set();
|
|
6923
|
+
const kept = properties.map((property) => {
|
|
6924
|
+
const pid = property.pid;
|
|
6925
|
+
if (pid === void 0 || !Number.isInteger(pid) || pid < 2 || used.has(pid)) return void 0;
|
|
6926
|
+
used.add(pid);
|
|
6927
|
+
return pid;
|
|
6928
|
+
});
|
|
6929
|
+
let next = Math.max(1, ...used) + 1;
|
|
6930
|
+
return kept.map((pid) => pid ?? next++);
|
|
6931
|
+
}
|
|
6932
|
+
function variantXml(property) {
|
|
6933
|
+
switch (property.type) {
|
|
6934
|
+
case "raw":
|
|
6935
|
+
return property.xml;
|
|
6936
|
+
case "lpwstr":
|
|
6937
|
+
return `<vt:lpwstr>${escape(property.value)}</vt:lpwstr>`;
|
|
6938
|
+
case "i4":
|
|
6939
|
+
return `<vt:i4>${Math.trunc(property.value)}</vt:i4>`;
|
|
6940
|
+
case "r8":
|
|
6941
|
+
return `<vt:r8>${String(property.value)}</vt:r8>`;
|
|
6942
|
+
case "bool":
|
|
6943
|
+
return `<vt:bool>${property.value ? "true" : "false"}</vt:bool>`;
|
|
6944
|
+
case "filetime":
|
|
6945
|
+
return `<vt:filetime>${escape(property.value)}</vt:filetime>`;
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
function writeCustomProperties(properties) {
|
|
6949
|
+
const seen = /* @__PURE__ */ new Set();
|
|
6950
|
+
const unique = properties.filter((property) => {
|
|
6951
|
+
const key2 = property.name.toLowerCase();
|
|
6952
|
+
if (!property.name || seen.has(key2)) return false;
|
|
6953
|
+
seen.add(key2);
|
|
6954
|
+
return true;
|
|
6955
|
+
});
|
|
6956
|
+
if (!unique.length) return void 0;
|
|
6957
|
+
const pids = allocateCustomPropertyIds(unique);
|
|
6958
|
+
const body = unique.map((property, index2) => {
|
|
6959
|
+
const link = property.linkTarget ? ` linkTarget="${escape(property.linkTarget, true)}"` : "";
|
|
6960
|
+
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[index2] ?? index2 + 2}" name="${escape(property.name, true)}"${link}>${variantXml(property)}</property>`;
|
|
6961
|
+
}).join("");
|
|
6962
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
6963
|
+
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
6964
|
+
}
|
|
6965
|
+
function parseCustomPropertyTexts(xml) {
|
|
6966
|
+
if (!xml) return [];
|
|
6967
|
+
const root = parseXml(xml, { label: "custom properties" }).documentElement;
|
|
6968
|
+
const out = [];
|
|
6969
|
+
for (const property of children(root, "property", NS.customProperties)) {
|
|
6970
|
+
const name = property.getAttribute("name") ?? "";
|
|
6971
|
+
if (!name) continue;
|
|
6972
|
+
const variant = elements(property)[0];
|
|
6973
|
+
const pid = Number.parseInt(property.getAttribute("pid") ?? "", 10);
|
|
6974
|
+
out.push({
|
|
6975
|
+
name,
|
|
6976
|
+
type: variant && isVt(variant) ? variant.localName : "",
|
|
6977
|
+
text: variant?.textContent ?? "",
|
|
6978
|
+
...Number.isFinite(pid) ? { pid } : {}
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
return out;
|
|
6982
|
+
}
|
|
6983
|
+
function customPropertyFromText(name, type, text2) {
|
|
6984
|
+
switch (type) {
|
|
6985
|
+
case "lpwstr":
|
|
6986
|
+
case "filetime":
|
|
6987
|
+
return { name, type, value: text2 };
|
|
6988
|
+
case "i4": {
|
|
6989
|
+
const value = Number.parseInt(text2, 10);
|
|
6990
|
+
if (INT32.test(text2) && String(value) === text2 && value === (value | 0))
|
|
6991
|
+
return { name, type, value };
|
|
6992
|
+
break;
|
|
6993
|
+
}
|
|
6994
|
+
case "r8": {
|
|
6995
|
+
const value = Number(text2);
|
|
6996
|
+
if (text2.trim() !== "" && String(value) === text2) return { name, type, value };
|
|
6997
|
+
break;
|
|
6998
|
+
}
|
|
6999
|
+
case "bool":
|
|
7000
|
+
if (text2 === "true" || text2 === "false") return { name, type, value: text2 === "true" };
|
|
7001
|
+
break;
|
|
7002
|
+
default:
|
|
7003
|
+
if (!/^[A-Za-z][A-Za-z0-9]*$/.test(type)) return { name, type: "lpwstr", value: text2 };
|
|
7004
|
+
}
|
|
7005
|
+
return { name, type: "raw", xml: `<vt:${type}>${escape(text2)}</vt:${type}>` };
|
|
7006
|
+
}
|
|
7007
|
+
var escape, isVt, INT32;
|
|
7008
|
+
var init_custom = __esm({
|
|
7009
|
+
"opc/properties/custom.ts"() {
|
|
7010
|
+
init_xml2();
|
|
7011
|
+
init_types3();
|
|
7012
|
+
escape = (text2, attribute7 = false) => {
|
|
7013
|
+
const out = text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
7014
|
+
return attribute7 ? out.replace(/"/g, """) : out;
|
|
7015
|
+
};
|
|
7016
|
+
isVt = (element2) => element2.namespaceURI === NS.vt || element2.prefix === "vt";
|
|
7017
|
+
INT32 = /^-?\d+$/;
|
|
7018
|
+
}
|
|
7019
|
+
});
|
|
7020
|
+
|
|
7021
|
+
// opc/properties/title-groups.ts
|
|
7022
|
+
function titleGroups(headingPairs, titlesOfParts) {
|
|
7023
|
+
let offset = 0;
|
|
7024
|
+
return headingPairs.map((pair) => {
|
|
7025
|
+
const count2 = Math.max(0, pair.count);
|
|
7026
|
+
const titles = titlesOfParts.slice(offset, offset + count2);
|
|
7027
|
+
offset += count2;
|
|
7028
|
+
return { name: pair.name, titles };
|
|
7029
|
+
});
|
|
7030
|
+
}
|
|
7031
|
+
function fromTitleGroups(groups) {
|
|
7032
|
+
return {
|
|
7033
|
+
headingPairs: groups.map((group) => ({ name: group.name, count: group.titles.length })),
|
|
7034
|
+
titlesOfParts: groups.flatMap((group) => group.titles)
|
|
7035
|
+
};
|
|
7036
|
+
}
|
|
7037
|
+
function replaceTitleGroup(headingPairs, titlesOfParts, group) {
|
|
7038
|
+
const match = group.match ?? ((name) => name === group.name);
|
|
7039
|
+
const groups = titleGroups(headingPairs, titlesOfParts);
|
|
7040
|
+
const target = groups.find((entry2) => match(entry2.name));
|
|
7041
|
+
if (target) target.titles = [...group.titles];
|
|
7042
|
+
else groups.push({ name: group.name, titles: [...group.titles] });
|
|
7043
|
+
return fromTitleGroups(groups);
|
|
7044
|
+
}
|
|
7045
|
+
var init_title_groups = __esm({
|
|
7046
|
+
"opc/properties/title-groups.ts"() {
|
|
7047
|
+
}
|
|
7048
|
+
});
|
|
7049
|
+
|
|
7050
|
+
// opc/properties/index.ts
|
|
7051
|
+
var init_properties = __esm({
|
|
7052
|
+
"opc/properties/index.ts"() {
|
|
7053
|
+
init_types3();
|
|
7054
|
+
init_core();
|
|
7055
|
+
init_app();
|
|
7056
|
+
init_custom();
|
|
7057
|
+
init_title_groups();
|
|
7058
|
+
}
|
|
7059
|
+
});
|
|
7060
|
+
|
|
7061
|
+
// pptx/core/utils/document-properties-model.ts
|
|
7062
|
+
function toPptxCoreProperties(core) {
|
|
7063
|
+
const result = {};
|
|
7064
|
+
for (const field of CORE_FIELDS) result[field] = trimmed(core[field]);
|
|
7065
|
+
return anyDefined(result) ? result : void 0;
|
|
7066
|
+
}
|
|
7067
|
+
function toPptxAppProperties(app) {
|
|
7068
|
+
const result = {
|
|
7069
|
+
application: trimmed(app.application),
|
|
7070
|
+
appVersion: trimmed(app.appVersion),
|
|
7071
|
+
presentationFormat: trimmed(app.presentationFormat),
|
|
7072
|
+
slides: app.slides,
|
|
7073
|
+
hiddenSlides: app.hiddenSlides,
|
|
7074
|
+
notes: app.notes,
|
|
7075
|
+
totalTime: app.totalTime,
|
|
7076
|
+
words: app.words,
|
|
7077
|
+
paragraphs: app.paragraphs,
|
|
7078
|
+
company: trimmed(app.company),
|
|
7079
|
+
manager: trimmed(app.manager),
|
|
7080
|
+
template: trimmed(app.template),
|
|
7081
|
+
hyperlinkBase: trimmed(app.hyperlinkBase),
|
|
7082
|
+
docSecurity: app.docSecurity,
|
|
7083
|
+
mmClips: app.mmClips,
|
|
7084
|
+
scaleCrop: app.scaleCrop,
|
|
7085
|
+
linksUpToDate: app.linksUpToDate,
|
|
7086
|
+
sharedDoc: app.sharedDoc,
|
|
7087
|
+
hyperlinksChanged: app.hyperlinksChanged
|
|
7088
|
+
};
|
|
7089
|
+
return anyDefined(result) ? result : void 0;
|
|
7090
|
+
}
|
|
7091
|
+
function toPptxCustomProperties(texts) {
|
|
7092
|
+
return texts.flatMap((entry2) => {
|
|
7093
|
+
const name = entry2.name.trim();
|
|
7094
|
+
if (!name) return [];
|
|
7095
|
+
const known = CUSTOM_TYPES.has(entry2.type);
|
|
7096
|
+
return [{ name, value: known ? entry2.text : "", type: known ? entry2.type : "unknown" }];
|
|
7097
|
+
});
|
|
7098
|
+
}
|
|
7099
|
+
function applyCoreOverrides(core, overrides) {
|
|
7100
|
+
const next = { ...core };
|
|
7101
|
+
for (const field of CORE_FIELDS) {
|
|
7102
|
+
const value = overrides?.[field];
|
|
7103
|
+
if (value === void 0) continue;
|
|
7104
|
+
const text2 = String(value).trim();
|
|
7105
|
+
if (text2) next[field] = text2;
|
|
7106
|
+
else delete next[field];
|
|
7107
|
+
}
|
|
7108
|
+
return next;
|
|
7109
|
+
}
|
|
7110
|
+
function applyAppOverrides(app, overrides) {
|
|
7111
|
+
const next = { ...app };
|
|
7112
|
+
for (const field of APP_TEXT_OVERRIDES) {
|
|
7113
|
+
const value = overrides?.[field];
|
|
7114
|
+
if (value === void 0) continue;
|
|
7115
|
+
const text2 = String(value).trim();
|
|
7116
|
+
if (text2) next[field] = text2;
|
|
7117
|
+
else delete next[field];
|
|
7118
|
+
}
|
|
7119
|
+
for (const field of APP_NUMBER_OVERRIDES) {
|
|
7120
|
+
const value = Number(overrides?.[field]);
|
|
7121
|
+
if (overrides?.[field] !== void 0 && Number.isFinite(value)) next[field] = Math.trunc(value);
|
|
7122
|
+
}
|
|
7123
|
+
return next;
|
|
7124
|
+
}
|
|
7125
|
+
function toCustomProperty(entry2) {
|
|
7126
|
+
const type = String(entry2.type || "lpwstr").trim().toLowerCase();
|
|
7127
|
+
return customPropertyFromText(
|
|
7128
|
+
entry2.name,
|
|
7129
|
+
CUSTOM_TYPES.has(type) ? type : "lpwstr",
|
|
7130
|
+
String(entry2.value ?? "")
|
|
7131
|
+
);
|
|
7132
|
+
}
|
|
7133
|
+
var CORE_FIELDS, APP_TEXT_OVERRIDES, APP_NUMBER_OVERRIDES, trimmed, anyDefined, CUSTOM_TYPES;
|
|
7134
|
+
var init_document_properties_model = __esm({
|
|
7135
|
+
"pptx/core/utils/document-properties-model.ts"() {
|
|
7136
|
+
init_properties();
|
|
7137
|
+
CORE_FIELDS = [
|
|
7138
|
+
"title",
|
|
7139
|
+
"subject",
|
|
7140
|
+
"creator",
|
|
7141
|
+
"keywords",
|
|
7142
|
+
"description",
|
|
7143
|
+
"lastModifiedBy",
|
|
7144
|
+
"revision",
|
|
7145
|
+
"created",
|
|
7146
|
+
"modified",
|
|
7147
|
+
"category",
|
|
7148
|
+
"contentStatus"
|
|
7149
|
+
];
|
|
7150
|
+
APP_TEXT_OVERRIDES = [
|
|
7151
|
+
"application",
|
|
7152
|
+
"appVersion",
|
|
7153
|
+
"presentationFormat",
|
|
7154
|
+
"company",
|
|
7155
|
+
"manager",
|
|
7156
|
+
"template"
|
|
7157
|
+
];
|
|
7158
|
+
APP_NUMBER_OVERRIDES = [
|
|
7159
|
+
"slides",
|
|
7160
|
+
"hiddenSlides",
|
|
7161
|
+
"notes",
|
|
7162
|
+
"totalTime",
|
|
7163
|
+
"words",
|
|
7164
|
+
"paragraphs"
|
|
7165
|
+
];
|
|
7166
|
+
trimmed = (value) => value?.trim() || void 0;
|
|
7167
|
+
anyDefined = (record3) => Object.values(record3).some((value) => value !== void 0);
|
|
7168
|
+
CUSTOM_TYPES = /* @__PURE__ */ new Set(["lpwstr", "i4", "bool", "filetime", "r8", "i2", "ui4", "lpstr"]);
|
|
7169
|
+
}
|
|
7170
|
+
});
|
|
7171
|
+
|
|
7172
|
+
// pptx/core/builders/sdk/presentation-app-properties.ts
|
|
7173
|
+
function blankAppXml(slideCount) {
|
|
7174
|
+
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
7175
|
+
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
|
|
7176
|
+
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
|
|
7177
|
+
<Application>pptx-viewer-sdk</Application>
|
|
7178
|
+
<Slides>${slideCount}</Slides>
|
|
7179
|
+
<ScaleCrop>false</ScaleCrop>
|
|
7180
|
+
<LinksUpToDate>false</LinksUpToDate>
|
|
7181
|
+
<SharedDoc>false</SharedDoc>
|
|
7182
|
+
<HyperlinksChanged>false</HyperlinksChanged>
|
|
7183
|
+
<AppVersion>1.0000</AppVersion>
|
|
7184
|
+
</Properties>`;
|
|
7185
|
+
}
|
|
7186
|
+
function validate(input2) {
|
|
7187
|
+
for (const [field, value] of Object.entries(input2)) {
|
|
7188
|
+
if (!INPUT_FIELDS.has(field)) {
|
|
7189
|
+
throw new RangeError(
|
|
7190
|
+
`appProperties.${field} cannot be set when a presentation is created; it takes ${[...INPUT_FIELDS].join(", ")} (counts are computed on save)`
|
|
7191
|
+
);
|
|
7192
|
+
}
|
|
7193
|
+
if (value !== void 0 && typeof value !== "string") {
|
|
7194
|
+
throw new RangeError(`appProperties.${field} must be a string`);
|
|
7195
|
+
}
|
|
7196
|
+
}
|
|
7197
|
+
const version2 = input2.appVersion?.trim();
|
|
7198
|
+
if (version2 && !APP_VERSION.test(version2)) {
|
|
7199
|
+
throw new RangeError(
|
|
7200
|
+
`appProperties.appVersion must be digits, a dot and four digits (e.g. "16.0000"), got "${input2.appVersion}"`
|
|
7201
|
+
);
|
|
7202
|
+
}
|
|
7203
|
+
}
|
|
7204
|
+
function newPresentationAppXml(slideCount, input2) {
|
|
7205
|
+
const xml = blankAppXml(slideCount);
|
|
7206
|
+
if (input2 === void 0) {
|
|
7207
|
+
return xml;
|
|
7208
|
+
}
|
|
7209
|
+
validate(input2);
|
|
7210
|
+
return writeAppProperties(applyAppOverrides(parseAppProperties(xml), input2), xml);
|
|
7211
|
+
}
|
|
7212
|
+
var INPUT_FIELDS, APP_VERSION;
|
|
7213
|
+
var init_presentation_app_properties = __esm({
|
|
7214
|
+
"pptx/core/builders/sdk/presentation-app-properties.ts"() {
|
|
7215
|
+
init_properties();
|
|
7216
|
+
init_document_properties_model();
|
|
7217
|
+
INPUT_FIELDS = /* @__PURE__ */ new Set([
|
|
7218
|
+
"application",
|
|
7219
|
+
"appVersion",
|
|
7220
|
+
"presentationFormat",
|
|
7221
|
+
"company",
|
|
7222
|
+
"manager",
|
|
7223
|
+
"template"
|
|
7224
|
+
]);
|
|
7225
|
+
APP_VERSION = /^\d+\.\d{4}$/u;
|
|
7226
|
+
}
|
|
7227
|
+
});
|
|
7228
|
+
|
|
5485
7229
|
// pptx/core/builders/sdk/standard-layout-placeholders.ts
|
|
5486
7230
|
function standardLayoutPlaceholders(type, width, height) {
|
|
5487
7231
|
if (type === "blank") return [];
|
|
@@ -5806,19 +7550,6 @@ function corePropsXml(title, creator) {
|
|
|
5806
7550
|
<dcterms:modified xsi:type="dcterms:W3CDTF">${now}</dcterms:modified>
|
|
5807
7551
|
</cp:coreProperties>`;
|
|
5808
7552
|
}
|
|
5809
|
-
function appPropsXml(slideCount) {
|
|
5810
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
5811
|
-
<Properties xmlns="http://schemas.openxmlformats.org/officeDocument/2006/extended-properties"
|
|
5812
|
-
xmlns:vt="http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes">
|
|
5813
|
-
<Application>pptx-viewer-sdk</Application>
|
|
5814
|
-
<Slides>${slideCount}</Slides>
|
|
5815
|
-
<ScaleCrop>false</ScaleCrop>
|
|
5816
|
-
<LinksUpToDate>false</LinksUpToDate>
|
|
5817
|
-
<SharedDoc>false</SharedDoc>
|
|
5818
|
-
<HyperlinksChanged>false</HyperlinksChanged>
|
|
5819
|
-
<AppVersion>1.0000</AppVersion>
|
|
5820
|
-
</Properties>`;
|
|
5821
|
-
}
|
|
5822
7553
|
async function buildBlankPresentationArchive(options2) {
|
|
5823
7554
|
const width = options2?.width ?? DEFAULT_WIDTH;
|
|
5824
7555
|
const height = options2?.height ?? DEFAULT_HEIGHT;
|
|
@@ -5860,7 +7591,7 @@ async function buildBlankPresentationArchive(options2) {
|
|
|
5860
7591
|
zip.file("ppt/viewProps.xml", viewPropsXml());
|
|
5861
7592
|
zip.file("ppt/tableStyles.xml", tableStylesXml());
|
|
5862
7593
|
zip.file("docProps/core.xml", corePropsXml(options2?.title, options2?.creator));
|
|
5863
|
-
zip.file("docProps/app.xml",
|
|
7594
|
+
zip.file("docProps/app.xml", newPresentationAppXml(initialSlideCount, options2?.appProperties));
|
|
5864
7595
|
return zip.generateAsync({ type: "arraybuffer" });
|
|
5865
7596
|
}
|
|
5866
7597
|
var DEFAULT_WIDTH, DEFAULT_HEIGHT, DEFAULT_COLORS, DEFAULT_MAJOR_FONT, DEFAULT_MINOR_FONT, STANDARD_LAYOUTS, PresentationBuilder;
|
|
@@ -5870,6 +7601,7 @@ var init_PresentationBuilder = __esm({
|
|
|
5870
7601
|
init_PptxHandler();
|
|
5871
7602
|
init_SlideBuilder();
|
|
5872
7603
|
init_layout_operations();
|
|
7604
|
+
init_presentation_app_properties();
|
|
5873
7605
|
init_standard_layout_placeholders();
|
|
5874
7606
|
DEFAULT_WIDTH = 12192e3;
|
|
5875
7607
|
DEFAULT_HEIGHT = 6858e3;
|
|
@@ -18324,7 +20056,7 @@ function child(parent, name) {
|
|
|
18324
20056
|
const value = key2 ? parent[key2] : void 0;
|
|
18325
20057
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
18326
20058
|
}
|
|
18327
|
-
function
|
|
20059
|
+
function children2(parent, name) {
|
|
18328
20060
|
const key2 = Object.keys(parent).find((candidate) => localName3(candidate) === name);
|
|
18329
20061
|
const value = key2 ? parent[key2] : void 0;
|
|
18330
20062
|
return (Array.isArray(value) ? value : value ? [value] : []).filter(
|
|
@@ -18354,7 +20086,7 @@ function parseDrawingLineDash(lineNode, normalizePreset) {
|
|
|
18354
20086
|
if (!custom2) {
|
|
18355
20087
|
return {};
|
|
18356
20088
|
}
|
|
18357
|
-
const rawSegments =
|
|
20089
|
+
const rawSegments = children2(custom2, "ds");
|
|
18358
20090
|
const valid = [];
|
|
18359
20091
|
for (const node2 of rawSegments) {
|
|
18360
20092
|
const dash = nonNegativeInt32(attribute(node2, "d"));
|
|
@@ -20591,220 +22323,6 @@ var init_chart_xlsx_cellref = __esm({
|
|
|
20591
22323
|
}
|
|
20592
22324
|
});
|
|
20593
22325
|
|
|
20594
|
-
// xml/namespaces.ts
|
|
20595
|
-
var NS;
|
|
20596
|
-
var init_namespaces = __esm({
|
|
20597
|
-
"xml/namespaces.ts"() {
|
|
20598
|
-
NS = {
|
|
20599
|
-
/** WordprocessingML main. */
|
|
20600
|
-
w: "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
|
|
20601
|
-
/** PresentationML main. */
|
|
20602
|
-
p: "http://schemas.openxmlformats.org/presentationml/2006/main",
|
|
20603
|
-
/** SpreadsheetML main. */
|
|
20604
|
-
x: "http://schemas.openxmlformats.org/spreadsheetml/2006/main",
|
|
20605
|
-
/** DrawingML main. */
|
|
20606
|
-
a: "http://schemas.openxmlformats.org/drawingml/2006/main",
|
|
20607
|
-
/** DrawingML chart. */
|
|
20608
|
-
c: "http://schemas.openxmlformats.org/drawingml/2006/chart",
|
|
20609
|
-
/** Office 2016 extended charts (waterfall, histogram, funnel...; `cx:chartSpace`). */
|
|
20610
|
-
cx: "http://schemas.microsoft.com/office/drawing/2014/chartex",
|
|
20611
|
-
/** Office 2010 chart extensions, including built-in modern chart styles. */
|
|
20612
|
-
c14: "http://schemas.microsoft.com/office/drawing/2007/8/2/chart",
|
|
20613
|
-
/** DrawingML diagram (SmartArt) main. */
|
|
20614
|
-
dgm: "http://schemas.openxmlformats.org/drawingml/2006/diagram",
|
|
20615
|
-
/** Office 2007+ diagram drawing (`dsp`). */
|
|
20616
|
-
dsp: "http://schemas.microsoft.com/office/drawing/2008/diagram",
|
|
20617
|
-
/** DrawingML Word drawing (`wp:inline`, `wp:anchor`). */
|
|
20618
|
-
wp: "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
|
|
20619
|
-
/** DrawingML picture. */
|
|
20620
|
-
pic: "http://schemas.openxmlformats.org/drawingml/2006/picture",
|
|
20621
|
-
/** Word 2010 shapes (`wps`). */
|
|
20622
|
-
wps: "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
|
|
20623
|
-
/** Relationships (`r:id`, `r:embed`). */
|
|
20624
|
-
r: "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
|
|
20625
|
-
/** Markup compatibility (`mc:AlternateContent`). */
|
|
20626
|
-
mc: "http://schemas.openxmlformats.org/markup-compatibility/2006",
|
|
20627
|
-
/** OPC relationships part. */
|
|
20628
|
-
rels: "http://schemas.openxmlformats.org/package/2006/relationships",
|
|
20629
|
-
/** OPC content types part. */
|
|
20630
|
-
contentTypes: "http://schemas.openxmlformats.org/package/2006/content-types",
|
|
20631
|
-
/** Office Math. */
|
|
20632
|
-
m: "http://schemas.openxmlformats.org/officeDocument/2006/math",
|
|
20633
|
-
/** Core properties. */
|
|
20634
|
-
cp: "http://schemas.openxmlformats.org/package/2006/metadata/core-properties",
|
|
20635
|
-
/** Dublin Core elements. */
|
|
20636
|
-
dc: "http://purl.org/dc/elements/1.1/",
|
|
20637
|
-
/** Legacy VML. */
|
|
20638
|
-
v: "urn:schemas-microsoft-com:vml",
|
|
20639
|
-
/** Office VML extensions. */
|
|
20640
|
-
o: "urn:schemas-microsoft-com:office:office",
|
|
20641
|
-
/** Word VML extensions. */
|
|
20642
|
-
w10: "urn:schemas-microsoft-com:office:word",
|
|
20643
|
-
/** SpreadsheetML drawing (`xdr:wsDr`, cell anchors). */
|
|
20644
|
-
xdr: "http://schemas.openxmlformats.org/drawingml/2006/spreadsheetDrawing",
|
|
20645
|
-
/** SpreadsheetML 2009 extensions (`x14:conditionalFormatting`, `x14:dataBar`). */
|
|
20646
|
-
x14: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/main",
|
|
20647
|
-
/** SpreadsheetML 2009 attribute extensions (`x14ac:dyDescent`). */
|
|
20648
|
-
x14ac: "http://schemas.microsoft.com/office/spreadsheetml/2009/9/ac",
|
|
20649
|
-
/** SpreadsheetML revision ids (`xr:uid`). */
|
|
20650
|
-
xr: "http://schemas.microsoft.com/office/spreadsheetml/2014/revision",
|
|
20651
|
-
/** Excel threaded comments and persons. */
|
|
20652
|
-
tc: "http://schemas.microsoft.com/office/spreadsheetml/2018/threadedcomments",
|
|
20653
|
-
/** Legacy VML Excel client data (`x:ClientData`). */
|
|
20654
|
-
xv: "urn:schemas-microsoft-com:office:excel",
|
|
20655
|
-
/** Extended (app) properties. */
|
|
20656
|
-
extendedProperties: "http://schemas.openxmlformats.org/officeDocument/2006/extended-properties",
|
|
20657
|
-
/** Dublin Core terms (`dcterms:created`). */
|
|
20658
|
-
dcterms: "http://purl.org/dc/terms/",
|
|
20659
|
-
/** Custom document properties (`docProps/custom.xml`). */
|
|
20660
|
-
customProperties: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
|
20661
|
-
/** Document property variant types (`vt:lpwstr`, `vt:vector`). */
|
|
20662
|
-
vt: "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
20663
|
-
/** XML itself (`xml:space`). */
|
|
20664
|
-
xml: "http://www.w3.org/XML/1998/namespace"
|
|
20665
|
-
};
|
|
20666
|
-
}
|
|
20667
|
-
});
|
|
20668
|
-
function checkXmlLimits(xml, label2, limits = {}) {
|
|
20669
|
-
const maxDepth2 = limits.maxDepth ?? DEFAULT_XML_LIMITS.maxDepth;
|
|
20670
|
-
const maxNodes = limits.maxNodes ?? DEFAULT_XML_LIMITS.maxNodes;
|
|
20671
|
-
let depth = 0;
|
|
20672
|
-
let nodes = 0;
|
|
20673
|
-
let at2 = xml.indexOf("<");
|
|
20674
|
-
while (at2 !== -1) {
|
|
20675
|
-
const skip = MARKUP_SKIPS.find(([open2]) => xml.startsWith(open2, at2));
|
|
20676
|
-
if (skip) {
|
|
20677
|
-
const end = xml.indexOf(skip[1], at2 + skip[0].length);
|
|
20678
|
-
if (end === -1) return;
|
|
20679
|
-
at2 = xml.indexOf("<", end + skip[1].length);
|
|
20680
|
-
continue;
|
|
20681
|
-
}
|
|
20682
|
-
TAG_RE.lastIndex = at2;
|
|
20683
|
-
const match = TAG_RE.exec(xml);
|
|
20684
|
-
if (!match) {
|
|
20685
|
-
at2 = xml.indexOf("<", at2 + 1);
|
|
20686
|
-
continue;
|
|
20687
|
-
}
|
|
20688
|
-
const [, closing, , selfClosing] = match;
|
|
20689
|
-
at2 = xml.indexOf("<", at2 + match[0].length);
|
|
20690
|
-
if (closing) {
|
|
20691
|
-
depth--;
|
|
20692
|
-
continue;
|
|
20693
|
-
}
|
|
20694
|
-
nodes++;
|
|
20695
|
-
if (nodes > maxNodes)
|
|
20696
|
-
throw new XmlLimitError(
|
|
20697
|
-
`${label2} XML exceeds the limit of ${maxNodes} elements`,
|
|
20698
|
-
"maxNodes",
|
|
20699
|
-
maxNodes
|
|
20700
|
-
);
|
|
20701
|
-
if (!selfClosing && ++depth > maxDepth2)
|
|
20702
|
-
throw new XmlLimitError(
|
|
20703
|
-
`${label2} XML exceeds the nesting depth limit of ${maxDepth2}`,
|
|
20704
|
-
"maxDepth",
|
|
20705
|
-
maxDepth2
|
|
20706
|
-
);
|
|
20707
|
-
}
|
|
20708
|
-
}
|
|
20709
|
-
function parseXml(xml, options2 = {}) {
|
|
20710
|
-
const label2 = options2.label ?? "OOXML";
|
|
20711
|
-
if (/<!DOCTYPE|<!ENTITY/i.test(xml))
|
|
20712
|
-
throw new Error(`${label2} XML with DTD or entity declarations is not supported`);
|
|
20713
|
-
checkXmlLimits(xml, label2, options2.limits);
|
|
20714
|
-
let parseError = "";
|
|
20715
|
-
let parsed;
|
|
20716
|
-
try {
|
|
20717
|
-
parsed = new xmldom.DOMParser({
|
|
20718
|
-
onError: (level2, message) => {
|
|
20719
|
-
if (level2 !== "warning" || options2.warningsAsErrors) parseError = message;
|
|
20720
|
-
}
|
|
20721
|
-
}).parseFromString(xml, "application/xml");
|
|
20722
|
-
} catch (error62) {
|
|
20723
|
-
throw new Error(
|
|
20724
|
-
`Invalid ${label2} XML: ${error62 instanceof Error ? error62.message : String(error62)}`,
|
|
20725
|
-
{ cause: error62 }
|
|
20726
|
-
);
|
|
20727
|
-
}
|
|
20728
|
-
if (parseError || !parsed.documentElement)
|
|
20729
|
-
throw new Error(`Invalid ${label2} XML: ${parseError || "missing root element"}`);
|
|
20730
|
-
if (CRLF_DECLARATION.test(xml)) crlfDeclarations.add(parsed);
|
|
20731
|
-
return parsed;
|
|
20732
|
-
}
|
|
20733
|
-
function named(element2, local, ns, lenient = true) {
|
|
20734
|
-
if (!element2 || element2.localName !== local) return false;
|
|
20735
|
-
return element2.namespaceURI === ns || lenient && !element2.namespaceURI;
|
|
20736
|
-
}
|
|
20737
|
-
function attr(element2, local, ns, prefix) {
|
|
20738
|
-
return element2?.getAttributeNS(ns, local) ?? element2?.getAttribute(`${prefix}:${local}`) ?? void 0;
|
|
20739
|
-
}
|
|
20740
|
-
var DEFAULT_XML_LIMITS, XmlLimitError, TAG_RE, MARKUP_SKIPS, CRLF_DECLARATION, crlfDeclarations, buildXml, isElement, elements, children2, first, relAttr;
|
|
20741
|
-
var init_xml = __esm({
|
|
20742
|
-
"xml/xml.ts"() {
|
|
20743
|
-
init_namespaces();
|
|
20744
|
-
DEFAULT_XML_LIMITS = {
|
|
20745
|
-
maxDepth: 512,
|
|
20746
|
-
maxNodes: 5e6
|
|
20747
|
-
};
|
|
20748
|
-
XmlLimitError = class extends Error {
|
|
20749
|
-
code = "xml-limit";
|
|
20750
|
-
/** The limit that was exceeded. */
|
|
20751
|
-
limit;
|
|
20752
|
-
/** Its value: the largest depth or element count allowed. */
|
|
20753
|
-
maximum;
|
|
20754
|
-
constructor(message, limit, maximum) {
|
|
20755
|
-
super(message);
|
|
20756
|
-
this.name = "XmlLimitError";
|
|
20757
|
-
this.limit = limit;
|
|
20758
|
-
this.maximum = maximum;
|
|
20759
|
-
}
|
|
20760
|
-
};
|
|
20761
|
-
TAG_RE = /<(\/?)([^\s\/><]+)(?:\s+[^\s=\/><]+\s*=\s*(?:"[^"<]*"|'[^'<]*'))*\s*(\/?)>/y;
|
|
20762
|
-
MARKUP_SKIPS = [
|
|
20763
|
-
["<!--", "-->"],
|
|
20764
|
-
["<![CDATA[", "]]>"],
|
|
20765
|
-
["<?", "?>"]
|
|
20766
|
-
];
|
|
20767
|
-
CRLF_DECLARATION = /^<\?xml[^>]*\?>\r\n/;
|
|
20768
|
-
crlfDeclarations = /* @__PURE__ */ new WeakSet();
|
|
20769
|
-
buildXml = (node2) => {
|
|
20770
|
-
const xml = new xmldom.XMLSerializer().serializeToString(node2);
|
|
20771
|
-
return crlfDeclarations.has(node2) ? xml.replace(/^(<\?xml[^>]*\?>)\n/, "$1\r\n") : xml;
|
|
20772
|
-
};
|
|
20773
|
-
isElement = (node2) => node2.nodeType === 1;
|
|
20774
|
-
elements = (parent) => Array.from(parent.childNodes).filter(isElement);
|
|
20775
|
-
children2 = (parent, local, ns, lenient = true) => elements(parent).filter((element2) => named(element2, local, ns, lenient));
|
|
20776
|
-
first = (parent, local, ns, lenient = true) => parent ? children2(parent, local, ns, lenient)[0] : void 0;
|
|
20777
|
-
relAttr = (element2, local) => attr(element2, local, NS.r, "r");
|
|
20778
|
-
}
|
|
20779
|
-
});
|
|
20780
|
-
|
|
20781
|
-
// xml/merge-three-way.ts
|
|
20782
|
-
var init_merge_three_way = __esm({
|
|
20783
|
-
"xml/merge-three-way.ts"() {
|
|
20784
|
-
}
|
|
20785
|
-
});
|
|
20786
|
-
|
|
20787
|
-
// xml/lite.ts
|
|
20788
|
-
var init_lite = __esm({
|
|
20789
|
-
"xml/lite.ts"() {
|
|
20790
|
-
}
|
|
20791
|
-
});
|
|
20792
|
-
var init_xpath = __esm({
|
|
20793
|
-
"xml/xpath.ts"() {
|
|
20794
|
-
}
|
|
20795
|
-
});
|
|
20796
|
-
|
|
20797
|
-
// xml/index.ts
|
|
20798
|
-
var init_xml2 = __esm({
|
|
20799
|
-
"xml/index.ts"() {
|
|
20800
|
-
init_namespaces();
|
|
20801
|
-
init_xml();
|
|
20802
|
-
init_merge_three_way();
|
|
20803
|
-
init_lite();
|
|
20804
|
-
init_xpath();
|
|
20805
|
-
}
|
|
20806
|
-
});
|
|
20807
|
-
|
|
20808
22326
|
// chart/workbook/sheet-cells.ts
|
|
20809
22327
|
function worksheetData(doc) {
|
|
20810
22328
|
const root = doc.documentElement;
|
|
@@ -27170,10 +28688,10 @@ var init_hier_hang = __esm({
|
|
|
27170
28688
|
});
|
|
27171
28689
|
|
|
27172
28690
|
// diagram/engine/axis.ts
|
|
27173
|
-
function
|
|
28691
|
+
function descendants2(point2, out) {
|
|
27174
28692
|
for (const child33 of point2.children) {
|
|
27175
28693
|
out.push(child33);
|
|
27176
|
-
|
|
28694
|
+
descendants2(child33, out);
|
|
27177
28695
|
}
|
|
27178
28696
|
}
|
|
27179
28697
|
function rootOf(point2) {
|
|
@@ -27185,7 +28703,7 @@ function rootOf(point2) {
|
|
|
27185
28703
|
}
|
|
27186
28704
|
function documentOrder(point2) {
|
|
27187
28705
|
const all = [rootOf(point2)];
|
|
27188
|
-
|
|
28706
|
+
descendants2(all[0], all);
|
|
27189
28707
|
return all;
|
|
27190
28708
|
}
|
|
27191
28709
|
function axisPoints(point2, axis) {
|
|
@@ -27196,12 +28714,12 @@ function axisPoints(point2, axis) {
|
|
|
27196
28714
|
return [...point2.children];
|
|
27197
28715
|
case "des": {
|
|
27198
28716
|
const out = [];
|
|
27199
|
-
|
|
28717
|
+
descendants2(point2, out);
|
|
27200
28718
|
return out;
|
|
27201
28719
|
}
|
|
27202
28720
|
case "desOrSelf": {
|
|
27203
28721
|
const out = [point2];
|
|
27204
|
-
|
|
28722
|
+
descendants2(point2, out);
|
|
27205
28723
|
return out;
|
|
27206
28724
|
}
|
|
27207
28725
|
case "par":
|
|
@@ -29106,7 +30624,7 @@ function parseAttributes(source2) {
|
|
|
29106
30624
|
}
|
|
29107
30625
|
return attrs4;
|
|
29108
30626
|
}
|
|
29109
|
-
function
|
|
30627
|
+
function tagEnd2(xml, from) {
|
|
29110
30628
|
let quote = "";
|
|
29111
30629
|
for (let i2 = from; i2 < xml.length; i2++) {
|
|
29112
30630
|
const ch = xml[i2];
|
|
@@ -29137,7 +30655,7 @@ function parseOrderedXml(xml) {
|
|
|
29137
30655
|
i2 = close < 0 ? -1 : xml.indexOf("<", close + 3);
|
|
29138
30656
|
continue;
|
|
29139
30657
|
}
|
|
29140
|
-
const end =
|
|
30658
|
+
const end = tagEnd2(xml, i2 + 1);
|
|
29141
30659
|
if (end < 0) {
|
|
29142
30660
|
break;
|
|
29143
30661
|
}
|
|
@@ -31639,7 +33157,7 @@ var init_node_text_projection = __esm({
|
|
|
31639
33157
|
});
|
|
31640
33158
|
|
|
31641
33159
|
// pptx/core/color/index.ts
|
|
31642
|
-
var
|
|
33160
|
+
var init_color2 = __esm({
|
|
31643
33161
|
"pptx/core/color/index.ts"() {
|
|
31644
33162
|
init_color_primitives();
|
|
31645
33163
|
init_color_transforms();
|
|
@@ -31887,7 +33405,7 @@ function parseBulletInfo(pPr, paragraphIndex = 0) {
|
|
|
31887
33405
|
var EMU_PER_PX3, ALIGN_MAP, SINGLE_LINE_HEIGHT_FACTOR;
|
|
31888
33406
|
var init_paragraph_properties_parser = __esm({
|
|
31889
33407
|
"pptx/core/utils/paragraph-properties-parser.ts"() {
|
|
31890
|
-
|
|
33408
|
+
init_color2();
|
|
31891
33409
|
init_xml_access();
|
|
31892
33410
|
init_tab_stops();
|
|
31893
33411
|
EMU_PER_PX3 = 9525;
|
|
@@ -42573,7 +44091,7 @@ var init_smartart_decompose = __esm({
|
|
|
42573
44091
|
});
|
|
42574
44092
|
|
|
42575
44093
|
// diagram/types.ts
|
|
42576
|
-
var
|
|
44094
|
+
var init_types4 = __esm({
|
|
42577
44095
|
"diagram/types.ts"() {
|
|
42578
44096
|
}
|
|
42579
44097
|
});
|
|
@@ -42786,347 +44304,6 @@ var init_hierarchy = __esm({
|
|
|
42786
44304
|
}
|
|
42787
44305
|
});
|
|
42788
44306
|
|
|
42789
|
-
// color/contrast.ts
|
|
42790
|
-
var init_contrast = __esm({
|
|
42791
|
-
"color/contrast.ts"() {
|
|
42792
|
-
}
|
|
42793
|
-
});
|
|
42794
|
-
|
|
42795
|
-
// color/unit-rgb.ts
|
|
42796
|
-
var init_unit_rgb = __esm({
|
|
42797
|
-
"color/unit-rgb.ts"() {
|
|
42798
|
-
}
|
|
42799
|
-
});
|
|
42800
|
-
|
|
42801
|
-
// color/sigma-gradient-stops.ts
|
|
42802
|
-
var init_sigma_gradient_stops = __esm({
|
|
42803
|
-
"color/sigma-gradient-stops.ts"() {
|
|
42804
|
-
}
|
|
42805
|
-
});
|
|
42806
|
-
|
|
42807
|
-
// color/hex-rgb.ts
|
|
42808
|
-
var init_hex_rgb = __esm({
|
|
42809
|
-
"color/hex-rgb.ts"() {
|
|
42810
|
-
}
|
|
42811
|
-
});
|
|
42812
|
-
|
|
42813
|
-
// color/theme-palette.ts
|
|
42814
|
-
var init_theme_palette = __esm({
|
|
42815
|
-
"color/theme-palette.ts"() {
|
|
42816
|
-
}
|
|
42817
|
-
});
|
|
42818
|
-
|
|
42819
|
-
// color/straight-alpha-stops.ts
|
|
42820
|
-
var init_straight_alpha_stops = __esm({
|
|
42821
|
-
"color/straight-alpha-stops.ts"() {
|
|
42822
|
-
}
|
|
42823
|
-
});
|
|
42824
|
-
|
|
42825
|
-
// color/office-gradient-stops.ts
|
|
42826
|
-
var init_office_gradient_stops = __esm({
|
|
42827
|
-
"color/office-gradient-stops.ts"() {
|
|
42828
|
-
}
|
|
42829
|
-
});
|
|
42830
|
-
|
|
42831
|
-
// color/index.ts
|
|
42832
|
-
var init_color2 = __esm({
|
|
42833
|
-
"color/index.ts"() {
|
|
42834
|
-
init_color_primitives();
|
|
42835
|
-
init_color_linear();
|
|
42836
|
-
init_contrast();
|
|
42837
|
-
init_unit_rgb();
|
|
42838
|
-
init_sigma_gradient_stops();
|
|
42839
|
-
init_hex_rgb();
|
|
42840
|
-
init_theme_palette();
|
|
42841
|
-
init_straight_alpha_stops();
|
|
42842
|
-
init_office_gradient_stops();
|
|
42843
|
-
}
|
|
42844
|
-
});
|
|
42845
|
-
|
|
42846
|
-
// drawingml/dom.ts
|
|
42847
|
-
function attributeReader(element2) {
|
|
42848
|
-
return (name) => {
|
|
42849
|
-
if (!element2) return void 0;
|
|
42850
|
-
const direct = element2.getAttribute(name);
|
|
42851
|
-
if (direct !== null) return direct;
|
|
42852
|
-
const attributes3 = element2.attributes;
|
|
42853
|
-
for (let index2 = 0; index2 < attributes3.length; index2++) {
|
|
42854
|
-
const candidate = attributes3.item(index2);
|
|
42855
|
-
if (candidate && candidate.localName === name) return candidate.value;
|
|
42856
|
-
}
|
|
42857
|
-
return void 0;
|
|
42858
|
-
};
|
|
42859
|
-
}
|
|
42860
|
-
function stringAttribute(element2, name) {
|
|
42861
|
-
const value = attributeReader(element2)(name)?.trim();
|
|
42862
|
-
return value ? value : void 0;
|
|
42863
|
-
}
|
|
42864
|
-
function integerAttribute(element2, name) {
|
|
42865
|
-
const parsed = Number.parseInt(attributeReader(element2)(name) ?? "", 10);
|
|
42866
|
-
return Number.isFinite(parsed) ? parsed : void 0;
|
|
42867
|
-
}
|
|
42868
|
-
function booleanAttribute(element2, name) {
|
|
42869
|
-
const value = attributeReader(element2)(name)?.trim().toLowerCase();
|
|
42870
|
-
if (value === "1" || value === "true") return true;
|
|
42871
|
-
if (value === "0" || value === "false") return false;
|
|
42872
|
-
return void 0;
|
|
42873
|
-
}
|
|
42874
|
-
function descendants2(root, local) {
|
|
42875
|
-
const result = [];
|
|
42876
|
-
const visit2 = (node2) => {
|
|
42877
|
-
for (const child33 of Array.from(node2.childNodes)) {
|
|
42878
|
-
if (!isElement(child33)) continue;
|
|
42879
|
-
if (child33.localName === local) result.push(child33);
|
|
42880
|
-
visit2(child33);
|
|
42881
|
-
}
|
|
42882
|
-
};
|
|
42883
|
-
visit2(root);
|
|
42884
|
-
return result;
|
|
42885
|
-
}
|
|
42886
|
-
var init_dom = __esm({
|
|
42887
|
-
"drawingml/dom.ts"() {
|
|
42888
|
-
init_xml2();
|
|
42889
|
-
}
|
|
42890
|
-
});
|
|
42891
|
-
|
|
42892
|
-
// drawingml/ordered-color-transforms.ts
|
|
42893
|
-
function orderedColorTransforms(channels, transforms) {
|
|
42894
|
-
let { r, g: g3, b } = channels;
|
|
42895
|
-
let alpha = 1;
|
|
42896
|
-
const wrap2 = (value) => (value % 360 + 360) % 360;
|
|
42897
|
-
for (const transform8 of transforms) {
|
|
42898
|
-
const { name, value } = transform8;
|
|
42899
|
-
const fraction = parseDrawingFraction(value);
|
|
42900
|
-
if (name === "alpha" && fraction !== void 0) alpha = clampUnitInterval(fraction);
|
|
42901
|
-
else if (name === "alphaMod" && fraction !== void 0)
|
|
42902
|
-
alpha = clampUnitInterval(alpha * fraction);
|
|
42903
|
-
else if (name === "alphaOff" && fraction !== void 0)
|
|
42904
|
-
alpha = clampUnitInterval(alpha + fraction);
|
|
42905
|
-
else if (name === "inv") [r, g3, b] = [255 - r, 255 - g3, 255 - b];
|
|
42906
|
-
else if (name === "gray") r = g3 = b = 0.299 * r + 0.587 * g3 + 0.114 * b;
|
|
42907
|
-
else if ((name === "shade" || name === "tint") && fraction !== void 0) {
|
|
42908
|
-
const mix = (channel) => linearToSrgb255(
|
|
42909
|
-
name === "shade" ? srgb255ToLinear(channel) * fraction : 1 - (1 - srgb255ToLinear(channel)) * fraction
|
|
42910
|
-
);
|
|
42911
|
-
[r, g3, b] = [mix(r), mix(g3), mix(b)];
|
|
42912
|
-
} else {
|
|
42913
|
-
const hsl = rgbToHsl(r, g3, b);
|
|
42914
|
-
if (name === "comp") hsl.h = wrap2(hsl.h + 180);
|
|
42915
|
-
else if (name === "hue") {
|
|
42916
|
-
const hue = parseDrawingHueDegrees(value);
|
|
42917
|
-
if (hue !== void 0) hsl.h = wrap2(hue);
|
|
42918
|
-
} else if (name === "hueOff") {
|
|
42919
|
-
const hue = parseDrawingHueDegrees(value);
|
|
42920
|
-
if (hue !== void 0) hsl.h = wrap2(hsl.h + hue);
|
|
42921
|
-
} else if (name === "hueMod" && fraction !== void 0) hsl.h = wrap2(hsl.h * fraction);
|
|
42922
|
-
else if (name === "sat" && fraction !== void 0) hsl.s = clampUnitInterval(fraction);
|
|
42923
|
-
else if (name === "satMod" && fraction !== void 0) hsl.s *= fraction;
|
|
42924
|
-
else if (name === "satOff" && fraction !== void 0)
|
|
42925
|
-
hsl.s = clampUnitInterval(hsl.s + fraction);
|
|
42926
|
-
else if (name === "lum" && fraction !== void 0) hsl.l = clampUnitInterval(fraction);
|
|
42927
|
-
else if (name === "lumMod" && fraction !== void 0)
|
|
42928
|
-
hsl.l = clampUnitInterval(hsl.l * fraction);
|
|
42929
|
-
else if (name === "lumOff" && fraction !== void 0)
|
|
42930
|
-
hsl.l = clampUnitInterval(hsl.l + fraction);
|
|
42931
|
-
else continue;
|
|
42932
|
-
({ r, g: g3, b } = hslToRgb(hsl.h, hsl.s, hsl.l, (channel) => channel, {
|
|
42933
|
-
clampSaturation: false
|
|
42934
|
-
}));
|
|
42935
|
-
}
|
|
42936
|
-
}
|
|
42937
|
-
return { r, g: g3, b, alpha };
|
|
42938
|
-
}
|
|
42939
|
-
var init_ordered_color_transforms = __esm({
|
|
42940
|
-
"drawingml/ordered-color-transforms.ts"() {
|
|
42941
|
-
init_color2();
|
|
42942
|
-
init_color_linear();
|
|
42943
|
-
}
|
|
42944
|
-
});
|
|
42945
|
-
|
|
42946
|
-
// drawingml/drawing-color.ts
|
|
42947
|
-
function colorValue(kind, element2) {
|
|
42948
|
-
const attribute7 = (name) => element2.getAttribute(name) ?? "";
|
|
42949
|
-
if (kind === "scrgb") return `${attribute7("r")},${attribute7("g")},${attribute7("b")}`;
|
|
42950
|
-
if (kind === "hsl") return `${attribute7("hue")},${attribute7("sat")},${attribute7("lum")}`;
|
|
42951
|
-
return attribute7("val");
|
|
42952
|
-
}
|
|
42953
|
-
function parseDrawingColorIn(container2) {
|
|
42954
|
-
if (!container2) return void 0;
|
|
42955
|
-
for (const element2 of elements(container2)) {
|
|
42956
|
-
const kind = COLOR_ELEMENTS[element2.localName];
|
|
42957
|
-
if (!kind || element2.namespaceURI && element2.namespaceURI !== NS.a) continue;
|
|
42958
|
-
return parseDrawingColor(element2);
|
|
42959
|
-
}
|
|
42960
|
-
return void 0;
|
|
42961
|
-
}
|
|
42962
|
-
function parseDrawingColor(element2) {
|
|
42963
|
-
const kind = COLOR_ELEMENTS[element2.localName];
|
|
42964
|
-
if (!kind) return void 0;
|
|
42965
|
-
const color3 = {
|
|
42966
|
-
kind,
|
|
42967
|
-
value: colorValue(kind, element2),
|
|
42968
|
-
transforms: elements(element2).map((child33) => ({
|
|
42969
|
-
name: child33.localName,
|
|
42970
|
-
value: child33.getAttribute("val") ?? ""
|
|
42971
|
-
}))
|
|
42972
|
-
};
|
|
42973
|
-
const fallback = kind === "system" ? element2.getAttribute("lastClr") : null;
|
|
42974
|
-
if (fallback) color3.fallback = fallback;
|
|
42975
|
-
return color3;
|
|
42976
|
-
}
|
|
42977
|
-
function parseDrawingColorList(container2) {
|
|
42978
|
-
if (!container2) return [];
|
|
42979
|
-
return elements(container2).flatMap((element2) => {
|
|
42980
|
-
const color3 = parseDrawingColor(element2);
|
|
42981
|
-
return color3 ? [color3] : [];
|
|
42982
|
-
});
|
|
42983
|
-
}
|
|
42984
|
-
function baseHex(color3, theme) {
|
|
42985
|
-
switch (color3.kind) {
|
|
42986
|
-
case "srgb":
|
|
42987
|
-
return /^[0-9a-f]{6}$/i.test(color3.value) ? `#${color3.value.toUpperCase()}` : void 0;
|
|
42988
|
-
case "scheme":
|
|
42989
|
-
return theme?.scheme(color3.value);
|
|
42990
|
-
case "system":
|
|
42991
|
-
return color3.fallback && /^[0-9a-f]{6}$/i.test(color3.fallback) ? `#${color3.fallback.toUpperCase()}` : void 0;
|
|
42992
|
-
case "preset":
|
|
42993
|
-
return PRESET_COLORS[color3.value];
|
|
42994
|
-
case "scrgb": {
|
|
42995
|
-
const [r, g3, b] = color3.value.split(",").map((part) => parseDrawingFraction(part));
|
|
42996
|
-
if (r === void 0 || g3 === void 0 || b === void 0) return void 0;
|
|
42997
|
-
return `#${toHex(scrgbLinearToSrgb8(r))}${toHex(scrgbLinearToSrgb8(g3))}${toHex(scrgbLinearToSrgb8(b))}`;
|
|
42998
|
-
}
|
|
42999
|
-
case "hsl": {
|
|
43000
|
-
const [h2, s, l] = color3.value.split(",");
|
|
43001
|
-
const hue = parseDrawingHueDegrees(h2);
|
|
43002
|
-
const sat = parseDrawingFraction(s);
|
|
43003
|
-
const lum = parseDrawingFraction(l);
|
|
43004
|
-
if (hue === void 0 || sat === void 0 || lum === void 0) return void 0;
|
|
43005
|
-
const { r, g: g3, b } = hslToRgb(hue, sat, lum);
|
|
43006
|
-
return `#${toHex(r)}${toHex(g3)}${toHex(b)}`;
|
|
43007
|
-
}
|
|
43008
|
-
}
|
|
43009
|
-
}
|
|
43010
|
-
function resolveDrawingColor(color3, theme, options2) {
|
|
43011
|
-
const base2 = baseHex(color3, theme);
|
|
43012
|
-
const rgb2 = base2 ? hexToRgbChannels(base2) : null;
|
|
43013
|
-
if (!rgb2) return void 0;
|
|
43014
|
-
if (options2?.transformOrder === "document") {
|
|
43015
|
-
const value = orderedColorTransforms(rgb2, color3.transforms);
|
|
43016
|
-
const round5 = options2.hslRounding === "halfDown" ? (channel) => Math.ceil(channel - 0.5) : Math.round;
|
|
43017
|
-
return {
|
|
43018
|
-
hex: `#${toHex(round5(value.r))}${toHex(round5(value.g))}${toHex(round5(value.b))}`,
|
|
43019
|
-
alpha: value.alpha,
|
|
43020
|
-
unapplied: [...new Set(color3.transforms.map((transform8) => transform8.name))].filter(
|
|
43021
|
-
(name) => !APPLIED.has(name)
|
|
43022
|
-
)
|
|
43023
|
-
};
|
|
43024
|
-
}
|
|
43025
|
-
let { r, g: g3, b } = rgb2;
|
|
43026
|
-
const find = (name) => color3.transforms.find((entry2) => entry2.name === name)?.value;
|
|
43027
|
-
const has2 = (name) => color3.transforms.some((entry2) => entry2.name === name);
|
|
43028
|
-
if (has2("comp")) {
|
|
43029
|
-
const hsl = rgbToHsl(r, g3, b);
|
|
43030
|
-
({ r, g: g3, b } = hslToRgb((hsl.h + 180) % 360, hsl.s, hsl.l));
|
|
43031
|
-
}
|
|
43032
|
-
if (has2("inv")) [r, g3, b] = [255 - r, 255 - g3, 255 - b];
|
|
43033
|
-
if (has2("gray")) r = g3 = b = Math.round(0.299 * r + 0.587 * g3 + 0.114 * b);
|
|
43034
|
-
const shade = parseDrawingPercent(find("shade"));
|
|
43035
|
-
if (shade !== void 0) {
|
|
43036
|
-
r = linearToSrgb255(srgb255ToLinear(r) * shade);
|
|
43037
|
-
g3 = linearToSrgb255(srgb255ToLinear(g3) * shade);
|
|
43038
|
-
b = linearToSrgb255(srgb255ToLinear(b) * shade);
|
|
43039
|
-
}
|
|
43040
|
-
const tint = parseDrawingPercent(find("tint"));
|
|
43041
|
-
if (tint !== void 0) {
|
|
43042
|
-
r = linearToSrgb255(1 - (1 - srgb255ToLinear(r)) * tint);
|
|
43043
|
-
g3 = linearToSrgb255(1 - (1 - srgb255ToLinear(g3)) * tint);
|
|
43044
|
-
b = linearToSrgb255(1 - (1 - srgb255ToLinear(b)) * tint);
|
|
43045
|
-
}
|
|
43046
|
-
if (["hue", "hueMod", "hueOff", "sat", "satMod", "satOff", "lum", "lumMod", "lumOff"].some(has2)) {
|
|
43047
|
-
const hsl = rgbToHsl(r, g3, b);
|
|
43048
|
-
const wrap2 = (degrees) => (degrees % 360 + 360) % 360;
|
|
43049
|
-
const hueAbs = parseDrawingHueDegrees(find("hue"));
|
|
43050
|
-
if (hueAbs !== void 0) hsl.h = wrap2(hueAbs);
|
|
43051
|
-
const hueMod = parseDrawingFraction(find("hueMod"));
|
|
43052
|
-
if (hueMod !== void 0) hsl.h = wrap2(hsl.h * hueMod);
|
|
43053
|
-
const hueOff = parseDrawingHueDegrees(find("hueOff"));
|
|
43054
|
-
if (hueOff !== void 0) hsl.h = wrap2(hsl.h + hueOff);
|
|
43055
|
-
const satAbs = parseDrawingFraction(find("sat"));
|
|
43056
|
-
if (satAbs !== void 0) hsl.s = clampUnitInterval(satAbs);
|
|
43057
|
-
const satMod = parseDrawingFraction(find("satMod"));
|
|
43058
|
-
if (satMod !== void 0) hsl.s = clampUnitInterval(hsl.s * satMod);
|
|
43059
|
-
const satOff = parseDrawingFraction(find("satOff"));
|
|
43060
|
-
if (satOff !== void 0) hsl.s = clampUnitInterval(hsl.s + satOff);
|
|
43061
|
-
const lumAbs = parseDrawingFraction(find("lum"));
|
|
43062
|
-
if (lumAbs !== void 0) hsl.l = clampUnitInterval(lumAbs);
|
|
43063
|
-
const lumMod = parseDrawingFraction(find("lumMod"));
|
|
43064
|
-
if (lumMod !== void 0) hsl.l = clampUnitInterval(hsl.l * lumMod);
|
|
43065
|
-
const lumOff = parseDrawingFraction(find("lumOff"));
|
|
43066
|
-
if (lumOff !== void 0) hsl.l = clampUnitInterval(hsl.l + lumOff);
|
|
43067
|
-
const round5 = options2?.hslRounding === "halfDown" ? (value) => Math.ceil(value - 0.5) : Math.round;
|
|
43068
|
-
({ r, g: g3, b } = hslToRgb(hsl.h, hsl.s, hsl.l, round5));
|
|
43069
|
-
}
|
|
43070
|
-
let alpha = parseDrawingPercent(find("alpha")) ?? 1;
|
|
43071
|
-
const alphaMod = parseDrawingFraction(find("alphaMod"));
|
|
43072
|
-
if (alphaMod !== void 0) alpha = clampUnitInterval(alpha * alphaMod);
|
|
43073
|
-
const alphaOff = parseDrawingFraction(find("alphaOff"));
|
|
43074
|
-
if (alphaOff !== void 0) alpha = clampUnitInterval(alpha + alphaOff);
|
|
43075
|
-
return {
|
|
43076
|
-
hex: `#${toHex(r)}${toHex(g3)}${toHex(b)}`,
|
|
43077
|
-
alpha,
|
|
43078
|
-
unapplied: [...new Set(color3.transforms.map((entry2) => entry2.name))].filter(
|
|
43079
|
-
(name) => !APPLIED.has(name)
|
|
43080
|
-
)
|
|
43081
|
-
};
|
|
43082
|
-
}
|
|
43083
|
-
var COLOR_ELEMENTS, PRESET_COLORS, APPLIED;
|
|
43084
|
-
var init_drawing_color = __esm({
|
|
43085
|
-
"drawingml/drawing-color.ts"() {
|
|
43086
|
-
init_color2();
|
|
43087
|
-
init_color_linear();
|
|
43088
|
-
init_dom();
|
|
43089
|
-
init_ordered_color_transforms();
|
|
43090
|
-
COLOR_ELEMENTS = {
|
|
43091
|
-
srgbClr: "srgb",
|
|
43092
|
-
schemeClr: "scheme",
|
|
43093
|
-
sysClr: "system",
|
|
43094
|
-
prstClr: "preset",
|
|
43095
|
-
scrgbClr: "scrgb",
|
|
43096
|
-
hslClr: "hsl"
|
|
43097
|
-
};
|
|
43098
|
-
PRESET_COLORS = {
|
|
43099
|
-
black: "#000000",
|
|
43100
|
-
white: "#FFFFFF",
|
|
43101
|
-
red: "#FF0000",
|
|
43102
|
-
green: "#008000",
|
|
43103
|
-
blue: "#0000FF",
|
|
43104
|
-
yellow: "#FFFF00",
|
|
43105
|
-
gray: "#808080",
|
|
43106
|
-
grey: "#808080"
|
|
43107
|
-
};
|
|
43108
|
-
APPLIED = /* @__PURE__ */ new Set([
|
|
43109
|
-
"alpha",
|
|
43110
|
-
"alphaMod",
|
|
43111
|
-
"alphaOff",
|
|
43112
|
-
"comp",
|
|
43113
|
-
"inv",
|
|
43114
|
-
"gray",
|
|
43115
|
-
"shade",
|
|
43116
|
-
"tint",
|
|
43117
|
-
"hue",
|
|
43118
|
-
"hueMod",
|
|
43119
|
-
"hueOff",
|
|
43120
|
-
"sat",
|
|
43121
|
-
"satMod",
|
|
43122
|
-
"satOff",
|
|
43123
|
-
"lum",
|
|
43124
|
-
"lumMod",
|
|
43125
|
-
"lumOff"
|
|
43126
|
-
]);
|
|
43127
|
-
}
|
|
43128
|
-
});
|
|
43129
|
-
|
|
43130
44307
|
// drawingml/scene3d-presets.ts
|
|
43131
44308
|
var CAMERA_PRESETS, LIGHT_RIGS, LIGHT_DIRECTIONS;
|
|
43132
44309
|
var init_scene3d_presets = __esm({
|
|
@@ -43228,390 +44405,6 @@ var init_scene3d_presets = __esm({
|
|
|
43228
44405
|
}
|
|
43229
44406
|
});
|
|
43230
44407
|
|
|
43231
|
-
// drawingml/picture-artistic.ts
|
|
43232
|
-
function parseArtisticPictureExtension(node2) {
|
|
43233
|
-
if (node2.namespaceURI !== NS.a || node2.localName !== "extLst") return void 0;
|
|
43234
|
-
const found = [];
|
|
43235
|
-
const unhandled = [];
|
|
43236
|
-
const pending = [node2];
|
|
43237
|
-
while (pending.length) {
|
|
43238
|
-
const item2 = pending.pop();
|
|
43239
|
-
if (item2 !== node2 && !(item2.namespaceURI === NS.a && item2.localName === "ext") && !(item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && (["imgProps", "imgLayer", "imgEffect", "useLocalDpi"].includes(item2.localName) || ARTISTIC_PRIMARY_ATTRIBUTE[item2.localName])))
|
|
43240
|
-
unhandled.push(item2.localName);
|
|
43241
|
-
if (item2.namespaceURI === "http://schemas.microsoft.com/office/drawing/2010/main" && item2.localName.startsWith("artistic"))
|
|
43242
|
-
found.push(item2);
|
|
43243
|
-
pending.push(...elements(item2));
|
|
43244
|
-
}
|
|
43245
|
-
if (found.length !== 1) return void 0;
|
|
43246
|
-
const effect = found[0];
|
|
43247
|
-
const key2 = ARTISTIC_PRIMARY_ATTRIBUTE[effect.localName];
|
|
43248
|
-
if (!key2) return void 0;
|
|
43249
|
-
const raw2 = key2 ? effect.getAttribute(key2) : null;
|
|
43250
|
-
const n = raw2 === null ? 0 : Number(raw2);
|
|
43251
|
-
if (!Number.isFinite(n)) return void 0;
|
|
43252
|
-
return {
|
|
43253
|
-
kind: "artistic",
|
|
43254
|
-
name: effect.localName,
|
|
43255
|
-
radius: effect.localName === "artisticBlur" ? n : n / 1e3,
|
|
43256
|
-
baked: true,
|
|
43257
|
-
...unhandled.length ? { unhandled } : {}
|
|
43258
|
-
};
|
|
43259
|
-
}
|
|
43260
|
-
var ARTISTIC_PRIMARY_ATTRIBUTE;
|
|
43261
|
-
var init_picture_artistic = __esm({
|
|
43262
|
-
"drawingml/picture-artistic.ts"() {
|
|
43263
|
-
init_xml2();
|
|
43264
|
-
ARTISTIC_PRIMARY_ATTRIBUTE = {
|
|
43265
|
-
artisticBlur: "radius",
|
|
43266
|
-
artisticCement: "crackSpacing",
|
|
43267
|
-
artisticChalkSketch: "pressure",
|
|
43268
|
-
artisticCrisscrossEtching: "pressure",
|
|
43269
|
-
artisticCutout: "numberOfShades",
|
|
43270
|
-
artisticFilmGrain: "grainSize",
|
|
43271
|
-
artisticGlass: "scaling",
|
|
43272
|
-
artisticGlowDiffused: "intensity",
|
|
43273
|
-
artisticGlowEdges: "smoothness",
|
|
43274
|
-
artisticLightScreen: "gridSize",
|
|
43275
|
-
artisticLineDrawing: "pencilSize",
|
|
43276
|
-
artisticMarker: "size",
|
|
43277
|
-
// Spelled "Mosiaic" in the schema; Microsoft's typo is part of the format.
|
|
43278
|
-
artisticMosiaicBubbles: "pressure",
|
|
43279
|
-
artisticPaintBrush: "brushSize",
|
|
43280
|
-
artisticPaintStrokes: "intensity",
|
|
43281
|
-
artisticPastelsSmooth: "scaling",
|
|
43282
|
-
artisticPencilGrayscale: "pencilSize",
|
|
43283
|
-
artisticPencilSketch: "pressure",
|
|
43284
|
-
artisticPhotocopy: "detail",
|
|
43285
|
-
artisticPlasticWrap: "smoothness",
|
|
43286
|
-
artisticTexturizer: "scaling",
|
|
43287
|
-
artisticWatercolorSponge: "brushSize"
|
|
43288
|
-
};
|
|
43289
|
-
}
|
|
43290
|
-
});
|
|
43291
|
-
|
|
43292
|
-
// drawingml/write-color.ts
|
|
43293
|
-
function drawingColorXml(color3) {
|
|
43294
|
-
const local = ELEMENTS[color3.kind];
|
|
43295
|
-
const doc = parseXml(`<a:${local} xmlns:a="${NS.a}"/>`);
|
|
43296
|
-
const root = doc.documentElement;
|
|
43297
|
-
if (color3.kind === "scrgb" || color3.kind === "hsl") {
|
|
43298
|
-
const keys = color3.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
43299
|
-
const values = color3.value.split(",");
|
|
43300
|
-
keys.forEach((key2, i2) => root.setAttribute(key2, values[i2] ?? "0"));
|
|
43301
|
-
} else root.setAttribute("val", color3.value);
|
|
43302
|
-
if (color3.fallback !== void 0 && color3.kind === "system")
|
|
43303
|
-
root.setAttribute("lastClr", color3.fallback);
|
|
43304
|
-
for (const transform8 of color3.transforms) {
|
|
43305
|
-
if (!/^[A-Za-z_][\w.-]*$/.test(transform8.name))
|
|
43306
|
-
throw new Error(`Invalid DrawingML transform ${transform8.name}`);
|
|
43307
|
-
const node2 = doc.createElementNS(NS.a, `a:${transform8.name}`);
|
|
43308
|
-
if (transform8.value !== "") node2.setAttribute("val", transform8.value);
|
|
43309
|
-
root.appendChild(node2);
|
|
43310
|
-
}
|
|
43311
|
-
return buildXml(doc);
|
|
43312
|
-
}
|
|
43313
|
-
var ELEMENTS;
|
|
43314
|
-
var init_write_color = __esm({
|
|
43315
|
-
"drawingml/write-color.ts"() {
|
|
43316
|
-
init_xml2();
|
|
43317
|
-
ELEMENTS = {
|
|
43318
|
-
srgb: "srgbClr",
|
|
43319
|
-
scheme: "schemeClr",
|
|
43320
|
-
system: "sysClr",
|
|
43321
|
-
preset: "prstClr",
|
|
43322
|
-
scrgb: "scrgbClr",
|
|
43323
|
-
hsl: "hslClr"
|
|
43324
|
-
};
|
|
43325
|
-
}
|
|
43326
|
-
});
|
|
43327
|
-
|
|
43328
|
-
// drawingml/patch-color.ts
|
|
43329
|
-
function patchDrawingColorIn(container2, color3) {
|
|
43330
|
-
const old = elements(container2).find((node2) => parseDrawingColor(node2));
|
|
43331
|
-
const before = parseDrawingColorIn(container2);
|
|
43332
|
-
if (!old || !before || before.kind !== color3.kind) {
|
|
43333
|
-
const next = container2.ownerDocument.importNode(
|
|
43334
|
-
parseXml(drawingColorXml(color3)).documentElement,
|
|
43335
|
-
true
|
|
43336
|
-
);
|
|
43337
|
-
if (old) container2.replaceChild(next, old);
|
|
43338
|
-
else container2.insertBefore(next, container2.firstChild);
|
|
43339
|
-
return;
|
|
43340
|
-
}
|
|
43341
|
-
if (before.value !== color3.value) {
|
|
43342
|
-
if (color3.kind === "scrgb" || color3.kind === "hsl") {
|
|
43343
|
-
const keys = color3.kind === "scrgb" ? ["r", "g", "b"] : ["hue", "sat", "lum"];
|
|
43344
|
-
const values = color3.value.split(",");
|
|
43345
|
-
keys.forEach((key2, index2) => old.setAttribute(key2, values[index2] ?? "0"));
|
|
43346
|
-
} else old.setAttribute("val", color3.value);
|
|
43347
|
-
}
|
|
43348
|
-
if (before.fallback !== color3.fallback && color3.kind === "system") {
|
|
43349
|
-
if (color3.fallback === void 0) old.removeAttribute("lastClr");
|
|
43350
|
-
else old.setAttribute("lastClr", color3.fallback);
|
|
43351
|
-
}
|
|
43352
|
-
const originals = elements(old);
|
|
43353
|
-
color3.transforms.forEach((transform8, index2) => {
|
|
43354
|
-
const source2 = originals[index2];
|
|
43355
|
-
if (source2?.localName === transform8.name) {
|
|
43356
|
-
if (before.transforms[index2]?.value !== transform8.value) {
|
|
43357
|
-
if (transform8.value === "") source2.removeAttribute("val");
|
|
43358
|
-
else source2.setAttribute("val", transform8.value);
|
|
43359
|
-
}
|
|
43360
|
-
return;
|
|
43361
|
-
}
|
|
43362
|
-
if (!/^[A-Za-z_][\w.-]*$/u.test(transform8.name))
|
|
43363
|
-
throw new Error("Invalid DrawingML colour transform");
|
|
43364
|
-
const next = old.ownerDocument.createElementNS(NS.a, `a:${transform8.name}`);
|
|
43365
|
-
if (transform8.value !== "") next.setAttribute("val", transform8.value);
|
|
43366
|
-
if (source2) old.replaceChild(next, source2);
|
|
43367
|
-
else old.appendChild(next);
|
|
43368
|
-
});
|
|
43369
|
-
for (const extra of originals.slice(color3.transforms.length)) old.removeChild(extra);
|
|
43370
|
-
}
|
|
43371
|
-
var init_patch_color = __esm({
|
|
43372
|
-
"drawingml/patch-color.ts"() {
|
|
43373
|
-
init_xml2();
|
|
43374
|
-
init_drawing_color();
|
|
43375
|
-
init_write_color();
|
|
43376
|
-
}
|
|
43377
|
-
});
|
|
43378
|
-
|
|
43379
|
-
// drawingml/picture-standard-effects.ts
|
|
43380
|
-
function parseStandardPictureEffect(node2) {
|
|
43381
|
-
const name = node2.localName;
|
|
43382
|
-
if (![
|
|
43383
|
-
"biLevel",
|
|
43384
|
-
"alphaInv",
|
|
43385
|
-
"alphaCeiling",
|
|
43386
|
-
"alphaFloor",
|
|
43387
|
-
"alphaRepl",
|
|
43388
|
-
"alphaBiLevel",
|
|
43389
|
-
"alphaMod",
|
|
43390
|
-
"duotone",
|
|
43391
|
-
"clrRepl",
|
|
43392
|
-
"clrChange",
|
|
43393
|
-
"hsl",
|
|
43394
|
-
"tint",
|
|
43395
|
-
"blur"
|
|
43396
|
-
].includes(name))
|
|
43397
|
-
return void 0;
|
|
43398
|
-
const values = {};
|
|
43399
|
-
for (const [key2, attribute7] of Object.entries(attrs[name] ?? {})) {
|
|
43400
|
-
const raw2 = node2.getAttribute(attribute7);
|
|
43401
|
-
if (raw2 === null) continue;
|
|
43402
|
-
const percent = raw2.endsWith("%");
|
|
43403
|
-
const n = Number(percent ? raw2.slice(0, -1) : raw2) / (key2 === "hue" ? 6e4 : key2 === "radiusEmu" ? 1 : percent ? 100 : 1e5);
|
|
43404
|
-
if (!Number.isFinite(n) || key2 === "hue" && (n < 0 || n >= 360) || key2 === "threshold" && (n < 0 || n > 1) || key2 === "radiusEmu" && (!Number.isSafeInteger(n) || n < 0) || ["saturation", "luminance", "amount"].includes(key2) && name !== "alphaMod" && (n < (name === "alphaRepl" ? 0 : -1) || n > 1))
|
|
43405
|
-
return void 0;
|
|
43406
|
-
values[key2] = n;
|
|
43407
|
-
}
|
|
43408
|
-
if (["biLevel", "alphaBiLevel"].includes(name) && values.threshold === void 0)
|
|
43409
|
-
return void 0;
|
|
43410
|
-
if (name === "alphaRepl" && values.amount === void 0) return void 0;
|
|
43411
|
-
if (name === "alphaMod") {
|
|
43412
|
-
const cont = first(node2, "cont", NS.a);
|
|
43413
|
-
const nested = cont ? elements(cont) : [];
|
|
43414
|
-
if (nested.length !== 1 || nested[0]?.localName !== "alphaModFix") return void 0;
|
|
43415
|
-
const raw2 = nested[0].getAttribute("amt") ?? "100000";
|
|
43416
|
-
const n = Number(raw2.endsWith("%") ? raw2.slice(0, -1) : raw2) / (raw2.endsWith("%") ? 100 : 1e5);
|
|
43417
|
-
if (!Number.isFinite(n) || n < 0) return void 0;
|
|
43418
|
-
values.amount = n;
|
|
43419
|
-
}
|
|
43420
|
-
let colors = [];
|
|
43421
|
-
if (name === "duotone") {
|
|
43422
|
-
const candidates = elements(node2).filter(
|
|
43423
|
-
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
43424
|
-
);
|
|
43425
|
-
colors = candidates.map((item2) => parseDrawingColor(item2)).filter((item2) => Boolean(item2));
|
|
43426
|
-
if (colors.length !== 2) return void 0;
|
|
43427
|
-
}
|
|
43428
|
-
if (name === "clrRepl") {
|
|
43429
|
-
const color3 = parseDrawingColorIn(node2);
|
|
43430
|
-
if (!color3) return void 0;
|
|
43431
|
-
colors = [color3];
|
|
43432
|
-
}
|
|
43433
|
-
if (name === "clrChange") {
|
|
43434
|
-
const from = parseDrawingColorIn(first(node2, "clrFrom", NS.a)), to = parseDrawingColorIn(first(node2, "clrTo", NS.a));
|
|
43435
|
-
if (!from || !to) return void 0;
|
|
43436
|
-
colors = [from, to];
|
|
43437
|
-
}
|
|
43438
|
-
if (name === "alphaInv") {
|
|
43439
|
-
const color3 = parseDrawingColorIn(node2);
|
|
43440
|
-
if (color3) colors = [color3];
|
|
43441
|
-
}
|
|
43442
|
-
return {
|
|
43443
|
-
kind: "standard",
|
|
43444
|
-
name,
|
|
43445
|
-
...Object.keys(values).length ? { values } : {},
|
|
43446
|
-
...colors.length ? { colors } : {},
|
|
43447
|
-
...name === "clrChange" && node2.hasAttribute("useA") ? { useAlpha: !["0", "false"].includes(node2.getAttribute("useA") ?? "") } : {},
|
|
43448
|
-
...name === "blur" && node2.hasAttribute("grow") ? { grow: !["0", "false"].includes(node2.getAttribute("grow") ?? "") } : {}
|
|
43449
|
-
};
|
|
43450
|
-
}
|
|
43451
|
-
function applyStandardPictureEffect(node2, effect) {
|
|
43452
|
-
const doc = node2.ownerDocument, before = parseStandardPictureEffect(node2);
|
|
43453
|
-
for (const [key2, value] of Object.entries(effect.values ?? {})) {
|
|
43454
|
-
if (!Number.isFinite(value) || key2 === "hue" && (value < 0 || value >= 360) || key2 === "threshold" && (value < 0 || value > 1) || key2 === "radiusEmu" && (!Number.isSafeInteger(value) || value < 0) || key2 === "amount" && effect.name === "alphaMod" && value < 0 || ["saturation", "luminance", "amount"].includes(key2) && effect.name !== "alphaMod" && (value < (effect.name === "alphaRepl" ? 0 : -1) || value > 1))
|
|
43455
|
-
throw new RangeError("Invalid picture effect values");
|
|
43456
|
-
}
|
|
43457
|
-
const count2 = effect.colors?.length ?? 0;
|
|
43458
|
-
if (["duotone", "clrChange"].includes(effect.name) && count2 !== 2 || effect.name === "clrRepl" && count2 !== 1 || effect.name === "alphaInv" && count2 > 1)
|
|
43459
|
-
throw new RangeError("Invalid picture effect colours");
|
|
43460
|
-
for (const [key2, attribute7] of Object.entries(attrs[effect.name] ?? {})) {
|
|
43461
|
-
const value = effect.values?.[key2];
|
|
43462
|
-
if (value === before?.values?.[key2]) continue;
|
|
43463
|
-
if (value === void 0) node2.removeAttribute(attribute7);
|
|
43464
|
-
else
|
|
43465
|
-
node2.setAttribute(
|
|
43466
|
-
attribute7,
|
|
43467
|
-
String(Math.round(value * (key2 === "hue" ? 6e4 : key2 === "radiusEmu" ? 1 : 1e5)))
|
|
43468
|
-
);
|
|
43469
|
-
}
|
|
43470
|
-
if (effect.name === "alphaMod" && effect.values?.amount !== before?.values?.amount) {
|
|
43471
|
-
const cont = first(node2, "cont", NS.a) ?? doc.createElementNS(NS.a, "a:cont");
|
|
43472
|
-
const fix = first(cont, "alphaModFix", NS.a) ?? doc.createElementNS(NS.a, "a:alphaModFix");
|
|
43473
|
-
fix.setAttribute("amt", String(Math.round((effect.values?.amount ?? 1) * 1e5)));
|
|
43474
|
-
if (!fix.parentNode) cont.appendChild(fix);
|
|
43475
|
-
if (!cont.parentNode) node2.appendChild(cont);
|
|
43476
|
-
}
|
|
43477
|
-
if (effect.useAlpha !== before?.useAlpha) {
|
|
43478
|
-
if (effect.useAlpha === void 0) node2.removeAttribute("useA");
|
|
43479
|
-
else node2.setAttribute("useA", effect.useAlpha ? "1" : "0");
|
|
43480
|
-
}
|
|
43481
|
-
if (effect.grow !== before?.grow) {
|
|
43482
|
-
if (effect.grow === void 0) node2.removeAttribute("grow");
|
|
43483
|
-
else node2.setAttribute("grow", effect.grow ? "1" : "0");
|
|
43484
|
-
}
|
|
43485
|
-
if (JSON.stringify(effect.colors) !== JSON.stringify(before?.colors)) {
|
|
43486
|
-
if (effect.name === "duotone") {
|
|
43487
|
-
const old = elements(node2).filter(
|
|
43488
|
-
(item2) => item2.namespaceURI === NS.a && /Clr$/.test(item2.localName)
|
|
43489
|
-
);
|
|
43490
|
-
for (let i2 = 0; i2 < (effect.colors?.length ?? 0); i2++) {
|
|
43491
|
-
const holder = doc.createElementNS(NS.a, "a:holder");
|
|
43492
|
-
if (old[i2]) holder.appendChild(doc.importNode(old[i2], true));
|
|
43493
|
-
patchDrawingColorIn(holder, effect.colors[i2]);
|
|
43494
|
-
const next = elements(holder)[0];
|
|
43495
|
-
if (old[i2]) node2.replaceChild(next, old[i2]);
|
|
43496
|
-
else node2.insertBefore(next, first(node2, "extLst", NS.a) ?? null);
|
|
43497
|
-
}
|
|
43498
|
-
} else if (effect.name === "clrChange") {
|
|
43499
|
-
for (const [i2, name] of ["clrFrom", "clrTo"].entries()) {
|
|
43500
|
-
const holder = first(node2, name, NS.a) ?? doc.createElementNS(NS.a, `a:${name}`);
|
|
43501
|
-
if (effect.colors?.[i2]) patchDrawingColorIn(holder, effect.colors[i2]);
|
|
43502
|
-
if (!holder.parentNode) node2.insertBefore(holder, first(node2, "extLst", NS.a) ?? null);
|
|
43503
|
-
}
|
|
43504
|
-
} else if (effect.colors?.[0]) patchDrawingColorIn(node2, effect.colors[0]);
|
|
43505
|
-
}
|
|
43506
|
-
if (!parseStandardPictureEffect(node2)) throw new RangeError("Invalid picture effect values");
|
|
43507
|
-
}
|
|
43508
|
-
var attrs;
|
|
43509
|
-
var init_picture_standard_effects = __esm({
|
|
43510
|
-
"drawingml/picture-standard-effects.ts"() {
|
|
43511
|
-
init_xml2();
|
|
43512
|
-
init_drawing_color();
|
|
43513
|
-
init_patch_color();
|
|
43514
|
-
attrs = {
|
|
43515
|
-
biLevel: { threshold: "thresh" },
|
|
43516
|
-
alphaRepl: { amount: "a" },
|
|
43517
|
-
alphaBiLevel: { threshold: "thresh" },
|
|
43518
|
-
hsl: { hue: "hue", saturation: "sat", luminance: "lum" },
|
|
43519
|
-
tint: { hue: "hue", amount: "amt" },
|
|
43520
|
-
blur: { radiusEmu: "rad" }
|
|
43521
|
-
};
|
|
43522
|
-
}
|
|
43523
|
-
});
|
|
43524
|
-
|
|
43525
|
-
// drawingml/picture-effects.ts
|
|
43526
|
-
function picturePercentage(value) {
|
|
43527
|
-
const text2 = String(value ?? "").trim();
|
|
43528
|
-
if (!text2) return void 0;
|
|
43529
|
-
const percent = text2.endsWith("%");
|
|
43530
|
-
const n = Number(percent ? text2.slice(0, -1) : text2) / (percent ? 100 : 1e5);
|
|
43531
|
-
return Number.isFinite(n) ? n : void 0;
|
|
43532
|
-
}
|
|
43533
|
-
function readPictureEffect(name, attribute7) {
|
|
43534
|
-
if (name === "grayscl") return { kind: "grayscale" };
|
|
43535
|
-
if (name === "lum") {
|
|
43536
|
-
const brightness = picturePercentage(attribute7("bright"));
|
|
43537
|
-
const contrast = picturePercentage(attribute7("contrast"));
|
|
43538
|
-
for (const [name2, value] of [
|
|
43539
|
-
["bright", brightness],
|
|
43540
|
-
["contrast", contrast]
|
|
43541
|
-
]) {
|
|
43542
|
-
const raw2 = attribute7(name2);
|
|
43543
|
-
if (raw2 !== void 0 && raw2 !== null && (value === void 0 || Math.abs(value) > 1))
|
|
43544
|
-
return void 0;
|
|
43545
|
-
}
|
|
43546
|
-
return {
|
|
43547
|
-
kind: "luminance",
|
|
43548
|
-
...brightness !== void 0 ? { brightness } : {},
|
|
43549
|
-
...contrast !== void 0 ? { contrast } : {}
|
|
43550
|
-
};
|
|
43551
|
-
}
|
|
43552
|
-
if (name === "alphaModFix") {
|
|
43553
|
-
const raw2 = attribute7("amt");
|
|
43554
|
-
const amount = raw2 === void 0 || raw2 === null ? 1 : picturePercentage(raw2);
|
|
43555
|
-
if (amount !== void 0 && amount >= 0) return { kind: "alphaModFix", amount };
|
|
43556
|
-
}
|
|
43557
|
-
return void 0;
|
|
43558
|
-
}
|
|
43559
|
-
function parsePictureEffects(blip) {
|
|
43560
|
-
if (!blip) return [];
|
|
43561
|
-
return elements(blip).map((node2) => ({
|
|
43562
|
-
...(node2.namespaceURI === NS.a ? readPictureEffect(node2.localName, (name) => node2.getAttribute(name)) ?? parseStandardPictureEffect(node2) ?? parseArtisticPictureExtension(node2) : void 0) ?? { kind: "unsupported", name: node2.localName },
|
|
43563
|
-
sourceXml: buildXml(node2)
|
|
43564
|
-
}));
|
|
43565
|
-
}
|
|
43566
|
-
function applyPictureEffects(blip, effects2) {
|
|
43567
|
-
if (JSON.stringify(parsePictureEffects(blip)) === JSON.stringify(effects2)) return;
|
|
43568
|
-
const nodes = effects2.map((effect) => {
|
|
43569
|
-
const name = effect.kind === "grayscale" ? "grayscl" : effect.kind === "luminance" ? "lum" : effect.kind === "unsupported" ? effect.name : effect.kind === "artistic" ? "extLst" : effect.kind === "standard" ? effect.name : effect.kind;
|
|
43570
|
-
if (effect.kind === "artistic") {
|
|
43571
|
-
const before = effect.sourceXml ? parseArtisticPictureExtension(parseXml(effect.sourceXml).documentElement) : void 0;
|
|
43572
|
-
if (!effect.baked || !before || before.name !== effect.name || before.radius !== effect.radius)
|
|
43573
|
-
throw new Error("Artistic authoring requires a host-generated baked picture cache");
|
|
43574
|
-
}
|
|
43575
|
-
const source2 = effect.sourceXml ? parseXml(effect.sourceXml).documentElement : void 0;
|
|
43576
|
-
if (effect.kind === "unsupported" && !source2)
|
|
43577
|
-
throw new Error("An unsupported picture effect needs source XML");
|
|
43578
|
-
const node2 = source2 ? blip.ownerDocument.importNode(source2, true) : blip.ownerDocument.createElementNS(NS.a, `a:${name}`);
|
|
43579
|
-
if (effect.kind !== "unsupported" && (node2.namespaceURI !== NS.a || node2.localName !== name))
|
|
43580
|
-
throw new Error("Picture effect source does not match its kind");
|
|
43581
|
-
const set3 = (name2, value) => {
|
|
43582
|
-
const original = picturePercentage(node2.getAttribute(name2));
|
|
43583
|
-
if (value === void 0) node2.removeAttribute(name2);
|
|
43584
|
-
else if (value !== original) {
|
|
43585
|
-
if (!Number.isFinite(value)) throw new RangeError("Picture effect must be finite");
|
|
43586
|
-
node2.setAttribute(name2, String(Math.round(value * 1e5)));
|
|
43587
|
-
}
|
|
43588
|
-
};
|
|
43589
|
-
if (effect.kind === "luminance") {
|
|
43590
|
-
if ([effect.brightness, effect.contrast].some(
|
|
43591
|
-
(value) => value !== void 0 && (!Number.isFinite(value) || Math.abs(value) > 1)
|
|
43592
|
-
))
|
|
43593
|
-
throw new RangeError("Picture luminance must be between -1 and 1");
|
|
43594
|
-
set3("bright", effect.brightness);
|
|
43595
|
-
set3("contrast", effect.contrast);
|
|
43596
|
-
}
|
|
43597
|
-
if (effect.kind === "alphaModFix") {
|
|
43598
|
-
if (effect.amount < 0) throw new RangeError("Picture alpha must be nonnegative");
|
|
43599
|
-
set3("amt", effect.amount);
|
|
43600
|
-
}
|
|
43601
|
-
if (effect.kind === "standard") applyStandardPictureEffect(node2, effect);
|
|
43602
|
-
return node2;
|
|
43603
|
-
});
|
|
43604
|
-
for (const node2 of elements(blip)) blip.removeChild(node2);
|
|
43605
|
-
for (const node2 of nodes) blip.appendChild(node2);
|
|
43606
|
-
}
|
|
43607
|
-
var init_picture_effects = __esm({
|
|
43608
|
-
"drawingml/picture-effects.ts"() {
|
|
43609
|
-
init_picture_artistic();
|
|
43610
|
-
init_picture_standard_effects();
|
|
43611
|
-
init_xml2();
|
|
43612
|
-
}
|
|
43613
|
-
});
|
|
43614
|
-
|
|
43615
44408
|
// drawingml/read-3d-values.ts
|
|
43616
44409
|
function readScene3DValues(node2, read) {
|
|
43617
44410
|
const out = {};
|
|
@@ -43964,7 +44757,7 @@ function parseDrawingFill(properties) {
|
|
|
43964
44757
|
return color3 ? { kind: "solid", color: color3 } : { kind: "unsupported", element: "solidFill" };
|
|
43965
44758
|
}
|
|
43966
44759
|
case "gradFill": {
|
|
43967
|
-
const stops =
|
|
44760
|
+
const stops = children(first(fill3, "gsLst", NS.a) ?? fill3, "gs", NS.a).flatMap((stop) => {
|
|
43968
44761
|
const color3 = parseDrawingColorIn(stop);
|
|
43969
44762
|
const position4 = Number.parseInt(stop.getAttribute("pos") ?? "", 10);
|
|
43970
44763
|
return color3 && Number.isFinite(position4) ? [{ position: position4 / 1e3, color: color3 }] : [];
|
|
@@ -44032,7 +44825,7 @@ function parseDrawingLine(ln) {
|
|
|
44032
44825
|
if (alignment !== null) line2.alignment = alignment;
|
|
44033
44826
|
const custom2 = first(ln, "custDash", NS.a);
|
|
44034
44827
|
if (custom2 && !dash) {
|
|
44035
|
-
line2.customDash =
|
|
44828
|
+
line2.customDash = children(custom2, "ds", NS.a).flatMap((node2) => {
|
|
44036
44829
|
const dash2 = drawingDashLength(node2.getAttribute("d"));
|
|
44037
44830
|
const space = drawingDashLength(node2.getAttribute("sp"));
|
|
44038
44831
|
return dash2 !== void 0 && space !== void 0 ? [{ dash: dash2, space, sourceXml: buildXml(node2) }] : [];
|
|
@@ -44258,7 +45051,7 @@ function readAttributes2(element2, out) {
|
|
|
44258
45051
|
if (fontAlign) out.fontAlign = fontAlign;
|
|
44259
45052
|
}
|
|
44260
45053
|
function readTabStops(element2) {
|
|
44261
|
-
return
|
|
45054
|
+
return children(element2, "tab", NS.a).map((tab) => {
|
|
44262
45055
|
const stop = {};
|
|
44263
45056
|
const position4 = integerAttribute(tab, "pos");
|
|
44264
45057
|
if (position4 !== void 0) stop.positionEmu = position4;
|
|
@@ -44399,11 +45192,11 @@ function parseDrawingBodyProperties(element2) {
|
|
|
44399
45192
|
...read("fontScale") !== void 0 && fontScale !== void 0 ? { fontScale } : {},
|
|
44400
45193
|
...read("lnSpcReduction") !== void 0 && reduction !== void 0 ? { lineSpacingReduction: reduction } : {}
|
|
44401
45194
|
};
|
|
44402
|
-
} else if (name === "scene3d" &&
|
|
45195
|
+
} else if (name === "scene3d" && children(element2, "scene3d", NS.a).length === 1)
|
|
44403
45196
|
out.scene3d = parseDrawingTextScene3D(child33);
|
|
44404
|
-
else if (name === "sp3d" &&
|
|
45197
|
+
else if (name === "sp3d" && children(element2, "sp3d", NS.a).length === 1 && !first(element2, "flatTx", NS.a))
|
|
44405
45198
|
out.shape3d = parseDrawingTextShape3D(child33);
|
|
44406
|
-
else if (name === "flatTx" &&
|
|
45199
|
+
else if (name === "flatTx" && children(element2, "flatTx", NS.a).length === 1 && !first(element2, "sp3d", NS.a))
|
|
44407
45200
|
out.flatText3d = parseDrawingFlatText3D(child33);
|
|
44408
45201
|
else extra.push(outerXml(child33));
|
|
44409
45202
|
}
|
|
@@ -44475,7 +45268,7 @@ function parseDrawingRichTextBody(element2) {
|
|
|
44475
45268
|
return {
|
|
44476
45269
|
...bodyProperties ? { bodyProperties } : {},
|
|
44477
45270
|
...listStyle ? { listStyle } : {},
|
|
44478
|
-
paragraphs:
|
|
45271
|
+
paragraphs: children(element2, "p", NS.a).map(parseDrawingParagraph)
|
|
44479
45272
|
};
|
|
44480
45273
|
}
|
|
44481
45274
|
function drawingParagraphText(paragraph2) {
|
|
@@ -44641,7 +45434,7 @@ var init_text2 = __esm({
|
|
|
44641
45434
|
});
|
|
44642
45435
|
|
|
44643
45436
|
// diagram/edit/types.ts
|
|
44644
|
-
var
|
|
45437
|
+
var init_types5 = __esm({
|
|
44645
45438
|
"diagram/edit/types.ts"() {
|
|
44646
45439
|
}
|
|
44647
45440
|
});
|
|
@@ -45788,7 +46581,7 @@ var init_format = __esm({
|
|
|
45788
46581
|
// diagram/edit/index.ts
|
|
45789
46582
|
var init_edit = __esm({
|
|
45790
46583
|
"diagram/edit/index.ts"() {
|
|
45791
|
-
|
|
46584
|
+
init_types5();
|
|
45792
46585
|
init_shape_match();
|
|
45793
46586
|
init_node_ops();
|
|
45794
46587
|
init_node_order();
|
|
@@ -45937,7 +46730,7 @@ function drawingFillXml(fill3) {
|
|
|
45937
46730
|
list3 = doc.createElementNS(NS.a, "a:gsLst");
|
|
45938
46731
|
root.insertBefore(list3, root.firstChild);
|
|
45939
46732
|
}
|
|
45940
|
-
const stops =
|
|
46733
|
+
const stops = children(list3, "gs", NS.a).filter(
|
|
45941
46734
|
(node2) => parseDrawingColorIn(node2) && Number.isFinite(Number.parseInt(node2.getAttribute("pos") ?? "", 10))
|
|
45942
46735
|
);
|
|
45943
46736
|
fill3.stops.forEach((stop, index2) => {
|
|
@@ -46028,7 +46821,7 @@ function remove(host, names) {
|
|
|
46028
46821
|
}
|
|
46029
46822
|
function patchDrawingLine(ln, line2) {
|
|
46030
46823
|
const before = line2.sourceXml ? parseDrawingLine(ln) : void 0;
|
|
46031
|
-
const changed = (key2) => !before || !
|
|
46824
|
+
const changed = (key2) => !before || !same2(before[key2], line2[key2]);
|
|
46032
46825
|
for (const [key2, attribute7] of [
|
|
46033
46826
|
["widthEmu", "w"],
|
|
46034
46827
|
["cap", "cap"],
|
|
@@ -46126,7 +46919,7 @@ function drawingLineXml(line2) {
|
|
|
46126
46919
|
patchDrawingLine(doc.documentElement, line2);
|
|
46127
46920
|
return buildXml(doc);
|
|
46128
46921
|
}
|
|
46129
|
-
var FILLS, ORDER,
|
|
46922
|
+
var FILLS, ORDER, same2;
|
|
46130
46923
|
var init_write_line = __esm({
|
|
46131
46924
|
"drawingml/write-line.ts"() {
|
|
46132
46925
|
init_xml2();
|
|
@@ -46145,7 +46938,7 @@ var init_write_line = __esm({
|
|
|
46145
46938
|
"tailEnd",
|
|
46146
46939
|
"extLst"
|
|
46147
46940
|
];
|
|
46148
|
-
|
|
46941
|
+
same2 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
46149
46942
|
}
|
|
46150
46943
|
});
|
|
46151
46944
|
|
|
@@ -46195,7 +46988,7 @@ function drawingEffectXml(effect) {
|
|
|
46195
46988
|
const before = effect.sourceXml ? parseDrawingEffect(root) : void 0;
|
|
46196
46989
|
const current = effect;
|
|
46197
46990
|
const baseline = before;
|
|
46198
|
-
const changed = (key2) => !baseline || !
|
|
46991
|
+
const changed = (key2) => !baseline || !same3(baseline[key2], current[key2]);
|
|
46199
46992
|
for (const [key2, attribute7] of Object.entries({
|
|
46200
46993
|
...NUMBERS[effect.kind],
|
|
46201
46994
|
...STRINGS[effect.kind],
|
|
@@ -46254,7 +47047,7 @@ function drawingEffectsXml(value) {
|
|
|
46254
47047
|
patchDrawingEffects(doc.documentElement, value);
|
|
46255
47048
|
return buildXml(doc);
|
|
46256
47049
|
}
|
|
46257
|
-
var KINDS, TAGS, GEOMETRY, TRANSFORM, NUMBERS, STRINGS, BOOLEANS, COLORED,
|
|
47050
|
+
var KINDS, TAGS, GEOMETRY, TRANSFORM, NUMBERS, STRINGS, BOOLEANS, COLORED, same3;
|
|
46258
47051
|
var init_drawing_effects = __esm({
|
|
46259
47052
|
"drawingml/drawing-effects.ts"() {
|
|
46260
47053
|
init_xml2();
|
|
@@ -46306,7 +47099,7 @@ var init_drawing_effects = __esm({
|
|
|
46306
47099
|
blur: { grow: "grow" }
|
|
46307
47100
|
};
|
|
46308
47101
|
COLORED = /* @__PURE__ */ new Set(["outerShadow", "innerShadow", "presetShadow", "glow"]);
|
|
46309
|
-
|
|
47102
|
+
same3 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
46310
47103
|
}
|
|
46311
47104
|
});
|
|
46312
47105
|
|
|
@@ -47331,8 +48124,8 @@ function connectionLabel(connection, transitionText) {
|
|
|
47331
48124
|
}
|
|
47332
48125
|
function textBodyParagraphs(body) {
|
|
47333
48126
|
if (!body) return [];
|
|
47334
|
-
return
|
|
47335
|
-
(paragraph2) =>
|
|
48127
|
+
return children(body, "p", NS.a).map(
|
|
48128
|
+
(paragraph2) => descendants(paragraph2, "t").map((run2) => run2.textContent ?? "").join("")
|
|
47336
48129
|
);
|
|
47337
48130
|
}
|
|
47338
48131
|
function parsePoint(element2) {
|
|
@@ -47378,7 +48171,7 @@ function parseDiagramDataModel(source2, part) {
|
|
|
47378
48171
|
const report = (code, message) => issues.push({ code, message, ...part ? { part } : {} });
|
|
47379
48172
|
const points7 = [];
|
|
47380
48173
|
const ids = /* @__PURE__ */ new Set();
|
|
47381
|
-
for (const element2 of
|
|
48174
|
+
for (const element2 of children(first(root, "ptLst", NS.dgm) ?? root, "pt", NS.dgm)) {
|
|
47382
48175
|
const point2 = parsePoint(element2);
|
|
47383
48176
|
if (!point2) {
|
|
47384
48177
|
report("POINT_ID_REQUIRED", "dgm:pt requires modelId.");
|
|
@@ -47397,7 +48190,7 @@ function parseDiagramDataModel(source2, part) {
|
|
|
47397
48190
|
const connections = [];
|
|
47398
48191
|
const parentById = /* @__PURE__ */ new Map();
|
|
47399
48192
|
const connectionIds = /* @__PURE__ */ new Set();
|
|
47400
|
-
for (const element2 of
|
|
48193
|
+
for (const element2 of children(first(root, "cxnLst", NS.dgm) ?? root, "cxn", NS.dgm)) {
|
|
47401
48194
|
const connection = parseConnectionAttributes(attributeReader(element2));
|
|
47402
48195
|
if (!connection) {
|
|
47403
48196
|
report("CONNECTION_ATTRIBUTE_REQUIRED", "dgm:cxn requires srcId and destId.");
|
|
@@ -47420,15 +48213,15 @@ function parseDiagramDataModel(source2, part) {
|
|
|
47420
48213
|
if ((!connection.type || connection.type === "parOf") && !parentById.has(connection.destId))
|
|
47421
48214
|
parentById.set(connection.destId, connection.sourceId);
|
|
47422
48215
|
}
|
|
47423
|
-
const ext =
|
|
48216
|
+
const ext = descendants(root, "dataModelExt")[0];
|
|
47424
48217
|
const drawingRelId = stringAttribute(ext, "relId");
|
|
47425
|
-
const generated =
|
|
48218
|
+
const generated = descendants(root, "generatedCache").find(
|
|
47426
48219
|
(node2) => node2.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
47427
48220
|
);
|
|
47428
48221
|
const generatedCacheDigest = generated?.getAttribute("drawingSha256");
|
|
47429
48222
|
return {
|
|
47430
48223
|
points: points7,
|
|
47431
|
-
...
|
|
48224
|
+
...descendants(root, "generatedCache").some(
|
|
47432
48225
|
(node2) => node2.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
47433
48226
|
) ? { generatedCache: true } : {},
|
|
47434
48227
|
...generatedCacheDigest ? { generatedCacheDigest } : {},
|
|
@@ -47497,7 +48290,7 @@ var init_layout_category = __esm({
|
|
|
47497
48290
|
function parseDefinitionHeader(root) {
|
|
47498
48291
|
const header = {
|
|
47499
48292
|
uniqueId: stringAttribute(root, "uniqueId") ?? "",
|
|
47500
|
-
categories:
|
|
48293
|
+
categories: children(first(root, "catLst", NS.dgm) ?? root, "cat", NS.dgm).flatMap((cat) => {
|
|
47501
48294
|
const type = stringAttribute(cat, "type");
|
|
47502
48295
|
const priority = Number.parseInt(cat.getAttribute("pri") ?? "", 10);
|
|
47503
48296
|
return type ? [{ type, ...Number.isFinite(priority) ? { priority } : {} }] : [];
|
|
@@ -47515,7 +48308,7 @@ function colorList(container2) {
|
|
|
47515
48308
|
}
|
|
47516
48309
|
function parseDiagramColors(source2) {
|
|
47517
48310
|
const root = rootOf3(source2);
|
|
47518
|
-
const labels2 =
|
|
48311
|
+
const labels2 = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
47519
48312
|
name: stringAttribute(label2, "name") ?? "",
|
|
47520
48313
|
fill: colorList(first(label2, "fillClrLst", NS.dgm)),
|
|
47521
48314
|
line: colorList(first(label2, "linClrLst", NS.dgm)),
|
|
@@ -47562,7 +48355,7 @@ function spatialScene(scene) {
|
|
|
47562
48355
|
}
|
|
47563
48356
|
function parseDiagramQuickStyle(source2) {
|
|
47564
48357
|
const root = rootOf3(source2);
|
|
47565
|
-
const labels2 =
|
|
48358
|
+
const labels2 = children(root, "styleLbl", NS.dgm).map((label2) => ({
|
|
47566
48359
|
name: stringAttribute(label2, "name") ?? "",
|
|
47567
48360
|
...parseStyleReferences(first(label2, "style", NS.dgm)),
|
|
47568
48361
|
hasScene3d: Boolean(first(label2, "scene3d", NS.dgm)),
|
|
@@ -47588,7 +48381,7 @@ function parseDiagramLayoutSummary(source2) {
|
|
|
47588
48381
|
...header,
|
|
47589
48382
|
...family ? { family } : {},
|
|
47590
48383
|
...rootAlgorithm ? { rootAlgorithm } : {},
|
|
47591
|
-
layoutNodeCount:
|
|
48384
|
+
layoutNodeCount: descendants(root, "layoutNode").length
|
|
47592
48385
|
};
|
|
47593
48386
|
}
|
|
47594
48387
|
var rootOf3, hasContent;
|
|
@@ -48044,530 +48837,6 @@ var init_embedded_packages = __esm({
|
|
|
48044
48837
|
}
|
|
48045
48838
|
});
|
|
48046
48839
|
|
|
48047
|
-
// opc/properties/types.ts
|
|
48048
|
-
var CUSTOM_PROPERTIES_FMTID, PROPERTY_CONTENT_TYPES;
|
|
48049
|
-
var init_types5 = __esm({
|
|
48050
|
-
"opc/properties/types.ts"() {
|
|
48051
|
-
CUSTOM_PROPERTIES_FMTID = "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}";
|
|
48052
|
-
PROPERTY_CONTENT_TYPES = {
|
|
48053
|
-
core: "application/vnd.openxmlformats-package.core-properties+xml",
|
|
48054
|
-
app: "application/vnd.openxmlformats-officedocument.extended-properties+xml",
|
|
48055
|
-
custom: "application/vnd.openxmlformats-officedocument.custom-properties+xml"
|
|
48056
|
-
};
|
|
48057
|
-
}
|
|
48058
|
-
});
|
|
48059
|
-
|
|
48060
|
-
// opc/properties/patch.ts
|
|
48061
|
-
function tagEnd2(xml, from) {
|
|
48062
|
-
let quote = "";
|
|
48063
|
-
for (let i2 = from + 1; i2 < xml.length; i2++) {
|
|
48064
|
-
const ch = xml[i2];
|
|
48065
|
-
if (quote) {
|
|
48066
|
-
if (ch === quote) quote = "";
|
|
48067
|
-
} else if (ch === '"' || ch === "'") quote = ch;
|
|
48068
|
-
else if (ch === ">") return i2 + 1;
|
|
48069
|
-
}
|
|
48070
|
-
throw new Error("Unterminated tag in property part");
|
|
48071
|
-
}
|
|
48072
|
-
function skipMarkup(xml, at2) {
|
|
48073
|
-
if (xml.startsWith("<!--", at2)) return xml.indexOf("-->", at2) + 3;
|
|
48074
|
-
if (xml.startsWith("<![CDATA[", at2)) return xml.indexOf("]]>", at2) + 3;
|
|
48075
|
-
if (xml.startsWith("<?", at2)) return xml.indexOf("?>", at2) + 2;
|
|
48076
|
-
return void 0;
|
|
48077
|
-
}
|
|
48078
|
-
function scan(xml) {
|
|
48079
|
-
let i2 = 0;
|
|
48080
|
-
let rootStart = -1;
|
|
48081
|
-
while (rootStart < 0) {
|
|
48082
|
-
const lt = xml.indexOf("<", i2);
|
|
48083
|
-
if (lt < 0) throw new Error("Property part has no root element");
|
|
48084
|
-
const skipped = skipMarkup(xml, lt);
|
|
48085
|
-
if (skipped !== void 0) i2 = skipped;
|
|
48086
|
-
else rootStart = lt;
|
|
48087
|
-
}
|
|
48088
|
-
const openEnd = tagEnd2(xml, rootStart);
|
|
48089
|
-
if (xml[openEnd - 2] === "/") {
|
|
48090
|
-
const root = {
|
|
48091
|
-
start: rootStart,
|
|
48092
|
-
openEnd,
|
|
48093
|
-
closeStart: openEnd,
|
|
48094
|
-
end: openEnd,
|
|
48095
|
-
selfClosing: true
|
|
48096
|
-
};
|
|
48097
|
-
return { root, children: [] };
|
|
48098
|
-
}
|
|
48099
|
-
const children16 = [];
|
|
48100
|
-
let depth = 0;
|
|
48101
|
-
let child33;
|
|
48102
|
-
i2 = openEnd;
|
|
48103
|
-
for (; ; ) {
|
|
48104
|
-
const lt = xml.indexOf("<", i2);
|
|
48105
|
-
if (lt < 0) throw new Error("Property part root is not closed");
|
|
48106
|
-
const skipped = skipMarkup(xml, lt);
|
|
48107
|
-
if (skipped !== void 0) {
|
|
48108
|
-
i2 = skipped;
|
|
48109
|
-
continue;
|
|
48110
|
-
}
|
|
48111
|
-
const end = tagEnd2(xml, lt);
|
|
48112
|
-
i2 = end;
|
|
48113
|
-
if (xml[lt + 1] === "/") {
|
|
48114
|
-
if (depth === 0) {
|
|
48115
|
-
const root = { start: rootStart, openEnd, closeStart: lt, end, selfClosing: false };
|
|
48116
|
-
return { root, children: children16 };
|
|
48117
|
-
}
|
|
48118
|
-
depth--;
|
|
48119
|
-
if (depth === 0 && child33)
|
|
48120
|
-
children16.push({ ...child33, closeStart: lt, end, selfClosing: false });
|
|
48121
|
-
} else if (xml[end - 2] === "/") {
|
|
48122
|
-
if (depth === 0)
|
|
48123
|
-
children16.push({ start: lt, openEnd: end, closeStart: end, end, selfClosing: true });
|
|
48124
|
-
} else {
|
|
48125
|
-
if (depth === 0) child33 = { start: lt, openEnd: end };
|
|
48126
|
-
depth++;
|
|
48127
|
-
}
|
|
48128
|
-
}
|
|
48129
|
-
}
|
|
48130
|
-
var XMLNS, escapeText, qualifiedName, PartPatch;
|
|
48131
|
-
var init_patch = __esm({
|
|
48132
|
-
"opc/properties/patch.ts"() {
|
|
48133
|
-
init_xml2();
|
|
48134
|
-
XMLNS = "http://www.w3.org/2000/xmlns/";
|
|
48135
|
-
escapeText = (text2) => text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/\r/g, "
");
|
|
48136
|
-
qualifiedName = (xml, span2) => /^<([^\s/>]+)/.exec(xml.slice(span2.start, span2.openEnd))?.[1] ?? "";
|
|
48137
|
-
PartPatch = class {
|
|
48138
|
-
constructor(xml, rootElement) {
|
|
48139
|
-
this.xml = xml;
|
|
48140
|
-
const { root, children: children16 } = scan(xml);
|
|
48141
|
-
const kids = elements(rootElement);
|
|
48142
|
-
if (kids.length !== children16.length) throw new Error("Property part markup is not supported");
|
|
48143
|
-
kids.forEach((kid, index2) => this.spans.set(kid, children16[index2]));
|
|
48144
|
-
this.root = root;
|
|
48145
|
-
for (const attribute7 of Array.from(rootElement.attributes)) {
|
|
48146
|
-
if (attribute7.name === "xmlns") this.defaultNs = attribute7.value;
|
|
48147
|
-
else if (attribute7.namespaceURI === XMLNS || attribute7.name.startsWith("xmlns:"))
|
|
48148
|
-
this.prefixes.set(attribute7.value, attribute7.localName);
|
|
48149
|
-
}
|
|
48150
|
-
}
|
|
48151
|
-
xml;
|
|
48152
|
-
root;
|
|
48153
|
-
spans = /* @__PURE__ */ new Map();
|
|
48154
|
-
edits = [];
|
|
48155
|
-
appended = [];
|
|
48156
|
-
prefixes = /* @__PURE__ */ new Map();
|
|
48157
|
-
defaultNs = null;
|
|
48158
|
-
seq = 0;
|
|
48159
|
-
add(start, end, text2) {
|
|
48160
|
-
this.edits.push({ start, end, text: text2, seq: this.seq++ });
|
|
48161
|
-
}
|
|
48162
|
-
span(element2) {
|
|
48163
|
-
const span2 = this.spans.get(element2);
|
|
48164
|
-
if (!span2) throw new Error("Element is not a child of the patched root");
|
|
48165
|
-
return span2;
|
|
48166
|
-
}
|
|
48167
|
-
/** The prefix bound to `ns` on the root, declaring `preferred` for it when none is. */
|
|
48168
|
-
prefix(ns, preferred) {
|
|
48169
|
-
const known = this.prefixes.get(ns);
|
|
48170
|
-
if (known !== void 0) return known;
|
|
48171
|
-
const taken = new Set(this.prefixes.values());
|
|
48172
|
-
let prefix = preferred;
|
|
48173
|
-
for (let n = 1; taken.has(prefix); n++) prefix = `${preferred}${n}`;
|
|
48174
|
-
this.prefixes.set(ns, prefix);
|
|
48175
|
-
const at2 = this.root.openEnd - (this.root.selfClosing ? 2 : 1);
|
|
48176
|
-
this.add(at2, at2, ` xmlns:${prefix}="${ns}"`);
|
|
48177
|
-
return prefix;
|
|
48178
|
-
}
|
|
48179
|
-
/** `local` qualified for an element in `ns`: unprefixed in the default namespace. */
|
|
48180
|
-
qualify(ns, local, preferred) {
|
|
48181
|
-
return this.defaultNs === ns && !this.prefixes.has(ns) ? local : `${this.prefix(ns, preferred)}:${local}`;
|
|
48182
|
-
}
|
|
48183
|
-
/** Replaces the element's content, keeping its start tag (and attributes) as written. */
|
|
48184
|
-
setContent(element2, content2) {
|
|
48185
|
-
const span2 = this.span(element2);
|
|
48186
|
-
if (span2.selfClosing)
|
|
48187
|
-
this.add(span2.openEnd - 2, span2.openEnd, `>${content2}</${qualifiedName(this.xml, span2)}>`);
|
|
48188
|
-
else this.add(span2.openEnd, span2.closeStart, content2);
|
|
48189
|
-
}
|
|
48190
|
-
/** Adds ` name="value"` text to the element's start tag. */
|
|
48191
|
-
addAttribute(element2, attribute7) {
|
|
48192
|
-
const span2 = this.span(element2);
|
|
48193
|
-
const at2 = span2.openEnd - (span2.selfClosing ? 2 : 1);
|
|
48194
|
-
this.add(at2, at2, attribute7);
|
|
48195
|
-
}
|
|
48196
|
-
remove(element2) {
|
|
48197
|
-
const span2 = this.span(element2);
|
|
48198
|
-
this.add(span2.start, span2.end, "");
|
|
48199
|
-
}
|
|
48200
|
-
/** Inserts `markup` before `before`, or as the root's last child. */
|
|
48201
|
-
insert(markup, before) {
|
|
48202
|
-
if (before) {
|
|
48203
|
-
const at2 = this.span(before).start;
|
|
48204
|
-
this.add(at2, at2, markup);
|
|
48205
|
-
} else this.appended.push(markup);
|
|
48206
|
-
}
|
|
48207
|
-
toString() {
|
|
48208
|
-
const edits = [...this.edits];
|
|
48209
|
-
if (this.appended.length) {
|
|
48210
|
-
const text2 = this.appended.join("");
|
|
48211
|
-
const root = this.root;
|
|
48212
|
-
if (root.selfClosing) {
|
|
48213
|
-
const name = qualifiedName(this.xml, root);
|
|
48214
|
-
edits.push({
|
|
48215
|
-
start: root.end - 2,
|
|
48216
|
-
end: root.end,
|
|
48217
|
-
text: `>${text2}</${name}>`,
|
|
48218
|
-
seq: this.seq
|
|
48219
|
-
});
|
|
48220
|
-
} else edits.push({ start: root.closeStart, end: root.closeStart, text: text2, seq: this.seq });
|
|
48221
|
-
}
|
|
48222
|
-
edits.sort((a, b) => a.start - b.start || a.end - a.start - (b.end - b.start) || a.seq - b.seq);
|
|
48223
|
-
let out = "";
|
|
48224
|
-
let at2 = 0;
|
|
48225
|
-
for (const edit of edits) {
|
|
48226
|
-
out += this.xml.slice(at2, edit.start) + edit.text;
|
|
48227
|
-
at2 = Math.max(at2, edit.end);
|
|
48228
|
-
}
|
|
48229
|
-
return out + this.xml.slice(at2);
|
|
48230
|
-
}
|
|
48231
|
-
};
|
|
48232
|
-
}
|
|
48233
|
-
});
|
|
48234
|
-
|
|
48235
|
-
// opc/properties/core.ts
|
|
48236
|
-
function parseCoreProperties(xml) {
|
|
48237
|
-
const out = {};
|
|
48238
|
-
if (!xml) return out;
|
|
48239
|
-
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
48240
|
-
for (const [field, prefix] of FIELDS) {
|
|
48241
|
-
const text2 = first(root, field, NS[prefix])?.textContent ?? "";
|
|
48242
|
-
if (text2 !== "") out[field] = text2;
|
|
48243
|
-
}
|
|
48244
|
-
return out;
|
|
48245
|
-
}
|
|
48246
|
-
function writeCoreProperties(props, sourceXml) {
|
|
48247
|
-
const xml = sourceXml ?? EMPTY_CORE;
|
|
48248
|
-
const root = parseXml(xml, { label: "core properties" }).documentElement;
|
|
48249
|
-
const patch = new PartPatch(xml, root);
|
|
48250
|
-
for (const [field, prefix, isDate] of FIELDS) {
|
|
48251
|
-
const ns = NS[prefix];
|
|
48252
|
-
const value = props[field];
|
|
48253
|
-
const element2 = first(root, field, ns);
|
|
48254
|
-
if (value === void 0 || value === "") {
|
|
48255
|
-
if (element2 && (element2.textContent ?? "") !== "") patch.remove(element2);
|
|
48256
|
-
continue;
|
|
48257
|
-
}
|
|
48258
|
-
if (element2 && element2.textContent === value) continue;
|
|
48259
|
-
const typed = () => ` ${patch.prefix(XSI, "xsi")}:type="${patch.prefix(NS.dcterms, "dcterms")}:W3CDTF"`;
|
|
48260
|
-
if (element2) {
|
|
48261
|
-
if (isDate && !element2.getAttributeNS(XSI, "type")) patch.addAttribute(element2, typed());
|
|
48262
|
-
patch.setContent(element2, escapeText(value));
|
|
48263
|
-
continue;
|
|
48264
|
-
}
|
|
48265
|
-
const name = patch.qualify(ns, field, prefix);
|
|
48266
|
-
patch.insert(`<${name}${isDate ? typed() : ""}>${escapeText(value)}</${name}>`);
|
|
48267
|
-
}
|
|
48268
|
-
return patch.toString();
|
|
48269
|
-
}
|
|
48270
|
-
var XSI, FIELDS, EMPTY_CORE, formatW3cdtf;
|
|
48271
|
-
var init_core = __esm({
|
|
48272
|
-
"opc/properties/core.ts"() {
|
|
48273
|
-
init_xml2();
|
|
48274
|
-
init_patch();
|
|
48275
|
-
XSI = "http://www.w3.org/2001/XMLSchema-instance";
|
|
48276
|
-
FIELDS = [
|
|
48277
|
-
["title", "dc", false],
|
|
48278
|
-
["subject", "dc", false],
|
|
48279
|
-
["creator", "dc", false],
|
|
48280
|
-
["keywords", "cp", false],
|
|
48281
|
-
["description", "dc", false],
|
|
48282
|
-
["lastModifiedBy", "cp", false],
|
|
48283
|
-
["created", "dcterms", true],
|
|
48284
|
-
["modified", "dcterms", true],
|
|
48285
|
-
["category", "cp", false],
|
|
48286
|
-
["contentStatus", "cp", false],
|
|
48287
|
-
["revision", "cp", false],
|
|
48288
|
-
["language", "dc", false],
|
|
48289
|
-
["identifier", "dc", false],
|
|
48290
|
-
["lastPrinted", "cp", false],
|
|
48291
|
-
["version", "cp", false]
|
|
48292
|
-
];
|
|
48293
|
-
FIELDS.map(([field]) => field);
|
|
48294
|
-
EMPTY_CORE = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
48295
|
-
<cp:coreProperties xmlns:cp="${NS.cp}" xmlns:dc="${NS.dc}" xmlns:dcterms="${NS.dcterms}" xmlns:dcmitype="http://purl.org/dc/dcmitype/" xmlns:xsi="${XSI}"/>`;
|
|
48296
|
-
formatW3cdtf = (date5) => date5.toISOString().replace(/\.\d{3}Z$/, "Z");
|
|
48297
|
-
}
|
|
48298
|
-
});
|
|
48299
|
-
|
|
48300
|
-
// opc/properties/app.ts
|
|
48301
|
-
function namespacesOf(root) {
|
|
48302
|
-
if (root.localName !== "Properties") return void 0;
|
|
48303
|
-
if (root.namespaceURI === NS.extendedProperties) return { app: NS.extendedProperties, vt: NS.vt };
|
|
48304
|
-
if (root.namespaceURI === STRICT_APP_NAMESPACES.extendedProperties)
|
|
48305
|
-
return { app: STRICT_APP_NAMESPACES.extendedProperties, vt: STRICT_APP_NAMESPACES.vt };
|
|
48306
|
-
return void 0;
|
|
48307
|
-
}
|
|
48308
|
-
function vectorItems(element2, vt) {
|
|
48309
|
-
const vector = first(element2, "vector", vt);
|
|
48310
|
-
return vector ? elements(vector) : [];
|
|
48311
|
-
}
|
|
48312
|
-
function readPairs(element2, vt) {
|
|
48313
|
-
const variants = vectorItems(element2, vt).map((variant) => elements(variant)[0]);
|
|
48314
|
-
const out = [];
|
|
48315
|
-
for (let i2 = 0; i2 + 1 < variants.length; i2 += 2) {
|
|
48316
|
-
const name = variants[i2]?.textContent ?? "";
|
|
48317
|
-
const count2 = Number.parseInt(variants[i2 + 1]?.textContent ?? "", 10);
|
|
48318
|
-
out.push({ name, count: Number.isFinite(count2) ? count2 : 0 });
|
|
48319
|
-
}
|
|
48320
|
-
return out;
|
|
48321
|
-
}
|
|
48322
|
-
function readField(element2, kind, vt) {
|
|
48323
|
-
const text2 = element2.textContent ?? "";
|
|
48324
|
-
if (kind === "pairs") return readPairs(element2, vt);
|
|
48325
|
-
if (kind === "titles") return vectorItems(element2, vt).map((item2) => item2.textContent ?? "");
|
|
48326
|
-
if (kind === "bool") return text2.trim() === "true" || text2.trim() === "1";
|
|
48327
|
-
if (kind === "int") {
|
|
48328
|
-
const value = Number.parseInt(text2, 10);
|
|
48329
|
-
return Number.isFinite(value) ? value : void 0;
|
|
48330
|
-
}
|
|
48331
|
-
return text2 === "" ? void 0 : text2;
|
|
48332
|
-
}
|
|
48333
|
-
function readKnown(root, ns) {
|
|
48334
|
-
const out = {};
|
|
48335
|
-
for (const [field, local, kind] of FIELDS2) {
|
|
48336
|
-
const element2 = first(root, local, ns.app);
|
|
48337
|
-
if (!element2) continue;
|
|
48338
|
-
const value = readField(element2, kind, ns.vt);
|
|
48339
|
-
if (value !== void 0) out[field] = value;
|
|
48340
|
-
}
|
|
48341
|
-
return out;
|
|
48342
|
-
}
|
|
48343
|
-
function parseAppProperties(xml) {
|
|
48344
|
-
if (!xml) return {};
|
|
48345
|
-
const root = parseXml(xml, { label: "app properties" }).documentElement;
|
|
48346
|
-
const ns = namespacesOf(root);
|
|
48347
|
-
return ns ? readKnown(root, ns) : {};
|
|
48348
|
-
}
|
|
48349
|
-
function content(kind, value, vt) {
|
|
48350
|
-
if (kind === "bool") return value ? "true" : "false";
|
|
48351
|
-
if (kind === "int") return String(Math.trunc(value));
|
|
48352
|
-
if (kind === "text") return escapeText(String(value));
|
|
48353
|
-
const item2 = (local, text2) => `<${vt}:${local}>${escapeText(text2)}</${vt}:${local}>`;
|
|
48354
|
-
const items = kind === "pairs" ? value.flatMap((pair) => [
|
|
48355
|
-
`<${vt}:variant>${item2("lpstr", pair.name)}</${vt}:variant>`,
|
|
48356
|
-
`<${vt}:variant>${item2("i4", String(Math.trunc(pair.count)))}</${vt}:variant>`
|
|
48357
|
-
]) : value.map((title) => item2("lpstr", title));
|
|
48358
|
-
const baseType = kind === "pairs" ? "variant" : "lpstr";
|
|
48359
|
-
return `<${vt}:vector size="${items.length}" baseType="${baseType}">${items.join("")}</${vt}:vector>`;
|
|
48360
|
-
}
|
|
48361
|
-
function writeAppProperties(props, sourceXml) {
|
|
48362
|
-
const xml = sourceXml ?? EMPTY_APP;
|
|
48363
|
-
const root = parseXml(xml, { label: "app properties" }).documentElement;
|
|
48364
|
-
const ns = namespacesOf(root);
|
|
48365
|
-
if (!ns) throw new Error("app properties root is not an extended-properties element");
|
|
48366
|
-
const patch = new PartPatch(xml, root);
|
|
48367
|
-
const prior = readKnown(root, ns);
|
|
48368
|
-
const ownPrefix = root.prefix ? `${root.prefix}:` : "";
|
|
48369
|
-
FIELDS2.forEach(([field, local, kind], index2) => {
|
|
48370
|
-
const value = props[field];
|
|
48371
|
-
const existing = first(root, local, ns.app);
|
|
48372
|
-
if (value === void 0 || kind === "text" && value === "") {
|
|
48373
|
-
if (existing && (existing.textContent ?? "") !== "") patch.remove(existing);
|
|
48374
|
-
return;
|
|
48375
|
-
}
|
|
48376
|
-
if (existing && same3(prior[field], value)) return;
|
|
48377
|
-
const vt = kind === "pairs" || kind === "titles" ? patch.prefix(ns.vt, "vt") : "";
|
|
48378
|
-
const body = content(kind, value, vt);
|
|
48379
|
-
if (existing) {
|
|
48380
|
-
patch.setContent(existing, body);
|
|
48381
|
-
return;
|
|
48382
|
-
}
|
|
48383
|
-
const next = FIELDS2.slice(index2 + 1).map(([, name]) => first(root, name, ns.app)).find((node2) => node2 !== void 0);
|
|
48384
|
-
patch.insert(`<${ownPrefix}${local}>${body}</${ownPrefix}${local}>`, next);
|
|
48385
|
-
});
|
|
48386
|
-
return patch.toString();
|
|
48387
|
-
}
|
|
48388
|
-
var FIELDS2, STRICT_APP_NAMESPACES, EMPTY_APP, same3;
|
|
48389
|
-
var init_app = __esm({
|
|
48390
|
-
"opc/properties/app.ts"() {
|
|
48391
|
-
init_xml2();
|
|
48392
|
-
init_patch();
|
|
48393
|
-
FIELDS2 = [
|
|
48394
|
-
["template", "Template", "text"],
|
|
48395
|
-
["totalTime", "TotalTime", "int"],
|
|
48396
|
-
["pages", "Pages", "int"],
|
|
48397
|
-
["words", "Words", "int"],
|
|
48398
|
-
["characters", "Characters", "int"],
|
|
48399
|
-
["application", "Application", "text"],
|
|
48400
|
-
["docSecurity", "DocSecurity", "int"],
|
|
48401
|
-
["presentationFormat", "PresentationFormat", "text"],
|
|
48402
|
-
["lines", "Lines", "int"],
|
|
48403
|
-
["paragraphs", "Paragraphs", "int"],
|
|
48404
|
-
["slides", "Slides", "int"],
|
|
48405
|
-
["notes", "Notes", "int"],
|
|
48406
|
-
["hiddenSlides", "HiddenSlides", "int"],
|
|
48407
|
-
["mmClips", "MMClips", "int"],
|
|
48408
|
-
["scaleCrop", "ScaleCrop", "bool"],
|
|
48409
|
-
["headingPairs", "HeadingPairs", "pairs"],
|
|
48410
|
-
["titlesOfParts", "TitlesOfParts", "titles"],
|
|
48411
|
-
["manager", "Manager", "text"],
|
|
48412
|
-
["company", "Company", "text"],
|
|
48413
|
-
["linksUpToDate", "LinksUpToDate", "bool"],
|
|
48414
|
-
["charactersWithSpaces", "CharactersWithSpaces", "int"],
|
|
48415
|
-
["sharedDoc", "SharedDoc", "bool"],
|
|
48416
|
-
["hyperlinkBase", "HyperlinkBase", "text"],
|
|
48417
|
-
["hyperlinksChanged", "HyperlinksChanged", "bool"],
|
|
48418
|
-
["appVersion", "AppVersion", "text"]
|
|
48419
|
-
];
|
|
48420
|
-
STRICT_APP_NAMESPACES = {
|
|
48421
|
-
extendedProperties: "http://purl.oclc.org/ooxml/officeDocument/extendedProperties",
|
|
48422
|
-
vt: "http://purl.oclc.org/ooxml/officeDocument/docPropsVTypes"
|
|
48423
|
-
};
|
|
48424
|
-
EMPTY_APP = `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
48425
|
-
<Properties xmlns="${NS.extendedProperties}" xmlns:vt="${NS.vt}"/>`;
|
|
48426
|
-
same3 = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
48427
|
-
}
|
|
48428
|
-
});
|
|
48429
|
-
|
|
48430
|
-
// opc/properties/custom.ts
|
|
48431
|
-
function allocateCustomPropertyIds(properties) {
|
|
48432
|
-
const used = /* @__PURE__ */ new Set();
|
|
48433
|
-
const kept = properties.map((property) => {
|
|
48434
|
-
const pid = property.pid;
|
|
48435
|
-
if (pid === void 0 || !Number.isInteger(pid) || pid < 2 || used.has(pid)) return void 0;
|
|
48436
|
-
used.add(pid);
|
|
48437
|
-
return pid;
|
|
48438
|
-
});
|
|
48439
|
-
let next = Math.max(1, ...used) + 1;
|
|
48440
|
-
return kept.map((pid) => pid ?? next++);
|
|
48441
|
-
}
|
|
48442
|
-
function variantXml(property) {
|
|
48443
|
-
switch (property.type) {
|
|
48444
|
-
case "raw":
|
|
48445
|
-
return property.xml;
|
|
48446
|
-
case "lpwstr":
|
|
48447
|
-
return `<vt:lpwstr>${escape(property.value)}</vt:lpwstr>`;
|
|
48448
|
-
case "i4":
|
|
48449
|
-
return `<vt:i4>${Math.trunc(property.value)}</vt:i4>`;
|
|
48450
|
-
case "r8":
|
|
48451
|
-
return `<vt:r8>${String(property.value)}</vt:r8>`;
|
|
48452
|
-
case "bool":
|
|
48453
|
-
return `<vt:bool>${property.value ? "true" : "false"}</vt:bool>`;
|
|
48454
|
-
case "filetime":
|
|
48455
|
-
return `<vt:filetime>${escape(property.value)}</vt:filetime>`;
|
|
48456
|
-
}
|
|
48457
|
-
}
|
|
48458
|
-
function writeCustomProperties(properties) {
|
|
48459
|
-
const seen = /* @__PURE__ */ new Set();
|
|
48460
|
-
const unique = properties.filter((property) => {
|
|
48461
|
-
const key2 = property.name.toLowerCase();
|
|
48462
|
-
if (!property.name || seen.has(key2)) return false;
|
|
48463
|
-
seen.add(key2);
|
|
48464
|
-
return true;
|
|
48465
|
-
});
|
|
48466
|
-
if (!unique.length) return void 0;
|
|
48467
|
-
const pids = allocateCustomPropertyIds(unique);
|
|
48468
|
-
const body = unique.map((property, index2) => {
|
|
48469
|
-
const link = property.linkTarget ? ` linkTarget="${escape(property.linkTarget, true)}"` : "";
|
|
48470
|
-
return `<property fmtid="${CUSTOM_PROPERTIES_FMTID}" pid="${pids[index2] ?? index2 + 2}" name="${escape(property.name, true)}"${link}>${variantXml(property)}</property>`;
|
|
48471
|
-
}).join("");
|
|
48472
|
-
return `<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
|
48473
|
-
<Properties xmlns="${NS.customProperties}" xmlns:vt="${NS.vt}">${body}</Properties>`;
|
|
48474
|
-
}
|
|
48475
|
-
function parseCustomPropertyTexts(xml) {
|
|
48476
|
-
if (!xml) return [];
|
|
48477
|
-
const root = parseXml(xml, { label: "custom properties" }).documentElement;
|
|
48478
|
-
const out = [];
|
|
48479
|
-
for (const property of children2(root, "property", NS.customProperties)) {
|
|
48480
|
-
const name = property.getAttribute("name") ?? "";
|
|
48481
|
-
if (!name) continue;
|
|
48482
|
-
const variant = elements(property)[0];
|
|
48483
|
-
const pid = Number.parseInt(property.getAttribute("pid") ?? "", 10);
|
|
48484
|
-
out.push({
|
|
48485
|
-
name,
|
|
48486
|
-
type: variant && isVt(variant) ? variant.localName : "",
|
|
48487
|
-
text: variant?.textContent ?? "",
|
|
48488
|
-
...Number.isFinite(pid) ? { pid } : {}
|
|
48489
|
-
});
|
|
48490
|
-
}
|
|
48491
|
-
return out;
|
|
48492
|
-
}
|
|
48493
|
-
function customPropertyFromText(name, type, text2) {
|
|
48494
|
-
switch (type) {
|
|
48495
|
-
case "lpwstr":
|
|
48496
|
-
case "filetime":
|
|
48497
|
-
return { name, type, value: text2 };
|
|
48498
|
-
case "i4": {
|
|
48499
|
-
const value = Number.parseInt(text2, 10);
|
|
48500
|
-
if (INT32.test(text2) && String(value) === text2 && value === (value | 0))
|
|
48501
|
-
return { name, type, value };
|
|
48502
|
-
break;
|
|
48503
|
-
}
|
|
48504
|
-
case "r8": {
|
|
48505
|
-
const value = Number(text2);
|
|
48506
|
-
if (text2.trim() !== "" && String(value) === text2) return { name, type, value };
|
|
48507
|
-
break;
|
|
48508
|
-
}
|
|
48509
|
-
case "bool":
|
|
48510
|
-
if (text2 === "true" || text2 === "false") return { name, type, value: text2 === "true" };
|
|
48511
|
-
break;
|
|
48512
|
-
default:
|
|
48513
|
-
if (!/^[A-Za-z][A-Za-z0-9]*$/.test(type)) return { name, type: "lpwstr", value: text2 };
|
|
48514
|
-
}
|
|
48515
|
-
return { name, type: "raw", xml: `<vt:${type}>${escape(text2)}</vt:${type}>` };
|
|
48516
|
-
}
|
|
48517
|
-
var escape, isVt, INT32;
|
|
48518
|
-
var init_custom = __esm({
|
|
48519
|
-
"opc/properties/custom.ts"() {
|
|
48520
|
-
init_xml2();
|
|
48521
|
-
init_types5();
|
|
48522
|
-
escape = (text2, attribute7 = false) => {
|
|
48523
|
-
const out = text2.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">");
|
|
48524
|
-
return attribute7 ? out.replace(/"/g, """) : out;
|
|
48525
|
-
};
|
|
48526
|
-
isVt = (element2) => element2.namespaceURI === NS.vt || element2.prefix === "vt";
|
|
48527
|
-
INT32 = /^-?\d+$/;
|
|
48528
|
-
}
|
|
48529
|
-
});
|
|
48530
|
-
|
|
48531
|
-
// opc/properties/title-groups.ts
|
|
48532
|
-
function titleGroups(headingPairs, titlesOfParts) {
|
|
48533
|
-
let offset = 0;
|
|
48534
|
-
return headingPairs.map((pair) => {
|
|
48535
|
-
const count2 = Math.max(0, pair.count);
|
|
48536
|
-
const titles = titlesOfParts.slice(offset, offset + count2);
|
|
48537
|
-
offset += count2;
|
|
48538
|
-
return { name: pair.name, titles };
|
|
48539
|
-
});
|
|
48540
|
-
}
|
|
48541
|
-
function fromTitleGroups(groups) {
|
|
48542
|
-
return {
|
|
48543
|
-
headingPairs: groups.map((group) => ({ name: group.name, count: group.titles.length })),
|
|
48544
|
-
titlesOfParts: groups.flatMap((group) => group.titles)
|
|
48545
|
-
};
|
|
48546
|
-
}
|
|
48547
|
-
function replaceTitleGroup(headingPairs, titlesOfParts, group) {
|
|
48548
|
-
const match = group.match ?? ((name) => name === group.name);
|
|
48549
|
-
const groups = titleGroups(headingPairs, titlesOfParts);
|
|
48550
|
-
const target = groups.find((entry2) => match(entry2.name));
|
|
48551
|
-
if (target) target.titles = [...group.titles];
|
|
48552
|
-
else groups.push({ name: group.name, titles: [...group.titles] });
|
|
48553
|
-
return fromTitleGroups(groups);
|
|
48554
|
-
}
|
|
48555
|
-
var init_title_groups = __esm({
|
|
48556
|
-
"opc/properties/title-groups.ts"() {
|
|
48557
|
-
}
|
|
48558
|
-
});
|
|
48559
|
-
|
|
48560
|
-
// opc/properties/index.ts
|
|
48561
|
-
var init_properties = __esm({
|
|
48562
|
-
"opc/properties/index.ts"() {
|
|
48563
|
-
init_types5();
|
|
48564
|
-
init_core();
|
|
48565
|
-
init_app();
|
|
48566
|
-
init_custom();
|
|
48567
|
-
init_title_groups();
|
|
48568
|
-
}
|
|
48569
|
-
});
|
|
48570
|
-
|
|
48571
48840
|
// opc/signature/detection.ts
|
|
48572
48841
|
function detectDigitalSignatures(zipEntryPaths) {
|
|
48573
48842
|
const sigPaths = zipEntryPaths.filter(
|
|
@@ -48742,7 +49011,7 @@ function withDiagramPictureSources(dataXml2, source2) {
|
|
|
48742
49011
|
const doc = parseXml(dataXml2);
|
|
48743
49012
|
const root = doc.documentElement;
|
|
48744
49013
|
const points7 = first(root, "ptLst", NS.dgm);
|
|
48745
|
-
const live =
|
|
49014
|
+
const live = children(points7 ?? root, "pt", NS.dgm).filter(
|
|
48746
49015
|
(point2) => !["doc", "pres", "parTrans", "sibTrans"].includes(point2.getAttribute("type") ?? "node")
|
|
48747
49016
|
);
|
|
48748
49017
|
for (const element2 of [...root.getElementsByTagNameNS(DIAGRAM_PICTURE_SOURCE_NS, "pictures")]) {
|
|
@@ -48770,7 +49039,7 @@ function withDiagramPictureSources(dataXml2, source2) {
|
|
|
48770
49039
|
const fill3 = parseXml(picture.fill.sourceXml).documentElement;
|
|
48771
49040
|
element2.appendChild(doc.importNode(fill3, true));
|
|
48772
49041
|
payload.appendChild(element2);
|
|
48773
|
-
const presentations =
|
|
49042
|
+
const presentations = children(points7 ?? root, "pt", NS.dgm).filter((point2) => {
|
|
48774
49043
|
const props = first(point2, "prSet", NS.dgm);
|
|
48775
49044
|
return point2.getAttribute("type") === "pres" && props?.getAttribute("presAssocID") === picture.nodeId && (picture.role && props.getAttribute("presName") === picture.role || picture.styleLabel && props.getAttribute("presStyleLbl") === picture.styleLabel);
|
|
48776
49045
|
});
|
|
@@ -48876,7 +49145,7 @@ function diagramLayoutData(input2) {
|
|
|
48876
49145
|
data.layoutDefinition = { rootNode: {}, rawXmlText: input2.source.layoutXml };
|
|
48877
49146
|
if (input2.source?.dataXml) {
|
|
48878
49147
|
const root = parseXml(input2.source.dataXml).documentElement;
|
|
48879
|
-
const vars =
|
|
49148
|
+
const vars = descendants(root, "presLayoutVars")[0];
|
|
48880
49149
|
const direction = first(vars, "dir", NS.dgm)?.getAttribute("val");
|
|
48881
49150
|
const values = {};
|
|
48882
49151
|
if (direction === "norm" || direction === "rev") values.direction = direction;
|
|
@@ -48934,7 +49203,7 @@ function previewDiagramLayout(input2) {
|
|
|
48934
49203
|
const computed = runEngineLayout(data, box, data.nodes, palette, intensity);
|
|
48935
49204
|
if (computed) {
|
|
48936
49205
|
const result = applyCustomLayoutOverrides(computed, data.nodes, box);
|
|
48937
|
-
const declaresConnectors = input2.source?.layoutXml &&
|
|
49206
|
+
const declaresConnectors = input2.source?.layoutXml && descendants(parseXml(input2.source.layoutXml).documentElement, "alg").some(
|
|
48938
49207
|
(algorithm) => algorithm.getAttribute("type") === "conn"
|
|
48939
49208
|
);
|
|
48940
49209
|
if (declaresConnectors && data.nodes.some((node2) => node2.parentId) && !result.nodes.some((node2) => /connector|^line(?:Inv)?$/i.test(node2.presetOverride ?? "")))
|
|
@@ -49103,7 +49372,7 @@ function add(parent, namespace, name, attrs4 = {}) {
|
|
|
49103
49372
|
function withDiagramDrawingRelationship(xml, relationshipId2) {
|
|
49104
49373
|
const doc = parseXml(xml);
|
|
49105
49374
|
const model2 = doc.documentElement;
|
|
49106
|
-
let extension =
|
|
49375
|
+
let extension = descendants(model2, "dataModelExt").find((node2) => node2.namespaceURI === DSP2);
|
|
49107
49376
|
if (!extension) {
|
|
49108
49377
|
const extLst = first(model2, "extLst", NS.dgm) ?? add(model2, NS.dgm, "dgm:extLst");
|
|
49109
49378
|
extension = add(add(extLst, NS.a, "a:ext", { uri: DSP2 }), DSP2, "dsp:dataModelExt", {
|
|
@@ -49151,7 +49420,7 @@ function buildGeneratedDiagramCache(dataXml2, input2) {
|
|
|
49151
49420
|
(effect) => effect.kind !== "outerShadow" || !resolveDrawingOuterShadow(effect, { scheme: (name) => scheme2[name] })
|
|
49152
49421
|
))
|
|
49153
49422
|
return void 0;
|
|
49154
|
-
const point2 =
|
|
49423
|
+
const point2 = children(points7, "pt", NS.dgm).find(
|
|
49155
49424
|
(point3) => point3.getAttribute("modelId") === shape2.sourceNodeId
|
|
49156
49425
|
);
|
|
49157
49426
|
const direct = model2.nodes.find((node2) => node2.modelId === shape2.sourceNodeId);
|
|
@@ -49217,21 +49486,21 @@ function buildGeneratedDiagramCache(dataXml2, input2) {
|
|
|
49217
49486
|
} catch {
|
|
49218
49487
|
return void 0;
|
|
49219
49488
|
}
|
|
49220
|
-
const oldMarkers =
|
|
49489
|
+
const oldMarkers = descendants(root, "generatedCache").filter(
|
|
49221
49490
|
(node2) => node2.namespaceURI === GENERATED_DIAGRAM_CACHE_NS
|
|
49222
49491
|
);
|
|
49223
49492
|
const oldIds = new Set(
|
|
49224
49493
|
oldMarkers.flatMap(
|
|
49225
|
-
(marker3) =>
|
|
49494
|
+
(marker3) => descendants(marker3, "shape").map((node2) => node2.getAttribute("id"))
|
|
49226
49495
|
)
|
|
49227
49496
|
);
|
|
49228
|
-
for (const point2 of
|
|
49497
|
+
for (const point2 of children(points7, "pt", NS.dgm))
|
|
49229
49498
|
if (oldIds.has(point2.getAttribute("modelId"))) points7.removeChild(point2);
|
|
49230
|
-
for (const edge of
|
|
49499
|
+
for (const edge of children(connections, "cxn", NS.dgm))
|
|
49231
49500
|
if (oldIds.has(edge.getAttribute("destId"))) connections.removeChild(edge);
|
|
49232
49501
|
for (const marker3 of oldMarkers) {
|
|
49233
49502
|
const parent = marker3.parentNode;
|
|
49234
|
-
if (parent &&
|
|
49503
|
+
if (parent && children(parent, "generatedCache", GENERATED_DIAGRAM_CACHE_NS).length === 1 && parent.childNodes.length === 1)
|
|
49235
49504
|
parent.parentNode?.removeChild(parent);
|
|
49236
49505
|
else parent?.removeChild(marker3);
|
|
49237
49506
|
}
|
|
@@ -49428,7 +49697,7 @@ function parseParagraph(paragraph2) {
|
|
|
49428
49697
|
function parseDrawingTextBody(body) {
|
|
49429
49698
|
if (!body) return void 0;
|
|
49430
49699
|
const properties = first(body, "bodyPr", NS.a);
|
|
49431
|
-
const paragraphs =
|
|
49700
|
+
const paragraphs = children(body, "p", NS.a).map(parseParagraph);
|
|
49432
49701
|
const result = {
|
|
49433
49702
|
paragraphs,
|
|
49434
49703
|
text: paragraphs.map((paragraph2) => paragraph2.runs.map((run2) => run2.text).join("")).join("\n")
|
|
@@ -49464,14 +49733,14 @@ function operand(value, vars) {
|
|
|
49464
49733
|
function parseCustomGeometry(custom2, width, height) {
|
|
49465
49734
|
const pathList = first(custom2, "pathLst", NS.a);
|
|
49466
49735
|
if (!pathList) return void 0;
|
|
49467
|
-
const pathNodes =
|
|
49736
|
+
const pathNodes = children(pathList, "path", NS.a);
|
|
49468
49737
|
const contextWidth = width;
|
|
49469
49738
|
const contextHeight = height;
|
|
49470
49739
|
const vars = createBuiltinVariables({ w: contextWidth, h: contextHeight });
|
|
49471
49740
|
for (const list3 of ["avLst", "gdLst"]) {
|
|
49472
49741
|
const parent = first(custom2, list3, NS.a);
|
|
49473
49742
|
if (!parent) continue;
|
|
49474
|
-
for (const guide of
|
|
49743
|
+
for (const guide of children(parent, "gd", NS.a)) {
|
|
49475
49744
|
const name = guide.getAttribute("name");
|
|
49476
49745
|
const formula2 = parseFormula(guide.getAttribute("fmla") ?? "");
|
|
49477
49746
|
if (!name || ARITY2[formula2.op] !== formula2.args.length || formula2.args.some((arg) => !Number.isFinite(operand(arg, vars))))
|
|
@@ -49487,7 +49756,7 @@ function parseCustomGeometry(custom2, width, height) {
|
|
|
49487
49756
|
const value = (node2, name) => operand(node2.getAttribute(name), vars);
|
|
49488
49757
|
for (const node2 of elements(path4)) {
|
|
49489
49758
|
if (node2.namespaceURI !== NS.a) return void 0;
|
|
49490
|
-
const points7 =
|
|
49759
|
+
const points7 = children(node2, "pt", NS.a).map((point2) => ({
|
|
49491
49760
|
x: value(point2, "x"),
|
|
49492
49761
|
y: value(point2, "y")
|
|
49493
49762
|
}));
|
|
@@ -49600,7 +49869,7 @@ function parseDrawingGeometry(spPr) {
|
|
|
49600
49869
|
const adjustments = {};
|
|
49601
49870
|
const avLst = first(preset, "avLst", NS.a);
|
|
49602
49871
|
if (avLst)
|
|
49603
|
-
for (const guide of
|
|
49872
|
+
for (const guide of children(avLst, "gd", NS.a)) {
|
|
49604
49873
|
const name = guide.getAttribute("name");
|
|
49605
49874
|
const match = /^val\s+(-?\d+)/u.exec(guide.getAttribute("fmla") ?? "");
|
|
49606
49875
|
if (name && match?.[1]) adjustments[name] = Number.parseInt(match[1], 10);
|
|
@@ -50422,7 +50691,7 @@ var init_shape_path_gradient = __esm({
|
|
|
50422
50691
|
// diagram/index.ts
|
|
50423
50692
|
var init_diagram = __esm({
|
|
50424
50693
|
"diagram/index.ts"() {
|
|
50425
|
-
|
|
50694
|
+
init_types4();
|
|
50426
50695
|
init_engine2();
|
|
50427
50696
|
init_layout();
|
|
50428
50697
|
init_hierarchy();
|
|
@@ -79102,117 +79371,6 @@ var init_app_properties_text_stats = __esm({
|
|
|
79102
79371
|
}
|
|
79103
79372
|
});
|
|
79104
79373
|
|
|
79105
|
-
// pptx/core/utils/document-properties-model.ts
|
|
79106
|
-
function toPptxCoreProperties(core) {
|
|
79107
|
-
const result = {};
|
|
79108
|
-
for (const field of CORE_FIELDS) result[field] = trimmed(core[field]);
|
|
79109
|
-
return anyDefined(result) ? result : void 0;
|
|
79110
|
-
}
|
|
79111
|
-
function toPptxAppProperties(app) {
|
|
79112
|
-
const result = {
|
|
79113
|
-
application: trimmed(app.application),
|
|
79114
|
-
appVersion: trimmed(app.appVersion),
|
|
79115
|
-
presentationFormat: trimmed(app.presentationFormat),
|
|
79116
|
-
slides: app.slides,
|
|
79117
|
-
hiddenSlides: app.hiddenSlides,
|
|
79118
|
-
notes: app.notes,
|
|
79119
|
-
totalTime: app.totalTime,
|
|
79120
|
-
words: app.words,
|
|
79121
|
-
paragraphs: app.paragraphs,
|
|
79122
|
-
company: trimmed(app.company),
|
|
79123
|
-
manager: trimmed(app.manager),
|
|
79124
|
-
template: trimmed(app.template),
|
|
79125
|
-
hyperlinkBase: trimmed(app.hyperlinkBase),
|
|
79126
|
-
docSecurity: app.docSecurity,
|
|
79127
|
-
mmClips: app.mmClips,
|
|
79128
|
-
scaleCrop: app.scaleCrop,
|
|
79129
|
-
linksUpToDate: app.linksUpToDate,
|
|
79130
|
-
sharedDoc: app.sharedDoc,
|
|
79131
|
-
hyperlinksChanged: app.hyperlinksChanged
|
|
79132
|
-
};
|
|
79133
|
-
return anyDefined(result) ? result : void 0;
|
|
79134
|
-
}
|
|
79135
|
-
function toPptxCustomProperties(texts) {
|
|
79136
|
-
return texts.flatMap((entry2) => {
|
|
79137
|
-
const name = entry2.name.trim();
|
|
79138
|
-
if (!name) return [];
|
|
79139
|
-
const known = CUSTOM_TYPES.has(entry2.type);
|
|
79140
|
-
return [{ name, value: known ? entry2.text : "", type: known ? entry2.type : "unknown" }];
|
|
79141
|
-
});
|
|
79142
|
-
}
|
|
79143
|
-
function applyCoreOverrides(core, overrides) {
|
|
79144
|
-
const next = { ...core };
|
|
79145
|
-
for (const field of CORE_FIELDS) {
|
|
79146
|
-
const value = overrides?.[field];
|
|
79147
|
-
if (value === void 0) continue;
|
|
79148
|
-
const text2 = String(value).trim();
|
|
79149
|
-
if (text2) next[field] = text2;
|
|
79150
|
-
else delete next[field];
|
|
79151
|
-
}
|
|
79152
|
-
return next;
|
|
79153
|
-
}
|
|
79154
|
-
function applyAppOverrides(app, overrides) {
|
|
79155
|
-
const next = { ...app };
|
|
79156
|
-
for (const field of APP_TEXT_OVERRIDES) {
|
|
79157
|
-
const value = overrides?.[field];
|
|
79158
|
-
if (value === void 0) continue;
|
|
79159
|
-
const text2 = String(value).trim();
|
|
79160
|
-
if (text2) next[field] = text2;
|
|
79161
|
-
else delete next[field];
|
|
79162
|
-
}
|
|
79163
|
-
for (const field of APP_NUMBER_OVERRIDES) {
|
|
79164
|
-
const value = Number(overrides?.[field]);
|
|
79165
|
-
if (overrides?.[field] !== void 0 && Number.isFinite(value)) next[field] = Math.trunc(value);
|
|
79166
|
-
}
|
|
79167
|
-
return next;
|
|
79168
|
-
}
|
|
79169
|
-
function toCustomProperty(entry2) {
|
|
79170
|
-
const type = String(entry2.type || "lpwstr").trim().toLowerCase();
|
|
79171
|
-
return customPropertyFromText(
|
|
79172
|
-
entry2.name,
|
|
79173
|
-
CUSTOM_TYPES.has(type) ? type : "lpwstr",
|
|
79174
|
-
String(entry2.value ?? "")
|
|
79175
|
-
);
|
|
79176
|
-
}
|
|
79177
|
-
var CORE_FIELDS, APP_TEXT_OVERRIDES, APP_NUMBER_OVERRIDES, trimmed, anyDefined, CUSTOM_TYPES;
|
|
79178
|
-
var init_document_properties_model = __esm({
|
|
79179
|
-
"pptx/core/utils/document-properties-model.ts"() {
|
|
79180
|
-
init_properties();
|
|
79181
|
-
CORE_FIELDS = [
|
|
79182
|
-
"title",
|
|
79183
|
-
"subject",
|
|
79184
|
-
"creator",
|
|
79185
|
-
"keywords",
|
|
79186
|
-
"description",
|
|
79187
|
-
"lastModifiedBy",
|
|
79188
|
-
"revision",
|
|
79189
|
-
"created",
|
|
79190
|
-
"modified",
|
|
79191
|
-
"category",
|
|
79192
|
-
"contentStatus"
|
|
79193
|
-
];
|
|
79194
|
-
APP_TEXT_OVERRIDES = [
|
|
79195
|
-
"application",
|
|
79196
|
-
"appVersion",
|
|
79197
|
-
"presentationFormat",
|
|
79198
|
-
"company",
|
|
79199
|
-
"manager",
|
|
79200
|
-
"template"
|
|
79201
|
-
];
|
|
79202
|
-
APP_NUMBER_OVERRIDES = [
|
|
79203
|
-
"slides",
|
|
79204
|
-
"hiddenSlides",
|
|
79205
|
-
"notes",
|
|
79206
|
-
"totalTime",
|
|
79207
|
-
"words",
|
|
79208
|
-
"paragraphs"
|
|
79209
|
-
];
|
|
79210
|
-
trimmed = (value) => value?.trim() || void 0;
|
|
79211
|
-
anyDefined = (record3) => Object.values(record3).some((value) => value !== void 0);
|
|
79212
|
-
CUSTOM_TYPES = /* @__PURE__ */ new Set(["lpwstr", "i4", "bool", "filetime", "r8", "i2", "ui4", "lpstr"]);
|
|
79213
|
-
}
|
|
79214
|
-
});
|
|
79215
|
-
|
|
79216
79374
|
// pptx/core/services/custom-properties-package.ts
|
|
79217
79375
|
async function ensureCustomPropertiesPackagingArtifacts(context) {
|
|
79218
79376
|
const ctFile = context.zip.file("[Content_Types].xml");
|
|
@@ -105878,7 +106036,7 @@ var init_parse_util = __esm({
|
|
|
105878
106036
|
function parseCache(node2) {
|
|
105879
106037
|
const cache = {
|
|
105880
106038
|
type: node2.localName === "numCache" || node2.localName === "numLit" ? "number" : "string",
|
|
105881
|
-
points:
|
|
106039
|
+
points: children(node2, "pt", NS.c).map((pt2) => {
|
|
105882
106040
|
const point2 = { value: cChild(pt2, "v")?.textContent ?? "" };
|
|
105883
106041
|
const index2 = Number(attribute6(pt2, "idx") ?? Number.NaN);
|
|
105884
106042
|
if (Number.isInteger(index2) && index2 >= 0) point2.index = index2;
|
|
@@ -105905,7 +106063,7 @@ function parseDataSource(element2) {
|
|
|
105905
106063
|
if (cache) source2.cache = parseCache(cache);
|
|
105906
106064
|
const levels = cChild(ref, "multiLvlStrCache");
|
|
105907
106065
|
if (levels) {
|
|
105908
|
-
source2.levels =
|
|
106066
|
+
source2.levels = children(levels, "lvl", NS.c).map(parseCache);
|
|
105909
106067
|
const count2 = Number(cVal(levels, "ptCount") ?? Number.NaN);
|
|
105910
106068
|
if (Number.isInteger(count2) && count2 >= 0) source2.levelPointCount = count2;
|
|
105911
106069
|
}
|
|
@@ -105974,7 +106132,7 @@ function labelOptions(context, element2) {
|
|
|
105974
106132
|
}
|
|
105975
106133
|
function parseDataLabels(context, element2) {
|
|
105976
106134
|
if (!element2) return void 0;
|
|
105977
|
-
const labels2 =
|
|
106135
|
+
const labels2 = children(element2, "dLbl", NS.c).map((node2) => {
|
|
105978
106136
|
reportUnmodelled(context, node2, LABEL);
|
|
105979
106137
|
return assignDefined(labelOptions(context, node2), {
|
|
105980
106138
|
index: cNumber(context, node2, "idx"),
|
|
@@ -106258,10 +106416,10 @@ function parseErrorBars(context, element2) {
|
|
|
106258
106416
|
);
|
|
106259
106417
|
}
|
|
106260
106418
|
function parseSeriesAnalysis(context, series) {
|
|
106261
|
-
const trendlines =
|
|
106419
|
+
const trendlines = children(series, "trendline", NS.c).map(
|
|
106262
106420
|
(node2) => parseTrendline(context, node2)
|
|
106263
106421
|
);
|
|
106264
|
-
const errorBars2 =
|
|
106422
|
+
const errorBars2 = children(series, "errBars", NS.c).map((node2) => parseErrorBars(context, node2));
|
|
106265
106423
|
return {
|
|
106266
106424
|
...trendlines.length ? { trendlines } : {},
|
|
106267
106425
|
...errorBars2.length ? { errorBars: errorBars2 } : {}
|
|
@@ -106346,7 +106504,7 @@ function parseSeries(context, element2) {
|
|
|
106346
106504
|
reportUnmodelled(context, element2, SERIES);
|
|
106347
106505
|
return assignDefined(
|
|
106348
106506
|
{
|
|
106349
|
-
dataPoints:
|
|
106507
|
+
dataPoints: children(element2, "dPt", NS.c).map((point2) => parseDataPoint(context, point2)),
|
|
106350
106508
|
...parseSeriesAnalysis(context, element2)
|
|
106351
106509
|
},
|
|
106352
106510
|
{
|
|
@@ -106419,7 +106577,7 @@ var init_parse_series = __esm({
|
|
|
106419
106577
|
function customSplit(context, element2) {
|
|
106420
106578
|
if (!element2) return void 0;
|
|
106421
106579
|
reportUnmodelled(context, element2, /* @__PURE__ */ new Set(["secondPiePt"]));
|
|
106422
|
-
return
|
|
106580
|
+
return children(element2, "secondPiePt", NS.c).flatMap((point2) => {
|
|
106423
106581
|
const raw2 = attribute6(point2, "val")?.trim();
|
|
106424
106582
|
const index2 = raw2 ? Number(raw2) : Number.NaN;
|
|
106425
106583
|
return Number.isInteger(index2) && index2 >= 0 ? [index2] : [];
|
|
@@ -106439,8 +106597,8 @@ function parseGroup(context, element2) {
|
|
|
106439
106597
|
kind,
|
|
106440
106598
|
element: element2.localName,
|
|
106441
106599
|
is3D,
|
|
106442
|
-
series:
|
|
106443
|
-
axisIds:
|
|
106600
|
+
series: children(element2, "ser", NS.c).map((ser) => parseSeries(context, ser)),
|
|
106601
|
+
axisIds: children(element2, "axId", NS.c).flatMap((axis) => {
|
|
106444
106602
|
const raw2 = attribute6(axis, "val")?.trim();
|
|
106445
106603
|
const id = raw2 ? Number(raw2) : Number.NaN;
|
|
106446
106604
|
return Number.isFinite(id) ? [id] : [];
|
|
@@ -106676,7 +106834,7 @@ var init_parse_plot = __esm({
|
|
|
106676
106834
|
// chart/parse-space.ts
|
|
106677
106835
|
function parseLegend(context, element2) {
|
|
106678
106836
|
reportUnmodelled(context, element2, LEGEND);
|
|
106679
|
-
const entries =
|
|
106837
|
+
const entries = children(element2, "legendEntry", NS.c).map(
|
|
106680
106838
|
(entry2) => assignDefined(
|
|
106681
106839
|
{},
|
|
106682
106840
|
{
|
|
@@ -106715,14 +106873,14 @@ function parseView3D(context, element2) {
|
|
|
106715
106873
|
function chartStyle(context, space) {
|
|
106716
106874
|
const direct = cNumber(context, space, "style");
|
|
106717
106875
|
if (direct !== void 0) return direct;
|
|
106718
|
-
for (const alternate of
|
|
106876
|
+
for (const alternate of children(space, "AlternateContent", NS.mc)) {
|
|
106719
106877
|
const style = cNumber(context, first(alternate, "Fallback", NS.mc), "style");
|
|
106720
106878
|
if (style !== void 0) return style;
|
|
106721
106879
|
}
|
|
106722
106880
|
return void 0;
|
|
106723
106881
|
}
|
|
106724
106882
|
function c14Style(space) {
|
|
106725
|
-
for (const alternate of
|
|
106883
|
+
for (const alternate of children(space, "AlternateContent", NS.mc)) {
|
|
106726
106884
|
const raw2 = attribute6(first(first(alternate, "Choice", NS.mc), "style", NS.c14, false), "val");
|
|
106727
106885
|
const value = raw2?.trim() ? Number(raw2) : Number.NaN;
|
|
106728
106886
|
if (Number.isFinite(value)) return value;
|
|
@@ -109339,7 +109497,7 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
|
|
|
109339
109497
|
throw new Error("The chart workbook structure is protected.");
|
|
109340
109498
|
const sheets = first(workbook, "sheets", NS.x);
|
|
109341
109499
|
if (!sheets) throw new Error("The chart workbook has no sheets element.");
|
|
109342
|
-
const entries =
|
|
109500
|
+
const entries = children(sheets, "sheet", NS.x);
|
|
109343
109501
|
const names = new Set(entries.map((sheet2) => (sheet2.getAttribute("name") ?? "").toLowerCase()));
|
|
109344
109502
|
const base2 = options2.nameBase ?? "ChartData";
|
|
109345
109503
|
if (!base2.trim() || /[\\/?*\[\]:]/u.test(base2) || base2.startsWith("'") || base2.endsWith("'"))
|
|
@@ -109369,7 +109527,7 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
|
|
|
109369
109527
|
break;
|
|
109370
109528
|
}
|
|
109371
109529
|
}
|
|
109372
|
-
const ids = new Set(
|
|
109530
|
+
const ids = new Set(children(rels, "Relationship", NS.rels).map((rel) => rel.getAttribute("Id")));
|
|
109373
109531
|
let id = "";
|
|
109374
109532
|
for (let n = 1; ; n++) {
|
|
109375
109533
|
if (!ids.has(`rId${n}`)) {
|
|
@@ -109390,7 +109548,7 @@ async function appendChartWorkbookSheet(bytes, rowsForName, options2 = {}) {
|
|
|
109390
109548
|
views = element(workbook, "bookViews");
|
|
109391
109549
|
workbook.insertBefore(views, sheets);
|
|
109392
109550
|
}
|
|
109393
|
-
let workbookViews =
|
|
109551
|
+
let workbookViews = children(views, "workbookView", NS.x);
|
|
109394
109552
|
if (workbookViews.length === 0) {
|
|
109395
109553
|
const view = element(views, "workbookView");
|
|
109396
109554
|
views.appendChild(view);
|
|
@@ -109435,7 +109593,7 @@ async function appendChartExWorkbookData(bytes, before, after) {
|
|
|
109435
109593
|
if (!xml) throw new Error("The chart workbook is missing.");
|
|
109436
109594
|
const root = parseXml(xml).documentElement;
|
|
109437
109595
|
const defined = first(root, "definedNames", NS.x);
|
|
109438
|
-
const names = defined ?
|
|
109596
|
+
const names = defined ? children(defined, "definedName", NS.x) : [];
|
|
109439
109597
|
const resolve = (name) => names.find(
|
|
109440
109598
|
(entry2) => entry2.getAttribute("name")?.toLowerCase() === name.toLowerCase() && !entry2.hasAttribute("localSheetId")
|
|
109441
109599
|
)?.textContent ?? void 0;
|
|
@@ -109825,11 +109983,11 @@ function parseRegionValueColorPositions(xml) {
|
|
|
109825
109983
|
if (!positions2) return void 0;
|
|
109826
109984
|
const count2 = positions2.getAttribute("count");
|
|
109827
109985
|
const native = ["min", "mid", "max"].some((key2) => first(positions2, key2, NS.cx));
|
|
109828
|
-
if (native || count2 !== null &&
|
|
109986
|
+
if (native || count2 !== null && children(positions2, "pos", NS.cx).length === 0) {
|
|
109829
109987
|
const keys = count2 === "3" || first(positions2, "mid", NS.cx) ? ["min", "mid", "max"] : ["min", "max"];
|
|
109830
109988
|
return keys.map((key2) => schemaPosition(first(positions2, key2, NS.cx), key2));
|
|
109831
109989
|
}
|
|
109832
|
-
const legacy =
|
|
109990
|
+
const legacy = children(positions2, "pos", NS.cx).flatMap(
|
|
109833
109991
|
(element2) => {
|
|
109834
109992
|
const type = element2.getAttribute("type");
|
|
109835
109993
|
if (type === "min" || type === "max") return [{ kind: type }];
|
|
@@ -111193,14 +111351,14 @@ function extensionRoot(xml) {
|
|
|
111193
111351
|
function chartDataLabelsRange(labels2) {
|
|
111194
111352
|
if (!labels2.extLst) return void 0;
|
|
111195
111353
|
const root = extensionRoot(labels2.extLst);
|
|
111196
|
-
const ext =
|
|
111354
|
+
const ext = children(root, "ext", NS.c).find((node2) => node2.getAttribute("uri") === URI);
|
|
111197
111355
|
if (!ext) return void 0;
|
|
111198
|
-
const range =
|
|
111199
|
-
const formula2 = range &&
|
|
111356
|
+
const range = children(ext, "datalabelsRange", C15)[0];
|
|
111357
|
+
const formula2 = range && children(range, "f", C15)[0]?.textContent;
|
|
111200
111358
|
if (!formula2) return void 0;
|
|
111201
|
-
const cache =
|
|
111202
|
-
const count2 = Number(cache &&
|
|
111203
|
-
const points7 = cache ?
|
|
111359
|
+
const cache = children(range, "dlblRangeCache", C15)[0];
|
|
111360
|
+
const count2 = Number(cache && children(cache, "ptCount", NS.c)[0]?.getAttribute("val"));
|
|
111361
|
+
const points7 = cache ? children(cache, "pt", NS.c) : [];
|
|
111204
111362
|
const indices = points7.map((pt2) => Number(pt2.getAttribute("idx")));
|
|
111205
111363
|
const length = indices.reduce(
|
|
111206
111364
|
(max, index2) => Number.isSafeInteger(index2) && index2 >= 0 ? Math.max(max, index2 + 1) : max,
|
|
@@ -111212,9 +111370,9 @@ function chartDataLabelsRange(labels2) {
|
|
|
111212
111370
|
points7.forEach((pt2, i2) => {
|
|
111213
111371
|
const index2 = indices[i2];
|
|
111214
111372
|
if (Number.isSafeInteger(index2) && index2 >= 0)
|
|
111215
|
-
values[index2] =
|
|
111373
|
+
values[index2] = children(pt2, "v", NS.c)[0]?.textContent ?? "";
|
|
111216
111374
|
});
|
|
111217
|
-
const show =
|
|
111375
|
+
const show = children(ext, "showDataLabelsRange", C15)[0]?.getAttribute("val");
|
|
111218
111376
|
return { formula: formula2, cache: values, show: show === "1" || show === "true" };
|
|
111219
111377
|
}
|
|
111220
111378
|
function patchRange(labels2, range, show) {
|
|
@@ -111222,7 +111380,7 @@ function patchRange(labels2, range, show) {
|
|
|
111222
111380
|
if (!range && !previous || range && previous && range.formula === previous.formula && show === previous.show && JSON.stringify(range.cache) === JSON.stringify(previous.cache))
|
|
111223
111381
|
return;
|
|
111224
111382
|
const root = extensionRoot(labels2.extLst);
|
|
111225
|
-
let ext =
|
|
111383
|
+
let ext = children(root, "ext", NS.c).find((node2) => node2.getAttribute("uri") === URI);
|
|
111226
111384
|
if (!ext) {
|
|
111227
111385
|
ext = root.ownerDocument.createElementNS(NS.c, "c:ext");
|
|
111228
111386
|
ext.setAttribute("uri", URI);
|
|
@@ -112812,7 +112970,7 @@ function displayNaAsBlank(draft, value) {
|
|
|
112812
112970
|
`<c:wrapper xmlns:c="${NS.c}" xmlns:c16r3="${C16R32}">${draft.chartExtLst ?? "<c:extLst/>"}</c:wrapper>`
|
|
112813
112971
|
).documentElement;
|
|
112814
112972
|
const root = first(wrapper, "extLst", NS.c);
|
|
112815
|
-
let extension =
|
|
112973
|
+
let extension = children(root, "ext", NS.c).find(
|
|
112816
112974
|
(node2) => node2.getAttribute("uri") === DISPLAY_URI
|
|
112817
112975
|
);
|
|
112818
112976
|
let options2 = first(extension, "dataDisplayOptions16", C16R32);
|
|
@@ -133247,6 +133405,21 @@ var init_image_alpha_effects = __esm({
|
|
|
133247
133405
|
}
|
|
133248
133406
|
});
|
|
133249
133407
|
|
|
133408
|
+
// pptx/core/core/runtime/blip-extension-order.ts
|
|
133409
|
+
function keepExtensionListLast(blip) {
|
|
133410
|
+
const key2 = Object.keys(blip).find((candidate) => candidate.split(":").at(-1) === "extLst");
|
|
133411
|
+
if (key2 === void 0) {
|
|
133412
|
+
return;
|
|
133413
|
+
}
|
|
133414
|
+
const value = blip[key2];
|
|
133415
|
+
delete blip[key2];
|
|
133416
|
+
blip[key2] = value;
|
|
133417
|
+
}
|
|
133418
|
+
var init_blip_extension_order = __esm({
|
|
133419
|
+
"pptx/core/core/runtime/blip-extension-order.ts"() {
|
|
133420
|
+
}
|
|
133421
|
+
});
|
|
133422
|
+
|
|
133250
133423
|
// pptx/core/core/runtime/image-color-effects.ts
|
|
133251
133424
|
function child32(parent, name) {
|
|
133252
133425
|
if (!parent) {
|
|
@@ -136047,7 +136220,7 @@ function parseTableStyleList(parsed, ensureArray20, resolveImagePath, themeConte
|
|
|
136047
136220
|
var TABLE_STYLE_PART_SEQUENCE;
|
|
136048
136221
|
var init_table_style_entry_parse = __esm({
|
|
136049
136222
|
"pptx/core/core/runtime/table-style-entry-parse.ts"() {
|
|
136050
|
-
|
|
136223
|
+
init_color2();
|
|
136051
136224
|
init_table_style_border_parse();
|
|
136052
136225
|
init_table_style_fill_parse();
|
|
136053
136226
|
TABLE_STYLE_PART_SEQUENCE = [
|
|
@@ -140253,6 +140426,7 @@ var init_PptxHandlerRuntimeSaveImageEffects = __esm({
|
|
|
140253
140426
|
init_crop_shape_geometry();
|
|
140254
140427
|
init_image_a14_effects_writer();
|
|
140255
140428
|
init_image_alpha_effects();
|
|
140429
|
+
init_blip_extension_order();
|
|
140256
140430
|
init_image_color_effects();
|
|
140257
140431
|
init_image_crop_save();
|
|
140258
140432
|
init_PptxHandlerRuntimeSaveShapeXml();
|
|
@@ -140370,6 +140544,7 @@ var init_PptxHandlerRuntimeSaveImageEffects = __esm({
|
|
|
140370
140544
|
delete blip["a:blur"];
|
|
140371
140545
|
}
|
|
140372
140546
|
applyA14ImageExtension(blip, nextEffects);
|
|
140547
|
+
keepExtensionListLast(blip);
|
|
140373
140548
|
}
|
|
140374
140549
|
normalizePresetGeometry(shapeType) {
|
|
140375
140550
|
return this.elementXmlBuilder.normalizePresetGeometry(shapeType);
|
|
@@ -155379,7 +155554,7 @@ var init_PptxHandlerRuntimeShapeImageFill = __esm({
|
|
|
155379
155554
|
var PptxHandlerRuntime62;
|
|
155380
155555
|
var init_PptxHandlerRuntimeTextDefaults = __esm({
|
|
155381
155556
|
"pptx/core/core/runtime/PptxHandlerRuntimeTextDefaults.ts"() {
|
|
155382
|
-
|
|
155557
|
+
init_color2();
|
|
155383
155558
|
init_paragraph_properties_parser();
|
|
155384
155559
|
init_PptxHandlerRuntimeShapeImageFill();
|
|
155385
155560
|
PptxHandlerRuntime62 = class extends PptxHandlerRuntime61 {
|
|
@@ -159316,7 +159491,7 @@ var init_PptxHandlerRuntimeSlideUtils = __esm({
|
|
|
159316
159491
|
var PptxHandlerRuntime75;
|
|
159317
159492
|
var init_PptxHandlerRuntimePlaceholderStyles = __esm({
|
|
159318
159493
|
"pptx/core/core/runtime/PptxHandlerRuntimePlaceholderStyles.ts"() {
|
|
159319
|
-
|
|
159494
|
+
init_color2();
|
|
159320
159495
|
init_color_xml_preservation();
|
|
159321
159496
|
init_paragraph_properties_parser();
|
|
159322
159497
|
init_xml_access();
|
|
@@ -170888,7 +171063,7 @@ __export(helpers_exports, {
|
|
|
170888
171063
|
init_types();
|
|
170889
171064
|
init_PptxHandler();
|
|
170890
171065
|
init_constants2();
|
|
170891
|
-
|
|
171066
|
+
init_color2();
|
|
170892
171067
|
init_geometry2();
|
|
170893
171068
|
|
|
170894
171069
|
// pptx/core/builders/sdk/diff-operations.ts
|
|
@@ -179680,7 +179855,7 @@ __export(external_exports, {
|
|
|
179680
179855
|
uuidv4: () => uuidv4,
|
|
179681
179856
|
uuidv6: () => uuidv6,
|
|
179682
179857
|
uuidv7: () => uuidv7,
|
|
179683
|
-
validate: () =>
|
|
179858
|
+
validate: () => validate2,
|
|
179684
179859
|
validateAsync: () => validateAsync,
|
|
179685
179860
|
void: () => _void2,
|
|
179686
179861
|
withParser: () => withParser,
|
|
@@ -179998,7 +180173,7 @@ __export(core_exports2, {
|
|
|
179998
180173
|
urlHostnameOk: () => urlHostnameOk,
|
|
179999
180174
|
urlProtocolOk: () => urlProtocolOk,
|
|
180000
180175
|
util: () => util_exports,
|
|
180001
|
-
validate: () =>
|
|
180176
|
+
validate: () => validate2,
|
|
180002
180177
|
validateAsync: () => validateAsync,
|
|
180003
180178
|
validateURL: () => validateURL,
|
|
180004
180179
|
version: () => version,
|
|
@@ -181250,7 +181425,7 @@ var _safeParseAsync = (_Err) => async (schema, value, _ctx) => {
|
|
|
181250
181425
|
var safeParseAsync = /* @__PURE__ */ _safeParseAsync($ZodRealError);
|
|
181251
181426
|
var COMPILE_INVALID = /* @__PURE__ */ Symbol.for("zod.compile.invalid");
|
|
181252
181427
|
var COMPILE_FALLBACK = /* @__PURE__ */ Symbol.for("zod.compile.fallback");
|
|
181253
|
-
var
|
|
181428
|
+
var validate2 = ((schema, value, _ctx) => {
|
|
181254
181429
|
const validator = schema._zod.bag.validator;
|
|
181255
181430
|
if (validator !== void 0) {
|
|
181256
181431
|
if (validator(value) !== COMPILE_INVALID)
|
|
@@ -196804,7 +196979,7 @@ var ZodType = /* @__PURE__ */ $constructor("ZodType", (inst, def) => {
|
|
|
196804
196979
|
util_exports.own(this, "spa", value);
|
|
196805
196980
|
},
|
|
196806
196981
|
validate(data, params) {
|
|
196807
|
-
return
|
|
196982
|
+
return validate2(this, data, params);
|
|
196808
196983
|
},
|
|
196809
196984
|
validateAsync(data, params) {
|
|
196810
196985
|
return validateAsync(this, data, params);
|