Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

@office-open/core

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@office-open/core - npm Package Compare versions

Comparing version
0.6.4
to
0.6.5
+611
dist/chart-Bd9E-YhB.mjs
import { a as BuilderElement, b as XmlComponent, c as chartAttr, h as wrapEl, o as EmptyElement } from "./xml-components-CADgke8j.mjs";
//#region src/chart/axes.ts
/**
* c:scaling — axis scaling configuration (minOccurs=1 in EG_AxShared).
*/
var Scaling = class extends XmlComponent {
constructor() {
super("c:scaling");
this.root.push(wrapEl("c:orientation", chartAttr({ val: "minMax" })));
}
};
/**
* c:catAx — category axis.
*/
var CatAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:catAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "b" })));
this.root.push(wrapEl("c:auto", chartAttr({ val: 1 })));
this.root.push(wrapEl("c:lblOffset", chartAttr({ val: 100 })));
this.root.push(wrapEl("c:noMultiLvlLbl", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
}
};
/**
* c:valAx — value axis.
*/
var ValAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:valAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "l" })));
this.root.push(wrapEl("c:numFmt", chartAttr({
formatCode: "General",
sourceLinked: 1
})));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
this.root.push(new BuilderElement({ name: "c:spPr" }));
}
};
//#endregion
//#region src/chart/series/series-data.ts
const createStrRef = (values) => {
return new StrRef(typeof values === "string" ? [values] : values);
};
const createNumRef = (values) => new NumRef(values);
var StrRef = class extends XmlComponent {
constructor(values) {
super("c:strRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new StrCache(values));
}
};
var StrCache = class extends XmlComponent {
constructor(values) {
super("c:strCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
}
};
var StrPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", value));
}
};
var NumRef = class extends XmlComponent {
constructor(values) {
super("c:numRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new NumCache(values));
}
};
var NumCache = class extends XmlComponent {
constructor(values) {
super("c:numCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
this.root.push(new FormatCode("General"));
for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
}
};
var NumPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", String(value)));
}
};
var FormatCode = class extends XmlComponent {
constructor(code) {
super("c:formatCode");
this.root.push(code);
}
};
var StringValue = class extends XmlComponent {
constructor(name, val) {
super(name);
this.root.push(val);
}
};
//#endregion
//#region src/chart/chart-types/area-chart.ts
var AreaChart = class extends XmlComponent {
constructor(options) {
super("c:areaChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var AreaSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$4(series.name));
this.root.push(new SeriesCat$4(categories));
this.root.push(new SeriesVal$4(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$4 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$4 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$4 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/bar-chart.ts
var BarChart = class extends XmlComponent {
constructor(options) {
super("c:barChart");
this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var BarSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$3(series.name));
this.root.push(new SeriesCat$3(categories));
this.root.push(new SeriesVal$3(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$3 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$3 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$3 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/line-chart.ts
var LineChart = class extends XmlComponent {
constructor(options) {
super("c:lineChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var LineSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$2(series.name));
this.root.push(new SeriesCat$2(categories));
this.root.push(new SeriesVal$2(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$2 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$2 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$2 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/pie-chart.ts
var PieChart = class extends XmlComponent {
constructor(options) {
super("c:pieChart");
this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
}
};
var PieSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$1(series.name));
this.root.push(new SeriesCat$1(categories));
this.root.push(new SeriesVal$1(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$1 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$1 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$1 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/scatter-chart.ts
var ScatterChart = class extends XmlComponent {
constructor(options) {
super("c:scatterChart");
this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var ScatterSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx(series.name));
this.root.push(new SeriesCat(categories));
this.root.push(new SeriesVal(series.values));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new EmptyElement("c:size"));
}
};
var SeriesTx = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/create-chart-type.ts
const createChartType = (options) => {
switch (options.type) {
case "column":
case "bar": return new BarChart({
barDirection: options.type === "column" ? "col" : "bar",
categories: options.categories,
series: options.series
});
case "line": return new LineChart({
categories: options.categories,
series: options.series
});
case "pie": return new PieChart({
categories: options.categories,
series: options.series
});
case "area": return new AreaChart({
categories: options.categories,
series: options.series
});
case "scatter": return new ScatterChart({
categories: options.categories,
series: options.series
});
default: throw new Error(`Unsupported chart type: ${options.type}`);
}
};
//#endregion
//#region src/chart/title.ts
var ChartTitle = class extends XmlComponent {
constructor(title) {
super("c:title");
this.root.push(new TitleTx(title));
this.root.push(new TitleOverlay());
}
};
var TitleTx = class extends XmlComponent {
constructor(title) {
super("c:tx");
const rich = new class extends XmlComponent {
constructor() {
super("c:rich");
}
}();
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:bodyPr");
}
}());
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:lstStyle");
}
}());
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(new class extends XmlComponent {
constructor() {
super("a:t");
this.root.push(title);
}
}());
p["root"].push(r);
rich["root"].push(p);
this.root.push(rich);
}
};
var TitleOverlay = class extends XmlComponent {
constructor() {
super("c:overlay");
this.root.push(chartAttr({ val: 0 }));
}
};
//#endregion
//#region src/chart/chart-space.ts
/**
* ChartSpace — root element for chart XML parts (c:chartSpace).
*
* Full XSD-compliant implementation with all optional elements.
*
* @module
*/
/**
* c:chartSpace — root element for chart XML parts.
*/
var ChartSpace = class extends XmlComponent {
constructor(options) {
super("c:chartSpace");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
}));
this.root.push(wrapEl("c:date1904", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:lang", chartAttr({ val: "en-US" })));
this.root.push(wrapEl("c:roundedCorners", chartAttr({ val: 0 })));
const chart = new ChartContainer();
if (options.title) chart["root"].push(new ChartTitle(options.title));
chart["root"].push(wrapEl("c:autoTitleDeleted", chartAttr({ val: 0 })));
const plotArea = new PlotArea();
plotArea["root"].push(new BuilderElement({ name: "c:layout" }));
plotArea["root"].push(createChartType({
categories: options.categories,
series: options.series,
type: options.type
}));
if (options.type !== "pie") if (options.type === "scatter") {
plotArea["root"].push(new ValAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
} else {
plotArea["root"].push(new CatAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
}
chart["root"].push(plotArea);
if (options.showLegend !== false) chart["root"].push(createLegend());
this.root.push(chart);
this.root.push(createChartSpPr());
this.root.push(createChartTxPr());
if (options.style !== void 0) this.root.push(new ChartStyle(options.style));
}
};
var ChartContainer = class extends XmlComponent {
constructor() {
super("c:chart");
}
};
var PlotArea = class extends XmlComponent {
constructor() {
super("c:plotArea");
}
};
function createLegend() {
const legend = new class extends XmlComponent {
constructor() {
super("c:legend");
}
}();
legend["root"].push(wrapEl("c:legendPos", chartAttr({ val: "b" })));
legend["root"].push(new BuilderElement({ name: "c:layout" }));
legend["root"].push(wrapEl("c:overlay", chartAttr({ val: 0 })));
legend["root"].push(createNoFillSpPr());
legend["root"].push(createTxPr());
return legend;
}
function createNoFillSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(new BuilderElement({ name: "a:bodyPr" }));
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(createBodyPr());
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createBodyPr() {
return new BuilderElement({
name: "a:bodyPr",
attributes: {
rot: {
key: "rot",
value: "0"
},
spcFirstLastPara: {
key: "spcFirstLastPara",
value: "1"
},
vertOverflow: {
key: "vertOverflow",
value: "ellipsis"
},
vert: {
key: "vert",
value: "horz"
},
wrap: {
key: "wrap",
value: "square"
},
anchor: {
key: "anchor",
value: "ctr"
},
anchorCtr: {
key: "anchorCtr",
value: "1"
}
}
});
}
function createTextParagraph() {
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const pPr = new class extends XmlComponent {
constructor() {
super("a:pPr");
}
}();
pPr["root"].push(new BuilderElement({ name: "a:defRPr" }));
p["root"].push(pPr);
p["root"].push(new BuilderElement({
name: "a:endParaRPr",
attributes: { lang: {
key: "lang",
value: "en-US"
} }
}));
return p;
}
var ChartStyle = class extends XmlComponent {
constructor(val) {
super("c:style");
this.root.push(chartAttr({ val: String(val) }));
}
};
//#endregion
//#region src/chart/chart-collection.ts
var ChartCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addChart(key, chartData) {
this.map.set(key, chartData);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
export { ScatterChart as a, BarChart as c, createStrRef as d, CatAx as f, createChartType as i, AreaChart as l, ChartSpace as n, PieChart as o, ValAx as p, ChartTitle as r, LineChart as s, ChartCollection as t, createNumRef as u };

Sorry, the diff of this file is too big to display

import { r as PositiveUniversalMeasure } from "./values-QyWq4U4A.mjs";
import { Element } from "@office-open/xml";
//#region src/xml-components/types.d.ts
/**
* XML-serializable object types for OOXML document generation.
*
* @module
*/
/**
* Attributes for an XML element.
*/
type IXmlAttribute = Readonly<Record<string, string | number | boolean>>;
/**
* Object that can be serialized to XML.
*/
type IXmlableObject = Readonly<Record<string, any>>;
//#endregion
//#region src/xml-components/base.d.ts
/**
* Context object passed through the XML tree during serialization.
*
* @typeParam TFileData - The type of the root file data object (format-specific)
*/
interface Context<TFileData = unknown> {
/** The root file data object being serialized (format-specific). */
readonly fileData?: TFileData;
/** Current traversal stack of components (mutable for performance). */
readonly stack: IXmlableObject[];
}
/**
* Abstract base class for all XML components.
*/
declare abstract class BaseXmlComponent {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
protected readonly rootKey: string;
constructor(rootKey: string);
/**
* Prepares this component for XML serialization.
*
* @param context - The serialization context
* @returns The XML-serializable object, or undefined to exclude from output
*/
abstract prepForXml(context: Context): IXmlableObject | undefined;
}
//#endregion
//#region src/xml-components/component.d.ts
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
declare const EMPTY_OBJECT: {};
/**
* Base class for all XML components in OOXML documents.
*/
declare abstract class XmlComponent extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root: (BaseXmlComponent | IXmlableObject | string)[];
constructor(rootKey: string);
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context: Context): string;
/**
* @deprecated Internal use only.
*/
addChildElement(child: BaseXmlComponent | string): XmlComponent;
}
/**
* XML component that is excluded from output if it has no meaningful content.
*/
declare abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
private readonly includeIfEmpty;
constructor(rootKey: string, includeIfEmpty?: boolean);
prepForXml(context: Context): IXmlableObject | undefined;
}
//#endregion
//#region src/xml-components/attributes.d.ts
/**
* Maps TypeScript property names to their XML attribute names.
*/
type AttributeMap<T> = Record<keyof T, string>;
/**
* Simple attribute data as a key-value record.
*/
type AttributeData = Record<string, boolean | number | string>;
/**
* Structured attribute payload with explicit key-value mapping.
*/
type AttributePayload<T> = { readonly [P in keyof T]: {
readonly key: string;
readonly value: T[P];
} };
/**
* Base class for creating XML attributes with automatic name mapping.
*/
declare abstract class XmlAttributeComponent<T extends Record<string, any>> extends BaseXmlComponent {
private readonly root;
/** Optional mapping from property names to XML attribute names. */
protected readonly xmlKeys?: AttributeMap<T>;
constructor(root: T);
prepForXml(_: Context): IXmlableObject;
}
/**
* Next-generation attribute component with explicit key-value pairs.
*/
declare class NextAttributeComponent<T> extends BaseXmlComponent {
private readonly root;
constructor(root: AttributePayload<T>);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/elements.d.ts
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
declare function attrObj(name: string, attrs: Record<string, string | number | boolean | undefined>): IXmlableObject;
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
declare function onOffObj(name: string, val?: boolean | undefined): IXmlableObject;
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
declare function hpsMeasureObj(name: string, val: number | PositiveUniversalMeasure): IXmlableObject;
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
declare function stringValObj(name: string, val: string): IXmlableObject;
/**
* Build a numeric value attribute XML object without allocation.
*/
declare function numberValObj(name: string, val: number): IXmlableObject;
/**
* Build a string enum value attribute XML object without allocation.
*/
declare function stringEnumValObj<T extends string>(name: string, val: T): IXmlableObject;
/**
* Build an element wrapping a text string without allocation.
*/
declare function stringContainerObj(name: string, val: string): IXmlableObject;
/**
* XML element representing an empty element (CT_Empty).
*/
declare class EmptyElement extends XmlComponent {}
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
declare class BuilderElement<T = {}> extends XmlComponent {
constructor({
name,
attributes,
children
}: {
readonly name: string;
readonly attributes?: AttributePayload<T>;
readonly children?: readonly (BaseXmlComponent | IXmlableObject | string)[];
});
}
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
declare const chartAttr: (attrs: Record<string, string | number | boolean>) => BaseXmlComponent;
/**
* Wraps a component in a named XmlComponent element.
*/
declare function wrapEl(elementName: string, child: BaseXmlComponent): XmlComponent;
//#endregion
//#region src/xml-components/imported.d.ts
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
declare const convertToXmlComponent: (element: Element) => ImportedXmlComponent | string | undefined;
/**
* XML component representing imported XML content.
*/
declare class ImportedXmlComponent extends XmlComponent {
protected _sourceXml?: string;
static fromXmlString(importedContent: string): ImportedXmlComponent;
get sourceXml(): string | undefined;
toXml(_context: Context): string;
constructor(rootKey: string, _attr?: any);
push(xmlComponent: XmlComponent | string): void;
}
/**
* Represents attributes for imported root elements.
*/
declare class ImportedRootElementAttributes extends XmlComponent {
private readonly _attr;
constructor(_attr: any);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/initializable.d.ts
/**
* XML component that can be initialized from another component.
*/
declare abstract class InitializableXmlComponent extends XmlComponent {
constructor(rootKey: string, initComponent?: XmlComponent);
}
//#endregion
export { XmlComponent as C, IXmlableObject as D, IXmlAttribute as E, IgnoreIfEmptyXmlComponent as S, Context as T, AttributeMap as _, BuilderElement as a, XmlAttributeComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, AttributeData as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, AttributePayload as v, BaseXmlComponent as w, EMPTY_OBJECT as x, NextAttributeComponent as y };

Sorry, the diff of this file is too big to display

import { C as XmlComponent } from "./index-B1wzvu1m.mjs";
//#region src/smartart/categories.d.ts
/** Layout ID → OOXML category type */
declare const LAYOUT_CATEGORIES: Record<string, string>;
/** Style ID → OOXML category type */
declare const STYLE_CATEGORIES: Record<string, string>;
/** Color ID → OOXML category type */
declare const COLOR_CATEGORIES: Record<string, string>;
//#endregion
//#region src/smartart/built-in-definitions.d.ts
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
declare function getLayoutXml(layoutId: string): string;
/**
* Returns style stub XML with the given uniqueId.
*/
declare function getStyleXml(styleId: string): string;
/**
* Returns color stub XML with the given uniqueId.
*/
declare function getColorXml(colorId: string): string;
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
declare const DEFAULT_DRAWING_XML: string;
//#endregion
//#region src/smartart/data-model/connection.d.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
declare class Connection extends XmlComponent {
constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
}
//#endregion
//#region src/smartart/data-model/data-model.d.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
declare class DataModel extends XmlComponent {
constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
}
//#endregion
//#region src/smartart/data-model/point.d.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
declare class Point extends XmlComponent {
constructor(modelId: string, text: string, type?: string);
}
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
declare class TransPoint extends XmlComponent {
constructor(modelId: string, type: string, cxnId: string);
}
//#endregion
//#region src/smartart/smartart-collection.d.ts
interface SmartArtData {
readonly key: string;
readonly dataModel: DataModel;
readonly layout: string;
readonly style: string;
readonly color: string;
}
/**
* Manages SmartArt parts in a document.
*/
declare class SmartArtCollection {
private readonly map;
constructor();
addSmartArt(key: string, data: SmartArtData): void;
get array(): readonly SmartArtData[];
}
//#endregion
//#region src/smartart/tree-to-model.d.ts
interface TreeNode {
readonly text: string;
readonly children?: readonly TreeNode[];
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => DataModel;
//#endregion
export { Point as a, Connection as c, getLayoutXml as d, getStyleXml as f, STYLE_CATEGORIES as h, SmartArtData as i, DEFAULT_DRAWING_XML as l, LAYOUT_CATEGORIES as m, createDataModel as n, TransPoint as o, COLOR_CATEGORIES as p, SmartArtCollection as r, DataModel as s, TreeNode as t, getColorXml as u };
import { Element } from "@office-open/xml";
//#region src/patch/xml-namespace.d.ts
/**
* Namespace configuration for XML patch operations.
*
* Parameterises element names so the same patch algorithm works for both
* DOCX (`w:*`) and PPTX (`a:*`) documents.
*/
interface XmlNamespaceConfig {
readonly paragraph: string;
readonly run: string;
readonly text: string;
readonly runProperties: string;
}
declare const DOCX_NS: XmlNamespaceConfig;
declare const PPTX_NS: XmlNamespaceConfig;
//#endregion
//#region src/patch/xml-replacer.d.ts
interface ReplacerConfig {
readonly ns: XmlNamespaceConfig;
readonly formatChild: (child: unknown, context: unknown) => Element[];
readonly preserveSpace?: boolean;
}
interface ReplacerResult {
readonly element: Element;
readonly didFindOccurrence: boolean;
}
declare function createReplacer(config: ReplacerConfig): ({
json,
patch,
patchText,
context,
keepOriginalStyles
}: {
readonly json: Element;
readonly patch: {
readonly type: string;
readonly children: readonly unknown[];
};
readonly patchText: string;
readonly context: unknown;
readonly keepOriginalStyles?: boolean;
}) => ReplacerResult;
//#endregion
//#region src/patch/run-renderer.d.ts
interface ElementWrapper {
readonly element: Element;
readonly index: number;
readonly parent: ElementWrapper | undefined;
}
interface RenderedParagraphNode {
readonly text: string;
readonly runs: readonly IRenderedRunNode[];
readonly index: number;
readonly pathToParagraph: readonly number[];
}
interface StartAndEnd {
readonly start: number;
readonly end: number;
}
type IParts = {
readonly text: string;
readonly index: number;
} & StartAndEnd;
type IRenderedRunNode = {
readonly text: string;
readonly parts: readonly IParts[];
readonly index: number;
} & StartAndEnd;
declare function createRunRenderer(ns: XmlNamespaceConfig): (node: ElementWrapper) => RenderedParagraphNode;
//#endregion
//#region src/patch/xml-traverser.d.ts
declare function createTraverser(ns: XmlNamespaceConfig): {
traverse: (node: Element) => readonly RenderedParagraphNode[];
findLocationOfText: (node: Element, text: string) => readonly RenderedParagraphNode[];
};
//#endregion
//#region src/patch/paragraph-token-replacer.d.ts
declare function createTokenReplacer(createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): ({
paragraphElement,
renderedParagraph,
originalText,
replacementText
}: {
readonly paragraphElement: Element;
readonly renderedParagraph: RenderedParagraphNode;
readonly originalText: string;
readonly replacementText: string;
}) => Element;
//#endregion
//#region src/patch/paragraph-split-inject.d.ts
declare class TokenNotFoundError extends Error {
constructor(token: string);
}
declare function createSplitInject(ns: XmlNamespaceConfig, createTextElementContents: (text: string) => Element[], options?: {
readonly preserveSpace?: boolean;
}): {
findRunElementIndexWithToken: (paragraphElement: Element, token: string) => number;
splitRunElement: (runElement: Element, token: string) => {
readonly left: Element;
readonly right: Element;
};
};
//#endregion
//#region src/patch/xml-patch-utils.d.ts
declare const toJson: (xmlData: string) => Element;
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
declare const createTextElementContents: (text: string) => Element[];
declare const patchSpaceAttribute: (element: Element) => Element;
declare const getFirstLevelElements: (relationships: Element, id: string) => Element[];
//#endregion
//#region src/patch/content-types-manager.d.ts
declare const appendContentType: (element: Element, contentType: string, extension: string) => void;
//#endregion
//#region src/patch/relationship-manager.d.ts
declare const getNextRelationshipIndex: (relationships: Element) => number;
declare const appendRelationship: (relationships: Element, id: number | string, type: string, target: string, targetMode?: string) => readonly Element[];
//#endregion
export { PPTX_NS as _, getFirstLevelElements as a, TokenNotFoundError as c, createTraverser as d, RenderedParagraphNode as f, DOCX_NS as g, createReplacer as h, createTextElementContents as i, createSplitInject as l, ReplacerConfig as m, getNextRelationshipIndex as n, patchSpaceAttribute as o, createRunRenderer as p, appendContentType as r, toJson as s, appendRelationship as t, createTokenReplacer as u, XmlNamespaceConfig as v };
import { C as XmlComponent } from "./index-B1wzvu1m.mjs";
//#region src/chart/axes.d.ts
/**
* c:catAx — category axis.
*/
declare class CatAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
/**
* c:valAx — value axis.
*/
declare class ValAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
//#endregion
//#region src/chart/chart-types/area-chart.d.ts
interface AreaChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class AreaChart extends XmlComponent {
constructor(options: AreaChartOptions);
}
//#endregion
//#region src/chart/chart-types/bar-chart.d.ts
interface BarChartOptions {
readonly barDirection: "col" | "bar";
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class BarChart extends XmlComponent {
constructor(options: BarChartOptions);
}
//#endregion
//#region src/chart/chart-types/line-chart.d.ts
interface LineChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class LineChart extends XmlComponent {
constructor(options: LineChartOptions);
}
//#endregion
//#region src/chart/chart-types/pie-chart.d.ts
interface PieChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class PieChart extends XmlComponent {
constructor(options: PieChartOptions);
}
//#endregion
//#region src/chart/chart-types/scatter-chart.d.ts
interface ScatterChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class ScatterChart extends XmlComponent {
constructor(options: ScatterChartOptions);
}
//#endregion
//#region src/chart/create-chart-type.d.ts
interface ChartSeriesData {
readonly name: string;
readonly values: readonly number[];
}
type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter";
interface ChartTypeOptions {
readonly type: ChartType;
readonly series: readonly ChartSeriesData[];
readonly categories: readonly string[];
}
declare const createChartType: (options: ChartTypeOptions) => BarChart | LineChart | PieChart | AreaChart | ScatterChart;
//#endregion
//#region src/chart/chart-space.d.ts
interface ChartSpaceOptions {
readonly title?: string;
readonly type: ChartType;
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
readonly showLegend?: boolean;
readonly style?: number;
}
/**
* c:chartSpace — root element for chart XML parts.
*/
declare class ChartSpace extends XmlComponent {
constructor(options: ChartSpaceOptions);
}
//#endregion
//#region src/chart/chart-collection.d.ts
interface ChartData {
readonly key: string;
readonly chartSpace: XmlComponent;
}
declare class ChartCollection {
private readonly map;
constructor();
addChart(key: string, chartData: ChartData): void;
get array(): readonly ChartData[];
}
//#endregion
//#region src/chart/series/series-data.d.ts
declare const createStrRef: (values: string | readonly string[]) => XmlComponent;
declare const createNumRef: (values: readonly number[]) => XmlComponent;
//#endregion
//#region src/chart/title.d.ts
declare class ChartTitle extends XmlComponent {
constructor(title: string);
}
//#endregion
export { CatAx as _, ChartData as a, ChartSeriesData as c, createChartType as d, ScatterChart as f, AreaChart as g, BarChart as h, ChartCollection as i, ChartType as l, LineChart as m, createNumRef as n, ChartSpace as o, PieChart as p, createStrRef as r, ChartSpaceOptions as s, ChartTitle as t, ChartTypeOptions as u, ValAx as v };
import { xml2js } from "@office-open/xml";
//#region src/patch/xml-namespace.ts
const DOCX_NS = {
paragraph: "w:p",
run: "w:r",
text: "w:t",
runProperties: "w:rPr"
};
const PPTX_NS = {
paragraph: "a:p",
run: "a:r",
text: "a:t",
runProperties: "a:rPr"
};
//#endregion
//#region src/patch/xml-patch-utils.ts
/**
* XML utility functions for patch operations.
*/
const toJson = (xmlData) => {
return xml2js(xmlData, {
captureSpacesBetweenElements: true,
compact: false
});
};
/**
* Creates the inner content of a text element (`w:t` / `a:t`).
*
* Returns `[{ type: "text", text }]` for non-empty text, `[]` for empty.
* The `xml:space` attribute is handled separately by `patchSpaceAttribute`.
*/
const createTextElementContents = (text) => text === "" ? [] : [{
text,
type: "text"
}];
const patchSpaceAttribute = (element) => ({
...element,
attributes: { "xml:space": "preserve" }
});
const getFirstLevelElements = (relationships, id) => relationships.elements?.filter((e) => e.name === id)[0].elements ?? [];
//#endregion
//#region src/patch/paragraph-split-inject.ts
var TokenNotFoundError = class extends Error {
constructor(token) {
super(`Token ${token} not found`);
this.name = "TokenNotFoundError";
}
};
function createSplitInject(ns, createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const findRunElementIndexWithToken = (paragraphElement, token) => {
for (let i = 0; i < (paragraphElement.elements ?? []).length; i++) {
const element = paragraphElement.elements[i];
if (element.type === "element" && element.name === ns.run) {
const textElement = (element.elements ?? []).filter((e) => e.type === "element" && e.name === ns.text);
for (const text of textElement) {
if (!text.elements?.[0]) continue;
if (text.elements[0].text?.includes(token)) return i;
}
}
}
throw new TokenNotFoundError(token);
};
const splitRunElement = (runElement, token) => {
let splitIndex = -1;
const splitElements = runElement.elements?.map((e, i) => {
if (splitIndex !== -1) return e;
if (e.type === "element" && e.name === ns.text) {
const splitText = (e.elements?.[0]?.text ?? "").split(token);
const newElements = splitText.map((t) => ({
...e,
...preserveSpace ? patchSpaceAttribute(e) : {},
elements: createTextElementContents(t)
}));
if (splitText.length > 1) splitIndex = i;
return newElements;
} else return e;
}).flat() ?? [];
return {
left: {
...JSON.parse(JSON.stringify(runElement)),
elements: splitElements.slice(0, splitIndex + 1)
},
right: {
...JSON.parse(JSON.stringify(runElement)),
elements: splitElements.slice(splitIndex + 1)
}
};
};
return {
findRunElementIndexWithToken,
splitRunElement
};
}
//#endregion
//#region src/patch/paragraph-token-replacer.ts
const ReplaceMode = {
START: 0,
MIDDLE: 1,
END: 2
};
function createTokenReplacer(createTextElementContents, options) {
const preserveSpace = options?.preserveSpace ?? true;
const patchTextElement = (element, text) => {
element.elements = createTextElementContents(text);
return element;
};
return ({ paragraphElement, renderedParagraph, originalText, replacementText }) => {
const startIndex = renderedParagraph.text.indexOf(originalText);
const endIndex = startIndex + originalText.length - 1;
let replaceMode = ReplaceMode.START;
for (const run of renderedParagraph.runs) for (const { text, index, start, end } of run.parts) switch (replaceMode) {
case ReplaceMode.START:
if (startIndex >= start && startIndex <= end) {
const offsetStartIndex = startIndex - start;
const offsetEndIndex = Math.min(endIndex, end) - start;
const partToReplace = text.substring(offsetStartIndex, offsetEndIndex + 1);
if (partToReplace === "") continue;
const firstPart = text.replace(partToReplace, replacementText);
patchTextElement(paragraphElement.elements[run.index].elements[index], firstPart);
replaceMode = ReplaceMode.MIDDLE;
continue;
}
break;
case ReplaceMode.MIDDLE:
if (endIndex <= end) {
const lastPart = text.substring(endIndex - start + 1);
patchTextElement(paragraphElement.elements[run.index].elements[index], lastPart);
const currentElement = paragraphElement.elements[run.index].elements[index];
paragraphElement.elements[run.index].elements[index] = preserveSpace ? patchSpaceAttribute(currentElement) : currentElement;
replaceMode = ReplaceMode.END;
} else patchTextElement(paragraphElement.elements[run.index].elements[index], "");
break;
}
return paragraphElement;
};
}
//#endregion
//#region src/patch/run-renderer.ts
function createRunRenderer(ns) {
const renderParagraphNode = (node) => {
if (node.element.name !== ns.paragraph) throw new Error(`Invalid node type: ${node.element.name}`);
if (!node.element.elements) return {
index: -1,
pathToParagraph: [],
runs: [],
text: ""
};
let currentRunStringLength = 0;
const runs = node.element.elements.map((element, i) => ({
element,
i
})).filter(({ element }) => element.name === ns.run).map(({ element, i }) => {
const renderedRunNode = renderRunNode(element, i, currentRunStringLength);
currentRunStringLength += renderedRunNode.text.length;
return renderedRunNode;
}).filter((e) => Boolean(e));
const text = runs.reduce((acc, curr) => acc + curr.text, "");
return {
index: node.index,
pathToParagraph: buildNodePath(node),
runs,
text
};
};
const renderRunNode = (node, index, currentRunStringIndex) => {
if (!node.elements) return {
end: currentRunStringIndex,
index: -1,
parts: [],
start: currentRunStringIndex,
text: ""
};
let currentTextStringIndex = currentRunStringIndex;
const parts = node.elements.map((element, i) => element.name === ns.text && element.elements && element.elements.length > 0 ? (() => {
const partStart = currentTextStringIndex;
currentTextStringIndex += (element.elements[0].text?.toString() ?? "").length;
return {
end: currentTextStringIndex - 1,
index: i,
start: partStart,
text: element.elements[0].text?.toString() ?? ""
};
})() : void 0).filter((e) => Boolean(e)).map((e) => e);
const text = parts.reduce((acc, curr) => acc + curr.text, "");
return {
end: currentTextStringIndex - 1,
index,
parts,
start: currentRunStringIndex,
text
};
};
return renderParagraphNode;
}
const buildNodePath = (node) => node.parent ? [...buildNodePath(node.parent), node.index] : [node.index];
//#endregion
//#region src/patch/xml-traverser.ts
const elementsToWrapper = (wrapper) => wrapper.element.elements?.map((e, i) => ({
element: e,
index: i,
parent: wrapper
})) ?? [];
function createTraverser(ns) {
const renderParagraphNode = createRunRenderer(ns);
const traverse = (node) => {
let renderedParagraphs = [];
const queue = [...elementsToWrapper({
element: node,
index: 0,
parent: void 0
})];
let currentNode;
while (queue.length > 0) {
currentNode = queue.shift();
if (currentNode.element.name === ns.paragraph) renderedParagraphs = [...renderedParagraphs, renderParagraphNode(currentNode)];
queue.push(...elementsToWrapper(currentNode));
}
return renderedParagraphs;
};
const findLocationOfText = (node, text) => traverse(node).filter((p) => p.text.includes(text));
return {
traverse,
findLocationOfText
};
}
//#endregion
//#region src/patch/xml-replacer.ts
const SPLIT_TOKEN = "ɵ";
function createReplacer(config) {
const { ns, formatChild } = config;
const { findLocationOfText } = createTraverser(ns);
const replaceTokenInParagraphElement = createTokenReplacer(createTextElementContents, { preserveSpace: config.preserveSpace });
const { findRunElementIndexWithToken, splitRunElement } = createSplitInject(ns, createTextElementContents, { preserveSpace: config.preserveSpace });
const replacer = ({ json, patch, patchText, context, keepOriginalStyles = true }) => {
const renderedParagraphs = findLocationOfText(json, patchText);
if (renderedParagraphs.length === 0) return {
didFindOccurrence: false,
element: json
};
for (const renderedParagraph of renderedParagraphs) {
const textJson = patch.children.flatMap((c) => formatChild(c, context));
switch (patch.type) {
case "file": {
const parentElement = goToParentElementFromPath(json, renderedParagraph.pathToParagraph);
const elementIndex = getLastElementIndexFromPath(renderedParagraph.pathToParagraph);
parentElement.elements.splice(elementIndex, 1, ...textJson);
break;
}
default: {
const paragraphElement = goToElementFromPath(json, renderedParagraph.pathToParagraph);
replaceTokenInParagraphElement({
originalText: patchText,
paragraphElement,
renderedParagraph,
replacementText: SPLIT_TOKEN
});
const index = findRunElementIndexWithToken(paragraphElement, SPLIT_TOKEN);
const runElementToBeReplaced = paragraphElement.elements[index];
const { left, right } = splitRunElement(runElementToBeReplaced, SPLIT_TOKEN);
let newRunElements = textJson;
let patchedRightElement = right;
if (keepOriginalStyles) {
const runElementNonTextualElements = runElementToBeReplaced.elements.filter((e) => e.type === "element" && e.name === ns.runProperties);
newRunElements = textJson.map((e) => {
if (e.type !== "element" || e.name !== ns.run || e.elements?.some((c) => c.type === "element" && c.name === ns.runProperties)) return e;
return {
...e,
elements: [...runElementNonTextualElements, ...e.elements ?? []]
};
});
patchedRightElement = {
...right,
elements: [...runElementNonTextualElements, ...right.elements]
};
}
paragraphElement.elements.splice(index, 1, left, ...newRunElements, patchedRightElement);
break;
}
}
}
return {
didFindOccurrence: true,
element: json
};
};
return replacer;
}
const goToElementFromPath = (json, path) => {
let element = json;
for (let i = 1; i < path.length; i++) {
const index = path[i];
element = element.elements[index];
}
return element;
};
const goToParentElementFromPath = (json, path) => goToElementFromPath(json, path.slice(0, -1));
const getLastElementIndexFromPath = (path) => path[path.length - 1];
//#endregion
//#region src/patch/content-types-manager.ts
const appendContentType = (element, contentType, extension) => {
const relationshipElements = getFirstLevelElements(element, "Types");
if (relationshipElements.some((el) => el.type === "element" && el.name === "Default" && el?.attributes?.ContentType === contentType && el?.attributes?.Extension === extension)) return;
relationshipElements.push({
attributes: {
ContentType: contentType,
Extension: extension
},
name: "Default",
type: "element"
});
};
//#endregion
//#region src/patch/relationship-manager.ts
const getIdFromRelationshipId = (relationshipId) => {
const output = parseInt(relationshipId.substring(3), 10);
return isNaN(output) ? 0 : output;
};
const getNextRelationshipIndex = (relationships) => {
return getFirstLevelElements(relationships, "Relationships").map((e) => getIdFromRelationshipId(e.attributes?.Id?.toString() ?? "")).reduce((acc, curr) => Math.max(acc, curr), 0) + 1;
};
const appendRelationship = (relationships, id, type, target, targetMode) => {
const relationshipElements = getFirstLevelElements(relationships, "Relationships");
relationshipElements.push({
attributes: {
Id: `rId${id}`,
Target: target,
TargetMode: targetMode,
Type: type
},
name: "Relationship",
type: "element"
});
return relationshipElements;
};
//#endregion
export { createTraverser as a, TokenNotFoundError as c, getFirstLevelElements as d, patchSpaceAttribute as f, PPTX_NS as h, createReplacer as i, createSplitInject as l, DOCX_NS as m, getNextRelationshipIndex as n, createRunRenderer as o, toJson as p, appendContentType as r, createTokenReplacer as s, appendRelationship as t, createTextElementContents as u };
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "../index-DNLRdIqy.mjs";
export { DOCX_NS, PPTX_NS, RenderedParagraphNode, ReplacerConfig, TokenNotFoundError, XmlNamespaceConfig, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "../patch-BdMU95aX.mjs";
export { DOCX_NS, PPTX_NS, TokenNotFoundError, appendContentType, appendRelationship, createReplacer, createRunRenderer, createSplitInject, createTextElementContents, createTokenReplacer, createTraverser, getFirstLevelElements, getNextRelationshipIndex, patchSpaceAttribute, toJson };
//#region src/values.d.ts
/**
* Runtime validation and type conversion functions for OOXML specification values.
*
* This module provides runtime checks and cleanup for value types in the OOXML spec
* that aren't easily expressed through the TypeScript type system alone. These
* validators help prevent silent failures and corrupted documents by enforcing
* spec-compliant values at runtime.
*
* @module
*/
/**
* A measurement value with optional sign and unit suffix.
*
* Supports units: mm (millimeters), cm (centimeters), in (inches),
* pt (points), pc (picas), pi (picas).
*
* Pattern: `-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
*
* @example
* ```typescript
* const measure: UniversalMeasure = "10.5mm";
* const negative: UniversalMeasure = "-5pt";
* ```
*/
type UniversalMeasure = `${"-" | ""}${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A positive measurement value with unit suffix.
*
* Same as UniversalMeasure but restricted to positive values only.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @example
* ```typescript
* const measure: PositiveUniversalMeasure = "10.5mm";
* ```
*/
type PositiveUniversalMeasure = `${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A percentage value with optional sign.
*
* Pattern: `-?[0-9]+(\.[0-9]+)?%`
*
* Reference: ST_Percentage in OOXML specification
*
* @example
* ```typescript
* const percent: Percentage = "50%";
* const negative: Percentage = "-10.5%";
* ```
*/
type Percentage = `${"-" | ""}${number}%`;
/**
* A positive percentage value.
*
* Same as Percentage but restricted to positive values only.
*
* Reference: ST_PositivePercentage in OOXML specification
*
* @example
* ```typescript
* const percent: PositivePercentage = "50%";
* ```
*/
type PositivePercentage = `${number}%`;
/**
* A relative measurement value using em or ex units.
*
* Used in VML text boxes for font-relative measurements.
*
* @example
* ```typescript
* const measure: RelativeMeasure = "2em";
* const negative: RelativeMeasure = "-0.5ex";
* ```
*/
type RelativeMeasure = `${"-" | ""}${number}${"em" | "ex"}`;
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
declare const decimalNumber: (val: number) => number;
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
declare const unsignedDecimalNumber: (val: number) => number;
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
declare const hexBinary: (val: string, length: number) => string;
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
declare const longHexNumber: (val: string) => string;
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
declare const shortHexNumber: (val: string) => string;
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
declare const uCharHexNumber: (val: string) => string;
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
declare const universalMeasureValue: (val: UniversalMeasure) => UniversalMeasure;
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
declare const positiveUniversalMeasureValue: (val: PositiveUniversalMeasure) => PositiveUniversalMeasure;
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
declare const hexColorValue: (val: string) => string;
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const signedTwipsMeasureValue: (val: UniversalMeasure | number) => UniversalMeasure | number;
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
declare const hpsMeasureValue: (val: PositiveUniversalMeasure | number) => string | number;
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
declare const signedHpsMeasureValue: (val: UniversalMeasure | number) => string | number;
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const twipsMeasureValue: (val: PositiveUniversalMeasure | number) => PositiveUniversalMeasure | number;
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
declare const percentageValue: (val: Percentage) => Percentage;
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
declare const measurementOrPercentValue: (val: number | Percentage | UniversalMeasure) => number | UniversalMeasure | Percentage;
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
declare const eighthPointMeasureValue: (val: number) => number;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
declare const pointMeasureValue: (val: number) => number;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
declare const dateTimeValue: (val: Date) => string;
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
declare const ThemeColor: {
readonly DARK1: "dark1";
readonly LIGHT1: "light1";
readonly DARK2: "dark2";
readonly LIGHT2: "light2";
readonly ACCENT1: "accent1";
readonly ACCENT2: "accent2";
readonly ACCENT3: "accent3";
readonly ACCENT4: "accent4";
readonly ACCENT5: "accent5";
readonly ACCENT6: "accent6";
readonly HYPERLINK: "hyperlink";
readonly FOLLOWED_HYPERLINK: "followedHyperlink";
readonly NONE: "none";
readonly BACKGROUND1: "background1";
readonly TEXT1: "text1";
readonly BACKGROUND2: "background2";
readonly TEXT2: "text2";
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
declare const ThemeFont: {
readonly MAJOR_EAST_ASIA: "majorEastAsia";
readonly MAJOR_BIDI: "majorBidi";
readonly MAJOR_ASCII: "majorAscii";
readonly MAJOR_H_ANSI: "majorHAnsi";
readonly MINOR_EAST_ASIA: "minorEastAsia";
readonly MINOR_BIDI: "minorBidi";
readonly MINOR_ASCII: "minorAscii";
readonly MINOR_H_ANSI: "minorHAnsi";
};
//#endregion
export { uCharHexNumber as C, twipsMeasureValue as S, unsignedDecimalNumber as T, pointMeasureValue as _, ThemeColor as a, signedHpsMeasureValue as b, dateTimeValue as c, hexBinary as d, hexColorValue as f, percentageValue as g, measurementOrPercentValue as h, RelativeMeasure as i, decimalNumber as l, longHexNumber as m, PositivePercentage as n, ThemeFont as o, hpsMeasureValue as p, PositiveUniversalMeasure as r, UniversalMeasure as s, Percentage as t, eighthPointMeasureValue as u, positiveUniversalMeasureValue as v, universalMeasureValue as w, signedTwipsMeasureValue as x, shortHexNumber as y };
+1
-112

@@ -1,113 +0,2 @@

import { C as XmlComponent } from "../index-mjYQ4KiG.mjs";
//#region src/chart/axes.d.ts
/**
* c:catAx — category axis.
*/
declare class CatAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
/**
* c:valAx — value axis.
*/
declare class ValAx extends XmlComponent {
constructor(axId: number, crossAx: number);
}
//#endregion
//#region src/chart/chart-types/area-chart.d.ts
interface AreaChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class AreaChart extends XmlComponent {
constructor(options: AreaChartOptions);
}
//#endregion
//#region src/chart/chart-types/bar-chart.d.ts
interface BarChartOptions {
readonly barDirection: "col" | "bar";
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class BarChart extends XmlComponent {
constructor(options: BarChartOptions);
}
//#endregion
//#region src/chart/chart-types/line-chart.d.ts
interface LineChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class LineChart extends XmlComponent {
constructor(options: LineChartOptions);
}
//#endregion
//#region src/chart/chart-types/pie-chart.d.ts
interface PieChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class PieChart extends XmlComponent {
constructor(options: PieChartOptions);
}
//#endregion
//#region src/chart/chart-types/scatter-chart.d.ts
interface ScatterChartOptions {
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
}
declare class ScatterChart extends XmlComponent {
constructor(options: ScatterChartOptions);
}
//#endregion
//#region src/chart/create-chart-type.d.ts
interface ChartSeriesData {
readonly name: string;
readonly values: readonly number[];
}
type ChartType = "column" | "bar" | "line" | "pie" | "area" | "scatter";
interface ChartTypeOptions {
readonly type: ChartType;
readonly series: readonly ChartSeriesData[];
readonly categories: readonly string[];
}
declare const createChartType: (options: ChartTypeOptions) => BarChart | LineChart | PieChart | AreaChart | ScatterChart;
//#endregion
//#region src/chart/chart-space.d.ts
interface ChartSpaceOptions {
readonly title?: string;
readonly type: ChartType;
readonly categories: readonly string[];
readonly series: readonly ChartSeriesData[];
readonly showLegend?: boolean;
readonly style?: number;
}
/**
* c:chartSpace — root element for chart XML parts.
*/
declare class ChartSpace extends XmlComponent {
constructor(options: ChartSpaceOptions);
}
//#endregion
//#region src/chart/chart-collection.d.ts
interface ChartData {
readonly key: string;
readonly chartSpace: XmlComponent;
}
declare class ChartCollection {
private readonly map;
constructor();
addChart(key: string, chartData: ChartData): void;
get array(): readonly ChartData[];
}
//#endregion
//#region src/chart/series/series-data.d.ts
declare const createStrRef: (values: string | readonly string[]) => XmlComponent;
declare const createNumRef: (values: readonly number[]) => XmlComponent;
//#endregion
//#region src/chart/title.d.ts
declare class ChartTitle extends XmlComponent {
constructor(title: string);
}
//#endregion
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "../index-DZobntUT.mjs";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };

@@ -1,611 +0,2 @@

import { a as BuilderElement, b as XmlComponent, c as chartAttr, h as wrapEl, o as EmptyElement } from "../xml-components-CADgke8j.mjs";
//#region src/chart/axes.ts
/**
* c:scaling — axis scaling configuration (minOccurs=1 in EG_AxShared).
*/
var Scaling = class extends XmlComponent {
constructor() {
super("c:scaling");
this.root.push(wrapEl("c:orientation", chartAttr({ val: "minMax" })));
}
};
/**
* c:catAx — category axis.
*/
var CatAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:catAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "b" })));
this.root.push(wrapEl("c:auto", chartAttr({ val: 1 })));
this.root.push(wrapEl("c:lblOffset", chartAttr({ val: 100 })));
this.root.push(wrapEl("c:noMultiLvlLbl", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
}
};
/**
* c:valAx — value axis.
*/
var ValAx = class extends XmlComponent {
constructor(axId, crossAx) {
super("c:valAx");
this.root.push(wrapEl("c:axId", chartAttr({ val: axId })));
this.root.push(new Scaling());
this.root.push(wrapEl("c:delete", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:axPos", chartAttr({ val: "l" })));
this.root.push(wrapEl("c:numFmt", chartAttr({
formatCode: "General",
sourceLinked: 1
})));
this.root.push(wrapEl("c:crossAx", chartAttr({ val: crossAx })));
this.root.push(wrapEl("c:crosses", chartAttr({ val: "autoZero" })));
this.root.push(new BuilderElement({ name: "c:spPr" }));
}
};
//#endregion
//#region src/chart/series/series-data.ts
const createStrRef = (values) => {
return new StrRef(typeof values === "string" ? [values] : values);
};
const createNumRef = (values) => new NumRef(values);
var StrRef = class extends XmlComponent {
constructor(values) {
super("c:strRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new StrCache(values));
}
};
var StrCache = class extends XmlComponent {
constructor(values) {
super("c:strCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
for (let i = 0; i < values.length; i++) this.root.push(new StrPt(i, values[i]));
}
};
var StrPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", value));
}
};
var NumRef = class extends XmlComponent {
constructor(values) {
super("c:numRef");
this.root.push(new EmptyElement("c:f"));
this.root.push(new NumCache(values));
}
};
var NumCache = class extends XmlComponent {
constructor(values) {
super("c:numCache");
this.root.push(wrapEl("c:ptCount", chartAttr({ val: values.length })));
this.root.push(new FormatCode("General"));
for (let i = 0; i < values.length; i++) this.root.push(new NumPt(i, values[i]));
}
};
var NumPt = class extends XmlComponent {
constructor(index, value) {
super("c:pt");
this.root.push(chartAttr({ idx: index }));
this.root.push(new StringValue("c:v", String(value)));
}
};
var FormatCode = class extends XmlComponent {
constructor(code) {
super("c:formatCode");
this.root.push(code);
}
};
var StringValue = class extends XmlComponent {
constructor(name, val) {
super(name);
this.root.push(val);
}
};
//#endregion
//#region src/chart/chart-types/area-chart.ts
var AreaChart = class extends XmlComponent {
constructor(options) {
super("c:areaChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new AreaSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var AreaSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$4(series.name));
this.root.push(new SeriesCat$4(categories));
this.root.push(new SeriesVal$4(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$4 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$4 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$4 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/bar-chart.ts
var BarChart = class extends XmlComponent {
constructor(options) {
super("c:barChart");
this.root.push(wrapEl("c:barDir", chartAttr({ val: options.barDirection })));
this.root.push(wrapEl("c:grouping", chartAttr({ val: "clustered" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new BarSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var BarSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$3(series.name));
this.root.push(new SeriesCat$3(categories));
this.root.push(new SeriesVal$3(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$3 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$3 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$3 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/line-chart.ts
var LineChart = class extends XmlComponent {
constructor(options) {
super("c:lineChart");
this.root.push(wrapEl("c:grouping", chartAttr({ val: "standard" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new LineSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var LineSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$2(series.name));
this.root.push(new SeriesCat$2(categories));
this.root.push(new SeriesVal$2(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$2 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$2 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$2 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/pie-chart.ts
var PieChart = class extends XmlComponent {
constructor(options) {
super("c:pieChart");
this.root.push(wrapEl("c:varyColors", chartAttr({ val: true })));
for (let i = 0; i < options.series.length; i++) this.root.push(new PieSeries(i, options.series[i], options.categories));
}
};
var PieSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx$1(series.name));
this.root.push(new SeriesCat$1(categories));
this.root.push(new SeriesVal$1(series.values));
this.root.push(new EmptyElement("c:spPr"));
}
};
var SeriesTx$1 = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat$1 = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal$1 = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/chart-types/scatter-chart.ts
var ScatterChart = class extends XmlComponent {
constructor(options) {
super("c:scatterChart");
this.root.push(wrapEl("c:scatterStyle", chartAttr({ val: "line" })));
for (let i = 0; i < options.series.length; i++) this.root.push(new ScatterSeries(i, options.series[i], options.categories));
this.root.push(wrapEl("c:axId", chartAttr({ val: 10 })));
this.root.push(wrapEl("c:axId", chartAttr({ val: 20 })));
}
};
var ScatterSeries = class extends XmlComponent {
constructor(index, series, categories) {
super("c:ser");
this.root.push(wrapEl("c:idx", chartAttr({ val: index })));
this.root.push(wrapEl("c:order", chartAttr({ val: index })));
this.root.push(new SeriesTx(series.name));
this.root.push(new SeriesCat(categories));
this.root.push(new SeriesVal(series.values));
this.root.push(new EmptyElement("c:spPr"));
this.root.push(new EmptyElement("c:size"));
}
};
var SeriesTx = class extends XmlComponent {
constructor(name) {
super("c:tx");
this.root.push(createStrRef(name));
}
};
var SeriesCat = class extends XmlComponent {
constructor(categories) {
super("c:cat");
this.root.push(createStrRef(categories));
}
};
var SeriesVal = class extends XmlComponent {
constructor(values) {
super("c:val");
this.root.push(createNumRef(values));
}
};
//#endregion
//#region src/chart/create-chart-type.ts
const createChartType = (options) => {
switch (options.type) {
case "column":
case "bar": return new BarChart({
barDirection: options.type === "column" ? "col" : "bar",
categories: options.categories,
series: options.series
});
case "line": return new LineChart({
categories: options.categories,
series: options.series
});
case "pie": return new PieChart({
categories: options.categories,
series: options.series
});
case "area": return new AreaChart({
categories: options.categories,
series: options.series
});
case "scatter": return new ScatterChart({
categories: options.categories,
series: options.series
});
default: throw new Error(`Unsupported chart type: ${options.type}`);
}
};
//#endregion
//#region src/chart/title.ts
var ChartTitle = class extends XmlComponent {
constructor(title) {
super("c:title");
this.root.push(new TitleTx(title));
this.root.push(new TitleOverlay());
}
};
var TitleTx = class extends XmlComponent {
constructor(title) {
super("c:tx");
const rich = new class extends XmlComponent {
constructor() {
super("c:rich");
}
}();
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:bodyPr");
}
}());
rich["root"].push(new class extends XmlComponent {
constructor() {
super("a:lstStyle");
}
}());
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const r = new class extends XmlComponent {
constructor() {
super("a:r");
}
}();
r["root"].push(new class extends XmlComponent {
constructor() {
super("a:t");
this.root.push(title);
}
}());
p["root"].push(r);
rich["root"].push(p);
this.root.push(rich);
}
};
var TitleOverlay = class extends XmlComponent {
constructor() {
super("c:overlay");
this.root.push(chartAttr({ val: 0 }));
}
};
//#endregion
//#region src/chart/chart-space.ts
/**
* ChartSpace — root element for chart XML parts (c:chartSpace).
*
* Full XSD-compliant implementation with all optional elements.
*
* @module
*/
/**
* c:chartSpace — root element for chart XML parts.
*/
var ChartSpace = class extends XmlComponent {
constructor(options) {
super("c:chartSpace");
this.root.push(chartAttr({
"xmlns:a": "http://schemas.openxmlformats.org/drawingml/2006/main",
"xmlns:c": "http://schemas.openxmlformats.org/drawingml/2006/chart",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships"
}));
this.root.push(wrapEl("c:date1904", chartAttr({ val: 0 })));
this.root.push(wrapEl("c:lang", chartAttr({ val: "en-US" })));
this.root.push(wrapEl("c:roundedCorners", chartAttr({ val: 0 })));
const chart = new ChartContainer();
if (options.title) chart["root"].push(new ChartTitle(options.title));
chart["root"].push(wrapEl("c:autoTitleDeleted", chartAttr({ val: 0 })));
const plotArea = new PlotArea();
plotArea["root"].push(new BuilderElement({ name: "c:layout" }));
plotArea["root"].push(createChartType({
categories: options.categories,
series: options.series,
type: options.type
}));
if (options.type !== "pie") if (options.type === "scatter") {
plotArea["root"].push(new ValAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
} else {
plotArea["root"].push(new CatAx(10, 20));
plotArea["root"].push(new ValAx(20, 10));
}
chart["root"].push(plotArea);
if (options.showLegend !== false) chart["root"].push(createLegend());
this.root.push(chart);
this.root.push(createChartSpPr());
this.root.push(createChartTxPr());
if (options.style !== void 0) this.root.push(new ChartStyle(options.style));
}
};
var ChartContainer = class extends XmlComponent {
constructor() {
super("c:chart");
}
};
var PlotArea = class extends XmlComponent {
constructor() {
super("c:plotArea");
}
};
function createLegend() {
const legend = new class extends XmlComponent {
constructor() {
super("c:legend");
}
}();
legend["root"].push(wrapEl("c:legendPos", chartAttr({ val: "b" })));
legend["root"].push(new BuilderElement({ name: "c:layout" }));
legend["root"].push(wrapEl("c:overlay", chartAttr({ val: 0 })));
legend["root"].push(createNoFillSpPr());
legend["root"].push(createTxPr());
return legend;
}
function createNoFillSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartSpPr() {
const spPr = new class extends XmlComponent {
constructor() {
super("c:spPr");
}
}();
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
spPr["root"].push(new class extends XmlComponent {
constructor() {
super("a:ln");
this.root.push(new class extends XmlComponent {
constructor() {
super("a:noFill");
}
}());
}
}());
spPr["root"].push(new BuilderElement({ name: "a:effectLst" }));
return spPr;
}
function createChartTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(new BuilderElement({ name: "a:bodyPr" }));
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createTxPr() {
const txPr = new class extends XmlComponent {
constructor() {
super("c:txPr");
}
}();
txPr["root"].push(createBodyPr());
txPr["root"].push(new BuilderElement({ name: "a:lstStyle" }));
txPr["root"].push(createTextParagraph());
return txPr;
}
function createBodyPr() {
return new BuilderElement({
name: "a:bodyPr",
attributes: {
rot: {
key: "rot",
value: "0"
},
spcFirstLastPara: {
key: "spcFirstLastPara",
value: "1"
},
vertOverflow: {
key: "vertOverflow",
value: "ellipsis"
},
vert: {
key: "vert",
value: "horz"
},
wrap: {
key: "wrap",
value: "square"
},
anchor: {
key: "anchor",
value: "ctr"
},
anchorCtr: {
key: "anchorCtr",
value: "1"
}
}
});
}
function createTextParagraph() {
const p = new class extends XmlComponent {
constructor() {
super("a:p");
}
}();
const pPr = new class extends XmlComponent {
constructor() {
super("a:pPr");
}
}();
pPr["root"].push(new BuilderElement({ name: "a:defRPr" }));
p["root"].push(pPr);
p["root"].push(new BuilderElement({
name: "a:endParaRPr",
attributes: { lang: {
key: "lang",
value: "en-US"
} }
}));
return p;
}
var ChartStyle = class extends XmlComponent {
constructor(val) {
super("c:style");
this.root.push(chartAttr({ val: String(val) }));
}
};
//#endregion
//#region src/chart/chart-collection.ts
var ChartCollection = class {
map;
constructor() {
this.map = /* @__PURE__ */ new Map();
}
addChart(key, chartData) {
this.map.set(key, chartData);
}
get array() {
return [...this.map.values()];
}
};
//#endregion
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "../chart-Bd9E-YhB.mjs";
export { AreaChart, BarChart, CatAx, ChartCollection, ChartSpace, ChartTitle, LineChart, PieChart, ScatterChart, ValAx, createChartType, createNumRef, createStrRef };

@@ -1,5 +0,7 @@

import { Relationship, elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer } from "./archive.mjs";
import { C as XmlComponent, D as IXmlableObject, E as IXmlAttribute, S as IgnoreIfEmptyXmlComponent, T as Context, _ as AttributeMap, a as BuilderElement, b as XmlAttributeComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as AttributeData, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as AttributePayload, w as BaseXmlComponent, x as EMPTY_OBJECT, y as NextAttributeComponent } from "./index-mjYQ4KiG.mjs";
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-CIh0bdS1.mjs";
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "./index-DigYTiB_.mjs";
import { C as XmlComponent, D as IXmlableObject, E as IXmlAttribute, S as IgnoreIfEmptyXmlComponent, T as Context, _ as AttributeMap, a as BuilderElement, b as XmlAttributeComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as AttributeData, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as AttributePayload, w as BaseXmlComponent, x as EMPTY_OBJECT, y as NextAttributeComponent } from "./index-B1wzvu1m.mjs";
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-QyWq4U4A.mjs";
import { _ as CatAx, a as ChartData, c as ChartSeriesData, d as createChartType, f as ScatterChart, g as AreaChart, h as BarChart, i as ChartCollection, l as ChartType, m as LineChart, n as createNumRef, o as ChartSpace, p as PieChart, r as createStrRef, s as ChartSpaceOptions, t as ChartTitle, u as ChartTypeOptions, v as ValAx } from "./index-DZobntUT.mjs";
import { $ as RectAlignment, $t as createSolidFill, A as createBevel, At as FillOptions, B as createSoftEdgeEffect, Bt as RelativeRect, C as GeometryGuide, Ct as createGroupFill, D as createShape3D, Dt as createNoFill, E as Shape3DOptions, Et as createPatternFill, F as Point3D, Ft as GradientShadeOptions, G as EffectListOptions, Gt as TileOptions, H as EffectDagOptions, Ht as createGradientFill, I as Scene3DOptions, It as GradientStop, J as createReflectionEffect, Jt as createSourceRectangle, K as createEffectList, Kt as createTileInfo, L as SphereCoords, Lt as LinearShadeOptions, M as BackdropOptions, Mt as buildFill, N as CameraOptions, Nt as extractBlipFillMedia, O as BevelOptions, Ot as BlipFillConfigOptions, P as LightRigOptions, Pt as GradientFillOptions, Q as OuterShadowEffectOptions, Qt as createColorElement, R as Vector3D, Rt as PathShadeOptions, S as PresetGeometryOptions, St as createCustomDash, T as PresetMaterialType, Tt as PresetPattern, U as createEffectDag, Ut as createGradientStop, V as EffectContainerType, Vt as TileFlipMode, W as BlurEffectOptions, Wt as TileAlignment, X as PresetShadowVal, Xt as createBlipEffects, Y as PresetShadowEffectOptions, Yt as BlipEffectsOptions, Z as createPresetShadowEffect, Zt as SolidFillOptions, _ as PathCommand, _t as LineEndOptions, a as Transform2DOptions, an as createSchemeColor, at as BlendMode, b as createCustomGeometry, bt as createLineEnd, c as Stretch, cn as RgbColorOptions, ct as CompoundLine, d as createBlipFill, dn as PresetColorOptions, dt as OutlineFillProperties, en as SystemColor, et as createOuterShadowEffect, f as BlipOptions, fn as createPresetColor, ft as OutlineOptions, g as GeomRect, gn as createColorTransforms, gt as LineEndLength, h as CustomGeometryOptions, hn as ColorTransformOptions, ht as createOutline, i as GroupTransform2DOptions, in as SchemeColorOptions, it as createGlowEffect, j as createBottomBevel, jt as GradientStopOptions, k as BevelPresetType, kt as BlipFillMediaData, l as createExtentionList, ln as createRgbColor, lt as LineCap, m as ConnectionSite, mn as createHslColor, mt as PresetDash, n as MediaTransformation, nn as createSystemColor, nt as createInnerShadowEffect, o as createGroupTransform2D, on as ScRgbColorOptions, ot as FillOverlayEffectOptions, p as createBlip, pn as HslColorOptions, pt as PenAlignment, q as ReflectionEffectOptions, qt as SourceRectangleOptions, r as createTransformation, rn as SchemeColor, rt as GlowEffectOptions, s as createTransform2D, sn as createScRgbColor, st as createFillOverlayEffect, t as MediaDataTransformation, tn as SystemColorOptions, tt as InnerShadowEffectOptions, u as BlipFillOptions, un as PresetColor, ut as LineJoin, v as PathFillMode, vt as LineEndType, w as createAdjustmentValues, wt as PatternFillOptions, x as PresetGeometry, xt as DashStop, y as PathOptions, yt as LineEndWidth, z as createScene3D, zt as PathShadeType } from "./index-CuRO3Jmz.mjs";
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "./index-CZxcE4Q6.mjs";
import { _ as PPTX_NS, a as getFirstLevelElements, c as TokenNotFoundError, d as createTraverser, f as RenderedParagraphNode, g as DOCX_NS, h as createReplacer, i as createTextElementContents, l as createSplitInject, m as ReplacerConfig, n as getNextRelationshipIndex, o as patchSpaceAttribute, p as createRunRenderer, r as appendContentType, s as toJson, t as appendRelationship, u as createTokenReplacer, v as XmlNamespaceConfig } from "./index-DNLRdIqy.mjs";
import { Element } from "@office-open/xml";

@@ -250,3 +252,2 @@ import { ZipOptions, Zippable, Zippable as Zippable$1, strFromU8, unzipSync } from "fflate";

}
declare function parseCoreProperties(zip: Map<string, Uint8Array>): CoreProperties;
/**

@@ -275,3 +276,3 @@ * Parse core properties from an already-parsed XML element.

/**
* Parsed OOXML document backed by an unzipped ZIP map.
* Parsed OOXML archive backed by an unzipped ZIP map.
*

@@ -281,7 +282,7 @@ * Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)

*/
declare class ParsedDocument {
declare class ParsedArchive {
private readonly zip;
private readonly modified;
private readonly wrapperCache;
constructor(zip: Map<string, Uint8Array>);
constructor(data: Uint8Array);
/** Read an XML part as an Element tree. */

@@ -304,4 +305,4 @@ get(path: string): Element | undefined;

}
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedDocument. */
declare function parseArchive(data: Uint8Array): ParsedDocument;
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
declare function parseArchive(data: Uint8Array): ParsedArchive;
//#endregion

@@ -368,4 +369,4 @@ //#region src/raw-passthrough.d.ts

from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "topLeft" | "top" | "topRight" | "left" | "right" | "bottomLeft" | "bottom" | "bottomRight", "tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br">; /** The reverse map (XSD → user) */
reverse: Record<"tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br", "center" | "topLeft" | "top" | "topRight" | "left" | "right" | "bottomLeft" | "bottom" | "bottomRight">;
forward: Record<"topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight", "tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br">; /** The reverse map (XSD → user) */
reverse: Record<"tl" | "t" | "tr" | "l" | "ctr" | "r" | "bl" | "b" | "br", "topLeft" | "top" | "topRight" | "left" | "center" | "right" | "bottomLeft" | "bottom" | "bottomRight">;
};

@@ -375,4 +376,4 @@ declare const xsdTextAlign: {

from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "left" | "right" | "justify", "l" | "ctr" | "r" | "just">; /** The reverse map (XSD → user) */
reverse: Record<"l" | "ctr" | "r" | "just", "center" | "left" | "right" | "justify">;
forward: Record<"left" | "center" | "right" | "justify", "l" | "ctr" | "r" | "just">; /** The reverse map (XSD → user) */
reverse: Record<"l" | "ctr" | "r" | "just", "left" | "center" | "right" | "justify">;
};

@@ -382,4 +383,4 @@ declare const xsdTextAnchor: {

from: (xsd: string) => string; /** The forward map (user → XSD) */
forward: Record<"center" | "top" | "bottom", "t" | "ctr" | "b">; /** The reverse map (XSD → user) */
reverse: Record<"t" | "ctr" | "b", "center" | "top" | "bottom">;
forward: Record<"top" | "center" | "bottom", "t" | "ctr" | "b">; /** The reverse map (XSD → user) */
reverse: Record<"t" | "ctr" | "b", "top" | "center" | "bottom">;
};

@@ -471,2 +472,2 @@ declare const xsdLineCap: {

//#endregion
export { AppProperties, AttributeData, AttributeMap, AttributePayload, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, CompileFn, Connection, Context, CoreProperties, DEFAULT_DRAWING_XML, DataModel, type DefaultAttributes, EMPTY_OBJECT, EmptyElement, Formatter, IXmlAttribute, IXmlableObject, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, OoxmlMimeType, OutputByType, OutputType, type OverrideAttributes, Packer, ParsedDocument, Percentage, Point, PositivePercentage, PositiveUniversalMeasure, PrettifyType, RawPassthrough, Relationship, type RelationshipType, Relationships, RelativeMeasure, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, SmartArtRelOptions, TargetModeType, ThemeColor, ThemeFont, TransPoint, TreeNode, UniqueNumericIdCreator, UniversalMeasure, XmlAttributeComponent, XmlComponent, XmlifyedFile, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, type ZipOptions, type Zippable, addSmartArtRelationships, attrObj, buildCorePropertiesXml, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createDataModel, createDefault, createOverride, createPacker, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, elementToXml, escapeRegex, findRel, findRelsByType, formatId, getColorXml, getImageType, getLayoutXml, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCoreProperties, parseCorePropsElement, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, unzipToMap, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert, zipToBuffer };
export { AppProperties, AreaChart, AttributeData, AttributeMap, AttributePayload, BackdropOptions, BarChart, BaseXmlComponent, BevelOptions, BevelPresetType, BlendMode, BlipEffectsOptions, BlipFillConfigOptions, BlipFillMediaData, BlipFillOptions, BlipOptions, BlurEffectOptions, BuilderElement, COLOR_CATEGORIES, CameraOptions, CatAx, ChartCollection, ChartData, ChartSeriesData, ChartSpace, ChartSpaceOptions, ChartTitle, ChartType, ChartTypeOptions, ColorTransformOptions, CompileFn, CompoundLine, Connection, ConnectionSite, Context, CoreProperties, CustomGeometryOptions, DEFAULT_DRAWING_XML, DOCX_NS, DashStop, DataModel, type DefaultAttributes, EMPTY_OBJECT, EffectContainerType, EffectDagOptions, EffectListOptions, EmptyElement, FillOptions, FillOverlayEffectOptions, Formatter, GeomRect, GeometryGuide, GlowEffectOptions, GradientFillOptions, GradientShadeOptions, GradientStop, GradientStopOptions, GroupTransform2DOptions, HslColorOptions, IXmlAttribute, IXmlableObject, IdFormat, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, InnerShadowEffectOptions, LAYOUT_CATEGORIES, LightRigOptions, LineCap, LineChart, LineEndLength, LineEndOptions, LineEndType, LineEndWidth, LineJoin, LinearShadeOptions, MediaDataTransformation, MediaTransformation, NextAttributeComponent, OoxmlMimeType, OuterShadowEffectOptions, OutlineFillProperties, OutlineOptions, OutputByType, OutputType, type OverrideAttributes, PPTX_NS, Packer, ParsedArchive, PathCommand, PathFillMode, PathOptions, PathShadeOptions, PathShadeType, PatternFillOptions, PenAlignment, Percentage, PieChart, Point, Point3D, PositivePercentage, PositiveUniversalMeasure, PresetColor, PresetColorOptions, PresetDash, PresetGeometry, PresetGeometryOptions, PresetMaterialType, PresetPattern, PresetShadowEffectOptions, PresetShadowVal, PrettifyType, RawPassthrough, RectAlignment, ReflectionEffectOptions, type RelationshipType, Relationships, RelativeMeasure, RelativeRect, RenderedParagraphNode, ReplacerConfig, RgbColorOptions, STYLE_CATEGORIES, ScRgbColorOptions, ScatterChart, Scene3DOptions, SchemeColor, SchemeColorOptions, Shape3DOptions, SmartArtCollection, SmartArtData, SmartArtRelOptions, SolidFillOptions, SourceRectangleOptions, SphereCoords, Stretch, SystemColor, SystemColorOptions, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TileOptions, TokenNotFoundError, TransPoint, Transform2DOptions, TreeNode, UniqueNumericIdCreator, UniversalMeasure, ValAx, Vector3D, XmlAttributeComponent, XmlComponent, XmlNamespaceConfig, XmlifyedFile, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, type ZipOptions, type Zippable, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildFill, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, escapeRegex, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };
import { _ as XmlAttributeComponent, a as BuilderElement, b as XmlComponent, c as chartAttr, d as onOffObj, f as stringContainerObj, g as NextAttributeComponent, h as wrapEl, i as convertToXmlComponent, l as hpsMeasureObj, m as stringValObj, n as ImportedRootElementAttributes, o as EmptyElement, p as stringEnumValObj, r as ImportedXmlComponent, s as attrObj, t as InitializableXmlComponent, u as numberValObj, v as EMPTY_OBJECT, x as BaseXmlComponent, y as IgnoreIfEmptyXmlComponent } from "./xml-components-CADgke8j.mjs";
import { ThemeColor, ThemeFont, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber } from "./values.mjs";
import { A as convertPointsToEmu, C as convertEmuToInches, D as convertInchesToTwip, E as convertInchesToEmu, O as convertMillimetersToTwip, S as uniqueUuid, T as convertEmuToPoints, _ as xsdUnderlineStyle, a as xsdLineCap, b as uniqueId, c as xsdPathFillMode, d as xsdPresetShadow, f as xsdRectAlignment, g as xsdTextCaps, h as xsdTextAnchor, i as xsdEffectContainer, k as convertPixelsToEmu, l as xsdPattern, m as xsdTextAlign, n as xsdBlendMode, o as xsdLineEndSize, p as xsdStrikeStyle, r as xsdCompoundLine, s as xsdMaterialType, t as invertMap, u as xsdPenAlignment, v as xsdVerticalMergeRev, w as convertEmuToPixels, x as uniqueNumericIdCreator, y as hashedId } from "./xsd-mappings-BiTj9yJn.mjs";
import { $ as xsdCompoundLine, A as LineJoin, At as hashedId, B as createNoFill, Bt as convertPixelsToEmu, C as createOuterShadowEffect, Ct as createSchemeColor, D as createFillOverlayEffect, Dt as createPresetColor, E as BlendMode, Et as PresetColor, F as LineEndType, Ft as convertEmuToPixels, G as PathShadeType, H as extractBlipFillMedia, I as LineEndWidth, It as convertEmuToPoints, J as createGradientStop, K as TileFlipMode, L as createLineEnd, Lt as convertInchesToEmu, M as PresetDash, Mt as uniqueNumericIdCreator, N as createOutline, Nt as uniqueUuid, O as CompoundLine, Ot as createHslColor, P as LineEndLength, Pt as convertEmuToInches, Q as xsdBlendMode, R as createCustomDash, Rt as convertInchesToTwip, S as RectAlignment, St as SchemeColor, T as createGlowEffect, Tt as createRgbColor, U as PresetPattern, V as buildFill, Vt as convertPointsToEmu, W as createPatternFill, X as createTileInfo, Y as TileAlignment, Z as invertMap, _ as createEffectList, _t as createBlipEffects, a as createBlip, at as xsdPattern, b as PresetShadowVal, bt as SystemColor, c as PresetGeometry, ct as xsdRectAlignment, d as createShape3D, dt as xsdTextAnchor, et as xsdEffectContainer, f as BevelPresetType, ft as xsdTextCaps, g as createEffectDag, gt as createSourceRectangle, h as createScene3D, ht as Stretch, i as createBlipFill, it as xsdPathFillMode, j as PenAlignment, jt as uniqueId, k as LineCap, kt as createColorTransforms, l as createAdjustmentValues, lt as xsdStrikeStyle, m as createBottomBevel, mt as xsdVerticalMergeRev, n as createGroupTransform2D, nt as xsdLineEndSize, o as createExtentionList, ot as xsdPenAlignment, p as createBevel, pt as xsdUnderlineStyle, q as createGradientFill, r as createTransform2D, rt as xsdMaterialType, s as createCustomGeometry, st as xsdPresetShadow, t as createTransformation, tt as xsdLineCap, u as PresetMaterialType, ut as xsdTextAlign, v as createSoftEdgeEffect, vt as createColorElement, w as createInnerShadowEffect, wt as createScRgbColor, x as createPresetShadowEffect, xt as createSystemColor, y as createReflectionEffect, yt as createSolidFill, z as createGroupFill, zt as convertMillimetersToTwip } from "./drawingml-YMdpQfWs.mjs";
import { a as DataModel, c as getColorXml, d as COLOR_CATEGORIES, f as LAYOUT_CATEGORIES, i as TransPoint, l as getLayoutXml, n as SmartArtCollection, o as Connection, p as STYLE_CATEGORIES, r as Point, s as DEFAULT_DRAWING_XML, t as createDataModel, u as getStyleXml } from "./smartart-DBQ_rRfK.mjs";
import { elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer } from "./archive.mjs";
import { a as ScatterChart, c as BarChart, d as createStrRef, f as CatAx, i as createChartType, l as AreaChart, n as ChartSpace, o as PieChart, p as ValAx, r as ChartTitle, s as LineChart, t as ChartCollection, u as createNumRef } from "./chart-Bd9E-YhB.mjs";
import { a as createTraverser, c as TokenNotFoundError, d as getFirstLevelElements, f as patchSpaceAttribute, h as PPTX_NS, i as createReplacer, l as createSplitInject, m as DOCX_NS, n as getNextRelationshipIndex, o as createRunRenderer, p as toJson, r as appendContentType, s as createTokenReplacer, t as appendRelationship, u as createTextElementContents } from "./patch-BdMU95aX.mjs";
import { js2xml, textOf, xml2js } from "@office-open/xml";
import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, zip, zipSync } from "fflate";
import { AsyncZipDeflate, Zip, ZipPassThrough, strFromU8, strFromU8 as strFromU8$1, strToU8, unzipSync, unzipSync as unzipSync$1, zip, zipSync } from "fflate";
import { Readable } from "stream";

@@ -300,7 +301,2 @@ //#region src/output-type.ts

];
function parseCoreProperties(zip) {
const xml = readXmlFromZip(zip, "docProps/core.xml");
if (!xml) return {};
return parseCorePropsElement(xml);
}
/**

@@ -363,3 +359,3 @@ * Parse core properties from an already-parsed XML element.

/**
* Parsed OOXML document backed by an unzipped ZIP map.
* Parsed OOXML archive backed by an unzipped ZIP map.
*

@@ -369,8 +365,8 @@ * Provides unstorage-style API (get/set/getRaw/setRaw/remove/has/keys)

*/
var ParsedDocument = class {
var ParsedArchive = class {
zip;
modified = /* @__PURE__ */ new Map();
wrapperCache = /* @__PURE__ */ new Map();
constructor(zip) {
this.zip = zip;
constructor(data) {
this.zip = new Map(Object.entries(unzipSync$1(data)));
}

@@ -435,11 +431,11 @@ /** Read an XML part as an Element tree. */

save() {
const files = /* @__PURE__ */ new Map();
for (const [path, data] of this.zip) if (!this.modified.has(path)) files.set(path, data);
for (const [path, data] of this.modified) files.set(path, data);
return zipToBuffer(files);
const files = {};
for (const [path, data] of this.zip) if (!this.modified.has(path)) files[path] = data;
for (const [path, data] of this.modified) files[path] = data;
return zipSync(files);
}
};
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedDocument. */
/** Parse an OOXML archive (.docx, .pptx, .xlsx) into a ParsedArchive. */
function parseArchive(data) {
return new ParsedDocument(unzipToMap(data));
return new ParsedArchive(data);
}

@@ -552,2 +548,2 @@ //#endregion

//#endregion
export { AppProperties, BaseXmlComponent, BuilderElement, COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, NextAttributeComponent, OoxmlMimeType, ParsedDocument, Point, PrettifyType, RawPassthrough, Relationships, STYLE_CATEGORIES, SmartArtCollection, TargetModeType, ThemeColor, ThemeFont, TransPoint, XmlAttributeComponent, XmlComponent, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, addSmartArtRelationships, attrObj, buildCorePropertiesXml, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createDataModel, createDefault, createOverride, createPacker, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, elementToXml, escapeRegex, findRel, findRelsByType, formatId, getColorXml, getImageType, getLayoutXml, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, listFiles, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCoreProperties, parseCorePropsElement, parseRels, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, twipsMeasureValue, uCharHexNumber, uint8ToBase64, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, unzipToMap, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert, zipToBuffer };
export { AppProperties, AreaChart, BarChart, BaseXmlComponent, BevelPresetType, BlendMode, BuilderElement, COLOR_CATEGORIES, CatAx, ChartCollection, ChartSpace, ChartTitle, CompoundLine, Connection, DEFAULT_DRAWING_XML, DOCX_NS, DataModel, EMPTY_OBJECT, EmptyElement, Formatter, IgnoreIfEmptyXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent, InitializableXmlComponent, LAYOUT_CATEGORIES, LineCap, LineChart, LineEndLength, LineEndType, LineEndWidth, LineJoin, NextAttributeComponent, OoxmlMimeType, PPTX_NS, ParsedArchive, PathShadeType, PenAlignment, PieChart, Point, PresetColor, PresetDash, PresetGeometry, PresetMaterialType, PresetPattern, PresetShadowVal, PrettifyType, RawPassthrough, RectAlignment, Relationships, STYLE_CATEGORIES, ScatterChart, SchemeColor, SmartArtCollection, Stretch, SystemColor, TargetModeType, ThemeColor, ThemeFont, TileAlignment, TileFlipMode, TokenNotFoundError, TransPoint, ValAx, XmlAttributeComponent, XmlComponent, ZIP_DEFLATE_LEVEL, ZIP_STORED_LEVEL, addSmartArtRelationships, appendContentType, appendRelationship, attrObj, buildCorePropertiesXml, buildFill, chartAttr, collectPlaceholderKeys, convertEmuToInches, convertEmuToPixels, convertEmuToPoints, convertInchesToEmu, convertInchesToTwip, convertMillimetersToTwip, convertOutput, convertPixelsToEmu, convertPointsToEmu, convertPrettifyType, convertToXmlComponent, createAdjustmentValues, createBevel, createBlip, createBlipEffects, createBlipFill, createBottomBevel, createChartType, createColorElement, createColorTransforms, createCustomDash, createCustomGeometry, createDataModel, createDefault, createEffectDag, createEffectList, createExtentionList, createFillOverlayEffect, createGlowEffect, createGradientFill, createGradientStop, createGroupFill, createGroupTransform2D, createHslColor, createInnerShadowEffect, createLineEnd, createNoFill, createNumRef, createOuterShadowEffect, createOutline, createOverride, createPacker, createPatternFill, createPresetColor, createPresetShadowEffect, createReflectionEffect, createReplacer, createRgbColor, createRunRenderer, createScRgbColor, createScene3D, createSchemeColor, createShape3D, createSoftEdgeEffect, createSolidFill, createSourceRectangle, createSplitInject, createStrRef, createSystemColor, createTextElementContents, createTileInfo, createTokenReplacer, createTransform2D, createTransformation, createTraverser, createZipStream, dateTimeValue, decimalNumber, eighthPointMeasureValue, elementToCompact, escapeRegex, extractBlipFillMedia, formatId, getColorXml, getFirstLevelElements, getLayoutXml, getNextRelationshipIndex, getReferencedMedia, getStyleXml, hasPlaceholders, hashedId, hexBinary, hexColorValue, hpsMeasureObj, hpsMeasureValue, invertMap, longHexNumber, measurementOrPercentValue, numberValObj, onOffObj, parseArchive, parseCorePropsElement, patchSpaceAttribute, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, replaceChartPlaceholders, replaceImagePlaceholders, replaceSmartArtPlaceholders, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, strFromU8, stringContainerObj, stringEnumValObj, stringValObj, toJson, twipsMeasureValue, uCharHexNumber, uniqueId, uniqueNumericIdCreator, uniqueUuid, universalMeasureValue, unsignedDecimalNumber, unzipSync, wrapEl, xsdBlendMode, xsdCompoundLine, xsdEffectContainer, xsdLineCap, xsdLineEndSize, xsdMaterialType, xsdPathFillMode, xsdPattern, xsdPenAlignment, xsdPresetShadow, xsdRectAlignment, xsdStrikeStyle, xsdTextAlign, xsdTextAnchor, xsdTextCaps, xsdUnderlineStyle, xsdVerticalMergeRev, zipAndConvert, zipSyncAndConvert };

@@ -1,2 +0,2 @@

import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "../index-DigYTiB_.mjs";
import { a as Point, c as Connection, d as getLayoutXml, f as getStyleXml, h as STYLE_CATEGORIES, i as SmartArtData, l as DEFAULT_DRAWING_XML, m as LAYOUT_CATEGORIES, n as createDataModel, o as TransPoint, p as COLOR_CATEGORIES, r as SmartArtCollection, s as DataModel, t as TreeNode, u as getColorXml } from "../index-CZxcE4Q6.mjs";
export { COLOR_CATEGORIES, Connection, DEFAULT_DRAWING_XML, DataModel, LAYOUT_CATEGORIES, Point, STYLE_CATEGORIES, SmartArtCollection, SmartArtData, TransPoint, TreeNode, createDataModel, getColorXml, getLayoutXml, getStyleXml };

@@ -1,2 +0,2 @@

import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-CIh0bdS1.mjs";
import { C as uCharHexNumber, S as twipsMeasureValue, T as unsignedDecimalNumber, _ as pointMeasureValue, a as ThemeColor, b as signedHpsMeasureValue, c as dateTimeValue, d as hexBinary, f as hexColorValue, g as percentageValue, h as measurementOrPercentValue, i as RelativeMeasure, l as decimalNumber, m as longHexNumber, n as PositivePercentage, o as ThemeFont, p as hpsMeasureValue, r as PositiveUniversalMeasure, s as UniversalMeasure, t as Percentage, u as eighthPointMeasureValue, v as positiveUniversalMeasureValue, w as universalMeasureValue, x as signedTwipsMeasureValue, y as shortHexNumber } from "./values-QyWq4U4A.mjs";
export { Percentage, PositivePercentage, PositiveUniversalMeasure, RelativeMeasure, ThemeColor, ThemeFont, UniversalMeasure, dateTimeValue, decimalNumber, eighthPointMeasureValue, hexBinary, hexColorValue, hpsMeasureValue, longHexNumber, measurementOrPercentValue, percentageValue, pointMeasureValue, positiveUniversalMeasureValue, shortHexNumber, signedHpsMeasureValue, signedTwipsMeasureValue, twipsMeasureValue, uCharHexNumber, universalMeasureValue, unsignedDecimalNumber };
{
"name": "@office-open/core",
"version": "0.6.4",
"version": "0.6.5",
"description": "Shared OOXML infrastructure: XmlComponent, value validators, unit converters",

@@ -52,6 +52,2 @@ "keywords": [

"import": "./dist/drawingml/index.mjs"
},
"./archive": {
"types": "./dist/archive.d.mts",
"import": "./dist/archive.mjs"
}

@@ -63,3 +59,3 @@ },

"nanoid": "5.1.11",
"@office-open/xml": "0.6.4"
"@office-open/xml": "0.6.5"
},

@@ -66,0 +62,0 @@ "scripts": {

import { Element } from "@office-open/xml";
//#region src/archive.d.ts
/**
* Unzip an OOXML file (.docx, .pptx) into a Map of path → Uint8Array.
*/
declare function unzipToMap(data: Uint8Array): Map<string, Uint8Array>;
/**
* Read a file from the zip as a UTF-8 string.
*/
declare function readTextFromZip(zip: Map<string, Uint8Array>, path: string): string | undefined;
/**
* Parse an XML file from the zip into an Element tree.
*/
declare function readXmlFromZip(zip: Map<string, Uint8Array>, path: string): Element | undefined;
/**
* Read a binary file from the zip.
*/
declare function readBinaryFromZip(zip: Map<string, Uint8Array>, path: string): Uint8Array | undefined;
/**
* Parse all XML files in the zip into Element trees.
* Skips media files, binary files, and the main document/presentation file.
*/
declare function readAllXmlParts(zip: Map<string, Uint8Array>, options?: {
skipPaths?: string[];
}): Record<string, Element>;
/**
* List all files in the zip matching a prefix.
*/
declare function listFiles(zip: Map<string, Uint8Array>, prefix: string): string[];
/**
* Convert Uint8Array to base64 string.
*/
declare function uint8ToBase64(data: Uint8Array): string;
/**
* Determine image type from file extension.
*/
declare function getImageType(fileName: string): string;
interface Relationship {
id: string;
target: string;
type: string;
targetMode?: string;
}
declare function parseRels(zip: Map<string, Uint8Array>, path: string): Relationship[];
declare function findRel(rels: Relationship[], id: string): Relationship | undefined;
declare function findRelsByType(rels: Relationship[], typeSubstring: string): Relationship[];
/**
* Zip a map of path → Uint8Array/string into a ZIP buffer.
* XML strings are auto-encoded to UTF-8 bytes.
*/
declare function zipToBuffer(files: Map<string, Uint8Array | string>): Uint8Array;
/**
* Serialize an Element tree to an XML string.
*/
declare function elementToXml(el: Element): string;
//#endregion
export { Relationship, elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer };
import { attr, js2xml, xml2js } from "@office-open/xml";
import { strFromU8, strToU8, unzipSync, zipSync } from "fflate";
//#region src/archive.ts
const XML_PARSE_OPTIONS = {
nativeTypeAttributes: true,
captureSpacesBetweenElements: true
};
/**
* Unzip an OOXML file (.docx, .pptx) into a Map of path → Uint8Array.
*/
function unzipToMap(data) {
const entries = unzipSync(data);
const map = /* @__PURE__ */ new Map();
for (const [path, bytes] of Object.entries(entries)) map.set(path, bytes);
return map;
}
/**
* Read a file from the zip as a UTF-8 string.
*/
function readTextFromZip(zip, path) {
const data = zip.get(path);
if (data === void 0) return void 0;
return strFromU8(data);
}
/**
* Parse an XML file from the zip into an Element tree.
*/
function readXmlFromZip(zip, path) {
const text = readTextFromZip(zip, path);
if (text === void 0) return void 0;
return xml2js(text, XML_PARSE_OPTIONS).elements?.find((e) => e.type === "element");
}
/**
* Read a binary file from the zip.
*/
function readBinaryFromZip(zip, path) {
return zip.get(path);
}
/**
* Parse all XML files in the zip into Element trees.
* Skips media files, binary files, and the main document/presentation file.
*/
function readAllXmlParts(zip, options) {
const parts = {};
const skip = new Set(options?.skipPaths ?? []);
for (const path of zip.keys()) {
if (skip.has(path)) continue;
if (path.startsWith("word/media/") || path.startsWith("ppt/media/") || path.startsWith("xl/media/") || path.endsWith(".png") || path.endsWith(".jpg") || path.endsWith(".jpeg") || path.endsWith(".gif") || path.endsWith(".bmp") || path.endsWith(".tif") || path.endsWith(".tiff") || path.endsWith(".emf") || path.endsWith(".wmf") || path.endsWith(".svg") || path.endsWith(".wav") || path.endsWith(".mp3") || path.endsWith(".mp4") || path.endsWith(".avi") || path.endsWith(".wmv") || path.endsWith(".thmx") || path.endsWith(".bin")) continue;
const el = readXmlFromZip(zip, path);
if (el) parts[path] = el;
}
return parts;
}
/**
* List all files in the zip matching a prefix.
*/
function listFiles(zip, prefix) {
const result = [];
for (const path of zip.keys()) if (path.startsWith(prefix)) result.push(path);
return result;
}
/**
* Convert Uint8Array to base64 string.
*/
function uint8ToBase64(data) {
const chunkSize = 8192;
let binary = "";
for (let i = 0; i < data.length; i += chunkSize) {
const chunk = data.subarray(i, Math.min(i + chunkSize, data.length));
binary += String.fromCharCode(...chunk);
}
return btoa(binary);
}
/**
* Determine image type from file extension.
*/
function getImageType(fileName) {
const ext = fileName.split(".").pop()?.toLowerCase() ?? "";
if ([
"png",
"jpg",
"jpeg",
"gif",
"bmp",
"tif",
"tiff",
"ico",
"emf",
"wmf",
"svg"
].includes(ext)) return ext === "jpeg" ? "jpg" : ext;
return "png";
}
function parseRels(zip, path) {
const xml = readXmlFromZip(zip, path);
if (!xml) return [];
const result = [];
for (const rel of xml.elements ?? []) {
if (rel.name !== "Relationship") continue;
const id = attr(rel, "Id");
const target = attr(rel, "Target");
const type = attr(rel, "Type");
const targetMode = attr(rel, "TargetMode");
if (id && target) result.push({
id,
target,
type: type ?? "",
...targetMode ? { targetMode } : {}
});
}
return result;
}
function findRel(rels, id) {
return rels.find((r) => r.id === id);
}
function findRelsByType(rels, typeSubstring) {
return rels.filter((r) => r.type.includes(typeSubstring));
}
/**
* Zip a map of path → Uint8Array/string into a ZIP buffer.
* XML strings are auto-encoded to UTF-8 bytes.
*/
function zipToBuffer(files) {
const entries = {};
for (const [path, data] of files) entries[path] = typeof data === "string" ? strToU8(data) : data;
return zipSync(entries);
}
/**
* Serialize an Element tree to an XML string.
*/
function elementToXml(el) {
return js2xml(el);
}
//#endregion
export { elementToXml, findRel, findRelsByType, getImageType, listFiles, parseRels, readAllXmlParts, readBinaryFromZip, readTextFromZip, readXmlFromZip, uint8ToBase64, unzipToMap, zipToBuffer };
import { C as XmlComponent } from "./index-mjYQ4KiG.mjs";
//#region src/smartart/categories.d.ts
/** Layout ID → OOXML category type */
declare const LAYOUT_CATEGORIES: Record<string, string>;
/** Style ID → OOXML category type */
declare const STYLE_CATEGORIES: Record<string, string>;
/** Color ID → OOXML category type */
declare const COLOR_CATEGORIES: Record<string, string>;
//#endregion
//#region src/smartart/built-in-definitions.d.ts
/**
* Returns layout XML. Full XML for "default", minimal stub for others.
* Stub has no layoutNode so PowerPoint falls back to built-in definitions
* based on the uniqueId / loTypeId in the data model.
*/
declare function getLayoutXml(layoutId: string): string;
/**
* Returns style stub XML with the given uniqueId.
*/
declare function getStyleXml(styleId: string): string;
/**
* Returns color stub XML with the given uniqueId.
*/
declare function getColorXml(colorId: string): string;
/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */
declare const DEFAULT_DRAWING_XML: string;
//#endregion
//#region src/smartart/data-model/connection.d.ts
/**
* dgm:cxn — SmartArt data model connection (edge).
*/
declare class Connection extends XmlComponent {
constructor(modelId: string, srcId: string, destId: string, type?: string, srcOrd?: number, destOrd?: number, parTransId?: string, sibTransId?: string);
}
//#endregion
//#region src/smartart/data-model/data-model.d.ts
/**
* CT_DataModel — the complete data model for a SmartArt diagram.
*/
declare class DataModel extends XmlComponent {
constructor(points: readonly XmlComponent[], connections: readonly Connection[]);
}
//#endregion
//#region src/smartart/data-model/point.d.ts
/**
* dgm:pt — SmartArt data model point (node).
*/
declare class Point extends XmlComponent {
constructor(modelId: string, text: string, type?: string);
}
/**
* Transition point (parTrans or sibTrans) — no text body, references a connection.
*/
declare class TransPoint extends XmlComponent {
constructor(modelId: string, type: string, cxnId: string);
}
//#endregion
//#region src/smartart/smartart-collection.d.ts
interface SmartArtData {
readonly key: string;
readonly dataModel: DataModel;
readonly layout: string;
readonly style: string;
readonly color: string;
}
/**
* Manages SmartArt parts in a document.
*/
declare class SmartArtCollection {
private readonly map;
constructor();
addSmartArt(key: string, data: SmartArtData): void;
get array(): readonly SmartArtData[];
}
//#endregion
//#region src/smartart/tree-to-model.d.ts
interface TreeNode {
readonly text: string;
readonly children?: readonly TreeNode[];
}
/**
* Creates a DataModel from tree nodes with layout/style/color settings.
*/
declare const createDataModel: (nodes: readonly TreeNode[], layout?: string, style?: string, color?: string) => DataModel;
//#endregion
export { Point as a, Connection as c, getLayoutXml as d, getStyleXml as f, STYLE_CATEGORIES as h, SmartArtData as i, DEFAULT_DRAWING_XML as l, LAYOUT_CATEGORIES as m, createDataModel as n, TransPoint as o, COLOR_CATEGORIES as p, SmartArtCollection as r, DataModel as s, TreeNode as t, getColorXml as u };
import { r as PositiveUniversalMeasure } from "./values-CIh0bdS1.mjs";
import { Element } from "@office-open/xml";
//#region src/xml-components/types.d.ts
/**
* XML-serializable object types for OOXML document generation.
*
* @module
*/
/**
* Attributes for an XML element.
*/
type IXmlAttribute = Readonly<Record<string, string | number | boolean>>;
/**
* Object that can be serialized to XML.
*/
type IXmlableObject = Readonly<Record<string, any>>;
//#endregion
//#region src/xml-components/base.d.ts
/**
* Context object passed through the XML tree during serialization.
*
* @typeParam TFileData - The type of the root file data object (format-specific)
*/
interface Context<TFileData = unknown> {
/** The root file data object being serialized (format-specific). */
readonly fileData?: TFileData;
/** Current traversal stack of components (mutable for performance). */
readonly stack: IXmlableObject[];
}
/**
* Abstract base class for all XML components.
*/
declare abstract class BaseXmlComponent {
/** The XML element name for this component (e.g., "w:p" for paragraph). */
protected readonly rootKey: string;
constructor(rootKey: string);
/**
* Prepares this component for XML serialization.
*
* @param context - The serialization context
* @returns The XML-serializable object, or undefined to exclude from output
*/
abstract prepForXml(context: Context): IXmlableObject | undefined;
}
//#endregion
//#region src/xml-components/component.d.ts
/**
* Empty object singleton used for empty XML elements.
*
* @internal
*/
declare const EMPTY_OBJECT: {};
/**
* Base class for all XML components in OOXML documents.
*/
declare abstract class XmlComponent extends BaseXmlComponent {
/**
* Array of child components, text nodes, and attributes.
*/
root: (BaseXmlComponent | IXmlableObject | string)[];
constructor(rootKey: string);
/**
* Prepares this component and its children for XML serialization.
*/
prepForXml(context: Context): IXmlableObject | undefined;
/**
* Direct XML serialization. Override in subclasses for zero-allocation output.
* Default falls back to prepForXml() + xml().
*/
toXml(context: Context): string;
/**
* @deprecated Internal use only.
*/
addChildElement(child: BaseXmlComponent | string): XmlComponent;
}
/**
* XML component that is excluded from output if it has no meaningful content.
*/
declare abstract class IgnoreIfEmptyXmlComponent extends XmlComponent {
private readonly includeIfEmpty;
constructor(rootKey: string, includeIfEmpty?: boolean);
prepForXml(context: Context): IXmlableObject | undefined;
}
//#endregion
//#region src/xml-components/attributes.d.ts
/**
* Maps TypeScript property names to their XML attribute names.
*/
type AttributeMap<T> = Record<keyof T, string>;
/**
* Simple attribute data as a key-value record.
*/
type AttributeData = Record<string, boolean | number | string>;
/**
* Structured attribute payload with explicit key-value mapping.
*/
type AttributePayload<T> = { readonly [P in keyof T]: {
readonly key: string;
readonly value: T[P];
} };
/**
* Base class for creating XML attributes with automatic name mapping.
*/
declare abstract class XmlAttributeComponent<T extends Record<string, any>> extends BaseXmlComponent {
private readonly root;
/** Optional mapping from property names to XML attribute names. */
protected readonly xmlKeys?: AttributeMap<T>;
constructor(root: T);
prepForXml(_: Context): IXmlableObject;
}
/**
* Next-generation attribute component with explicit key-value pairs.
*/
declare class NextAttributeComponent<T> extends BaseXmlComponent {
private readonly root;
constructor(root: AttributePayload<T>);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/elements.d.ts
/**
* Build an XML element with arbitrary attributes, filtering out undefined values.
*/
declare function attrObj(name: string, attrs: Record<string, string | number | boolean | undefined>): IXmlableObject;
/**
* Build a CT_OnOff XML object without allocating any XmlComponent.
* `val=true` returns a frozen singleton (cached per name).
*/
declare function onOffObj(name: string, val?: boolean | undefined): IXmlableObject;
/**
* Build a CT_HpsMeasure XML object (half-point size) without allocation.
*/
declare function hpsMeasureObj(name: string, val: number | PositiveUniversalMeasure): IXmlableObject;
/**
* Build a CT_String XML object (string value attribute) without allocation.
*/
declare function stringValObj(name: string, val: string): IXmlableObject;
/**
* Build a numeric value attribute XML object without allocation.
*/
declare function numberValObj(name: string, val: number): IXmlableObject;
/**
* Build a string enum value attribute XML object without allocation.
*/
declare function stringEnumValObj<T extends string>(name: string, val: T): IXmlableObject;
/**
* Build an element wrapping a text string without allocation.
*/
declare function stringContainerObj(name: string, val: string): IXmlableObject;
/**
* XML element representing an empty element (CT_Empty).
*/
declare class EmptyElement extends XmlComponent {}
/**
* Flexible XML element builder with explicit attribute and child configuration.
*/
declare class BuilderElement<T = {}> extends XmlComponent {
constructor({
name,
attributes,
children
}: {
readonly name: string;
readonly attributes?: AttributePayload<T>;
readonly children?: readonly (BaseXmlComponent | IXmlableObject | string)[];
});
}
/**
* Creates a NextAttributeComponent with explicit XML attribute keys.
*/
declare const chartAttr: (attrs: Record<string, string | number | boolean>) => BaseXmlComponent;
/**
* Wraps a component in a named XmlComponent element.
*/
declare function wrapEl(elementName: string, child: BaseXmlComponent): XmlComponent;
//#endregion
//#region src/xml-components/imported.d.ts
/**
* Converts an xml-js Element into an XmlComponent tree.
*/
declare const convertToXmlComponent: (element: Element) => ImportedXmlComponent | string | undefined;
/**
* XML component representing imported XML content.
*/
declare class ImportedXmlComponent extends XmlComponent {
protected _sourceXml?: string;
static fromXmlString(importedContent: string): ImportedXmlComponent;
get sourceXml(): string | undefined;
toXml(_context: Context): string;
constructor(rootKey: string, _attr?: any);
push(xmlComponent: XmlComponent | string): void;
}
/**
* Represents attributes for imported root elements.
*/
declare class ImportedRootElementAttributes extends XmlComponent {
private readonly _attr;
constructor(_attr: any);
prepForXml(_: Context): IXmlableObject;
}
//#endregion
//#region src/xml-components/initializable.d.ts
/**
* XML component that can be initialized from another component.
*/
declare abstract class InitializableXmlComponent extends XmlComponent {
constructor(rootKey: string, initComponent?: XmlComponent);
}
//#endregion
export { XmlComponent as C, IXmlableObject as D, IXmlAttribute as E, IgnoreIfEmptyXmlComponent as S, Context as T, AttributeMap as _, BuilderElement as a, XmlAttributeComponent as b, chartAttr as c, onOffObj as d, stringContainerObj as f, AttributeData as g, wrapEl as h, convertToXmlComponent as i, hpsMeasureObj as l, stringValObj as m, ImportedRootElementAttributes as n, EmptyElement as o, stringEnumValObj as p, ImportedXmlComponent as r, attrObj as s, InitializableXmlComponent as t, numberValObj as u, AttributePayload as v, BaseXmlComponent as w, EMPTY_OBJECT as x, NextAttributeComponent as y };
//#region src/values.d.ts
/**
* Runtime validation and type conversion functions for OOXML specification values.
*
* This module provides runtime checks and cleanup for value types in the OOXML spec
* that aren't easily expressed through the TypeScript type system alone. These
* validators help prevent silent failures and corrupted documents by enforcing
* spec-compliant values at runtime.
*
* @module
*/
/**
* A measurement value with optional sign and unit suffix.
*
* Supports units: mm (millimeters), cm (centimeters), in (inches),
* pt (points), pc (picas), pi (picas).
*
* Pattern: `-?[0-9]+(\.[0-9]+)?(mm|cm|in|pt|pc|pi)`
*
* @example
* ```typescript
* const measure: UniversalMeasure = "10.5mm";
* const negative: UniversalMeasure = "-5pt";
* ```
*/
type UniversalMeasure = `${"-" | ""}${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A positive measurement value with unit suffix.
*
* Same as UniversalMeasure but restricted to positive values only.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @example
* ```typescript
* const measure: PositiveUniversalMeasure = "10.5mm";
* ```
*/
type PositiveUniversalMeasure = `${number}${"mm" | "cm" | "in" | "pt" | "pc" | "pi"}`;
/**
* A percentage value with optional sign.
*
* Pattern: `-?[0-9]+(\.[0-9]+)?%`
*
* Reference: ST_Percentage in OOXML specification
*
* @example
* ```typescript
* const percent: Percentage = "50%";
* const negative: Percentage = "-10.5%";
* ```
*/
type Percentage = `${"-" | ""}${number}%`;
/**
* A positive percentage value.
*
* Same as Percentage but restricted to positive values only.
*
* Reference: ST_PositivePercentage in OOXML specification
*
* @example
* ```typescript
* const percent: PositivePercentage = "50%";
* ```
*/
type PositivePercentage = `${number}%`;
/**
* A relative measurement value using em or ex units.
*
* Used in VML text boxes for font-relative measurements.
*
* @example
* ```typescript
* const measure: RelativeMeasure = "2em";
* const negative: RelativeMeasure = "-0.5ex";
* ```
*/
type RelativeMeasure = `${"-" | ""}${number}${"em" | "ex"}`;
/**
* Validates and converts a number to an integer (decimal number).
*
* Reference: ST_DecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored integer value
* @throws Error if the value is NaN
*
* @example
* ```typescript
* const num = decimalNumber(10.7); // Returns 10
* const negative = decimalNumber(-5.3); // Returns -5
* ```
*/
declare const decimalNumber: (val: number) => number;
/**
* Validates and converts a number to a positive integer (unsigned decimal number).
*
* Reference: ST_UnsignedDecimalNumber in OOXML specification
*
* @param val - The number to validate and convert
* @returns The floored positive integer value
* @throws Error if the value is NaN or negative
*
* @example
* ```typescript
* const num = unsignedDecimalNumber(10.7); // Returns 10
* const invalid = unsignedDecimalNumber(-5); // Throws Error
* ```
*/
declare const unsignedDecimalNumber: (val: number) => number;
/**
* Validates and normalizes a hexadecimal binary value.
*
* The xsd:hexBinary type represents binary data as a sequence of binary octets
* using hexadecimal encoding, where each binary octet is a two-character
* hexadecimal number. Both lowercase and uppercase letters A-F are permitted.
*
* @param val - The hexadecimal string to validate
* @param length - The expected length in bytes (not characters)
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid hex string of the expected length
*
* @example
* ```typescript
* hexBinary("0FB8", 2); // Valid: 2 bytes = 4 characters
* hexBinary("ABC", 2); // Invalid: wrong length
* ```
*/
declare const hexBinary: (val: string, length: number) => string;
/**
* Validates a long hexadecimal number (4 bytes / 8 characters).
*
* Reference: ST_LongHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 8-character hex string
*
* @example
* ```typescript
* const hex = longHexNumber("ABCD1234"); // Valid
* ```
*/
declare const longHexNumber: (val: string) => string;
/**
* Validates a short hexadecimal number (2 bytes / 4 characters).
*
* Reference: ST_ShortHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 4-character hex string
*
* @example
* ```typescript
* const hex = shortHexNumber("AB12"); // Valid
* ```
*/
declare const shortHexNumber: (val: string) => string;
/**
* Validates a single-byte hexadecimal number (1 byte / 2 characters).
*
* Reference: ST_UcharHexNumber in OOXML specification
*
* @param val - The hexadecimal string to validate
* @returns The validated hexadecimal string
* @throws Error if the value is not a valid 2-character hex string
*
* @example
* ```typescript
* const hex = uCharHexNumber("FF"); // Valid
* ```
*/
declare const uCharHexNumber: (val: string) => string;
/**
* Normalizes a universal measure value by parsing and reformatting.
*
* Ensures the numeric portion is properly formatted while preserving the unit.
*
* Reference: ST_UniversalMeasure in OOXML specification
*
* @param val - The universal measure string to normalize
* @returns The normalized universal measure
*
* @example
* ```typescript
* const measure = universalMeasureValue("10.500mm"); // Returns "10.5mm"
* ```
*/
declare const universalMeasureValue: (val: UniversalMeasure) => UniversalMeasure;
/**
* Validates and normalizes a positive universal measure value.
*
* Reference: ST_PositiveUniversalMeasure in OOXML specification
*
* @param val - The positive universal measure string to validate
* @returns The normalized positive universal measure
* @throws Error if the value is negative
*
* @example
* ```typescript
* const measure = positiveUniversalMeasureValue("10.5mm"); // Valid
* const invalid = positiveUniversalMeasureValue("-5mm"); // Throws Error
* ```
*/
declare const positiveUniversalMeasureValue: (val: PositiveUniversalMeasure) => PositiveUniversalMeasure;
/**
* Validates and normalizes a hexadecimal color value.
*
* Accepts either "auto" or a 6-character RGB hex value (with or without # prefix).
* The # prefix is commonly used but technically invalid in OOXML, so it is stripped
* for strict compliance.
*
* Reference: ST_HexColor in OOXML specification
*
* @param val - The color value to validate ("auto" or hex color)
* @returns The normalized color value
* @throws Error if the hex color is invalid
*
* @example
* ```typescript
* const color1 = hexColorValue("auto"); // Returns "auto"
* const color2 = hexColorValue("FF0000"); // Returns "FF0000"
* const color3 = hexColorValue("#00FF00"); // Returns "00FF00" (# stripped)
* ```
*/
declare const hexColorValue: (val: string) => string;
/**
* Validates a signed TWIP measurement value.
*
* Accepts either a universal measure string or a numeric TWIP value.
*
* Reference: ST_SignedTwipsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = signedTwipsMeasureValue("10mm");
* const measure2 = signedTwipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const signedTwipsMeasureValue: (val: UniversalMeasure | number) => UniversalMeasure | number;
/**
* Validates a half-point (HPS) measurement value.
*
* Accepts either a positive universal measure string or a positive number.
* HPS (half-points) are commonly used for font sizes.
*
* Reference: ST_HpsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const fontSize1 = hpsMeasureValue("12pt");
* const fontSize2 = hpsMeasureValue(24); // 12pt in half-points
* ```
*/
declare const hpsMeasureValue: (val: PositiveUniversalMeasure | number) => string | number;
/**
* Validates a signed half-point (HPS) measurement value.
*
* Accepts either a universal measure string or a numeric value.
*
* Reference: ST_SignedHpsMeasure in OOXML specification
*
* @param val - The measurement value (universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const spacing1 = signedHpsMeasureValue("6pt");
* const spacing2 = signedHpsMeasureValue(-12); // Negative spacing
* ```
*/
declare const signedHpsMeasureValue: (val: UniversalMeasure | number) => string | number;
/**
* Validates a positive TWIP measurement value.
*
* Accepts either a positive universal measure string or a positive number.
*
* Reference: ST_TwipsMeasure in OOXML specification
*
* @param val - The measurement value (positive universal measure or number)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const width1 = twipsMeasureValue("25.4mm");
* const width2 = twipsMeasureValue(1440); // 1 inch in TWIP
* ```
*/
declare const twipsMeasureValue: (val: PositiveUniversalMeasure | number) => PositiveUniversalMeasure | number;
/**
* Normalizes a percentage value by parsing and reformatting.
*
* Reference: ST_Percentage in OOXML specification
*
* @param val - The percentage string to normalize
* @returns The normalized percentage
*
* @example
* ```typescript
* const percent = percentageValue("50.000%"); // Returns "50%"
* ```
*/
declare const percentageValue: (val: Percentage) => Percentage;
/**
* Validates a measurement value that can be expressed as a number, percentage, or universal measure.
*
* Reference: ST_MeasurementOrPercent in OOXML specification
*
* @param val - The measurement value (number, percentage, or universal measure)
* @returns The normalized measurement value
*
* @example
* ```typescript
* const measure1 = measurementOrPercentValue(100); // Unqualified number
* const measure2 = measurementOrPercentValue("50%"); // Percentage
* const measure3 = measurementOrPercentValue("10mm"); // Universal measure
* ```
*/
declare const measurementOrPercentValue: (val: number | Percentage | UniversalMeasure) => number | UniversalMeasure | Percentage;
/**
* Validates an eighth-point measurement value.
*
* Eighth-points are used for fine-grained measurements in text formatting.
*
* Reference: ST_EighthPointMeasure in OOXML specification
*
* @param val - The measurement value in eighth-points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const measure = eighthPointMeasureValue(16); // 2 points
* ```
*/
declare const eighthPointMeasureValue: (val: number) => number;
/**
* Validates a point measurement value.
*
* Reference: ST_PointMeasure in OOXML specification
*
* @param val - The measurement value in points
* @returns The validated positive integer value
*
* @example
* ```typescript
* const fontSize = pointMeasureValue(12); // 12pt
* ```
*/
declare const pointMeasureValue: (val: number) => number;
/**
* Converts a JavaScript Date object to an ISO 8601 date-time string.
*
* The format is CCYY-MM-DDThh:mm:ss.sssZ where T is a literal and Z indicates UTC.
* This matches the xsd:dateTime format required by OOXML.
*
* Reference: ST_DateTime in OOXML specification
*
* @param val - The Date object to convert
* @returns An ISO 8601 formatted date-time string
*
* @example
* ```typescript
* const now = new Date();
* const timestamp = dateTimeValue(now); // Returns "2024-01-15T10:30:00.000Z"
* ```
*/
declare const dateTimeValue: (val: Date) => string;
/**
* Theme color values used throughout OOXML for referencing document theme colors.
*
* Reference: ST_ThemeColor in OOXML specification
*
* @publicApi
*/
declare const ThemeColor: {
readonly DARK1: "dark1";
readonly LIGHT1: "light1";
readonly DARK2: "dark2";
readonly LIGHT2: "light2";
readonly ACCENT1: "accent1";
readonly ACCENT2: "accent2";
readonly ACCENT3: "accent3";
readonly ACCENT4: "accent4";
readonly ACCENT5: "accent5";
readonly ACCENT6: "accent6";
readonly HYPERLINK: "hyperlink";
readonly FOLLOWED_HYPERLINK: "followedHyperlink";
readonly NONE: "none";
readonly BACKGROUND1: "background1";
readonly TEXT1: "text1";
readonly BACKGROUND2: "background2";
readonly TEXT2: "text2";
};
/**
* Theme font values used for referencing document theme fonts.
*
* Reference: ST_Theme in OOXML specification
*
* @publicApi
*/
declare const ThemeFont: {
readonly MAJOR_EAST_ASIA: "majorEastAsia";
readonly MAJOR_BIDI: "majorBidi";
readonly MAJOR_ASCII: "majorAscii";
readonly MAJOR_H_ANSI: "majorHAnsi";
readonly MINOR_EAST_ASIA: "minorEastAsia";
readonly MINOR_BIDI: "minorBidi";
readonly MINOR_ASCII: "minorAscii";
readonly MINOR_H_ANSI: "minorHAnsi";
};
//#endregion
export { uCharHexNumber as C, twipsMeasureValue as S, unsignedDecimalNumber as T, pointMeasureValue as _, ThemeColor as a, signedHpsMeasureValue as b, dateTimeValue as c, hexBinary as d, hexColorValue as f, percentageValue as g, measurementOrPercentValue as h, RelativeMeasure as i, decimalNumber as l, longHexNumber as m, PositivePercentage as n, ThemeFont as o, hpsMeasureValue as p, PositiveUniversalMeasure as r, UniversalMeasure as s, Percentage as t, eighthPointMeasureValue as u, positiveUniversalMeasureValue as v, universalMeasureValue as w, signedTwipsMeasureValue as x, shortHexNumber as y };
import hash from "hash.js";
import { customAlphabet, nanoid } from "nanoid/non-secure";
//#region src/converters.ts
/**
* OOXML unit conversion utilities.
*
* @module
*/
/**
* Converts millimeters to TWIP (twentieths of a point).
*/
const convertMillimetersToTwip = (millimeters) => Math.floor(millimeters / 25.4 * 72 * 20);
/**
* Converts inches to TWIP (twentieths of a point).
*/
const convertInchesToTwip = (inches) => Math.floor(inches * 72 * 20);
/**
* Converts pixels to EMU (96 DPI).
*/
const convertPixelsToEmu = (pixels) => Math.round(pixels * 9525);
/**
* Converts EMU to pixels (96 DPI).
*/
const convertEmuToPixels = (emus) => Math.round(emus / 9525);
/**
* Converts inches to EMU.
*/
const convertInchesToEmu = (inches) => Math.round(inches * 914400);
/**
* Converts EMU to inches.
*/
const convertEmuToInches = (emus) => emus / 914400;
/**
* Converts points to EMU.
*/
const convertPointsToEmu = (points) => Math.round(points * 12700);
/**
* Converts EMU to points.
*/
const convertEmuToPoints = (emus) => emus / 12700;
//#endregion
//#region src/id-generators.ts
/**
* Unique ID generation utilities.
*
* @module
*/
/**
* Creates a unique numeric ID generator with sequential numbering.
*/
const uniqueNumericIdCreator = (initial = 0) => {
let currentCount = initial;
return () => ++currentCount;
};
/**
* Generates a unique lowercase alphanumeric ID using nanoid.
*/
const uniqueId = () => nanoid().toLowerCase();
/**
* Generates a SHA-1 hash of the provided data.
*/
const hashedId = (data) => hash.sha1().update(data instanceof ArrayBuffer ? new Uint8Array(data) : data).digest("hex");
/**
* Generates a random hexadecimal string of specified length.
*/
const generateUuidPart = (count) => customAlphabet("1234567890abcdef", count)();
/**
* Generates a UUID v4-style unique identifier.
*/
const uniqueUuid = () => `${generateUuidPart(8)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(4)}-${generateUuidPart(12)}`;
//#endregion
//#region src/xsd-mappings.ts
/**
* Bidirectional mappings between user-friendly values and XSD abbreviated values.
*
* When XSD uses full English words (e.g. "center", "start"), values are used directly — no mapping needed.
* When XSD uses abbreviations (e.g. "ctr", "l", "rnd"), this module maps them to full words.
*
* Usage in generation (Options → XML): xsdAlign.to("center") → "ctr"
* Usage in parsing (XML → Options): xsdAlign.from("ctr") → "center"
*/
/** Invert a Record<K, V> into Record<V, K>. */
function invertMap(map) {
const result = {};
for (const key in map) result[map[key]] = key;
return result;
}
/** Create a bidirectional mapping helper from a single forward map. */
function bidi(forward) {
const reverse = invertMap(forward);
return {
/** User-friendly value → XSD value */
to: (key) => forward[key] ?? key,
/** XSD value → user-friendly value */
from: (xsd) => reverse[xsd] ?? xsd,
/** The forward map (user → XSD) */
forward,
/** The reverse map (XSD → user) */
reverse
};
}
const xsdRectAlignment = bidi({
topLeft: "tl",
top: "t",
topRight: "tr",
left: "l",
center: "ctr",
right: "r",
bottomLeft: "bl",
bottom: "b",
bottomRight: "br"
});
const xsdTextAlign = bidi({
left: "l",
center: "ctr",
right: "r",
justify: "just"
});
const xsdTextAnchor = bidi({
top: "t",
center: "ctr",
bottom: "b"
});
const xsdLineCap = bidi({
round: "rnd",
square: "sq",
flat: "flat"
});
const xsdCompoundLine = bidi({
single: "sng",
double: "dbl",
thickThin: "thickThin",
thinThick: "thinThick",
triple: "tri"
});
const xsdPenAlignment = bidi({
center: "ctr",
inside: "in"
});
const xsdLineEndSize = bidi({
small: "sm",
medium: "med",
large: "lg"
});
const xsdBlendMode = bidi({
over: "over",
multiply: "mult",
screen: "screen",
darken: "darken",
lighten: "lighten"
});
const xsdPathFillMode = bidi({
none: "none",
normal: "norm",
lighten: "lighten",
lightenLess: "lightenLess",
darken: "darken",
darkenLess: "darkenLess"
});
const xsdEffectContainer = bidi({
sibling: "sib",
tree: "tree"
});
const xsdPresetShadow = bidi({
shadow1: "shdw1",
shadow2: "shdw2",
shadow3: "shdw3",
shadow4: "shdw4",
shadow5: "shdw5",
shadow6: "shdw6",
shadow7: "shdw7",
shadow8: "shdw8",
shadow9: "shdw9",
shadow10: "shdw10",
shadow11: "shdw11",
shadow12: "shdw12",
shadow13: "shdw13",
shadow14: "shdw14",
shadow15: "shdw15",
shadow16: "shdw16",
shadow17: "shdw17",
shadow18: "shdw18",
shadow19: "shdw19",
shadow20: "shdw20"
});
const xsdMaterialType = bidi({
legacyMatte: "legacyMatte",
legacyPlastic: "legacyPlastic",
legacyMetal: "legacyMetal",
legacyWireframe: "legacyWireframe",
matte: "matte",
plastic: "plastic",
metal: "metal",
warmMatte: "warmMatte",
translucentPowder: "translucentPowder",
powder: "powder",
darkEdge: "dkEdge",
softEdge: "softEdge",
clear: "clear",
flat: "flat",
softMetal: "softmetal"
});
const xsdPattern = bidi({
percent5: "pct5",
percent10: "pct10",
percent20: "pct20",
percent25: "pct25",
percent30: "pct30",
percent40: "pct40",
percent50: "pct50",
percent60: "pct60",
percent70: "pct70",
percent75: "pct75",
percent80: "pct80",
percent90: "pct90",
horizontal: "horz",
vertical: "vert",
lightHorizontal: "ltHorz",
lightVertical: "ltVert",
darkHorizontal: "dkHorz",
darkVertical: "dkVert",
narrowHorizontal: "narHorz",
narrowVertical: "narVert",
dashedHorizontal: "dashHorz",
dashedVertical: "dashVert",
cross: "cross",
downDiagonal: "dnDiag",
upDiagonal: "upDiag",
lightDownDiagonal: "ltDnDiag",
lightUpDiagonal: "ltUpDiag",
darkDownDiagonal: "dkDnDiag",
darkUpDiagonal: "dkUpDiag",
wideDownDiagonal: "wdDnDiag",
wideUpDiagonal: "wdUpDiag",
dashedDownDiagonal: "dashDnDiag",
dashedUpDiagonal: "dashUpDiag",
diagonalCross: "diagCross",
smallChecker: "smCheck",
largeChecker: "lgCheck",
smallGrid: "smGrid",
largeGrid: "lgGrid",
dotGrid: "dotGrid",
smallConfetti: "smConfetti",
largeConfetti: "lgConfetti",
horizontalBrick: "horzBrick",
diagonalBrick: "diagBrick",
solidDiamond: "solidDmnd",
openDiamond: "openDmnd",
dottedDiamond: "dotDmnd",
plaid: "plaid",
sphere: "sphere",
weave: "weave",
divot: "divot",
shingle: "shingle",
wave: "wave",
trellis: "trellis",
zigZag: "zigZag"
});
const xsdVerticalMergeRev = bidi({
continue: "cont",
restart: "rest"
});
const xsdUnderlineStyle = bidi({
single: "sng",
double: "dbl",
none: "none"
});
const xsdStrikeStyle = bidi({
singleStrike: "sngStrike",
doubleStrike: "dblStrike",
noStrike: "noStrike"
});
const xsdTextCaps = bidi({
none: "none",
all: "all",
small: "small"
});
//#endregion
export { convertPointsToEmu as A, convertEmuToInches as C, convertInchesToTwip as D, convertInchesToEmu as E, convertMillimetersToTwip as O, uniqueUuid as S, convertEmuToPoints as T, xsdUnderlineStyle as _, xsdLineCap as a, uniqueId as b, xsdPathFillMode as c, xsdPresetShadow as d, xsdRectAlignment as f, xsdTextCaps as g, xsdTextAnchor as h, xsdEffectContainer as i, convertPixelsToEmu as k, xsdPattern as l, xsdTextAlign as m, xsdBlendMode as n, xsdLineEndSize as o, xsdStrikeStyle as p, xsdCompoundLine as r, xsdMaterialType as s, invertMap as t, xsdPenAlignment as u, xsdVerticalMergeRev as v, convertEmuToPixels as w, uniqueNumericIdCreator as x, hashedId as y };

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display