@office-open/core 0.12.1 → 0.12.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -2
- package/dist/chart/index.d.mts +1 -1
- package/dist/chart/index.mjs +1 -1
- package/dist/{chart-BAnjzVoe.mjs → chart-DEIF3VZn.mjs} +42 -49
- package/dist/chart-DEIF3VZn.mjs.map +1 -0
- package/dist/{index-k1h_t946.d.mts → index-BwRtWyaP.d.mts} +2 -1
- package/dist/index-BwRtWyaP.d.mts.map +1 -0
- package/dist/{index-Di6XPdGl.d.mts → index-DRggxtp7.d.mts} +2 -1
- package/dist/{index-Di6XPdGl.d.mts.map → index-DRggxtp7.d.mts.map} +1 -1
- package/dist/{index-BAxlDUQ1.d.mts → index-DfFszyH1.d.mts} +4 -1
- package/dist/index-DfFszyH1.d.mts.map +1 -0
- package/dist/index-L6AXewfV.d.mts.map +1 -1
- package/dist/index.d.mts +5 -3
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +33 -17
- package/dist/index.mjs.map +1 -1
- package/dist/smartart/index.d.mts +1 -1
- package/dist/smartart/index.mjs +1 -1
- package/dist/{smartart-DV6ZcN5R.mjs → smartart-YH87Emca.mjs} +12 -8
- package/dist/smartart-YH87Emca.mjs.map +1 -0
- package/dist/util/index.d.mts +1 -1
- package/dist/util/index.mjs +1 -1
- package/dist/{util-ptE16MEk.mjs → util-iHHKF2Rx.mjs} +76 -8
- package/dist/util-iHHKF2Rx.mjs.map +1 -0
- package/dist/vector/index.mjs +1 -1
- package/dist/{vector-DhLGZjP5.mjs → vector-DZ_OteHJ.mjs} +93 -78
- package/dist/vector-DZ_OteHJ.mjs.map +1 -0
- package/package.json +4 -3
- package/dist/chart-BAnjzVoe.mjs.map +0 -1
- package/dist/index-BAxlDUQ1.d.mts.map +0 -1
- package/dist/index-k1h_t946.d.mts.map +0 -1
- package/dist/smartart-DV6ZcN5R.mjs.map +0 -1
- package/dist/util-ptE16MEk.mjs.map +0 -1
- package/dist/vector-DhLGZjP5.mjs.map +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smartart-DV6ZcN5R.mjs","names":["stringifyInnerXml","stringifyLocalized","parseLocalized","stringifyInnerXml","stringifyInnerXml"],"sources":["../src/smartart/categories.ts","../src/smartart/data-model/connection.ts","../src/smartart/data-model/point.ts","../src/smartart/data-model/data-model.ts","../src/smartart/layout-definition.ts","../src/smartart/color-definition.ts","../src/smartart/style-definition.ts","../src/smartart/built-in-definitions.ts","../src/smartart/smartart-collection.ts","../src/smartart/tree-to-model.ts"],"sourcesContent":["/** Layout ID → OOXML category type */\nexport const LAYOUT_CATEGORIES: Record<string, string> = {\n default: \"list\",\n list1: \"list\",\n list2: \"list\",\n vList2: \"list\",\n hList1: \"list\",\n pList1: \"list\",\n process1: \"process\",\n process2: \"process\",\n process3: \"process\",\n process4: \"process\",\n chevron1: \"process\",\n chevron2: \"process\",\n arrow1: \"process\",\n arrow2: \"process\",\n cycle1: \"cycle\",\n cycle2: \"cycle\",\n cycle3: \"cycle\",\n cycle4: \"cycle\",\n cycle5: \"cycle\",\n hierarchy1: \"hier\",\n hierarchy2: \"hier\",\n hierarchy3: \"hier\",\n hierarchy4: \"hier\",\n orgChart1: \"hier\",\n pyramid1: \"pyramid\",\n pyramid2: \"pyramid\",\n pyramid3: \"pyramid\",\n matrix1: \"matrix\",\n matrix2: \"matrix\",\n matrix3: \"matrix\",\n radial1: \"rel\",\n radial2: \"rel\",\n radial3: \"rel\",\n venn1: \"rel\",\n funnel1: \"rel\",\n balance1: \"rel\",\n gear1: \"rel\",\n constOrg1: \"rel\",\n oppId1: \"rel\",\n};\n\n/** Style ID → OOXML category type */\nexport const STYLE_CATEGORIES: Record<string, string> = {\n simple1: \"simple\",\n simple2: \"simple\",\n simple3: \"simple\",\n simple4: \"simple\",\n simple5: \"simple\",\n moderate1: \"moderate\",\n moderate2: \"moderate\",\n moderate3: \"moderate\",\n moderate4: \"moderate\",\n polished1: \"polished\",\n polished2: \"polished\",\n polished3: \"polished\",\n polished4: \"polished\",\n professional1: \"professional\",\n professional2: \"professional\",\n professional3: \"professional\",\n professional4: \"professional\",\n cartoon1: \"cartoon\",\n cartoon2: \"cartoon\",\n cartoon3: \"cartoon\",\n cartoon4: \"cartoon\",\n powdery1: \"powdery\",\n powdery2: \"powdery\",\n powdery3: \"powdery\",\n powdery4: \"powdery\",\n burnt1: \"burnt\",\n burnt2: \"burnt\",\n burnt3: \"burnt\",\n burnt4: \"burnt\",\n};\n\n/** Color ID → OOXML category type */\nexport const COLOR_CATEGORIES: Record<string, string> = {\n accent1_2: \"accent1\",\n accent2_2: \"accent2\",\n accent3_2: \"accent3\",\n accent4_2: \"accent4\",\n accent5_2: \"accent5\",\n accent6_2: \"accent6\",\n colorful1: \"colorful\",\n colorful2: \"colorful\",\n colorful3: \"colorful\",\n colorful4: \"colorful\",\n dark1: \"dark\",\n dark2: \"dark\",\n primary1: \"primary\",\n primary2: \"primary\",\n gray1: \"gray\",\n gray2: \"gray\",\n};\n","import { escapeXml } from \"@office-open/xml\";\n\n/**\n * dgm:cxn — SmartArt data model connection (edge) XML stringifier.\n */\nexport function stringifyConnection(opts: {\n modelId: string | number;\n srcId: string | number;\n destId: string | number;\n type?: string;\n srcOrd?: number;\n destOrd?: number;\n parTransId?: string;\n sibTransId?: string;\n presId?: string;\n}): string {\n const attrs: string[] = [\n `modelId=\"${escapeXml(String(opts.modelId))}\"`,\n `srcId=\"${escapeXml(String(opts.srcId))}\"`,\n `destId=\"${escapeXml(String(opts.destId))}\"`,\n `srcOrd=\"${opts.srcOrd ?? 0}\"`,\n `destOrd=\"${opts.destOrd ?? 0}\"`,\n ];\n if (opts.type) attrs.push(`type=\"${escapeXml(opts.type)}\"`);\n if (opts.parTransId) attrs.push(`parTransId=\"${escapeXml(opts.parTransId)}\"`);\n if (opts.sibTransId) attrs.push(`sibTransId=\"${escapeXml(opts.sibTransId)}\"`);\n if (opts.presId) attrs.push(`presId=\"${escapeXml(opts.presId)}\"`);\n return `<dgm:cxn ${attrs.join(\" \")}/>`;\n}\n","import { escapeXml } from \"@office-open/xml\";\n\nexport interface PointPropertySetOptions {\n presentationAssociationId?: string;\n presentationName?: string;\n presentationStyleLabel?: string;\n presentationStyleIndex?: number;\n presentationStyleCount?: number;\n placeholderText?: string;\n placeholder?: boolean;\n customAngle?: number;\n customFlipVertical?: boolean;\n customFlipHorizontal?: boolean;\n customSizeX?: number;\n customSizeY?: number;\n customScaleX?: number;\n customScaleY?: number;\n customText?: boolean;\n customLinearFactorX?: number;\n customLinearFactorY?: number;\n customLinearFactorNeighborX?: number;\n customLinearFactorNeighborY?: number;\n customRadialScaleRadius?: number;\n customRadialScaleIncrement?: number;\n coherent3DOffset?: boolean;\n hideGeometry?: boolean;\n hideLastTransition?: boolean;\n lockTextEntry?: boolean;\n moveWith?: string;\n useDefault?: boolean;\n zOrderOffset?: number;\n layoutTypeId?: string;\n layoutCategoryId?: string;\n quickStyleTypeId?: string;\n quickStyleCategoryId?: string;\n colorStyleTypeId?: string;\n colorStyleCategoryId?: string;\n}\n\n/**\n * dgm:pt — SmartArt data model point (node) XML stringifier.\n */\nexport function stringifyPoint(\n modelId: string | number,\n text: string,\n type: string = \"node\",\n propertySet?: PointPropertySetOptions,\n connectionId?: string,\n): string {\n const cxnAttr = connectionId ? ` cxnId=\"${escapeXml(connectionId)}\"` : \"\";\n const parts: string[] = [];\n parts.push(\n `<dgm:pt modelId=\"${escapeXml(String(modelId))}\"${cxnAttr} type=\"${escapeXml(type)}\">`,\n );\n if (propertySet) {\n parts.push(stringifyPropertySet(propertySet));\n }\n parts.push(stringifyPointText(text));\n parts.push(\"</dgm:pt>\");\n return parts.join(\"\");\n}\n\n/**\n * dgm:pt — transition point (parTrans or sibTrans) XML stringifier.\n */\nexport function stringifyTransPoint(modelId: string, type: string, cxnId: string): string {\n return `<dgm:pt modelId=\"${escapeXml(modelId)}\" type=\"${escapeXml(type)}\" cxnId=\"${escapeXml(cxnId)}\"><dgm:spPr/></dgm:pt>`;\n}\n\nfunction stringifyPropertySet(opts: PointPropertySetOptions): string {\n const attr: string[] = [];\n if (opts.presentationAssociationId !== undefined)\n attr.push(`presAssocID=\"${escapeXml(opts.presentationAssociationId)}\"`);\n if (opts.presentationName !== undefined)\n attr.push(`presName=\"${escapeXml(opts.presentationName)}\"`);\n if (opts.presentationStyleLabel !== undefined)\n attr.push(`presStyleLbl=\"${escapeXml(opts.presentationStyleLabel)}\"`);\n if (opts.presentationStyleIndex !== undefined)\n attr.push(`presStyleIdx=\"${opts.presentationStyleIndex}\"`);\n if (opts.presentationStyleCount !== undefined)\n attr.push(`presStyleCnt=\"${opts.presentationStyleCount}\"`);\n if (opts.placeholderText !== undefined) attr.push(`phldrT=\"${escapeXml(opts.placeholderText)}\"`);\n if (opts.placeholder !== undefined) attr.push(`phldr=\"${opts.placeholder ? 1 : 0}\"`);\n if (opts.customAngle !== undefined) attr.push(`custAng=\"${opts.customAngle}\"`);\n if (opts.customFlipVertical !== undefined)\n attr.push(`custFlipVert=\"${opts.customFlipVertical ? 1 : 0}\"`);\n if (opts.customFlipHorizontal !== undefined)\n attr.push(`custFlipHor=\"${opts.customFlipHorizontal ? 1 : 0}\"`);\n if (opts.customSizeX !== undefined) attr.push(`custSzX=\"${opts.customSizeX}\"`);\n if (opts.customSizeY !== undefined) attr.push(`custSzY=\"${opts.customSizeY}\"`);\n if (opts.customScaleX !== undefined) attr.push(`custScaleX=\"${opts.customScaleX}\"`);\n if (opts.customScaleY !== undefined) attr.push(`custScaleY=\"${opts.customScaleY}\"`);\n if (opts.customText !== undefined) attr.push(`custT=\"${opts.customText ? 1 : 0}\"`);\n if (opts.customLinearFactorX !== undefined)\n attr.push(`custLinFactX=\"${opts.customLinearFactorX}\"`);\n if (opts.customLinearFactorY !== undefined)\n attr.push(`custLinFactY=\"${opts.customLinearFactorY}\"`);\n if (opts.customLinearFactorNeighborX !== undefined)\n attr.push(`custLinFactNeighborX=\"${opts.customLinearFactorNeighborX}\"`);\n if (opts.customLinearFactorNeighborY !== undefined)\n attr.push(`custLinFactNeighborY=\"${opts.customLinearFactorNeighborY}\"`);\n if (opts.customRadialScaleRadius !== undefined)\n attr.push(`custRadScaleRad=\"${opts.customRadialScaleRadius}\"`);\n if (opts.customRadialScaleIncrement !== undefined)\n attr.push(`custRadScaleInc=\"${opts.customRadialScaleIncrement}\"`);\n if (opts.coherent3DOffset !== undefined)\n attr.push(`coherent3DOff=\"${opts.coherent3DOffset ? 1 : 0}\"`);\n if (opts.hideGeometry !== undefined) attr.push(`hideGeom=\"${opts.hideGeometry ? 1 : 0}\"`);\n if (opts.hideLastTransition !== undefined)\n attr.push(`hideLastTrans=\"${opts.hideLastTransition ? 1 : 0}\"`);\n if (opts.lockTextEntry !== undefined) attr.push(`lkTxEntry=\"${opts.lockTextEntry ? 1 : 0}\"`);\n if (opts.moveWith !== undefined) attr.push(`moveWith=\"${escapeXml(opts.moveWith)}\"`);\n if (opts.useDefault !== undefined) attr.push(`useDef=\"${opts.useDefault ? 1 : 0}\"`);\n if (opts.zOrderOffset !== undefined) attr.push(`zOrderOff=\"${opts.zOrderOffset}\"`);\n if (opts.layoutTypeId !== undefined) attr.push(`loTypeId=\"${escapeXml(opts.layoutTypeId)}\"`);\n if (opts.layoutCategoryId !== undefined)\n attr.push(`loCatId=\"${escapeXml(opts.layoutCategoryId)}\"`);\n if (opts.quickStyleTypeId !== undefined)\n attr.push(`qsTypeId=\"${escapeXml(opts.quickStyleTypeId)}\"`);\n if (opts.quickStyleCategoryId !== undefined)\n attr.push(`qsCatId=\"${escapeXml(opts.quickStyleCategoryId)}\"`);\n if (opts.colorStyleTypeId !== undefined)\n attr.push(`csTypeId=\"${escapeXml(opts.colorStyleTypeId)}\"`);\n if (opts.colorStyleCategoryId !== undefined)\n attr.push(`csCatId=\"${escapeXml(opts.colorStyleCategoryId)}\"`);\n\n if (attr.length === 0) return \"\";\n return `<dgm:prSet ${attr.join(\" \")}/>`;\n}\n\nfunction stringifyPointText(text: string): string {\n const body = text ? `<a:r><a:t>${escapeXml(text)}</a:t></a:r>` : \"\";\n return `<dgm:t><a:bodyPr/><a:lstStyle/><a:p>${body}</a:p></dgm:t>`;\n}\n","/**\n * CT_DataModel XML stringifier — assembles complete SmartArt data model XML.\n *\n * @module\n */\n\nimport { attr, attrBool, attrNum, findChild } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport { stringifyConnection } from \"./connection\";\nimport { stringifyPoint } from \"./point\";\nimport type { PointPropertySetOptions } from \"./point\";\n\n/**\n * Build the complete dgm:dataModel XML from pre-serialized point and connection strings.\n */\nexport function stringifyDataModel(\n points: readonly string[],\n connections: readonly string[],\n): string {\n return [\n '<dgm:dataModel xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\" xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\">',\n `<dgm:ptLst>${points.join(\"\")}</dgm:ptLst>`,\n `<dgm:cxnLst>${connections.join(\"\")}</dgm:cxnLst>`,\n \"<dgm:bg/>\",\n \"<dgm:whole/>\",\n \"</dgm:dataModel>\",\n ].join(\"\");\n}\n\n/** dgm:pt — one data-model point (dgm:pt, CT_Pt). */\nexport interface ModelPointOptions {\n /** Point identity (dgm:pt `@modelId`). */\n modelId: string;\n /** Point kind (dgm:pt `@type`, ST_PtType). */\n type?: \"node\" | \"asst\" | \"doc\" | \"pres\" | \"parTrans\" | \"sibTrans\";\n /** Transition point owning connection (dgm:pt `@cxnId`, transition points only). */\n connectionId?: string;\n /** Point text (dgm:t). */\n text?: string;\n propertySet?: PointPropertySetOptions;\n}\n\n/** dgm:cxn — one data-model connection (CT_Cxn). */\nexport interface ModelConnectionOptions {\n modelId: string;\n sourceId: string;\n destinationId: string;\n /** Connection kind (dgm:cxn `@type`, ST_CxnType). */\n type?: \"parOf\" | \"presOf\" | \"presParOf\" | \"unknownRelationship\";\n sourceOrder?: number;\n destinationOrder?: number;\n parentTransitionId?: string;\n siblingTransitionId?: string;\n presentationId?: string;\n}\n\n/** dgm:dataModel — structured point/connection model (CT_DataModel). */\nexport interface DataModelOptions {\n points?: ModelPointOptions[];\n connections?: ModelConnectionOptions[];\n}\n\n/**\n * Serialize a structured data model (dgm:dataModel). Inside a layoutDef the\n * part-level namespaces are already declared, so this emits the bare element.\n */\nexport function stringifyDataModelOptions(model: DataModelOptions): string {\n const points = (model.points ?? []).map((p) =>\n stringifyPoint(p.modelId, p.text ?? \"\", p.type ?? \"node\", p.propertySet, p.connectionId),\n );\n const connections = (model.connections ?? []).map((c) =>\n stringifyConnection({\n modelId: c.modelId,\n srcId: c.sourceId,\n destId: c.destinationId,\n type: c.type,\n srcOrd: c.sourceOrder,\n destOrd: c.destinationOrder,\n parTransId: c.parentTransitionId,\n sibTransId: c.siblingTransitionId,\n presId: c.presentationId,\n }),\n );\n return (\n \"<dgm:dataModel>\" +\n `<dgm:ptLst>${points.join(\"\")}</dgm:ptLst>` +\n `<dgm:cxnLst>${connections.join(\"\")}</dgm:cxnLst>` +\n \"<dgm:bg/>\" +\n \"<dgm:whole/>\" +\n \"</dgm:dataModel>\"\n );\n}\n\n/** Parse dgm:dataModel into the structured model. */\nexport function parseDataModelOptions(el: Element | undefined): DataModelOptions | undefined {\n if (!el) return undefined;\n const result: DataModelOptions = {};\n\n const ptLst = findChild(el, \"dgm:ptLst\");\n if (ptLst) {\n const points: ModelPointOptions[] = [];\n for (const pt of ptLst.elements ?? []) {\n if (pt.name !== \"dgm:pt\") continue;\n const point: ModelPointOptions = { modelId: attr(pt, \"modelId\") ?? \"\" };\n const type = attr(pt, \"type\");\n if (type) point.type = type as ModelPointOptions[\"type\"];\n const cxnId = attr(pt, \"cxnId\");\n if (cxnId) point.connectionId = cxnId;\n const t = findChild(pt, \"dgm:t\");\n if (t) point.text = extractPointText(t);\n const prSet = findChild(pt, \"dgm:prSet\");\n if (prSet) point.propertySet = parsePointPropertySet(prSet);\n points.push(point);\n }\n result.points = points;\n }\n\n const cxnLst = findChild(el, \"dgm:cxnLst\");\n if (cxnLst) {\n const connections: ModelConnectionOptions[] = [];\n for (const cxn of cxnLst.elements ?? []) {\n if (cxn.name !== \"dgm:cxn\") continue;\n const connection: ModelConnectionOptions = {\n modelId: attr(cxn, \"modelId\") ?? \"\",\n sourceId: attr(cxn, \"srcId\") ?? \"\",\n destinationId: attr(cxn, \"destId\") ?? \"\",\n };\n const type = attr(cxn, \"type\");\n if (type) connection.type = type as ModelConnectionOptions[\"type\"];\n const srcOrd = attrNum(cxn, \"srcOrd\");\n if (srcOrd !== undefined) connection.sourceOrder = srcOrd;\n const destOrd = attrNum(cxn, \"destOrd\");\n if (destOrd !== undefined) connection.destinationOrder = destOrd;\n const parTransId = attr(cxn, \"parTransId\");\n if (parTransId) connection.parentTransitionId = parTransId;\n const sibTransId = attr(cxn, \"sibTransId\");\n if (sibTransId) connection.siblingTransitionId = sibTransId;\n const presId = attr(cxn, \"presId\");\n if (presId) connection.presentationId = presId;\n connections.push(connection);\n }\n result.connections = connections;\n }\n\n return Object.keys(result).length > 0 ? result : undefined;\n}\n\n/** dgm:t holds an a:p paragraph tree; flatten its text runs. */\nfunction extractPointText(t: Element): string {\n let out = \"\";\n const walk = (node: Element) => {\n for (const child of node.elements ?? []) {\n if (child.type === \"text\") out += String(child.text ?? \"\");\n else walk(child);\n }\n };\n walk(t);\n return out;\n}\n\n/** Attribute names of dgm:prSet keyed by PointPropertySetOptions field. */\nconst PRSET_ATTRS: readonly (readonly [string, string, \"string\" | \"number\" | \"boolean\"])[] = [\n [\"presentationAssociationId\", \"presAssocID\", \"string\"],\n [\"presentationName\", \"presName\", \"string\"],\n [\"presentationStyleLabel\", \"presStyleLbl\", \"string\"],\n [\"presentationStyleIndex\", \"presStyleIdx\", \"number\"],\n [\"presentationStyleCount\", \"presStyleCnt\", \"number\"],\n [\"placeholderText\", \"phldrT\", \"string\"],\n [\"placeholder\", \"phldr\", \"boolean\"],\n [\"customAngle\", \"custAng\", \"number\"],\n [\"customFlipVertical\", \"custFlipVert\", \"boolean\"],\n [\"customFlipHorizontal\", \"custFlipHor\", \"boolean\"],\n [\"customSizeX\", \"custSzX\", \"number\"],\n [\"customSizeY\", \"custSzY\", \"number\"],\n [\"customScaleX\", \"custScaleX\", \"number\"],\n [\"customScaleY\", \"custScaleY\", \"number\"],\n [\"customText\", \"custT\", \"boolean\"],\n [\"customLinearFactorX\", \"custLinFactX\", \"number\"],\n [\"customLinearFactorY\", \"custLinFactY\", \"number\"],\n [\"customLinearFactorNeighborX\", \"custLinFactNeighborX\", \"number\"],\n [\"customLinearFactorNeighborY\", \"custLinFactNeighborY\", \"number\"],\n [\"customRadialScaleRadius\", \"custRadScaleRad\", \"number\"],\n [\"customRadialScaleIncrement\", \"custRadScaleInc\", \"number\"],\n [\"coherent3DOffset\", \"coherent3DOff\", \"boolean\"],\n [\"hideGeometry\", \"hideGeom\", \"boolean\"],\n [\"hideLastTransition\", \"hideLastTrans\", \"boolean\"],\n [\"lockTextEntry\", \"lkTxEntry\", \"boolean\"],\n [\"moveWith\", \"moveWith\", \"string\"],\n [\"useDefault\", \"useDef\", \"boolean\"],\n [\"zOrderOffset\", \"zOrderOff\", \"number\"],\n [\"layoutTypeId\", \"loTypeId\", \"string\"],\n [\"layoutCategoryId\", \"loCatId\", \"string\"],\n [\"quickStyleTypeId\", \"qsTypeId\", \"string\"],\n [\"quickStyleCategoryId\", \"qsCatId\", \"string\"],\n [\"colorStyleTypeId\", \"csTypeId\", \"string\"],\n [\"colorStyleCategoryId\", \"csCatId\", \"string\"],\n];\n\nfunction parsePointPropertySet(prSet: Element): PointPropertySetOptions {\n const result: Record<string, unknown> = {};\n for (const [field, xmlName, kind] of PRSET_ATTRS) {\n if (kind === \"number\") {\n const v = attrNum(prSet, xmlName);\n if (v !== undefined) result[field] = v;\n } else if (kind === \"boolean\") {\n const v = attrBool(prSet, xmlName);\n if (v !== undefined) result[field] = v;\n } else {\n const v = attr(prSet, xmlName);\n if (v !== undefined && v !== \"\") result[field] = v;\n }\n }\n return result as PointPropertySetOptions;\n}\n","/**\n * SmartArt layout definition (dgm:layoutDef, CT_DiagramDefinition) — the\n * authoring-layer model describing how a diagram arranges its shapes.\n *\n * Bidirectional: stringify builds the layoutDef part body, parse reads one\n * back into the same options shape, so custom layouts round-trip intact.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_DiagramDefinition and the\n * CT_LayoutNode tree it contains).\n *\n * @module\n */\n\nimport { attr, attrNum, attrs, findChild } from \"@office-open/xml\";\nimport { OOXML_XML_DECLARATION } from \"@office-open/xml\";\nimport { stringify as stringifyInnerXml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport type {\n DiagramCategoryOptions,\n DiagramDescriptionOptions,\n DiagramNameOptions,\n} from \"../drawing/diagram/headers\";\nimport type {\n AdjustOptions,\n AnimateOneByOne,\n AnimationLevel,\n HierBranch,\n} from \"../drawing/diagram/layout-vars\";\nimport type { ShapeType } from \"../drawing/geometry/preset-geometry\";\nimport {\n xsdAnimLevel,\n xsdDiagramDirection,\n xsdHierBranch,\n xsdResizeHandles,\n} from \"../util/mappings\";\nimport { parseDataModelOptions, stringifyDataModelOptions } from \"./data-model\";\nimport type { DataModelOptions } from \"./data-model\";\n\n// ── Enumerations (ST_* from dml-diagram.xsd, verbatim token values) ──\n\n/** ST_AlgorithmType (dgm:alg `@type`). */\nexport type AlgorithmType =\n | \"composite\"\n | \"conn\"\n | \"cycle\"\n | \"hierChild\"\n | \"hierRoot\"\n | \"pyra\"\n | \"lin\"\n | \"sp\"\n | \"tx\"\n | \"snake\";\n\n/** ST_ConstraintRelationship (dgm:constr `@for`/`@refFor`). */\nexport type ConstraintRelationship = \"self\" | \"ch\" | \"des\";\n\n/** ST_ConstraintType (dgm:constr/`@type`/`@refType`, dgm:rule `@type`). */\nexport type ConstraintType =\n | \"none\"\n | \"alignOff\"\n | \"begMarg\"\n | \"bendDist\"\n | \"begPad\"\n | \"b\"\n | \"bMarg\"\n | \"bOff\"\n | \"ctrX\"\n | \"ctrXOff\"\n | \"ctrY\"\n | \"ctrYOff\"\n | \"connDist\"\n | \"diam\"\n | \"endMarg\"\n | \"endPad\"\n | \"h\"\n | \"hArH\"\n | \"hOff\"\n | \"l\"\n | \"lMarg\"\n | \"lOff\"\n | \"r\"\n | \"rMarg\"\n | \"rOff\"\n | \"primFontSz\"\n | \"pyraAcctRatio\"\n | \"secFontSz\"\n | \"sibSp\"\n | \"secSibSp\"\n | \"sp\"\n | \"stemThick\"\n | \"t\"\n | \"tMarg\"\n | \"tOff\"\n | \"userA\"\n | \"userB\"\n | \"userC\"\n | \"userD\"\n | \"userE\"\n | \"userF\"\n | \"userG\"\n | \"userH\"\n | \"userI\"\n | \"userJ\"\n | \"userK\"\n | \"userL\"\n | \"userM\"\n | \"userN\"\n | \"userO\"\n | \"userP\"\n | \"userQ\"\n | \"userR\"\n | \"userS\"\n | \"userT\"\n | \"userU\"\n | \"userV\"\n | \"userW\"\n | \"userX\"\n | \"userY\"\n | \"userZ\"\n | \"w\"\n | \"wArH\"\n | \"wOff\";\n\n/** ST_BoolOperator (dgm:constr `@op`). */\nexport type ConstraintOperator = \"none\" | \"equ\" | \"gte\" | \"lte\";\n\n/** ST_ChildOrderType (dgm:layoutNode `@chOrder`). */\nexport type ChildOrder = \"b\" | \"t\";\n\n/** ST_FunctionType (dgm:if `@func`). */\nexport type ConditionFunction =\n | \"cnt\"\n | \"pos\"\n | \"revPos\"\n | \"posEven\"\n | \"posOdd\"\n | \"var\"\n | \"depth\"\n | \"maxDepth\";\n\n/** ST_FunctionOperator (dgm:if `@op`). */\nexport type ConditionOperator = \"equ\" | \"neq\" | \"gt\" | \"lt\" | \"gte\" | \"lte\";\n\n/**\n * ST_ParameterId (dgm:param `@type`) — 55 transitional layout-parameter ids\n * verbatim, plus the numCol/animBg extension ids Office 2010+ layoutDefs use\n * (dgm14, outside the transitional XSD).\n */\nexport type AlgorithmParameterType =\n | \"horzAlign\"\n | \"vertAlign\"\n | \"chDir\"\n | \"chAlign\"\n | \"secChAlign\"\n | \"linDir\"\n | \"secLinDir\"\n | \"stElem\"\n | \"bendPt\"\n | \"connRout\"\n | \"begSty\"\n | \"endSty\"\n | \"dim\"\n | \"rotPath\"\n | \"ctrShpMap\"\n | \"nodeHorzAlign\"\n | \"nodeVertAlign\"\n | \"fallback\"\n | \"txDir\"\n | \"pyraAcctPos\"\n | \"pyraAcctTxMar\"\n | \"txBlDir\"\n | \"txAnchorHorz\"\n | \"txAnchorVert\"\n | \"txAnchorHorzCh\"\n | \"txAnchorVertCh\"\n | \"parTxLTRAlign\"\n | \"parTxRTLAlign\"\n | \"shpTxLTRAlignCh\"\n | \"shpTxRTLAlignCh\"\n | \"autoTxRot\"\n | \"grDir\"\n | \"flowDir\"\n | \"contDir\"\n | \"bkpt\"\n | \"off\"\n | \"hierAlign\"\n | \"bkPtFixedVal\"\n | \"stBulletLvl\"\n | \"stAng\"\n | \"spanAng\"\n | \"ar\"\n | \"lnSpPar\"\n | \"lnSpAfParP\"\n | \"lnSpCh\"\n | \"lnSpAfChP\"\n | \"rtShortDist\"\n | \"alignTx\"\n | \"pyraLvlNode\"\n | \"pyraAcctBkgdNode\"\n | \"pyraAcctTxNode\"\n | \"srcNode\"\n | \"dstNode\"\n | \"begPts\"\n | \"endPts\"\n | \"numCol\"\n | \"animBg\";\n\n/** ST_Direction (dgm:dir `@val`). */\nexport type DiagramDirection = \"normal\" | \"reversed\";\n\n/** ST_ResizeHandlesStr (dgm:resizeHandles `@val`). */\nexport type ResizeHandles = \"exact\" | \"relative\";\n\n// ST_FunctionArgument / ST_FunctionValue are unions of every layout-parameter\n// enum plus numbers; ST_AxisTypes / ST_ElementTypes / ST_Booleans / ST_Ints are\n// space-separated lists — those stay plain string by design.\n\n// dgm:title / dgm:desc reuse DiagramNameOptions / DiagramDescriptionOptions\n// (same CT_Name shape as the headers), dgm:cat reuses DiagramCategoryOptions,\n// and dgm:adjLst reuses AdjustOptions — all from drawing/diagram.\n\n// ── Shared building blocks ──\n\n/** dgm:sampData / dgm:styleData / dgm:clrData (CT_SampleData). */\nexport interface SampleDataOptions {\n /** Use the data model of the containing layout as sample (dgm:`@useDef`). */\n useDefault?: boolean;\n dataModel?: DataModelOptions;\n}\n\n/**\n * AG_IteratorAttributes — the traversal selector shared by presOf, forEach,\n * and when-branches. List-typed XSD attributes (axis, ptType, hideLastTrans,\n * st, cnt, step) surface as strings; single values read fine too.\n */\nexport interface DiagramIterationOptions {\n /** Selection axes, space-separated (dgm:`@axis`, ST_AxisTypes). */\n axis?: string;\n /** Selected point kinds, space-separated (dgm:`@ptType`, ST_ElementTypes). */\n pointType?: string;\n /** Hide the last transition point (dgm:`@hideLastTrans`, ST_Booleans). */\n hideLastTransition?: string;\n /** Start index (dgm:`@st`, ST_Ints). */\n start?: string;\n /** Iteration count (dgm:`@cnt`, ST_UnsignedInts). */\n count?: string;\n /** Index step (dgm:`@step`, ST_Ints). */\n step?: string;\n}\n\n/** dgm:alg (CT_Algorithm). */\nexport interface AlgorithmOptions {\n /** Layout algorithm (dgm:alg `@type`). */\n type: AlgorithmType;\n /** Revision counter (dgm:alg `@rev`). */\n revision?: number;\n /** Algorithm parameters (dgm:param*). */\n parameters?: AlgorithmParameterOptions[];\n}\n\n/** dgm:param (CT_Parameter) — inlined in AlgorithmOptions.parameters. */\nexport interface AlgorithmParameterOptions {\n /** Parameter name (dgm:param `@type`, ST_ParameterId). */\n type: AlgorithmParameterType;\n /**\n * Parameter value (dgm:param `@val`, ST_ParameterVal — a union of direction\n * tokens, numbers, and booleans, so it stays polymorphic).\n */\n value: string | number | boolean;\n}\n\n/** dgm:shape (CT_Shape) — the geometry template a layout node renders as. */\nexport interface LayoutShapeOptions {\n /** Shape rotation as a raw double (dgm:shape `@rot`). */\n rotation?: number;\n /** Preset geometry name or \"none\"/\"conn\" (dgm:shape `@type`, ST_LayoutShapeType). */\n type?: ShapeType | \"none\" | \"conn\";\n /** Preview picture relationship id (dgm:shape `@r:blip`). */\n blip?: string;\n /** Z-order offset (dgm:shape `@zOrderOff`). */\n zOrderOffset?: number;\n /** Hide the shape geometry, keep the text (dgm:shape `@hideGeom`). */\n hideGeometry?: boolean;\n /** Lock text entry (dgm:shape `@lkTxEntry`). */\n lockTextEntry?: boolean;\n /** Use the picture placeholder (dgm:shape `@blipPhldr`). */\n blipPlaceholder?: boolean;\n /** Geometry adjustment values (dgm:adjLst). */\n adjustments?: AdjustOptions[];\n}\n\n/** dgm:constr (CT_Constraint). */\nexport interface ConstraintOptions {\n /** Constrained dimension (dgm:constr `@type`). */\n type: ConstraintType;\n /** Related point the constraint applies to (dgm:constr `@for`). */\n for?: ConstraintRelationship;\n /** Layout-node name the constraint applies to (dgm:constr `@forName`). */\n forName?: string;\n /** Point kinds the constraint applies to (dgm:constr `@ptType`). */\n pointType?: string;\n /** Referenced dimension (dgm:constr `@refType`). */\n referenceType?: ConstraintType;\n /** Relationship of the referenced point (dgm:constr `@refFor`). */\n referenceFor?: ConstraintRelationship;\n /** Layout-node name of the referenced point (dgm:constr `@refForName`). */\n referenceForName?: string;\n /** Point kinds of the referenced point (dgm:constr `@refPtType`). */\n referencePointType?: string;\n /** How the reference combines with val (dgm:constr `@op`). */\n operation?: ConstraintOperator;\n /** Absolute value (dgm:constr `@val`). */\n value?: number;\n /** Factor applied to the reference (dgm:constr `@fact`). */\n factor?: number;\n}\n\n/** dgm:rule (CT_NumericRule). */\nexport interface LayoutRuleOptions {\n /** Rule dimension (dgm:rule `@type`). */\n type: ConstraintType;\n for?: ConstraintRelationship;\n forName?: string;\n pointType?: string;\n /** Preferred value (dgm:rule `@val`). */\n value?: number;\n /** Multiplied factor (dgm:rule `@fact`). */\n factor?: number;\n /** Upper bound (dgm:rule `@max`). */\n maximum?: number;\n}\n\n/** dgm:varLst (CT_LayoutVariablePropertySet). */\nexport interface VariableListOptions {\n /** This is an organization chart (dgm:orgChart `@val`). */\n organizationChart?: boolean;\n /** Maximum children per parent (dgm:chMax `@val`). */\n childMaximum?: number;\n /** Preferred children per parent (dgm:chPref `@val`). */\n childPreferred?: number;\n /** Bullets enabled on text nodes (dgm:bulletEnabled `@val`). */\n bulletEnabled?: boolean;\n /** Reading direction (dgm:dir `@val`). */\n direction?: DiagramDirection;\n /** Branch style for hierarchy layouts (dgm:hierBranch `@val`). */\n hierarchyBranchStyle?: HierBranch;\n /** Animate siblings one by one or as a branch (dgm:animOne `@val`). */\n animateOne?: AnimateOneByOne;\n /** Animate by level or from center (dgm:animLvl `@val`). */\n animateLevel?: AnimationLevel;\n /** Resize-handle behavior (dgm:resizeHandles `@val`). */\n resizeHandles?: ResizeHandles;\n}\n\n/** One alternative inside a choose — dgm:if (CT_When); `if` is a reserved word. */\nexport interface WhenOptions extends DiagramIterationOptions {\n name?: string;\n /** Selection function (dgm:if `@func`). */\n function: ConditionFunction;\n /** Function argument, usually a variable name (dgm:if `@arg`). */\n argument?: string;\n /** Comparison operator (dgm:if `@op`). */\n operator: ConditionOperator;\n /** Comparison value (dgm:if `@val`, ST_FunctionValue union). */\n value: string;\n children?: LayoutNodeChild[];\n}\n\n/** dgm:else (CT_Otherwise). */\nexport interface OtherwiseOptions {\n name?: string;\n children?: LayoutNodeChild[];\n}\n\n/** dgm:choose (CT_Choose): pick the first matching condition. */\nexport interface ChooseOptions {\n name?: string;\n /** Alternatives in priority order (dgm:if*, CT_When). */\n conditions: WhenOptions[];\n /** Fallback branch (dgm:else, CT_Otherwise). */\n otherwise?: OtherwiseOptions;\n}\n\n/**\n * The unordered, repeatable choice content of dgm:layoutNode / dgm:forEach /\n * dgm:if / dgm:else, as single-key objects so both order and repetition\n * round-trip (same pattern as paragraph children in the format packages).\n */\nexport type LayoutNodeChild =\n | { algorithm: AlgorithmOptions }\n | { shape: LayoutShapeOptions }\n | { presentationOf: DiagramIterationOptions }\n | { constraints: ConstraintOptions[] }\n | { rules: LayoutRuleOptions[] }\n | { variables: VariableListOptions }\n | { forEach: ForEachOptions }\n | { layoutNode: LayoutNodeOptions }\n | { choose: ChooseOptions };\n\n/** dgm:layoutNode (CT_LayoutNode) — one node of the layout tree. */\nexport interface LayoutNodeOptions {\n /** Unique name referenced by constraints and moveWith (dgm:`@name`). */\n name?: string;\n /** Formatting slot from styleDef/colorsDef (dgm:`@styleLbl`). */\n styleLabel?: string;\n /** Child ordering: bottom-first \"b\" or top-first \"t\" (dgm:`@chOrder`). */\n childOrder?: ChildOrder;\n /** Move with another named layout node (dgm:`@moveWith`). */\n moveWith?: string;\n children?: LayoutNodeChild[];\n /** Raw dgm:extLst inner XML — verbatim round-trip. */\n ext?: string;\n}\n\n/** dgm:forEach (CT_ForEach) — apply children to each selected point. */\nexport interface ForEachOptions extends DiagramIterationOptions {\n name?: string;\n /** Reference to a named layout node instead of inline children (dgm:`@ref`). */\n reference?: string;\n children?: LayoutNodeChild[];\n}\n\n/** dgm:layoutDef (CT_DiagramDefinition) — the layoutDef part root. */\nexport interface LayoutDefinitionOptions {\n /** Layout identity URI (dgm:layoutDef `@uniqueId`). */\n uniqueId?: string;\n /** Minimum Office version (dgm:layoutDef `@minVer`). */\n minVer?: string;\n /** Default quick-style label (dgm:layoutDef `@defStyle`). */\n defaultStyle?: string;\n /** Localized titles (dgm:title*). */\n titles?: DiagramNameOptions[];\n /** Localized descriptions (dgm:desc*). */\n descriptions?: DiagramDescriptionOptions[];\n /** Gallery categories (dgm:catLst). */\n categories?: DiagramCategoryOptions[];\n /** Sample data shown in the picker (dgm:sampData). */\n sampleData?: SampleDataOptions;\n /** Sample data styled for the quick style preview (dgm:styleData). */\n styleData?: SampleDataOptions;\n /** Sample data colored for the colors preview (dgm:clrData). */\n colorData?: SampleDataOptions;\n /** The layout tree (dgm:layoutNode, required). */\n layoutNode: LayoutNodeOptions;\n /** Raw dgm:extLst inner XML — verbatim round-trip. */\n ext?: string;\n}\n\n// ── Stringify ──\n\nfunction emitParameterValue(value: string | number | boolean): string {\n return typeof value === \"boolean\" ? (value ? \"1\" : \"0\") : String(value);\n}\n\nfunction stringifyAlgorithm(o: AlgorithmOptions): string {\n const params = (o.parameters ?? [])\n .map((p) => attrs({ type: p.type, val: emitParameterValue(p.value) }))\n .map((a) => `<dgm:param${a}/>`)\n .join(\"\");\n return `<dgm:alg${attrs({ type: o.type, rev: o.revision })}>${params}</dgm:alg>`;\n}\n\nfunction stringifyShape(o: LayoutShapeOptions): string {\n const adjustments = (o.adjustments ?? [])\n .map((a) => `<dgm:adj${attrs({ idx: a.idx, val: a.val })}/>`)\n .join(\"\");\n const adjLst = o.adjustments ? `<dgm:adjLst>${adjustments}</dgm:adjLst>` : \"\";\n const attrStr = attrs({\n rot: o.rotation,\n type: o.type,\n \"r:blip\": o.blip,\n zOrderOff: o.zOrderOffset,\n hideGeom: booleanAttr(o.hideGeometry),\n lkTxEntry: booleanAttr(o.lockTextEntry),\n blipPhldr: booleanAttr(o.blipPlaceholder),\n });\n return `<dgm:shape${attrStr}>${adjLst}</dgm:shape>`;\n}\n\nfunction stringifyConstraints(list: readonly ConstraintOptions[]): string {\n const items = list\n .map((c) => {\n const base = attrs({\n type: c.type,\n for: c.for,\n forName: c.forName,\n ptType: c.pointType,\n refType: c.referenceType,\n refFor: c.referenceFor,\n refForName: c.referenceForName,\n refPtType: c.referencePointType,\n op: c.operation,\n val: c.value,\n });\n const fact = c.factor !== undefined ? ` fact=\"${c.factor}\"` : \"\";\n return `<dgm:constr${base}${fact}/>`;\n })\n .join(\"\");\n return `<dgm:constrLst>${items}</dgm:constrLst>`;\n}\n\nfunction stringifyRules(list: readonly LayoutRuleOptions[]): string {\n const items = list\n .map((r) => {\n const base = attrs({\n type: r.type,\n for: r.for,\n forName: r.forName,\n ptType: r.pointType,\n val: r.value,\n max: r.maximum,\n });\n const fact = r.factor !== undefined ? ` fact=\"${r.factor}\"` : \"\";\n return `<dgm:rule${base}${fact}/>`;\n })\n .join(\"\");\n return `<dgm:ruleLst>${items}</dgm:ruleLst>`;\n}\n\nfunction stringifyVariables(o: VariableListOptions): string {\n const emit = (tag: string, value: string | number | boolean | undefined) =>\n value === undefined ? \"\" : `<dgm:${tag}${attrs({ val: value })}/>`;\n return (\n \"<dgm:varLst>\" +\n emit(\"orgChart\", booleanAttr(o.organizationChart)) +\n emit(\"chMax\", o.childMaximum) +\n emit(\"chPref\", o.childPreferred) +\n emit(\"bulletEnabled\", booleanAttr(o.bulletEnabled)) +\n emit(\"dir\", o.direction !== undefined ? xsdDiagramDirection.to(o.direction) : undefined) +\n emit(\n \"hierBranch\",\n o.hierarchyBranchStyle !== undefined ? xsdHierBranch.to(o.hierarchyBranchStyle) : undefined,\n ) +\n emit(\"animOne\", o.animateOne) +\n emit(\"animLvl\", o.animateLevel !== undefined ? xsdAnimLevel.to(o.animateLevel) : undefined) +\n emit(\n \"resizeHandles\",\n o.resizeHandles !== undefined ? xsdResizeHandles.to(o.resizeHandles) : undefined,\n ) +\n \"</dgm:varLst>\"\n );\n}\n\n/** Boolean options emit \"1\"/\"0\" when set; undefined stays absent. */\nfunction booleanAttr(value: boolean | undefined): string | number | undefined {\n return value === undefined ? undefined : value ? \"1\" : \"0\";\n}\n\nfunction selfClose(tag: string, record: Record<string, string | number | undefined>): string {\n return `<${tag}${attrs(record)}/>`;\n}\n\nfunction stringifyChildren(children: readonly LayoutNodeChild[] | undefined): string {\n let out = \"\";\n for (const child of children ?? []) {\n if (\"algorithm\" in child) out += stringifyAlgorithm(child.algorithm);\n else if (\"shape\" in child) out += stringifyShape(child.shape);\n else if (\"presentationOf\" in child)\n out += selfClose(\"dgm:presOf\", {\n axis: child.presentationOf.axis,\n ptType: child.presentationOf.pointType,\n hideLastTrans: child.presentationOf.hideLastTransition,\n st: child.presentationOf.start,\n cnt: child.presentationOf.count,\n step: child.presentationOf.step,\n });\n else if (\"constraints\" in child) out += stringifyConstraints(child.constraints);\n else if (\"rules\" in child) out += stringifyRules(child.rules);\n else if (\"variables\" in child) out += stringifyVariables(child.variables);\n else if (\"forEach\" in child) out += stringifyForEach(child.forEach);\n else if (\"layoutNode\" in child) out += stringifyLayoutNode(child.layoutNode);\n else if (\"choose\" in child) out += stringifyChoose(child.choose);\n }\n return out;\n}\n\nfunction stringifyLayoutNode(o: LayoutNodeOptions): string {\n // CT_LayoutNode declares extLst locally — the element is dgm-namespaced\n const body = stringifyChildren(o.children) + (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : \"\");\n return `<dgm:layoutNode${attrs({\n name: o.name,\n styleLbl: o.styleLabel,\n chOrder: o.childOrder,\n moveWith: o.moveWith,\n })}>${body}</dgm:layoutNode>`;\n}\n\nfunction stringifyForEach(o: ForEachOptions): string {\n const attrStr = attrs({ name: o.name, ref: o.reference, ...iterationRecord(o) });\n return `<dgm:forEach${attrStr}>${stringifyChildren(o.children)}</dgm:forEach>`;\n}\n\nfunction stringifyWhen(o: WhenOptions): string {\n const attrStr = attrs({\n name: o.name,\n ...iterationRecord(o),\n func: o.function,\n arg: o.argument,\n op: o.operator,\n val: o.value,\n });\n return `<dgm:if${attrStr}>${stringifyChildren(o.children)}</dgm:if>`;\n}\n\nfunction stringifyOtherwise(o: OtherwiseOptions): string {\n return `<dgm:else${attrs({ name: o.name })}>${stringifyChildren(o.children)}</dgm:else>`;\n}\n\nfunction stringifyChoose(o: ChooseOptions): string {\n const body =\n o.conditions.map(stringifyWhen).join(\"\") + (o.otherwise ? stringifyOtherwise(o.otherwise) : \"\");\n return `<dgm:choose${attrs({ name: o.name })}>${body}</dgm:choose>`;\n}\n\nfunction iterationRecord(o: DiagramIterationOptions): Record<string, string | undefined> {\n return {\n axis: o.axis,\n ptType: o.pointType,\n hideLastTrans: o.hideLastTransition,\n st: o.start,\n cnt: o.count,\n step: o.step,\n };\n}\n\nfunction stringifyLocalizedString(\n tag: string,\n o: DiagramNameOptions | DiagramDescriptionOptions,\n): string {\n return `<dgm:${tag}${attrs({ lang: o.lang, val: o.val })}/>`;\n}\n\nfunction stringifySampleData(tag: string, o: SampleDataOptions | undefined): string {\n if (!o) return \"\";\n const body = o.dataModel ? stringifyDataModelOptions(o.dataModel) : \"\";\n return `<dgm:${tag}${attrs({ useDef: booleanAttr(o.useDefault) })}>${body}</dgm:${tag}>`;\n}\n\n/**\n * Serialize a layout definition to the dgm:layoutDef element (no XML\n * declaration, no namespace declarations — the part wrapper adds both).\n */\nexport function stringifyLayoutDefinition(o: LayoutDefinitionOptions): string {\n const body =\n (o.titles ?? []).map((t) => stringifyLocalizedString(\"title\", t)).join(\"\") +\n (o.descriptions ?? []).map((d) => stringifyLocalizedString(\"desc\", d)).join(\"\") +\n (o.categories?.length\n ? `<dgm:catLst>${o.categories\n .map((c) => selfClose(\"dgm:cat\", { type: c.type, pri: c.pri }))\n .join(\"\")}</dgm:catLst>`\n : \"\") +\n stringifySampleData(\"sampData\", o.sampleData) +\n stringifySampleData(\"styleData\", o.styleData) +\n stringifySampleData(\"clrData\", o.colorData) +\n stringifyLayoutNode(o.layoutNode) +\n (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : \"\");\n return `<dgm:layoutDef${attrs({\n uniqueId: o.uniqueId,\n minVer: o.minVer,\n defStyle: o.defaultStyle,\n })}>${body}</dgm:layoutDef>`;\n}\n\nconst DGM_NS = \"http://schemas.openxmlformats.org/drawingml/2006/diagram\";\nconst A_NS = \"http://schemas.openxmlformats.org/drawingml/2006/main\";\nconst R_NS = \"http://schemas.openxmlformats.org/officeDocument/2006/relationships\";\n\n/**\n * Inject the part-level dgm/a namespace declarations into the root element of\n * a serialized layoutDef/styleDef/colorsDef body; r joins only when the body\n * actually uses the prefix (dgm:shape @r:blip preview references).\n */\nexport function withDiagramNamespaces(xml: string): string {\n const r = xml.includes(\"xmlns:r=\") ? \"\" : /\\sr:[\\w]+=/.test(xml) ? ` xmlns:r=\"${R_NS}\"` : \"\";\n return xml.replace(\n /^<dgm:(layoutDef|styleDef|colorsDef)/,\n `<dgm:$1 xmlns:dgm=\"${DGM_NS}\" xmlns:a=\"${A_NS}\"${r}`,\n );\n}\n\n// ── Parse ──\n\nfunction readIteration(el: Element): DiagramIterationOptions {\n const result: Partial<DiagramIterationOptions> = {};\n const axis = attr(el, \"axis\");\n if (axis !== undefined) result.axis = axis;\n const ptType = attr(el, \"ptType\");\n if (ptType !== undefined) result.pointType = ptType;\n const hideLastTrans = attr(el, \"hideLastTrans\");\n if (hideLastTrans !== undefined) result.hideLastTransition = hideLastTrans;\n const st = attr(el, \"st\");\n if (st !== undefined) result.start = st;\n const cnt = attr(el, \"cnt\");\n if (cnt !== undefined) result.count = cnt;\n const step = attr(el, \"step\");\n if (step !== undefined) result.step = step;\n return result as DiagramIterationOptions;\n}\n\nfunction parseAlgorithm(el: Element): AlgorithmOptions {\n const result: Partial<AlgorithmOptions> = {\n type: (attr(el, \"type\") ?? \"composite\") as AlgorithmType,\n };\n const rev = attrNum(el, \"rev\");\n if (rev !== undefined) result.revision = rev;\n const parameters: AlgorithmParameterOptions[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== \"dgm:param\") continue;\n const raw = attr(child, \"val\") ?? \"\";\n const numeric = Number(raw);\n parameters.push({\n type: (attr(child, \"type\") ?? \"\") as AlgorithmParameterType,\n value:\n raw === \"1\" || raw === \"0\"\n ? raw === \"1\"\n : Number.isFinite(numeric) && raw.trim() !== \"\"\n ? numeric\n : raw,\n });\n }\n if (parameters.length) result.parameters = parameters;\n return result as AlgorithmOptions;\n}\n\nfunction parseShape(el: Element): LayoutShapeOptions {\n const result: Partial<LayoutShapeOptions> = {};\n const rot = attrNum(el, \"rot\");\n if (rot !== undefined) result.rotation = rot;\n const type = attr(el, \"type\");\n if (type !== undefined && type !== \"none\") result.type = type as LayoutShapeOptions[\"type\"];\n const blip = attr(el, \"r:blip\");\n if (blip) result.blip = blip;\n const zOrderOff = attrNum(el, \"zOrderOff\");\n if (zOrderOff !== undefined) result.zOrderOffset = zOrderOff;\n const hideGeom = attr(el, \"hideGeom\");\n if (hideGeom !== undefined) result.hideGeometry = hideGeom === \"1\" || hideGeom === \"true\";\n const lkTxEntry = attr(el, \"lkTxEntry\");\n if (lkTxEntry !== undefined) result.lockTextEntry = lkTxEntry === \"1\" || lkTxEntry === \"true\";\n const blipPhldr = attr(el, \"blipPhldr\");\n if (blipPhldr !== undefined) result.blipPlaceholder = blipPhldr === \"1\" || blipPhldr === \"true\";\n const adjLst = findChild(el, \"dgm:adjLst\");\n if (adjLst) {\n const adjustments: AdjustOptions[] = [];\n for (const adj of adjLst.elements ?? []) {\n if (adj.name !== \"dgm:adj\") continue;\n const idx = attrNum(adj, \"idx\");\n const val = attrNum(adj, \"val\");\n if (idx !== undefined && val !== undefined) adjustments.push({ idx, val });\n }\n if (adjustments.length) result.adjustments = adjustments;\n }\n return result as LayoutShapeOptions;\n}\n\nfunction parseConstraint(el: Element): ConstraintOptions {\n const result: Partial<ConstraintOptions> = {\n type: (attr(el, \"type\") ?? \"none\") as ConstraintType,\n };\n const forRel = attr(el, \"for\");\n if (forRel !== undefined) result.for = forRel as ConstraintRelationship;\n const forName = attr(el, \"forName\");\n if (forName !== undefined && forName !== \"\") result.forName = forName;\n const ptType = attr(el, \"ptType\");\n if (ptType !== undefined && ptType !== \"all\") result.pointType = ptType;\n const refType = attr(el, \"refType\");\n if (refType !== undefined && refType !== \"none\") result.referenceType = refType as ConstraintType;\n const refFor = attr(el, \"refFor\");\n if (refFor !== undefined && refFor !== \"self\")\n result.referenceFor = refFor as ConstraintRelationship;\n const refForName = attr(el, \"refForName\");\n if (refForName !== undefined && refForName !== \"\") result.referenceForName = refForName;\n const refPtType = attr(el, \"refPtType\");\n if (refPtType !== undefined && refPtType !== \"all\") result.referencePointType = refPtType;\n const op = attr(el, \"op\");\n if (op !== undefined && op !== \"none\") result.operation = op as ConstraintOperator;\n const val = finiteAttr(el, \"val\");\n if (val !== undefined) result.value = val;\n const fact = finiteAttr(el, \"fact\");\n if (fact !== undefined && fact !== 1) result.factor = fact;\n return result as ConstraintOptions;\n}\n\nfunction parseRule(el: Element): LayoutRuleOptions {\n const result: Partial<LayoutRuleOptions> = {\n type: (attr(el, \"type\") ?? \"none\") as ConstraintType,\n };\n const forRel = attr(el, \"for\");\n if (forRel !== undefined && forRel !== \"self\") result.for = forRel as ConstraintRelationship;\n const forName = attr(el, \"forName\");\n if (forName !== undefined && forName !== \"\") result.forName = forName;\n const ptType = attr(el, \"ptType\");\n if (ptType !== undefined && ptType !== \"all\") result.pointType = ptType;\n const val = finiteAttr(el, \"val\");\n if (val !== undefined) result.value = val;\n const fact = finiteAttr(el, \"fact\");\n if (fact !== undefined) result.factor = fact;\n const max = finiteAttr(el, \"max\");\n if (max !== undefined) result.maximum = max;\n return result as LayoutRuleOptions;\n}\n\n/** Numeric attribute read; the XSD NaN default comes back as undefined. */\nfunction finiteAttr(el: Element, name: string): number | undefined {\n const raw = attr(el, name);\n if (raw === undefined) return undefined;\n const n = Number(raw);\n return Number.isFinite(n) ? n : undefined;\n}\n\nfunction parseVariables(el: Element): VariableListOptions {\n const result: Partial<VariableListOptions> = {};\n const readBool = (tag: string) => {\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n const v = attr(child, \"val\") ?? \"1\";\n return v === \"1\" || v === \"true\";\n }\n return undefined;\n };\n const readEnum = (tag: string) => {\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n return attr(child, \"val\") ?? \"\";\n }\n return undefined;\n };\n const readNumber = (tag: string) => {\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n const v = attrNum(child, \"val\");\n return v === -1 ? undefined : v;\n }\n return undefined;\n };\n const orgChart = readBool(\"orgChart\");\n if (orgChart !== undefined) result.organizationChart = orgChart;\n const chMax = readNumber(\"chMax\");\n if (chMax !== undefined) result.childMaximum = chMax;\n const chPref = readNumber(\"chPref\");\n if (chPref !== undefined) result.childPreferred = chPref;\n const bulletEnabled = readBool(\"bulletEnabled\");\n if (bulletEnabled !== undefined) result.bulletEnabled = bulletEnabled;\n const direction = readEnum(\"dir\");\n if (direction) result.direction = xsdDiagramDirection.from(direction) as DiagramDirection;\n const hierBranch = readEnum(\"hierBranch\");\n if (hierBranch) result.hierarchyBranchStyle = xsdHierBranch.from(hierBranch) as HierBranch;\n const animOne = readEnum(\"animOne\");\n if (animOne) result.animateOne = animOne as AnimateOneByOne;\n const animLvl = readEnum(\"animLvl\");\n if (animLvl) result.animateLevel = xsdAnimLevel.from(animLvl) as AnimationLevel;\n const resizeHandles = readEnum(\"resizeHandles\");\n if (resizeHandles) result.resizeHandles = xsdResizeHandles.from(resizeHandles) as ResizeHandles;\n return result as VariableListOptions;\n}\n\nfunction parseChildren(el: Element): LayoutNodeChild[] | undefined {\n const children: LayoutNodeChild[] = [];\n for (const child of el.elements ?? []) {\n switch (child.name) {\n case \"dgm:alg\":\n children.push({ algorithm: parseAlgorithm(child) });\n break;\n case \"dgm:shape\":\n children.push({ shape: parseShape(child) });\n break;\n case \"dgm:presOf\":\n children.push({ presentationOf: readIteration(child) });\n break;\n case \"dgm:constrLst\":\n children.push({\n constraints: (child.elements ?? [])\n .filter((c) => c.name === \"dgm:constr\")\n .map(parseConstraint),\n });\n break;\n case \"dgm:ruleLst\":\n children.push({\n rules: (child.elements ?? []).filter((c) => c.name === \"dgm:rule\").map(parseRule),\n });\n break;\n case \"dgm:varLst\":\n children.push({ variables: parseVariables(child) });\n break;\n case \"dgm:forEach\":\n children.push({ forEach: parseForEach(child) });\n break;\n case \"dgm:layoutNode\":\n children.push({ layoutNode: parseLayoutNode(child) });\n break;\n case \"dgm:choose\":\n children.push({ choose: parseChoose(child) });\n break;\n default:\n break;\n }\n }\n return children.length ? children : undefined;\n}\n\nfunction parseLayoutNode(el: Element): LayoutNodeOptions {\n const result: Partial<LayoutNodeOptions> = {};\n const name = attr(el, \"name\");\n if (name) result.name = name;\n const styleLbl = attr(el, \"styleLbl\");\n if (styleLbl) result.styleLabel = styleLbl;\n const chOrder = attr(el, \"chOrder\");\n if (chOrder !== undefined && chOrder !== \"b\") result.childOrder = chOrder as ChildOrder;\n const moveWith = attr(el, \"moveWith\");\n if (moveWith) result.moveWith = moveWith;\n const children = parseChildren(el);\n if (children) result.children = children;\n const extLst = findChild(el, \"dgm:extLst\") ?? findChild(el, \"a:extLst\");\n if (extLst) result.ext = stringifyInnerXml(extLst);\n return result as LayoutNodeOptions;\n}\n\nfunction parseForEach(el: Element): ForEachOptions {\n const result: Partial<ForEachOptions> = readIteration(el);\n const name = attr(el, \"name\");\n if (name) result.name = name;\n const ref = attr(el, \"ref\");\n if (ref) result.reference = ref;\n const children = parseChildren(el);\n if (children) result.children = children;\n return result as ForEachOptions;\n}\n\nfunction parseWhen(el: Element): WhenOptions {\n const result: Partial<WhenOptions> = {\n ...readIteration(el),\n function: (attr(el, \"func\") ?? \"cnt\") as ConditionFunction,\n operator: (attr(el, \"op\") ?? \"equ\") as ConditionOperator,\n value: attr(el, \"val\") ?? \"\",\n };\n const name = attr(el, \"name\");\n if (name) result.name = name;\n const arg = attr(el, \"arg\");\n if (arg !== undefined && arg !== \"none\") result.argument = arg;\n const children = parseChildren(el);\n if (children) result.children = children;\n return result as WhenOptions;\n}\n\nfunction parseChoose(el: Element): ChooseOptions {\n const conditions: WhenOptions[] = [];\n let otherwise: OtherwiseOptions | undefined;\n for (const child of el.elements ?? []) {\n if (child.name === \"dgm:if\") conditions.push(parseWhen(child));\n else if (child.name === \"dgm:else\") otherwise = parseOtherwise(child);\n }\n const result: Partial<ChooseOptions> = { conditions };\n const name = attr(el, \"name\");\n if (name) result.name = name;\n if (otherwise) result.otherwise = otherwise;\n return result as ChooseOptions;\n}\n\nfunction parseOtherwise(el: Element): OtherwiseOptions {\n const result: Partial<OtherwiseOptions> = {};\n const name = attr(el, \"name\");\n if (name) result.name = name;\n const children = parseChildren(el);\n if (children) result.children = children;\n return result as OtherwiseOptions;\n}\n\nfunction parseLocalizedStrings(\n el: Element,\n tag: string,\n): DiagramNameOptions[] | DiagramDescriptionOptions[] | undefined {\n const out: (DiagramNameOptions | DiagramDescriptionOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n const val = attr(child, \"val\") ?? \"\";\n const lang = attr(child, \"lang\");\n out.push(lang ? { lang, val } : { val });\n }\n return out.length ? (out as DiagramNameOptions[]) : undefined;\n}\n\nfunction parseSampleData(el: Element | undefined): SampleDataOptions | undefined {\n if (!el) return undefined;\n const result: Partial<SampleDataOptions> = {};\n const useDef = attr(el, \"useDef\");\n if (useDef !== undefined) result.useDefault = useDef === \"1\" || useDef === \"true\";\n const dataModel = parseDataModelOptions(findChild(el, \"dgm:dataModel\"));\n if (dataModel) result.dataModel = dataModel;\n return Object.keys(result).length ? (result as SampleDataOptions) : {};\n}\n\n/** Parse a dgm:layoutDef element into options. */\nexport function parseLayoutDefinition(el: Element): LayoutDefinitionOptions {\n const root = el.name === \"dgm:layoutDef\" ? el : (findChild(el, \"dgm:layoutDef\") ?? el);\n const result: Partial<LayoutDefinitionOptions> = {};\n const uniqueId = attr(root, \"uniqueId\");\n if (uniqueId) result.uniqueId = uniqueId;\n const minVer = attr(root, \"minVer\");\n if (minVer) result.minVer = minVer;\n const defStyle = attr(root, \"defStyle\");\n if (defStyle) result.defaultStyle = defStyle;\n const titles = parseLocalizedStrings(root, \"title\");\n if (titles) result.titles = titles;\n const descriptions = parseLocalizedStrings(root, \"desc\");\n if (descriptions) result.descriptions = descriptions;\n const catLst = findChild(root, \"dgm:catLst\");\n if (catLst) {\n const categories = (catLst.elements ?? [])\n .filter((c) => c.name === \"dgm:cat\")\n .map((c) => ({ type: attr(c, \"type\") ?? \"\", pri: attrNum(c, \"pri\") ?? 0 }));\n if (categories.length) result.categories = categories;\n }\n const sampleData = parseSampleData(findChild(root, \"dgm:sampData\"));\n if (sampleData) result.sampleData = sampleData;\n const styleData = parseSampleData(findChild(root, \"dgm:styleData\"));\n if (styleData) result.styleData = styleData;\n const colorData = parseSampleData(findChild(root, \"dgm:clrData\"));\n if (colorData) result.colorData = colorData;\n const layoutNode = findChild(root, \"dgm:layoutNode\");\n if (layoutNode) result.layoutNode = parseLayoutNode(layoutNode);\n const extLst = findChild(root, \"dgm:extLst\") ?? findChild(root, \"a:extLst\");\n if (extLst) result.ext = stringifyInnerXml(extLst);\n return result as LayoutDefinitionOptions;\n}\n\n/** layoutDef part descriptor — stringify emits the element, parse reads it. */\nexport const layoutDefDesc: CustomDescriptor<LayoutDefinitionOptions> = {\n kind: \"custom\",\n stringify: (opts: LayoutDefinitionOptions) => stringifyLayoutDefinition(opts),\n parse: (el: Element) => parseLayoutDefinition(el),\n};\n\n/** Full layoutDef part body: XML declaration + namespaces + the element. */\nexport function stringifyLayoutDefinitionPart(o: LayoutDefinitionOptions): string {\n return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyLayoutDefinition(o));\n}\n","/**\n * SmartArt color-transform definition (dgm:colorsDef, CT_ColorTransform) —\n * the authoring-layer model mapping style labels to color lists.\n *\n * Bidirectional: stringify builds the colors part body, parse reads one back\n * into the same options shape, so custom color transforms round-trip intact.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_ColorTransform,\n * CT_CTStyleLabel, CT_Colors with its EG_ColorChoice children).\n *\n * @module\n */\n\nimport { attr, attrs, findChild } from \"@office-open/xml\";\nimport { OOXML_XML_DECLARATION } from \"@office-open/xml\";\nimport { stringify as stringifyInnerXml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport { createColorList, parseColorList } from \"../drawing/diagram/diagram-style\";\nimport type { ColorListOptions, ColorStyleLabelOptions } from \"../drawing/diagram/diagram-style\";\nimport type {\n DiagramCategoryOptions,\n DiagramDescriptionOptions,\n DiagramNameOptions,\n} from \"../drawing/diagram/headers\";\nimport { withDiagramNamespaces } from \"./layout-definition\";\n\n/** dgm:colorsDef (CT_ColorTransform) — the colors part root. */\nexport interface ColorDefinitionOptions {\n /** Color-transform identity URI (dgm:colorsDef `@uniqueId`). */\n uniqueId?: string;\n /** Minimum Office version (dgm:colorsDef `@minVer`). */\n minVer?: string;\n /** Localized titles (dgm:title*). */\n titles?: DiagramNameOptions[];\n /** Localized descriptions (dgm:desc*). */\n descriptions?: DiagramDescriptionOptions[];\n /** Gallery categories (dgm:catLst). */\n categories?: DiagramCategoryOptions[];\n /** Color slots, at least one in a real part (dgm:styleLbl*). */\n styleLabels?: ColorStyleLabelOptions[];\n /** Raw dgm:extLst inner XML — verbatim round-trip. */\n ext?: string;\n}\n\n// CT_CTStyleLabel color lists in schema order: fill, line, effect, text line,\n// text fill, text effect.\nconst COLOR_LIST_FIELDS: readonly (readonly [string, keyof ColorStyleLabelOptions])[] = [\n [\"fillClrLst\", \"fillColorList\"],\n [\"linClrLst\", \"lineColorList\"],\n [\"effectClrLst\", \"effectColorList\"],\n [\"txLinClrLst\", \"textLineColorList\"],\n [\"txFillClrLst\", \"textFillColorList\"],\n [\"txEffectClrLst\", \"textEffectColorList\"],\n];\n\n// ── Stringify ──\n\nfunction stringifyLocalized(\n tag: string,\n o: DiagramNameOptions | DiagramDescriptionOptions,\n): string {\n return `<dgm:${tag}${attrs({ lang: o.lang, val: o.val })}/>`;\n}\n\nfunction stringifyColorStyleLabel(o: ColorStyleLabelOptions): string {\n let body = \"\";\n for (const [tag, field] of COLOR_LIST_FIELDS) {\n const list = o[field] as ColorListOptions | undefined;\n if (list) body += createColorList(`dgm:${tag}`, list);\n }\n return `<dgm:styleLbl${attrs({ name: o.name })}>${body}</dgm:styleLbl>`;\n}\n\n/**\n * Serialize a color-transform definition to the dgm:colorsDef element (no XML\n * declaration, no namespace declarations — the part wrapper adds both).\n */\nexport function stringifyColorDefinition(o: ColorDefinitionOptions): string {\n const body =\n (o.titles ?? []).map((t) => stringifyLocalized(\"title\", t)).join(\"\") +\n (o.descriptions ?? []).map((d) => stringifyLocalized(\"desc\", d)).join(\"\") +\n (o.categories?.length\n ? `<dgm:catLst>${o.categories\n .map((c) => `<dgm:cat${attrs({ type: c.type, pri: c.pri })}/>`)\n .join(\"\")}</dgm:catLst>`\n : \"\") +\n (o.styleLabels ?? []).map(stringifyColorStyleLabel).join(\"\") +\n // CT_ColorTransform declares extLst locally — the element is dgm-namespaced\n (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : \"\");\n return `<dgm:colorsDef${attrs({ uniqueId: o.uniqueId, minVer: o.minVer })}>${body}</dgm:colorsDef>`;\n}\n\n// ── Parse ──\n\nfunction parseColorStyleLabel(el: Element): ColorStyleLabelOptions {\n const result: Partial<ColorStyleLabelOptions> = { name: attr(el, \"name\") ?? \"\" };\n for (const [tag, field] of COLOR_LIST_FIELDS) {\n const listEl = findChild(el, `dgm:${tag}`);\n if (listEl) (result as Record<string, unknown>)[field] = parseColorList(listEl);\n }\n return result as ColorStyleLabelOptions;\n}\n\nfunction parseLocalized(\n el: Element,\n tag: string,\n): DiagramNameOptions[] | DiagramDescriptionOptions[] | undefined {\n const out: (DiagramNameOptions | DiagramDescriptionOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n const val = attr(child, \"val\") ?? \"\";\n const lang = attr(child, \"lang\");\n out.push(lang ? { lang, val } : { val });\n }\n return out.length ? (out as DiagramNameOptions[]) : undefined;\n}\n\n/** Parse a dgm:colorsDef element into options. */\nexport function parseColorDefinition(el: Element): ColorDefinitionOptions {\n const root = el.name === \"dgm:colorsDef\" ? el : (findChild(el, \"dgm:colorsDef\") ?? el);\n const result: Partial<ColorDefinitionOptions> = {};\n const uniqueId = attr(root, \"uniqueId\");\n if (uniqueId) result.uniqueId = uniqueId;\n const minVer = attr(root, \"minVer\");\n if (minVer) result.minVer = minVer;\n const titles = parseLocalized(root, \"title\");\n if (titles) result.titles = titles;\n const descriptions = parseLocalized(root, \"desc\");\n if (descriptions) result.descriptions = descriptions;\n const catLst = findChild(root, \"dgm:catLst\");\n if (catLst) {\n const categories = (catLst.elements ?? [])\n .filter((c) => c.name === \"dgm:cat\")\n .map((c) => ({ type: attr(c, \"type\") ?? \"\", pri: Number(attr(c, \"pri\") ?? 0) }));\n if (categories.length) result.categories = categories;\n }\n const styleLabels: ColorStyleLabelOptions[] = [];\n for (const child of root.elements ?? []) {\n if (child.name === \"dgm:styleLbl\") styleLabels.push(parseColorStyleLabel(child));\n }\n if (styleLabels.length) result.styleLabels = styleLabels;\n const extLst = findChild(root, \"dgm:extLst\") ?? findChild(root, \"a:extLst\");\n if (extLst) result.ext = stringifyInnerXml(extLst);\n return result as ColorDefinitionOptions;\n}\n\n/** colors part descriptor — stringify emits the element, parse reads it. */\nexport const colorsDefDesc: CustomDescriptor<ColorDefinitionOptions> = {\n kind: \"custom\",\n stringify: (opts) => stringifyColorDefinition(opts),\n parse: (el) => parseColorDefinition(el),\n};\n\n/** Full colors part body: XML declaration + namespaces + the element. */\nexport function stringifyColorDefinitionPart(o: ColorDefinitionOptions): string {\n return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyColorDefinition(o));\n}\n","/**\n * SmartArt quick-style definition (dgm:styleDef, CT_StyleDefinition) — the\n * authoring-layer model describing how a diagram's style labels are formatted.\n *\n * Bidirectional: stringify builds the quickStyle part body, parse reads one\n * back into the same options shape, so custom styles round-trip intact.\n *\n * Reference: ISO/IEC 29500-4, dml-diagram.xsd (CT_StyleDefinition,\n * CT_StyleLabel, CT_TextProps and the EG_Text3D group from dml-main.xsd).\n *\n * @module\n */\n\nimport { attr, attrs, findChild } from \"@office-open/xml\";\nimport { OOXML_XML_DECLARATION } from \"@office-open/xml\";\nimport { stringify as stringifyInnerXml } from \"@office-open/xml\";\nimport type { Element } from \"@office-open/xml\";\n\nimport type { CustomDescriptor } from \"../descriptor\";\nimport type { ReadContext, WriteContext } from \"../descriptor/context\";\nimport type {\n DiagramCategoryOptions,\n DiagramDescriptionOptions,\n DiagramNameOptions,\n} from \"../drawing/diagram/headers\";\nimport type { Scene3DOptions } from \"../drawing/three-d/scene-3d\";\nimport type { Shape3DOptions } from \"../drawing/three-d/shape-3d\";\nimport { scene3DDesc, shape3DDesc } from \"../drawing/three-d/three-d-descriptors\";\nimport { parseShapeStyle, stringifyShapeStyle } from \"../theme/style-matrix\";\nimport type { DefaultShapeStyleOptions } from \"../theme/theme-options\";\nimport { withDiagramNamespaces } from \"./layout-definition\";\n\n/** dgm:txPr (CT_TextProps) — a choice of 3D text treatments (EG_Text3D). */\nexport interface TextProperties3DOptions {\n /** 3D shape properties for the label text (a:sp3d). */\n shape3d?: Shape3DOptions;\n /** Flatten text to a plane at this z coordinate, EMU (a:flatTx `@z`). */\n flatText?: number;\n}\n\n/** dgm:styleLbl (CT_StyleLabel) — formatting for one style slot. */\nexport interface StyleLabelOptions {\n /** Slot name referenced by dgm:layoutNode `@styleLbl` (required). */\n name: string;\n /** Shared 3D scene for this label (dgm:scene3d). */\n scene3d?: Scene3DOptions;\n /** 3D shape properties (dgm:sp3d). */\n shape3d?: Shape3DOptions;\n /** 3D text properties (dgm:txPr). */\n textProperties?: TextProperties3DOptions;\n /** Theme style-matrix references (dgm:style, a:CT_ShapeStyle). */\n style?: DefaultShapeStyleOptions;\n /** Raw dgm:extLst inner XML — verbatim round-trip. */\n ext?: string;\n}\n\n/** dgm:styleDef (CT_StyleDefinition) — the quickStyle part root. */\nexport interface StyleDefinitionOptions {\n /** Style identity URI (dgm:styleDef `@uniqueId`). */\n uniqueId?: string;\n /** Minimum Office version (dgm:styleDef `@minVer`). */\n minVer?: string;\n /** Localized titles (dgm:title*). */\n titles?: DiagramNameOptions[];\n /** Localized descriptions (dgm:desc*). */\n descriptions?: DiagramDescriptionOptions[];\n /** Gallery categories (dgm:catLst). */\n categories?: DiagramCategoryOptions[];\n /** Shared 3D scene for the whole style (dgm:scene3d). */\n scene3d?: Scene3DOptions;\n /** Style slots, at least one in a real part (dgm:styleLbl*). */\n styleLabels?: StyleLabelOptions[];\n /** Raw dgm:extLst inner XML — verbatim round-trip. */\n ext?: string;\n}\n\n// Noop contexts: style definitions hold theme references and plain colors,\n// never media or relationships of their own.\nconst DIRECT_WRITE_CTX: WriteContext = {\n addRelationship: () => \"\",\n addMedia: () => \"\",\n addHyperlink: () => {},\n};\n\nconst DIRECT_READ_CTX: ReadContext = {\n resolveRelationship: () => undefined,\n getPart: () => undefined,\n getRaw: () => undefined,\n};\n\n// ── Stringify ──\n\n// CT_StyleLabel declares scene3d/sp3d/style as local dgm-namespace elements\n// wrapping dml-main content, so only the outer tag switches prefix; the\n// dml-main children (a:camera, a:lnRef, …) keep theirs.\nfunction renamespaceTag(tag: string, xml: string): string {\n return xml.replace(`<a:${tag}`, `<dgm:${tag}`).replace(`</a:${tag}>`, `</dgm:${tag}>`);\n}\n\nfunction stringifyTextProperties(o: TextProperties3DOptions, ctx: WriteContext): string {\n const body = o.shape3d\n ? (shape3DDesc.stringify(o.shape3d, ctx) ?? \"\")\n : o.flatText !== undefined\n ? `<a:flatTx${attrs({ z: o.flatText })}/>`\n : \"\";\n return body ? `<dgm:txPr>${body}</dgm:txPr>` : \"\";\n}\n\nfunction stringifyStyleLabel(o: StyleLabelOptions, ctx: WriteContext): string {\n let body = \"\";\n if (o.scene3d) body += renamespaceTag(\"scene3d\", scene3DDesc.stringify(o.scene3d, ctx) ?? \"\");\n if (o.shape3d) body += renamespaceTag(\"sp3d\", shape3DDesc.stringify(o.shape3d, ctx) ?? \"\");\n if (o.textProperties) body += stringifyTextProperties(o.textProperties, ctx);\n if (o.style) body += renamespaceTag(\"style\", stringifyShapeStyle(o.style, ctx));\n // CT_StyleLabel declares extLst locally — the element is dgm-namespaced\n if (o.ext) body += `<dgm:extLst>${o.ext}</dgm:extLst>`;\n return `<dgm:styleLbl${attrs({ name: o.name })}>${body}</dgm:styleLbl>`;\n}\n\nfunction stringifyLocalized(\n tag: string,\n o: DiagramNameOptions | DiagramDescriptionOptions,\n): string {\n return `<dgm:${tag}${attrs({ lang: o.lang, val: o.val })}/>`;\n}\n\n/**\n * Serialize a style definition to the dgm:styleDef element (no XML\n * declaration, no namespace declarations — the part wrapper adds both).\n */\nexport function stringifyStyleDefinition(o: StyleDefinitionOptions): string {\n const body =\n (o.titles ?? []).map((t) => stringifyLocalized(\"title\", t)).join(\"\") +\n (o.descriptions ?? []).map((d) => stringifyLocalized(\"desc\", d)).join(\"\") +\n (o.categories?.length\n ? `<dgm:catLst>${o.categories\n .map((c) => `<dgm:cat${attrs({ type: c.type, pri: c.pri })}/>`)\n .join(\"\")}</dgm:catLst>`\n : \"\") +\n (o.scene3d\n ? renamespaceTag(\"scene3d\", scene3DDesc.stringify(o.scene3d, DIRECT_WRITE_CTX) ?? \"\")\n : \"\") +\n (o.styleLabels ?? []).map((l) => stringifyStyleLabel(l, DIRECT_WRITE_CTX)).join(\"\") +\n (o.ext ? `<dgm:extLst>${o.ext}</dgm:extLst>` : \"\");\n return `<dgm:styleDef${attrs({ uniqueId: o.uniqueId, minVer: o.minVer })}>${body}</dgm:styleDef>`;\n}\n\n// ── Parse ──\n\nfunction parseTextProperties(el: Element): TextProperties3DOptions {\n const result: Partial<TextProperties3DOptions> = {};\n const sp3d = findChild(el, \"a:sp3d\");\n if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, DIRECT_READ_CTX);\n const flatTx = findChild(el, \"a:flatTx\");\n if (flatTx) {\n const z = attr(flatTx, \"z\");\n result.flatText = z !== undefined ? Number(z) : 0;\n }\n return result as TextProperties3DOptions;\n}\n\nfunction parseStyleLabel(el: Element): StyleLabelOptions {\n const result: Partial<StyleLabelOptions> = { name: attr(el, \"name\") ?? \"\" };\n const scene3d = findChild(el, \"dgm:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, DIRECT_READ_CTX);\n const sp3d = findChild(el, \"dgm:sp3d\");\n if (sp3d) result.shape3d = shape3DDesc.parse(sp3d, DIRECT_READ_CTX);\n const txPr = findChild(el, \"dgm:txPr\");\n if (txPr) result.textProperties = parseTextProperties(txPr);\n const style = findChild(el, \"dgm:style\");\n if (style) result.style = parseShapeStyle(style, DIRECT_READ_CTX);\n const extLst = findChild(el, \"dgm:extLst\") ?? findChild(el, \"a:extLst\");\n if (extLst) result.ext = stringifyInnerXml(extLst);\n return result as StyleLabelOptions;\n}\n\nfunction parseLocalized(\n el: Element,\n tag: string,\n): DiagramNameOptions[] | DiagramDescriptionOptions[] | undefined {\n const out: (DiagramNameOptions | DiagramDescriptionOptions)[] = [];\n for (const child of el.elements ?? []) {\n if (child.name !== `dgm:${tag}`) continue;\n const val = attr(child, \"val\") ?? \"\";\n const lang = attr(child, \"lang\");\n out.push(lang ? { lang, val } : { val });\n }\n return out.length ? (out as DiagramNameOptions[]) : undefined;\n}\n\n/** Parse a dgm:styleDef element into options. */\nexport function parseStyleDefinition(el: Element): StyleDefinitionOptions {\n const root = el.name === \"dgm:styleDef\" ? el : (findChild(el, \"dgm:styleDef\") ?? el);\n const result: Partial<StyleDefinitionOptions> = {};\n const uniqueId = attr(root, \"uniqueId\");\n if (uniqueId) result.uniqueId = uniqueId;\n const minVer = attr(root, \"minVer\");\n if (minVer) result.minVer = minVer;\n const titles = parseLocalized(root, \"title\");\n if (titles) result.titles = titles;\n const descriptions = parseLocalized(root, \"desc\");\n if (descriptions) result.descriptions = descriptions;\n const catLst = findChild(root, \"dgm:catLst\");\n if (catLst) {\n const categories = (catLst.elements ?? [])\n .filter((c) => c.name === \"dgm:cat\")\n .map((c) => ({ type: attr(c, \"type\") ?? \"\", pri: Number(attr(c, \"pri\") ?? 0) }));\n if (categories.length) result.categories = categories;\n }\n const scene3d = findChild(root, \"dgm:scene3d\");\n if (scene3d) result.scene3d = scene3DDesc.parse(scene3d, DIRECT_READ_CTX);\n const styleLabels: StyleLabelOptions[] = [];\n for (const child of root.elements ?? []) {\n if (child.name === \"dgm:styleLbl\") styleLabels.push(parseStyleLabel(child));\n }\n if (styleLabels.length) result.styleLabels = styleLabels;\n const extLst = findChild(root, \"dgm:extLst\") ?? findChild(root, \"a:extLst\");\n if (extLst) result.ext = stringifyInnerXml(extLst);\n return result as StyleDefinitionOptions;\n}\n\n/** quickStyle part descriptor — stringify emits the element, parse reads it. */\nexport const styleDefDesc: CustomDescriptor<StyleDefinitionOptions> = {\n kind: \"custom\",\n stringify: (opts) => stringifyStyleDefinition(opts),\n parse: (el) => parseStyleDefinition(el),\n};\n\n/** Full quickStyle part body: XML declaration + namespaces + the element. */\nexport function stringifyStyleDefinitionPart(o: StyleDefinitionOptions): string {\n return OOXML_XML_DECLARATION + withDiagramNamespaces(stringifyStyleDefinition(o));\n}\n","/**\n * SmartArt built-in definitions — layout, quick style, and color transforms.\n *\n * Emits layoutDef, styleDef, and colorsDef parts from typed constants through\n * the structured descriptors. All entries carry only the uniqueId plus a\n * schema-valid minimal body — Office applications resolve these to built-in\n * definitions; the \"default\" layout ships its full layout tree.\n *\n * @module\n */\n\nexport { COLOR_CATEGORIES, LAYOUT_CATEGORIES, STYLE_CATEGORIES } from \"./categories\";\n\nimport type { ColorListOptions } from \"../drawing/diagram/diagram-style\";\nimport type { Scene3DOptions } from \"../drawing/three-d/scene-3d\";\nimport { COLOR_CATEGORIES, LAYOUT_CATEGORIES, STYLE_CATEGORIES } from \"./categories\";\nimport { stringifyColorDefinitionPart, type ColorDefinitionOptions } from \"./color-definition\";\nimport type { ModelPointOptions } from \"./data-model/data-model\";\nimport { stringifyLayoutDefinitionPart, type LayoutDefinitionOptions } from \"./layout-definition\";\nimport { stringifyStyleDefinitionPart, type StyleDefinitionOptions } from \"./style-definition\";\n\n// ---------------------------------------------------------------------------\n// Layout XML — full for \"default\", stubs for everything else\n// ---------------------------------------------------------------------------\n\nconst BUILTIN_ACCENTS = [\"accent1\", \"accent2\", \"accent3\", \"accent4\", \"accent5\", \"accent6\"] as const;\n\n/** Sample-model point list shared by the layout stubs: a doc point plus placeholders. */\nfunction samplePoints(count: number): LayoutDefinitionOptions[\"sampleData\"] {\n const points: ModelPointOptions[] = [\n { modelId: \"0\", type: \"doc\" },\n ...Array.from({ length: count }, (_, i) => ({\n modelId: String(i + 1),\n propertySet: { placeholder: true },\n })),\n ];\n const connections = Array.from({ length: count }, (_, i) => ({\n modelId: String(count + 1 + i),\n sourceId: \"0\",\n destinationId: String(i + 1),\n sourceOrder: i,\n destinationOrder: 0,\n }));\n return { dataModel: { points, connections } };\n}\n\n/**\n * Full default list layout (urn:microsoft.com/office/officeart/2005/8/layout/default).\n */\nconst DEFAULT_LAYOUT: LayoutDefinitionOptions = {\n uniqueId: \"urn:microsoft.com/office/officeart/2005/8/layout/default\",\n titles: [{ val: \"\" }],\n descriptions: [{ val: \"\" }],\n categories: [{ type: \"list\", pri: 400 }],\n sampleData: samplePoints(5),\n styleData: {\n dataModel: {\n points: [{ modelId: \"0\", type: \"doc\" }, { modelId: \"1\" }, { modelId: \"2\" }],\n connections: [\n { modelId: \"3\", sourceId: \"0\", destinationId: \"1\", sourceOrder: 0, destinationOrder: 0 },\n { modelId: \"4\", sourceId: \"0\", destinationId: \"2\", sourceOrder: 1, destinationOrder: 0 },\n ],\n },\n },\n colorData: {\n dataModel: {\n points: [\n { modelId: \"0\", type: \"doc\" },\n ...Array.from({ length: 6 }, (_, i) => ({ modelId: String(i + 1) })),\n ],\n connections: Array.from({ length: 6 }, (_, i) => ({\n modelId: String(7 + i),\n sourceId: \"0\",\n destinationId: String(i + 1),\n sourceOrder: i,\n destinationOrder: 0,\n })),\n },\n },\n layoutNode: {\n name: \"diagram\",\n childOrder: \"b\",\n children: [\n { variables: { direction: \"normal\", resizeHandles: \"exact\" } },\n {\n choose: {\n name: \"Name0\",\n conditions: [\n {\n name: \"Name1\",\n function: \"var\",\n argument: \"dir\",\n operator: \"equ\",\n value: \"norm\",\n children: [\n {\n algorithm: {\n type: \"snake\",\n parameters: [\n { type: \"grDir\", value: \"tL\" },\n { type: \"flowDir\", value: \"row\" },\n { type: \"contDir\", value: \"sameDir\" },\n { type: \"off\", value: \"ctr\" },\n ],\n },\n },\n ],\n },\n ],\n otherwise: {\n name: \"Name2\",\n children: [\n {\n algorithm: {\n type: \"snake\",\n parameters: [\n { type: \"grDir\", value: \"tR\" },\n { type: \"flowDir\", value: \"row\" },\n { type: \"contDir\", value: \"sameDir\" },\n { type: \"off\", value: \"ctr\" },\n ],\n },\n },\n ],\n },\n },\n },\n { shape: { blipPlaceholder: false, adjustments: [] } },\n { presentationOf: {} },\n {\n constraints: [\n { type: \"w\", for: \"ch\", forName: \"node\", referenceType: \"w\", referencePointType: \"all\" },\n {\n type: \"h\",\n for: \"ch\",\n forName: \"node\",\n referenceType: \"w\",\n referenceFor: \"ch\",\n referenceForName: \"node\",\n factor: 0.6,\n },\n {\n type: \"w\",\n for: \"ch\",\n forName: \"sibTrans\",\n referenceType: \"w\",\n referenceFor: \"ch\",\n referenceForName: \"node\",\n factor: 0.1,\n },\n {\n type: \"sp\",\n referenceType: \"w\",\n referenceFor: \"ch\",\n referenceForName: \"sibTrans\",\n },\n { type: \"primFontSz\", for: \"ch\", forName: \"node\", operation: \"equ\", value: 65 },\n ],\n },\n { rules: [] },\n {\n forEach: {\n name: \"Name3\",\n axis: \"ch\",\n pointType: \"node\",\n start: \"1\",\n children: [\n {\n layoutNode: {\n name: \"node\",\n children: [\n { variables: { bulletEnabled: true } },\n { algorithm: { type: \"tx\" } },\n { shape: { type: \"rect\", adjustments: [] } },\n { presentationOf: { axis: \"desOrSelf\", pointType: \"node\" } },\n {\n constraints: [\n { type: \"lMarg\", referenceType: \"primFontSz\", factor: 0.3 },\n { type: \"rMarg\", referenceType: \"primFontSz\", factor: 0.3 },\n { type: \"tMarg\", referenceType: \"primFontSz\", factor: 0.3 },\n { type: \"bMarg\", referenceType: \"primFontSz\", factor: 0.3 },\n ],\n },\n // rule @fact/@max default to NaN in the XSD, so omitting them\n // means \"unbounded\" — same as the explicit NaN in Office's copy.\n { rules: [{ type: \"primFontSz\", value: 5 }] },\n ],\n },\n },\n {\n forEach: {\n name: \"Name4\",\n axis: \"followSib\",\n pointType: \"sibTrans\",\n count: \"1\",\n children: [\n {\n layoutNode: {\n name: \"sibTrans\",\n children: [\n { algorithm: { type: \"sp\" } },\n { shape: { adjustments: [] } },\n { presentationOf: {} },\n { constraints: [] },\n { rules: [] },\n ],\n },\n },\n ],\n },\n },\n ],\n },\n },\n ],\n },\n};\n\n/**\n * Returns layout XML. Full layout tree for \"default\", minimal stub for others.\n * Stubs keep a schema-required empty layoutNode; PowerPoint resolves built-in\n * definitions from the uniqueId / loTypeId in the data model.\n */\nexport function getLayoutXml(layoutId: string): string {\n if (layoutId === \"default\") return stringifyLayoutDefinitionPart(DEFAULT_LAYOUT);\n const layout: LayoutDefinitionOptions = {\n uniqueId: `urn:microsoft.com/office/officeart/2005/8/layout/${layoutId}`,\n titles: [{ val: \"\" }],\n descriptions: [{ val: \"\" }],\n categories: [{ type: LAYOUT_CATEGORIES[layoutId] ?? \"list\", pri: 400 }],\n sampleData: samplePoints(2),\n layoutNode: {},\n };\n return stringifyLayoutDefinitionPart(layout);\n}\n\n// ---------------------------------------------------------------------------\n// Style XML\n// ---------------------------------------------------------------------------\n\nconst STYLE_SCENE_3D: Scene3DOptions = {\n camera: { preset: \"orthographicFront\" },\n lightRig: { rig: \"threePt\", direction: \"top\" },\n};\n\n/**\n * Returns style XML. Each label node0…node5 ties one accent color into the\n * theme style matrix (line in tx1, fill in the accent), so PowerPoint renders\n * SmartArt shapes with themed fills and effects.\n */\nexport function getStyleXml(styleId: string): string {\n const style: StyleDefinitionOptions = {\n uniqueId: `urn:microsoft.com/office/officeart/2005/8/quickstyle/${styleId}`,\n titles: [{ val: \"\" }],\n descriptions: [{ val: \"\" }],\n categories: [{ type: STYLE_CATEGORIES[styleId] ?? \"simple\", pri: 10100 }],\n scene3d: STYLE_SCENE_3D,\n styleLabels: BUILTIN_ACCENTS.map((accent, i) => ({\n name: `node${i}`,\n style: {\n lineReference: { index: 2, color: { value: \"tx1\" } },\n fillReference: { index: 1, color: { value: accent } },\n effectReference: { index: 0, color: { value: \"tx1\" } },\n fontReference: { collection: \"minor\" as const, color: { value: \"tx1\" } },\n },\n })),\n };\n return stringifyStyleDefinitionPart(style);\n}\n\n// ---------------------------------------------------------------------------\n// Color XML\n// ---------------------------------------------------------------------------\n\nconst TINTED_TEXT = { value: \"tx1\", transforms: { tint: 75 } };\n\n/**\n * Returns color XML mapping the node0 label to color lists for the requested\n * color scheme (accent / colorful / dark / fallback).\n */\nexport function getColorXml(colorId: string): string {\n const accent = colorId.match(/^(accent\\d)/)?.[1] ?? \"accent1\";\n\n let fillColorList: ColorListOptions;\n let lineColorList: ColorListOptions;\n let textFillColorList: ColorListOptions;\n if (colorId.startsWith(\"colorful\")) {\n fillColorList = { colors: BUILTIN_ACCENTS.slice(0, 5).map((a) => ({ value: a })) };\n lineColorList = { colors: [{ value: \"lt1\" }] };\n textFillColorList = { colors: [{ value: \"tx1\" }] };\n } else if (colorId.startsWith(\"dark\")) {\n fillColorList = { colors: [{ value: \"dk1\" }, { value: \"dk2\" }] };\n lineColorList = { colors: [{ value: \"lt1\" }] };\n textFillColorList = { colors: [{ value: \"lt1\" }] };\n } else if (colorId.startsWith(\"accent\")) {\n fillColorList = { colors: [{ value: accent }] };\n lineColorList = { colors: [TINTED_TEXT] };\n textFillColorList = { colors: [{ value: \"tx1\" }] };\n } else {\n fillColorList = { colors: [{ value: \"accent1\" }] };\n lineColorList = { colors: [{ value: \"tx1\" }] };\n textFillColorList = { colors: [{ value: \"tx1\" }] };\n }\n\n const colors: ColorDefinitionOptions = {\n uniqueId: `urn:microsoft.com/office/officeart/2005/8/colors/${colorId}`,\n titles: [{ val: \"\" }],\n descriptions: [{ val: \"\" }],\n categories: [{ type: COLOR_CATEGORIES[colorId] ?? \"accent1\", pri: 11200 }],\n styleLabels: [\n {\n name: \"node0\",\n fillColorList,\n lineColorList,\n effectColorList: lineColorList,\n textFillColorList,\n textLineColorList: colorId.startsWith(\"accent\")\n ? { colors: [TINTED_TEXT] }\n : { colors: [] },\n textEffectColorList: textFillColorList,\n },\n ],\n };\n return stringifyColorDefinitionPart(colors);\n}\n\n/** Minimal drawing cache for SmartArt (Office apps auto-regenerate this on open) */\nexport const DEFAULT_DRAWING_XML =\n '<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>' +\n '<dsp:drawing xmlns:dgm=\"http://schemas.openxmlformats.org/drawingml/2006/diagram\" xmlns:dsp=\"http://schemas.microsoft.com/office/drawing/2008/diagram\" xmlns:a=\"http://schemas.openxmlformats.org/drawingml/2006/main\">' +\n \"<dsp:spTree>\" +\n '<dsp:nvGrpSpPr><dsp:cNvPr id=\"0\" name=\"\"/><dsp:cNvGrpSpPr/></dsp:nvGrpSpPr>' +\n \"<dsp:grpSpPr/>\" +\n \"</dsp:spTree>\" +\n \"</dsp:drawing>\";\n","/**\n * SmartArt data and collection for document generation.\n *\n * @module\n */\n\nimport type { DataType } from \"../util/data-type\";\nimport type { ColorDefinitionOptions } from \"./color-definition\";\nimport type { LayoutDefinitionOptions } from \"./layout-definition\";\nimport type { StyleDefinitionOptions } from \"./style-definition\";\n\n/**\n * Verbatim source parts for byte-exact SmartArt round-trip. When set on a\n * `SmartArtData` entry, the compiler re-emits these bytes under the\n * diagram part names instead of rebuilding from the modeled XML.\n */\nexport interface SmartArtRawParts {\n /** word/diagrams/dataN.xml source bytes. */\n data?: DataType;\n /** word/diagrams/layoutN.xml source bytes. */\n layout?: DataType;\n /** word/diagrams/quickStyleN.xml source bytes. */\n style?: DataType;\n /** word/diagrams/colorsN.xml source bytes. */\n color?: DataType;\n /**\n * word/diagrams/drawingN.xml source bytes — the pre-rendered dsp:drawing\n * snapshot (MS-ODRAWXML 2008 extension) Word caches beside the data model.\n * Falls back to an empty spTree shell when absent.\n */\n drawing?: DataType;\n /** Images referenced by the data part's own rels (dgm:pt blipFill art). */\n media?: { fileName: string; data: DataType }[];\n /** Verbatim rels XML of the data part (its rIds resolve against media). */\n dataRels?: DataType;\n}\n\nexport interface SmartArtData {\n key: string;\n dataModelXml: string;\n /** Built-in layout id (\"process1\") or a full custom layout definition. */\n layout: string | LayoutDefinitionOptions;\n /** Built-in quick-style id (\"simple1\") or a full custom style definition. */\n style: string | StyleDefinitionOptions;\n /** Built-in color-transform id (\"accent1_2\") or a full custom definition. */\n color: string | ColorDefinitionOptions;\n /**\n * Round-trip verbatim parts; emitted in place of the modeled XML. The\n * modeled fields stay populated so the Options remain readable and dropping\n * raw rebuilds from them.\n */\n raw?: SmartArtRawParts;\n}\n\n/**\n * Last URN segment of a custom definition's uniqueId — the id embedded in the\n * data model's doc-point type ids. Falls back to \"custom\" when unset.\n */\nexport function definitionId(definition: { uniqueId?: string }): string {\n return definition.uniqueId?.split(\"/\").pop() || \"custom\";\n}\n\n/**\n * Manages SmartArt parts in a document.\n */\nexport class SmartArtCollection {\n private map: Map<string, SmartArtData>;\n\n public constructor() {\n this.map = new Map<string, SmartArtData>();\n }\n\n public addSmartArt(key: string, data: SmartArtData): void {\n this.map.set(key, data);\n }\n\n public get array(): SmartArtData[] {\n return [...this.map.values()];\n }\n}\n","import { escapeXml } from \"@office-open/xml\";\n\nimport { COLOR_CATEGORIES, LAYOUT_CATEGORIES, STYLE_CATEGORIES } from \"./categories\";\nimport { stringifyConnection } from \"./data-model/connection\";\nimport { stringifyDataModel } from \"./data-model/data-model\";\nimport { stringifyPoint, stringifyTransPoint } from \"./data-model/point\";\n\nexport interface TreeNode {\n text: string;\n children?: readonly TreeNode[];\n}\n\nfunction stringifyDocPoint(layout: string, style: string, color: string): string {\n const loTypeId = `urn:microsoft.com/office/officeart/2005/8/layout/${layout}`;\n const loCatId = LAYOUT_CATEGORIES[layout] ?? \"list\";\n const qsTypeId = `urn:microsoft.com/office/officeart/2005/8/quickstyle/${style}`;\n const qsCatId = STYLE_CATEGORIES[style] ?? \"simple\";\n const csTypeId = `urn:microsoft.com/office/officeart/2005/8/colors/${color}`;\n const csCatId = COLOR_CATEGORIES[color] ?? \"accent1\";\n\n return [\n '<dgm:pt modelId=\"0\" type=\"doc\">',\n `<dgm:prSet loTypeId=\"${escapeXml(loTypeId)}\" loCatId=\"${escapeXml(loCatId)}\" qsTypeId=\"${escapeXml(qsTypeId)}\" qsCatId=\"${escapeXml(qsCatId)}\" csTypeId=\"${escapeXml(csTypeId)}\" csCatId=\"${escapeXml(csCatId)}\" phldr=\"0\"/>`,\n \"<dgm:spPr/>\",\n \"<dgm:t><a:bodyPr/><a:lstStyle/><a:p/></dgm:t>\",\n \"</dgm:pt>\",\n ].join(\"\");\n}\n\nfunction uuid(): string {\n return `{${crypto.randomUUID().toUpperCase()}}`;\n}\n\n/**\n * Creates SmartArt data model XML from tree nodes with layout/style/color settings.\n * Returns the XML string body (no XML declaration).\n */\nexport const createDataModel = (\n nodes: readonly TreeNode[],\n layout: string = \"default\",\n style: string = \"simple1\",\n color: string = \"accent1_2\",\n): string => {\n const pointStrs: string[] = [];\n const connectionStrs: string[] = [];\n\n pointStrs.push(stringifyDocPoint(layout, style, color));\n\n for (const [i, node] of nodes.entries()) {\n const walk = (node: TreeNode, parentUuid: string, srcOrd: number): void => {\n const nodeUuid = uuid();\n const parTransUuid = uuid();\n const sibTransUuid = uuid();\n const cxnUuid = uuid();\n\n pointStrs.push(stringifyTransPoint(parTransUuid, \"parTrans\", cxnUuid));\n pointStrs.push(stringifyTransPoint(sibTransUuid, \"sibTrans\", cxnUuid));\n pointStrs.push(stringifyPoint(nodeUuid, node.text));\n\n connectionStrs.push(\n stringifyConnection({\n modelId: parTransUuid,\n srcId: parentUuid,\n destId: nodeUuid,\n srcOrd,\n destOrd: 0,\n parTransId: parTransUuid,\n sibTransId: sibTransUuid,\n }),\n );\n\n if (node.children) {\n for (const [j, child] of node.children.entries()) {\n walk(child, nodeUuid, j);\n }\n }\n };\n walk(node, \"0\", i);\n }\n\n return stringifyDataModel(pointStrs, connectionStrs);\n};\n"],"mappings":";;;;;;AACA,MAAa,oBAA4C;CACvD,SAAS;CACT,OAAO;CACP,OAAO;CACP,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,UAAU;CACV,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,QAAQ;CACR,Q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AAK;GACtB,MAAM,eAAe,KAAK;GAC1B,MAAM,eAAe,KAAK;GAC1B,MAAM,UAAU,KAAK;GAErB,UAAU,KAAK,oBAAoB,cAAc,YAAY,OAAO,CAAC;GACrE,UAAU,KAAK,oBAAoB,cAAc,YAAY,OAAO,CAAC;GACrE,UAAU,KAAK,eAAe,UAAU,KAAK,IAAI,CAAC;GAElD,eAAe,KACb,oBAAoB;IAClB,SAAS;IACT,OAAO;IACP,QAAQ;IACR;IACA,SAAS;IACT,YAAY;IACZ,YAAY;GACd,CAAC,CACH;GAEA,IAAI,KAAK,UACP,KAAK,MAAM,CAAC,GAAG,UAAU,KAAK,SAAS,QAAQ,GAC7C,KAAK,OAAO,UAAU,CAAC;EAG7B;EACA,KAAK,MAAM,KAAK,CAAC;CACnB;CAEA,OAAO,mBAAmB,WAAW,cAAc;AACrD"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"util-ptE16MEk.mjs","names":[],"sources":["../src/opc/zip-native.ts","../src/opc/output.ts","../src/opc/packer.ts","../src/util/compile.ts","../src/util/crypto.ts","../src/util/placeholder.ts"],"sourcesContent":["/**\n * Native ZIP reader/writer with automatic fallback to fflate.\n *\n * `node:zlib` resolves in Node and Bun (via its Node compat layer), giving\n * `deflateRawSync` / `inflateRawSync` for DEFLATE/INFLATE and `zlib.crc32`\n * for CRC-32 — ~2-3x faster than fflate's pure-JS implementation. Browsers\n * and Deno lack a resolvable `node:zlib`, so the dynamic import rejects and\n * packer.ts falls back to fflate. We probe via the import itself rather than\n * `process.versions.node`: core's `shims: true` swaps `process` for a browser\n * stub that drops `versions.node`, which would silently disable native zlib\n * in any package consuming core's polyfilled build.\n *\n * @module\n */\n\nimport type { Zippable, ZipOptions } from \"fflate\";\n\n// ── CRC-32 lookup table ──\n\nconst CRC_TABLE = new Int32Array(256);\nfor (let i = 0; i < 256; i++) {\n let c = i;\n for (let k = 0; k < 8; k++) c = c & 1 ? (c >>> 1) ^ -306674912 : c >>> 1;\n CRC_TABLE[i] = c;\n}\n\nfunction computeCrc32(data: Uint8Array): number {\n let crc = -1;\n // CRC_TABLE is a fixed 256-entry lookup; the index is masked to [0,255], so the\n // access is guaranteed in-bounds — the `!` is a compile-time narrow, not a runtime check.\n for (const byte of data) {\n crc = CRC_TABLE[(crc ^ byte) & 0xff]! ^ (crc >>> 8);\n }\n return ~crc;\n}\n\n// ── Native zlib detection (Node.js ESM) ──\n\ntype DeflateFn = (data: Uint8Array, level: number) => Uint8Array;\ntype AsyncDeflateFn = (data: Uint8Array, level: number) => Promise<Uint8Array>;\ntype InflateFn = (data: Uint8Array) => Uint8Array;\ntype Crc32Fn = (data: Uint8Array) => number;\n\nlet _nativeDeflate: DeflateFn | undefined;\nlet _nativeDeflateAsync: AsyncDeflateFn | undefined;\nlet _nativeInflate: InflateFn | undefined;\nlet _nativeCrc32: Crc32Fn | undefined;\n\n// Bun-specific fast path: Bun.deflateSync/Bun.inflateSync emit/accept RAW\n// deflate (bit-identical to deflateRawSync output) but skip the node:zlib\n// compat wrapper — ~10x on the small parts that dominate OPC packages, ~2x\n// on inflate, ~1.3x on large buffers. Probed off globalThis since core ships\n// no bun-types dependency.\nconst bunApi = (\n globalThis as {\n Bun?: {\n deflateSync?: (data: Uint8Array, opts?: { level?: number }) => Uint8Array;\n inflateSync?: (data: Uint8Array) => Uint8Array;\n };\n }\n).Bun;\nif (typeof bunApi?.deflateSync === \"function\") {\n _nativeDeflate = (data: Uint8Array, level: number): Uint8Array =>\n bunApi.deflateSync!(data, { level });\n if (typeof bunApi.inflateSync === \"function\") {\n _nativeInflate = (data: Uint8Array): Uint8Array => bunApi.inflateSync!(data);\n }\n}\n\n// `node:zlib` resolves in Node and Bun (via its Node compat layer); in\n// browsers and Deno the dynamic import rejects, so we fall back to fflate.\n// The import itself is the probe — do NOT gate on `process.versions.node`:\n// core's `shims: true` swaps `process` for a browser stub that drops\n// `versions.node`, which would silently disable native zlib in any package\n// that consumes core's polyfilled build.\ntry {\n // top-level await — ESM standard. Resolves to zlib with deflateRawSync;\n // rejects (or yields a stub without it) on incomplete polyfills.\n const zlib = await import(\"node:zlib\");\n if (typeof zlib.deflateRawSync !== \"function\") throw new Error(\"no native deflate\");\n if (_nativeDeflate === undefined) {\n _nativeDeflate = (data: Uint8Array, level: number): Uint8Array =>\n zlib.deflateRawSync(data, { level });\n }\n _nativeDeflateAsync = (data: Uint8Array, level: number): Promise<Uint8Array> =>\n new Promise<Uint8Array>((resolve, reject) =>\n zlib.deflateRaw(data, { level }, (err, result) => {\n if (err) reject(err);\n else resolve(result);\n }),\n );\n _nativeCrc32 =\n typeof zlib.crc32 === \"function\" ? (data: Uint8Array) => zlib.crc32(data) : computeCrc32;\n // Inflate is optional (deflate presence doesn't guarantee it), so probe\n // separately — nativeUnzip only becomes available when this resolves.\n if (typeof zlib.inflateRawSync === \"function\" && _nativeInflate === undefined) {\n _nativeInflate = (data: Uint8Array): Uint8Array => zlib.inflateRawSync(data);\n }\n} catch {\n // Browser/Deno or Node-like runtime without usable zlib — fflate fallback\n}\n\nexport const hasNativeDeflate = (): boolean => _nativeDeflate !== undefined;\n\nexport const hasNativeInflate = (): boolean => _nativeInflate !== undefined;\n\n// fflate's async zip entries hand every chunk to a dedicated worker via\n// postMessage with a transfer list. On Bun that worker pool hurts: teardown\n// lags creation, so back-to-back stream generations accumulate cost (measured\n// 0.4s → 4.4s per drain on a 130-part deck) and embedded pools crash outright\n// (vitest bench: \"Worker exited unexpectedly\"). Main-thread deflate is the\n// better trade there; Node keeps the worker path for its parallel libuv pool.\nconst _prefersMainThreadDeflate = typeof bunApi?.deflateSync === \"function\";\n\n/**\n * True when DEFLATE work should run on the main thread instead of fflate's\n * per-entry workers (Bun). See {@link createZipStream} in packer.ts.\n */\nexport const prefersMainThreadDeflate = (): boolean => _prefersMainThreadDeflate;\n\n/**\n * Synchronous native CRC-32 (`zlib.crc32`, Node/Bun only) — undefined where no\n * native zlib resolved (browsers/Deno). Used by media dedup as a fast content\n * key; callers keep their own JS fallback. ~59× faster than a JS hash on\n * 100 MB inputs.\n */\nexport function nativeCrc32(data: Uint8Array): number | undefined {\n return _nativeCrc32?.(data);\n}\n\n// ── LE write helpers ──\n\nfunction wU16(b: Uint8Array, o: number, v: number): void {\n b[o] = v & 0xff;\n b[o + 1] = (v >> 8) & 0xff;\n}\n\nfunction wU32(b: Uint8Array, o: number, v: number): void {\n b[o] = v & 0xff;\n b[o + 1] = (v >> 8) & 0xff;\n b[o + 2] = (v >> 16) & 0xff;\n b[o + 3] = (v >> 24) & 0xff;\n}\n\n// ── Per-entry metadata ──\n\ninterface Entry {\n filename: Uint8Array;\n data: Uint8Array;\n uncompressedSize: number;\n crc: number;\n method: number; // 0 = STORE, 8 = DEFLATE\n localOffset: number;\n}\n\n// ── Phase 1 helpers ──\n\nfunction resolveEntryData(\n raw: Zippable[string],\n defaultLevel: number,\n): { data: Uint8Array; level: number } {\n if (Array.isArray(raw)) {\n return { data: raw[0] as Uint8Array, level: (raw[1] as ZipOptions).level ?? defaultLevel };\n }\n return { data: raw as Uint8Array, level: defaultLevel };\n}\n\nfunction compressOne(\n data: Uint8Array,\n level: number,\n deflate: DeflateFn,\n): { compressed: Uint8Array; method: number } {\n if (level === 0) return { compressed: data, method: 0 };\n const compressed = deflate(data, level);\n if (compressed.length >= data.length) return { compressed: data, method: 0 };\n return { compressed, method: 8 };\n}\n\nasync function compressOneAsync(\n data: Uint8Array,\n level: number,\n deflate: AsyncDeflateFn,\n): Promise<{ compressed: Uint8Array; method: number }> {\n if (level === 0) return { compressed: data, method: 0 };\n const compressed = await deflate(data, level);\n if (compressed.length >= data.length) return { compressed: data, method: 0 };\n return { compressed, method: 8 };\n}\n\n// ── Phase 2+3: calculate sizes + write ZIP buffer ──\n\nfunction writeZipBuffer(entries: Entry[]): Uint8Array {\n let totalSize = 0;\n for (const e of entries) {\n totalSize += 30 + e.filename.length + e.data.length;\n }\n const cdOffset = totalSize;\n let cdSize = 0;\n for (const e of entries) {\n cdSize += 46 + e.filename.length;\n }\n totalSize += cdSize + 22;\n\n const buf = new Uint8Array(totalSize);\n let offset = 0;\n\n // Local file headers + data\n for (const e of entries) {\n e.localOffset = offset;\n wU32(buf, offset, 0x04034b50); // signature\n wU16(buf, offset + 4, 20); // version needed\n wU16(buf, offset + 6, 0); // flags\n wU16(buf, offset + 8, e.method); // compression method\n wU16(buf, offset + 10, 0); // mod time\n wU16(buf, offset + 12, 0); // mod date\n wU32(buf, offset + 14, e.crc);\n wU32(buf, offset + 18, e.data.length); // compressed size\n wU32(buf, offset + 22, e.uncompressedSize);\n wU16(buf, offset + 26, e.filename.length);\n wU16(buf, offset + 28, 0); // extra field length\n offset += 30;\n\n buf.set(e.filename, offset);\n offset += e.filename.length;\n\n buf.set(e.data, offset);\n offset += e.data.length;\n }\n\n // Central directory\n for (const e of entries) {\n wU32(buf, offset, 0x02014b50); // signature\n wU16(buf, offset + 4, 20); // version made by\n wU16(buf, offset + 6, 20); // version needed\n wU16(buf, offset + 8, 0); // flags\n wU16(buf, offset + 10, e.method);\n wU16(buf, offset + 12, 0); // mod time\n wU16(buf, offset + 14, 0); // mod date\n wU32(buf, offset + 16, e.crc);\n wU32(buf, offset + 20, e.data.length);\n wU32(buf, offset + 24, e.uncompressedSize);\n wU16(buf, offset + 28, e.filename.length);\n wU16(buf, offset + 30, 0); // extra field length\n wU16(buf, offset + 32, 0); // comment length\n wU16(buf, offset + 34, 0); // disk number start\n wU16(buf, offset + 36, 0); // internal attrs\n wU32(buf, offset + 38, 0); // external attrs\n wU32(buf, offset + 42, e.localOffset);\n offset += 46;\n\n buf.set(e.filename, offset);\n offset += e.filename.length;\n }\n\n // End of Central Directory Record\n wU32(buf, offset, 0x06054b50);\n wU16(buf, offset + 4, 0); // disk number\n wU16(buf, offset + 6, 0); // CD disk\n wU16(buf, offset + 8, entries.length);\n wU16(buf, offset + 10, entries.length);\n wU32(buf, offset + 12, cdSize);\n wU32(buf, offset + 16, cdOffset);\n wU16(buf, offset + 20, 0); // comment length\n\n return buf;\n}\n\n// ── Public API ──\n\nconst textEncoder = new TextEncoder();\nconst textDecoder = new TextDecoder();\n\nexport function nativeZip(files: Zippable, level: number = 6): Uint8Array {\n if (!_nativeDeflate) throw new Error(\"Native deflate not available\");\n const crc = _nativeCrc32 ?? computeCrc32;\n const entries: Entry[] = [];\n\n for (const key of Object.keys(files)) {\n const raw = files[key];\n if (raw === undefined) continue; // Object.keys guarantees presence; guard narrows the type\n const { data, level: entryLevel } = resolveEntryData(raw, level);\n const c = crc(data);\n const { compressed, method } = compressOne(data, entryLevel, _nativeDeflate);\n entries.push({\n filename: textEncoder.encode(key),\n data: compressed,\n uncompressedSize: data.length,\n crc: c,\n method,\n localOffset: 0,\n });\n }\n\n return writeZipBuffer(entries);\n}\n\nexport async function nativeZipAsync(files: Zippable, level: number = 6): Promise<Uint8Array> {\n const deflateAsync = _nativeDeflateAsync;\n if (!deflateAsync) throw new Error(\"Native async deflate not available\");\n const crc = _nativeCrc32 ?? computeCrc32;\n\n // All entries deflate in parallel — node:zlib async calls run on the libuv\n // thread pool, so a multi-part package compresses in roughly one-deflate\n // wall clock instead of the sum (pool size caps true parallelism; task\n // queueing is cheap relative to the deflate work itself). CRC runs inline\n // on the main thread before each entry's first await.\n const entries = (\n await Promise.all(\n Object.keys(files).map(async (key): Promise<Entry | null> => {\n const raw = files[key];\n if (raw === undefined) return null; // Object.keys guarantees presence; guard narrows the type\n const { data, level: entryLevel } = resolveEntryData(raw, level);\n const c = crc(data);\n const { compressed, method } = await compressOneAsync(data, entryLevel, deflateAsync);\n return {\n filename: textEncoder.encode(key),\n data: compressed,\n uncompressedSize: data.length,\n crc: c,\n method,\n localOffset: 0,\n };\n }),\n )\n ).filter((e): e is Entry => e !== null);\n\n return writeZipBuffer(entries);\n}\n\n// ── LE read helpers (ZIP parsing) ──\n\nfunction rU16(b: Uint8Array, o: number): number {\n return b[o]! | (b[o + 1]! << 8);\n}\n\nfunction rU32(b: Uint8Array, o: number): number {\n return (b[o]! | (b[o + 1]! << 8) | (b[o + 2]! << 16) | (b[o + 3]! << 24)) >>> 0;\n}\n\n// ── ZIP central-directory parsing ──\n\nconst EOCD_MAGIC = 0x06054b50;\nconst CD_MAGIC = 0x02014b50;\n\ninterface ZipEntryMeta {\n name: string;\n method: number;\n compSize: number;\n crc: number;\n dataStart: number;\n}\n\n/** Locate the End-of-Central-Directory record (within a 64 KB comment window). */\nfunction findEocd(b: Uint8Array): number {\n const min = Math.max(0, b.length - 65557); // 22-byte EOCD + up to 65535-byte comment\n for (let i = b.length - 22; i >= min; i--) {\n if (rU32(b, i) === EOCD_MAGIC) return i;\n }\n throw new Error(\"ZIP EOCD record not found\");\n}\n\n/** Walk the central directory and resolve each entry's payload offset. */\nfunction readCentralDirectory(buf: Uint8Array): ZipEntryMeta[] {\n const eocd = findEocd(buf);\n const count = rU16(buf, eocd + 10);\n const cdOffset = rU32(buf, eocd + 16);\n const entries: ZipEntryMeta[] = [];\n let p = cdOffset;\n for (let i = 0; i < count; i++) {\n if (rU32(buf, p) !== CD_MAGIC) throw new Error(`ZIP central directory corrupt at offset ${p}`);\n const method = rU16(buf, p + 10);\n const crc = rU32(buf, p + 16);\n const compSize = rU32(buf, p + 20);\n const nameLen = rU16(buf, p + 28);\n const extraLen = rU16(buf, p + 30);\n const cmtLen = rU16(buf, p + 32);\n const localOff = rU32(buf, p + 42);\n // Uint8Array.toString() yields \"120,46,...\" (comma-joined bytes), not the\n // UTF-8 string — decode explicitly so entry names are real paths.\n const name = textDecoder.decode(buf.subarray(p + 46, p + 46 + nameLen));\n // The local header carries its own name/extra lengths, which can differ\n // from the CD's; read them to locate the entry's payload precisely.\n const lNameLen = rU16(buf, localOff + 26);\n const lExtraLen = rU16(buf, localOff + 28);\n entries.push({\n name,\n method,\n compSize,\n crc,\n dataStart: localOff + 30 + lNameLen + lExtraLen,\n });\n p += 46 + nameLen + extraLen + cmtLen;\n }\n return entries;\n}\n\n/**\n * Decompress a ZIP archive via `node:zlib` `inflateRawSync`, mirroring fflate's\n * `unzipSync` signature and CRC-32 integrity check. Node/Bun only — callers\n * gate on {@link hasNativeInflate} and fall back to fflate `unzipSync` elsewhere.\n * Measured ~2x faster than fflate on large OOXML packages.\n */\nexport function nativeUnzip(buf: Uint8Array): Record<string, Uint8Array> {\n if (!_nativeInflate) throw new Error(\"Native inflate not available\");\n const inflate = _nativeInflate;\n const crc = _nativeCrc32 ?? computeCrc32;\n const out: Record<string, Uint8Array> = {};\n for (const e of readCentralDirectory(buf)) {\n const raw = buf.subarray(e.dataStart, e.dataStart + e.compSize);\n const dec = e.method === 0 ? raw.slice() : inflate(raw);\n // >>> 0 normalizes the signed CRC_TABLE accumulation against zlib's unsigned crc32.\n if (crc(dec) >>> 0 !== e.crc) throw new Error(`ZIP CRC-32 mismatch: ${e.name}`);\n out[e.name] = dec;\n }\n return out;\n}\n","/**\n * Output type definitions for OOXML document export.\n *\n * @module\n */\n\nimport { strFromU8 } from \"fflate\";\n\nimport { encodeBase64 } from \"../util/base64\";\n\nexport interface OutputByType {\n base64: string;\n string: string;\n text: string;\n binarystring: string;\n array: readonly number[];\n uint8array: Uint8Array;\n arraybuffer: ArrayBuffer;\n blob: Blob;\n nodebuffer: Buffer;\n}\n\nexport type OutputType = keyof OutputByType;\n\n/* V8 ignore start */\nexport const OoxmlMimeType = {\n DOCX: \"application/vnd.openxmlformats-officedocument.wordprocessingml.document\",\n PPTX: \"application/vnd.openxmlformats-officedocument.presentationml.presentation\",\n XLSX: \"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet\",\n} as const;\n\nexport const convertOutput = <T extends OutputType>(\n data: Uint8Array,\n type: T,\n mimeType: string = OoxmlMimeType.DOCX,\n): OutputByType[T] => {\n switch (type) {\n case \"nodebuffer\":\n // Zero-copy: wrap the zip output's underlying ArrayBuffer as a Buffer\n // view instead of copying it (~11MB for an image-heavy file) on every\n // generate(). Safe because the source buffer is freshly allocated and\n // never mutated after this point.\n return Buffer.from(data.buffer, data.byteOffset, data.byteLength) as OutputByType[T];\n case \"blob\":\n return new Blob(\n [(data.buffer as ArrayBuffer).slice(data.byteOffset, data.byteOffset + data.byteLength)],\n { type: mimeType },\n ) as OutputByType[T];\n case \"arraybuffer\":\n return data.buffer.slice(\n data.byteOffset,\n data.byteOffset + data.byteLength,\n ) as OutputByType[T];\n case \"uint8array\":\n return data as OutputByType[T];\n case \"base64\":\n return encodeBase64(data) as OutputByType[T];\n case \"string\":\n case \"text\":\n case \"binarystring\":\n return strFromU8(data, true) as OutputByType[T];\n case \"array\":\n return [...data] as unknown as OutputByType[T];\n /* V8 ignore next */\n default:\n return data as unknown as OutputByType[T];\n }\n};\n/* V8 ignore stop */\n","/**\n * Shared packer utilities for OOXML document generation.\n *\n * @module\n */\n\nimport {\n type AsyncZippable,\n type ZipOptions,\n type Zippable,\n AsyncZipDeflate,\n Zip,\n ZipDeflate,\n ZipPassThrough,\n zip,\n zipSync,\n} from \"fflate\";\n\nimport { convertOutput } from \"./output\";\nimport type { OutputByType, OutputType } from \"./output\";\nimport {\n hasNativeDeflate,\n nativeZip,\n nativeZipAsync,\n prefersMainThreadDeflate,\n} from \"./zip-native\";\n\nexport type { Zippable, ZipOptions } from \"fflate\";\nexport { strFromU8, unzipSync, zipSync } from \"fflate\";\n\nexport interface XmlifyedFile {\n path: string;\n data: string | Uint8Array;\n}\n\n/** Default DEFLATE level for XML entries (SuperFast, matching MS Office). */\nexport const ZIP_DEFLATE_LEVEL = 1;\n\n/** Default DEFLATE level for compressible media (EMF/WMF/BMP/TIFF/SVG). MS\n * Office uses CompressionOption.Normal (~zlib 6); SuperFast (1) inflates EMF\n * output ~15% (measured against a real Office-generated package). */\nexport const ZIP_MEDIA_LEVEL = 6;\n\n/** Level for already-compressed media — STORE (no compression). */\nexport const ZIP_STORED_LEVEL = 0;\n\n/**\n * Media formats already compressed internally (DEFLATE for PNG, DCT for JPEG,\n * LZW for GIF; video/audio containers carry their own codec streams).\n * Re-compressing via zip DEFLATE wastes CPU and often inflates the data, so\n * MS Office STORE-s these (CompressionOption.NotCompressed → zip method 0).\n * Everything else (EMF/WMF/BMP/TIFF/SVG/WAV…) is compressible → DEFLATE —\n * measured on a real Office package, EMF at zlib level 6 matches Office\n * output where SuperFast inflates ~15%.\n */\nconst PRECOMPRESSED_MEDIA_EXT = new Set([\n \"jpg\",\n \"jpeg\",\n \"png\",\n \"gif\",\n \"mp4\",\n \"mov\",\n \"wmv\",\n \"mpg\",\n \"mpeg\",\n \"mp3\",\n \"wma\",\n \"aac\",\n]);\n\n/**\n * Resolve the ZIP level for a media entry by file-name extension, matching MS\n * Office: already-compressed raster formats → STORE (0), everything else →\n * DEFLATE (`mediaLevel`, default Normal). A `compression.media` override\n * therefore applies only to compressible formats, never forcing DEFLATE onto\n * pre-compressed assets.\n */\nexport const levelForMediaName = (fileName: string, mediaLevel: number): number => {\n const dot = fileName.lastIndexOf(\".\");\n const ext = dot < 0 ? \"\" : fileName.slice(dot + 1).toLowerCase();\n return PRECOMPRESSED_MEDIA_EXT.has(ext) ? ZIP_STORED_LEVEL : mediaLevel;\n};\n\n/** Compression options for ZIP output (zlib levels 0-9, matching fflate). */\nexport interface CompressionOptions {\n /** DEFLATE level for XML files. Default: 1 (SuperFast, matching MS Office). */\n xml?: number;\n /**\n * DEFLATE level for compressible media (EMF/WMF/BMP/TIFF/…). Already-compressed\n * formats (PNG/JPEG/GIF) are always STOREd regardless, matching MS Office.\n * Default: 6 (Normal, matching MS Office for EMF/WMF).\n */\n media?: number;\n}\n\n/** Options for Packer output methods. */\nexport interface PackerOptions<T extends OutputType = \"nodebuffer\"> {\n /** Output format. Defaults to `\"nodebuffer\"` (Node.js Buffer). */\n type?: T;\n /** Custom XML/ZIP file overrides. */\n overrides?: XmlifyedFile[];\n /** Compression levels for ZIP entries. */\n compression?: CompressionOptions;\n}\n\n/**\n * Asynchronously compress files and convert to the requested output format.\n *\n * Where a native zlib resolved (Node/Bun), entries deflate in parallel on the\n * libuv thread pool; elsewhere fflate compresses off the main thread.\n * XML entries use DEFLATE level 1 (SuperFast) by default. Media entries are\n * split by type, matching MS Office: already-compressed formats (PNG/JPEG/GIF)\n * are STOREd, everything else uses the `media` level (default Normal).\n * Set `{ media: ZIP_STORED_LEVEL }` to STORE all compressible media too.\n */\nexport const zipAndConvert = async <T extends OutputType>(\n files: Zippable,\n type: T,\n mimeType: string,\n level: number = ZIP_DEFLATE_LEVEL,\n): Promise<OutputByType[T]> => {\n const zipped = hasNativeDeflate()\n ? await nativeZipAsync(files, level)\n : await new Promise<Uint8Array>((resolve, reject) => {\n zip(\n files as AsyncZippable,\n { level: level as ZipOptions[\"level\"], consume: true },\n (err, data) => {\n if (err) reject(err);\n else resolve(data);\n },\n );\n });\n return convertOutput(zipped, type, mimeType);\n};\n\n/**\n * Synchronously compress files and convert to the requested output format.\n *\n * Uses synchronous DEFLATE compression for maximum throughput.\n * Blocks the event loop — prefer {@link zipAndConvert} in server contexts.\n */\nexport const zipSyncAndConvert = <T extends OutputType>(\n files: Zippable,\n type: T,\n mimeType: string,\n level: number = ZIP_DEFLATE_LEVEL,\n): OutputByType[T] => {\n const zipped = hasNativeDeflate()\n ? nativeZip(files, level)\n : zipSync(files, { level: level as ZipOptions[\"level\"] });\n return convertOutput(zipped, type, mimeType);\n};\n\n/**\n * Create a `ReadableStream<Uint8Array>` from compressed file entries.\n *\n * Uses fflate's `AsyncZipDeflate` for non-blocking DEFLATE compression.\n * `STORED` entries (media) pass through synchronously.\n * Works in both Node.js and browsers (Web Streams API).\n */\nexport const createZipStream = (\n files: Zippable,\n defaultLevel: number = ZIP_DEFLATE_LEVEL,\n): ReadableStream<Uint8Array> => {\n // Bun's worker teardown lags creation, so per-entry workers accumulate cost\n // across back-to-back generations — see prefersMainThreadDeflate(). Node\n // keeps AsyncZipDeflate for its parallel libuv thread pool.\n const mainThread = prefersMainThreadDeflate();\n return new ReadableStream<Uint8Array>({\n start(controller) {\n try {\n const zip = new Zip((err, chunk, _final) => {\n if (err) {\n controller.error(err);\n return;\n }\n controller.enqueue(chunk);\n if (_final) {\n controller.close();\n }\n });\n\n for (const [name, data] of Object.entries(files)) {\n const raw = Array.isArray(data) ? (data[0] as Uint8Array) : (data as Uint8Array);\n const level = Array.isArray(data)\n ? ((data[1] as ZipOptions).level ?? defaultLevel)\n : defaultLevel;\n const workerPath = level !== ZIP_STORED_LEVEL && !mainThread;\n const entry =\n level === ZIP_STORED_LEVEL\n ? new ZipPassThrough(name)\n : workerPath\n ? new AsyncZipDeflate(name, { level: level as ZipOptions[\"level\"] })\n : new ZipDeflate(name, { level: level as ZipOptions[\"level\"] });\n zip.add(entry);\n // AsyncZipDeflate transfers each pushed buffer to its worker\n // (postMessage move semantics), detaching the caller's view —\n // regenerating from the same files would push an already-detached\n // buffer and throw DataCloneError. Only the worker entry needs the\n // copy; pass-through and main-thread entries keep zero-copy.\n entry.push(workerPath ? raw.slice() : raw, true);\n }\n\n zip.end();\n } catch (err) {\n controller.error(err instanceof Error ? err : new Error(String(err)));\n }\n },\n });\n};\n\n// ── Streaming ZIP writer ──\n\n/**\n * Incremental sink for one ZIP part. Feed chunks as they are produced; the\n * entry's local header is emitted on {@link ZipStreamWriter.addPart} and the\n * trailing CRC/sizes on {@link end} — the part's full content never has to\n * exist in memory at once.\n */\nexport interface ZipPartSink {\n /** Append a chunk to the part. */\n push(chunk: Uint8Array): void;\n /** Finalize the part, optionally with a final chunk. Must be called before adding the next one. */\n end(lastChunk?: Uint8Array): void;\n}\n\n/**\n * Incremental ZIP archive writer over fflate's streaming `Zip` — parts are\n * added and completed one at a time; compressed output flows to `ondata` as\n * it is produced. This is the constant-memory counterpart to\n * {@link createZipStream} (which requires the complete `Zippable` up front):\n * serialize each part chunk-wise into the returned sink instead of building\n * the full part string.\n *\n * Parts must be added in order — `[Content_Types].xml` first per OPC. The\n * whole archive finishes when {@link ZipStreamWriter.end} is called.\n */\nexport class ZipStreamWriter {\n private readonly zip: Zip;\n private current: AsyncZipDeflate | ZipDeflate | ZipPassThrough | undefined;\n private readonly mainThread = prefersMainThreadDeflate();\n\n constructor(\n ondata: (err: Error | null, chunk: Uint8Array, final: boolean) => void,\n private readonly defaultLevel: number = ZIP_DEFLATE_LEVEL,\n ) {\n this.zip = new Zip(ondata);\n }\n\n /** Add a part and return its incremental sink. `end()` the previous first. */\n addPart(name: string, level: number = this.defaultLevel): ZipPartSink {\n if (this.current) throw new Error(`ZipStreamWriter: previous part not finalized`);\n const workerPath = level !== ZIP_STORED_LEVEL && !this.mainThread;\n const entry =\n level === ZIP_STORED_LEVEL\n ? new ZipPassThrough(name)\n : workerPath\n ? new AsyncZipDeflate(name, { level: level as ZipOptions[\"level\"] })\n : new ZipDeflate(name, { level: level as ZipOptions[\"level\"] });\n // AsyncZipDeflate hands chunks to a worker; ondata delivery is asynchronous,\n // so ordering between parts is preserved by fflate's internal queue. The\n // worker transfer-detaches every chunk it is handed, so sinks receive\n // copies — a caller-held buffer must survive repeated generations.\n this.zip.add(entry);\n this.current = entry;\n return {\n push: (chunk) => entry.push(workerPath ? chunk.slice() : chunk, false),\n end: (lastChunk?: Uint8Array) => {\n entry.push((workerPath ? lastChunk?.slice() : lastChunk) ?? new Uint8Array(0), true);\n this.current = undefined;\n },\n };\n }\n\n /** Finish the archive (central directory + EOCD). */\n end(): void {\n if (this.current) throw new Error(`ZipStreamWriter: unclosed part at end()`);\n this.zip.end();\n }\n}\n\n// ── Factory function ──\n\n/**\n * Compile function provided by each package to convert a file object into a Zippable map.\n */\nexport type CompileFn<TFile> = (\n file: TFile,\n overrides?: XmlifyedFile[],\n mediaLevel?: number,\n) => Zippable;\n\n/**\n * Packer interface returned by {@link createPacker}.\n *\n * Async methods use fflate Web Workers for non-blocking compression.\n * Sync methods use synchronous compression for maximum throughput in\n * CLI scripts and build tools.\n */\nexport interface Packer<TFile> {\n /** Compile file to Zippable map (synchronous). */\n compile: CompileFn<TFile>;\n\n /** Generic async output — returns the requested OutputType. */\n pack<T extends OutputType = \"nodebuffer\">(\n file: TFile,\n options?: PackerOptions<T>,\n ): Promise<OutputByType[T]>;\n /** Generic sync output — returns the requested OutputType. */\n packSync<T extends OutputType = \"nodebuffer\">(\n file: TFile,\n options?: PackerOptions<T>,\n ): OutputByType[T];\n\n /** Async → `Promise<Uint8Array>` (like `Response.bytes()`). */\n toBytes(file: TFile, options?: PackerOptions): Promise<Uint8Array>;\n /** Sync → `Uint8Array`. */\n toBytesSync(file: TFile, options?: PackerOptions): Uint8Array;\n\n /** Async → `Promise<string>` (raw ZIP content as string). */\n toString(file: TFile, options?: PackerOptions): Promise<string>;\n /** Sync → `string`. */\n toStringSync(file: TFile, options?: PackerOptions): string;\n\n /** Async → `Promise<Buffer>` (Node.js). */\n toBuffer(file: TFile, options?: PackerOptions): Promise<Buffer>;\n /** Sync → `Buffer` (Node.js). */\n toBufferSync(file: TFile, options?: PackerOptions): Buffer;\n\n /** Async → `Promise<string>` (base64-encoded). */\n toBase64(file: TFile, options?: PackerOptions): Promise<string>;\n /** Sync → `string` (base64-encoded). */\n toBase64Sync(file: TFile, options?: PackerOptions): string;\n\n /** Async → `Promise<Blob>` (browser). */\n toBlob(file: TFile, options?: PackerOptions): Promise<Blob>;\n /** Sync → `Blob`. */\n toBlobSync(file: TFile, options?: PackerOptions): Blob;\n\n /** Async → `Promise<ArrayBuffer>`. */\n toArrayBuffer(file: TFile, options?: PackerOptions): Promise<ArrayBuffer>;\n /** Sync → `ArrayBuffer`. */\n toArrayBufferSync(file: TFile, options?: PackerOptions): ArrayBuffer;\n\n /** Streaming output via `ReadableStream<Uint8Array>` (cross-platform, uses Web Workers). */\n toStream(file: TFile, options?: PackerOptions): ReadableStream<Uint8Array>;\n}\n\n/**\n * Create a Packer object with all output format methods.\n *\n * Centralises the ZIP → convert pipeline and the streaming implementation\n * so that each OOXML package only needs to provide a `compile` function and\n * a MIME type.\n */\nexport const createPacker = <TFile>(options: {\n compile: CompileFn<TFile>;\n mimeType: string;\n}): Packer<TFile> => {\n const { compile, mimeType } = options;\n\n const pack = async <T extends OutputType = \"nodebuffer\">(\n file: TFile,\n opts?: PackerOptions<T>,\n ): Promise<OutputByType[T]> => {\n const type = opts?.type ?? (\"nodebuffer\" as T);\n const files = compile(file, opts?.overrides ?? [], opts?.compression?.media ?? ZIP_MEDIA_LEVEL);\n return zipAndConvert(files, type, mimeType, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n const toBytes = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"uint8array\" });\n const toString = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"string\" });\n const toBuffer = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"nodebuffer\" });\n const toBase64 = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"base64\" });\n const toBlob = (file: TFile, opts?: PackerOptions) => pack(file, { ...opts, type: \"blob\" });\n const toArrayBuffer = (file: TFile, opts?: PackerOptions) =>\n pack(file, { ...opts, type: \"arraybuffer\" });\n\n // ── Sync methods (zipSync, maximum throughput) ──\n\n const packSync = <T extends OutputType = \"nodebuffer\">(\n file: TFile,\n opts?: PackerOptions<T>,\n ): OutputByType[T] => {\n const type = opts?.type ?? (\"nodebuffer\" as T);\n const files = compile(file, opts?.overrides ?? [], opts?.compression?.media ?? ZIP_MEDIA_LEVEL);\n return zipSyncAndConvert(files, type, mimeType, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n const toBytesSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"uint8array\" });\n const toStringSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"string\" });\n const toBufferSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"nodebuffer\" });\n const toBase64Sync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"base64\" });\n const toBlobSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"blob\" });\n const toArrayBufferSync = (file: TFile, opts?: PackerOptions) =>\n packSync(file, { ...opts, type: \"arraybuffer\" });\n\n // ── Stream ──\n\n const toStream = (file: TFile, opts?: PackerOptions) => {\n const mediaLevel = opts?.compression?.media ?? ZIP_MEDIA_LEVEL;\n let files: Zippable;\n try {\n files = compile(file, opts?.overrides ?? [], mediaLevel);\n } catch (err) {\n return new ReadableStream<Uint8Array>({\n start(controller) {\n controller.error(err instanceof Error ? err : new Error(String(err)));\n },\n });\n }\n return createZipStream(files, opts?.compression?.xml ?? ZIP_DEFLATE_LEVEL);\n };\n\n return {\n compile,\n pack,\n packSync,\n toBytes,\n toBytesSync,\n toString,\n toStringSync,\n toBuffer,\n toBufferSync,\n toBase64,\n toBase64Sync,\n toBlob,\n toBlobSync,\n toArrayBuffer,\n toArrayBufferSync,\n toStream,\n };\n};\n","/**\n * Shared compiler utilities for OOXML document generation.\n *\n * @module\n */\n\nimport { levelForMediaName } from \"../opc/packer\";\nimport type { XmlifyedFile, ZipOptions, Zippable } from \"../opc/packer\";\n\n/** Reusable TextEncoder instance (stateless, safe to share). */\nconst encoder = new TextEncoder();\n\nexport type XmlifyedFileEntry = XmlifyedFile | readonly XmlifyedFile[] | undefined;\n\n/** Add one binary ZIP entry using the shared media compression policy. */\nexport function addBinaryFile(\n files: Zippable,\n path: string,\n data: Uint8Array,\n mediaLevel: number,\n): void {\n files[path] = [data, { level: levelForMediaName(path, mediaLevel) as ZipOptions[\"level\"] }];\n}\n\n/**\n * Convert XML files, overrides, and media into a Zippable structure.\n *\n * Mapping values may be optional arrays so package compilers can pass their\n * natural part mappings without reimplementing flattening and byte encoding.\n */\nexport function compileMapping<T extends object>(\n mapping: T & { [K in keyof T]: XmlifyedFileEntry },\n overrides?: readonly XmlifyedFile[],\n media?: readonly { data: Uint8Array; path: string }[],\n mediaLevel: number = 0,\n): Zippable {\n const files: Zippable = {};\n for (const entry of Object.values(mapping) as XmlifyedFileEntry[]) {\n if (entry === undefined) continue;\n const entries = Array.isArray(entry) ? entry : [entry];\n for (const file of entries) {\n files[file.path] = typeof file.data === \"string\" ? encoder.encode(file.data) : file.data;\n }\n }\n for (const override of overrides ?? []) {\n files[override.path] =\n typeof override.data === \"string\" ? encoder.encode(override.data) : override.data;\n }\n for (const file of media ?? []) {\n addBinaryFile(files, file.path, file.data, mediaLevel);\n }\n return files;\n}\n","/**\n * Password hashing utilities for OOXML document protection.\n *\n * Implements ECMA-376 Agile Encryption password derivation.\n * Passwords are encoded as UTF-16LE per the OOXML specification.\n *\n * Uses `@noble`/hashes for SHA-512 — audited, cross-platform,\n * and comparable in speed to node:crypto for this workload.\n *\n * @module\n */\n\nimport { sha512 } from \"@noble/hashes/sha2.js\";\n\nimport { encodeBase64 } from \"./base64\";\n\n// ── Helpers ──\n\nfunction utf16leEncode(str: string): Uint8Array {\n const bytes = new Uint8Array(str.length * 2);\n for (let i = 0; i < str.length; i++) {\n const code = str.charCodeAt(i);\n bytes[i * 2] = code & 0xff;\n bytes[i * 2 + 1] = (code >> 8) & 0xff;\n }\n return bytes;\n}\n\n// ── Public API ──\n\nexport function randomBytes(length: number): Uint8Array {\n const bytes = new Uint8Array(length);\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition\n if (typeof crypto !== \"undefined\" && crypto.getRandomValues) {\n crypto.getRandomValues(bytes);\n } else {\n for (let i = 0; i < length; i++) {\n bytes[i] = Math.floor(Math.random() * 256);\n }\n }\n return bytes;\n}\n\n/**\n * Computes the ECMA-376 Agile Encryption hash for a password.\n *\n * Algorithm: SHA-512(salt + UTF-16LE(password)), then iterate\n * SHA-512(hash + i.toUint32LE()) spinCount times.\n */\nexport function hashPasswordAgile(password: string, salt: Uint8Array, spinCount: number): string {\n const pwBytes = utf16leEncode(password);\n\n // h = SHA-512(salt + password_utf16le)\n const initial = new Uint8Array(salt.length + pwBytes.length);\n initial.set(salt, 0);\n initial.set(pwBytes, salt.length);\n\n let h = sha512(initial);\n for (let i = 0; i < spinCount; i++) {\n const buf = new Uint8Array(h.length + 4);\n buf.set(h, 0);\n buf[h.length] = i & 0xff;\n buf[h.length + 1] = (i >> 8) & 0xff;\n buf[h.length + 2] = (i >> 16) & 0xff;\n buf[h.length + 3] = (i >> 24) & 0xff;\n h = sha512(buf);\n }\n\n return encodeBase64(new Uint8Array(h));\n}\n\n/**\n * Derives a password hash for OOXML document protection.\n *\n * Returns base64-encoded hashValue, saltValue, spinCount, and algorithmName\n * suitable for direct use in document protection options.\n */\nexport function derivePasswordHash(\n password: string,\n spinCount = 100000,\n): { hashValue: string; saltValue: string; spinCount: number; algorithmName: string } {\n const salt = randomBytes(16);\n const hashValue = hashPasswordAgile(password, salt, spinCount);\n return {\n hashValue,\n saltValue: encodeBase64(salt),\n spinCount,\n algorithmName: \"SHA-512\",\n };\n}\n","/**\n * Placeholder detection and replacement utilities for compiler post-processing.\n *\n * Both DOCX and PPTX compilers use placeholder tokens (e.g. `{chart:key}`)\n * in XML strings to defer relationship ID assignment. This module provides\n * fast pre-check utilities and shared replacement functions.\n */\n\nexport type IdFormat = \"rId\" | \"plain\";\n\nexport const formatId = (offset: number, index: number, style: IdFormat): string =>\n style === \"rId\" ? `rId${offset + index}` : `${offset + index}`;\n\n/**\n * Find the next `{key}` placeholder at/after `from`. Returns `[open, close]`\n * brace indices, or undefined when none remain. Mirrors the semantics of\n * `/\\{([^{}]+)\\}/g`: empty keys and keys containing `{` are skipped (the scan\n * restarts after the nested brace), matching what the regex would accept.\n */\nfunction nextPlaceholder(xml: string, from: number): [number, number] | undefined {\n let pos = from;\n for (;;) {\n const open = xml.indexOf(\"{\", pos);\n if (open === -1) return undefined;\n const close = xml.indexOf(\"}\", open + 1);\n if (close === -1) return undefined;\n const keyLen = close - open - 1;\n if (keyLen === 0) {\n pos = open + 1;\n continue;\n }\n const nextOpen = xml.indexOf(\"{\", open + 1);\n if (nextOpen !== -1 && nextOpen < close) {\n // Nested \"{\" inside the candidate key — the regex would restart there.\n pos = open + 1;\n continue;\n }\n return [open, close];\n }\n}\n\n/** Replace `{name}` placeholders with the given values (missing keys stay). */\nexport function replacePlaceholders(xml: string, map: Map<string, string>): string {\n const parts: string[] = [];\n let last = 0;\n let pos = 0;\n for (;;) {\n const found = nextPlaceholder(xml, pos);\n if (found === undefined) break;\n const [open, close] = found;\n const replacement = map.get(xml.substring(open + 1, close));\n if (replacement !== undefined) {\n parts.push(xml.substring(last, open), replacement);\n last = close + 1;\n }\n pos = close + 1;\n }\n if (last === 0) return xml;\n parts.push(xml.substring(last));\n return parts.join(\"\");\n}\n\nexport function hasPlaceholders(xml: string): boolean {\n return xml.includes(\"{\");\n}\n\nexport function collectPlaceholderKeys(xml: string, prefix: string): string[] {\n const keys = new Set<string>();\n const search = `{${prefix}`;\n let pos = 0;\n\n while ((pos = xml.indexOf(search, pos)) !== -1) {\n const keyStart = pos + search.length;\n const keyEnd = xml.indexOf(\"}\", keyStart);\n if (keyEnd === -1) break;\n\n const key = xml.substring(keyStart, keyEnd);\n if (key.length > 0) keys.add(key);\n pos = keyEnd + 1;\n }\n\n return [...keys];\n}\n\nexport function replaceImagePlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (mediaData.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of mediaData.entries()) {\n map.set(item.fileName, formatId(offset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function getReferencedMedia(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return mediaArray.filter((image) => xml.includes(`{${image.fileName}}`));\n}\n\n/**\n * Combined find + replace for image placeholders in a single pass.\n *\n * Scans XML for `{fileName}` placeholders, replaces them with formatted IDs,\n * and returns the list of referenced media items for relationship registration.\n * More efficient than calling getReferencedMedia() + replaceImagePlaceholders() separately.\n */\nexport function findAndReplaceImagePlaceholders(\n xml: string,\n mediaArray: { fileName: string }[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n sourceRids?: ReadonlyMap<string, string>,\n): { xml: string; referenced: { fileName: string }[] } {\n if (mediaArray.length === 0 || !hasPlaceholders(xml)) {\n return { xml, referenced: [] };\n }\n // Build fileName → mediaItem lookup\n const itemMap = new Map<string, { fileName: string }>();\n for (const item of mediaArray) {\n itemMap.set(item.fileName, item);\n }\n\n const referenced: { fileName: string }[] = [];\n const replaceMap = new Map<string, string>();\n const parts: string[] = [];\n let last = 0;\n let pos = 0;\n\n for (;;) {\n const found = nextPlaceholder(xml, pos);\n if (found === undefined) break;\n const [open, close] = found;\n const key = xml.substring(open + 1, close);\n const item = itemMap.get(key);\n if (item !== undefined) {\n let id = replaceMap.get(key);\n if (id === undefined) {\n // Source round-trip: when the source rels captured the rId for this\n // media file, the body XML must reference that exact rId — the\n // structured compiler's rels will then point to the same target. Using\n // an offset-derived id here would dangle the body's `r:embed` against\n // a rel pointing at a different media item.\n const override = sourceRids?.get(key);\n // Use the referenced-local position (not the global media index) so the\n // generated IDs align with the caller's per-part addRelationship(offset+i)\n // loop. Using the global index desyncs the body's r:embed from the part's\n // .rels when a part references only a subset of the global media array\n // (e.g. headers/footers, whose images sit at high global indices).\n id = override ?? formatId(offset, referenced.length, idFormat);\n replaceMap.set(key, id);\n referenced.push(item);\n }\n parts.push(xml.substring(last, open), id);\n last = close + 1;\n }\n pos = close + 1;\n }\n\n if (last === 0) return { xml, referenced: [] };\n parts.push(xml.substring(last));\n return { xml: parts.join(\"\"), referenced };\n}\n\n/**\n * Replace all placeholder types in a single pass.\n *\n * Combines image, chart, smartart, and arbitrary key-value replacements\n * into one regex scan of the XML string. Used by compilers to avoid\n * multiple full-string passes on large documents.\n */\nexport function replaceAllPlaceholders(\n xml: string,\n entries: Array<{ prefix?: string; key: string; value: string }>,\n): string {\n if (entries.length === 0 || !hasPlaceholders(xml)) return xml;\n const map = new Map<string, string>();\n for (const { prefix, key, value } of entries) {\n map.set(prefix ? `${prefix}${key}` : key, value);\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function replaceChartPlaceholders(\n xml: string,\n chartKeys: string[],\n offset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (chartKeys.length === 0) return xml;\n const map = new Map<string, string>();\n for (let i = 0; i < chartKeys.length; i++) {\n map.set(`chart:${chartKeys[i]}`, formatId(offset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nimport type { RelationshipType } from \"../opc/relationships\";\n\nexport interface SmartArtRelOptions {\n pathPrefix: string;\n styleRelType: RelationshipType;\n /**\n * Whether a SmartArt carries the optional diagramDrawing part (the Office\n * render cache). Unset means every SmartArt does — a fresh authoring\n * package never carries it, so round-trip callers pass the source fact.\n */\n hasDrawing?: (key: string) => boolean;\n}\n\nexport function replaceSmartArtPlaceholders(\n xml: string,\n keys: string[],\n dataOffset: number,\n idFormat: IdFormat = \"rId\",\n): string {\n if (keys.length === 0) return xml;\n const count = keys.length;\n const loOffset = dataOffset + count;\n const qsOffset = loOffset + count;\n const csOffset = qsOffset + count;\n\n const map = new Map<string, string>();\n for (let i = 0; i < count; i++) {\n map.set(`smartart:${keys[i]}`, formatId(dataOffset, i, idFormat));\n map.set(`smartart-lo:${keys[i]}`, formatId(loOffset, i, idFormat));\n map.set(`smartart-qs:${keys[i]}`, formatId(qsOffset, i, idFormat));\n map.set(`smartart-cs:${keys[i]}`, formatId(csOffset, i, idFormat));\n }\n return replacePlaceholders(xml, map);\n}\n\nexport function addSmartArtRelationships(\n keys: string[],\n addRel: (id: number, type: RelationshipType, target: string, targetMode?: string) => void,\n baseOffset: number,\n globalStartIndex: number,\n options: SmartArtRelOptions,\n): void {\n const { pathPrefix, styleRelType, hasDrawing } = options;\n const count = keys.length;\n const loOffset = baseOffset + count;\n const qsOffset = loOffset + count;\n const csOffset = qsOffset + count;\n\n for (let i = 0; i < keys.length; i++) {\n const gi = globalStartIndex + i;\n addRel(\n baseOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramData\",\n `${pathPrefix}diagrams/data${gi + 1}.xml`,\n );\n addRel(\n loOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramLayout\",\n `${pathPrefix}diagrams/layout${gi + 1}.xml`,\n );\n addRel(qsOffset + i, styleRelType, `${pathPrefix}diagrams/quickStyle${gi + 1}.xml`);\n addRel(\n csOffset + i,\n \"http://schemas.openxmlformats.org/officeDocument/2006/relationships/diagramColors\",\n `${pathPrefix}diagrams/colors${gi + 1}.xml`,\n );\n if (hasDrawing === undefined || hasDrawing(keys[i]!)) {\n const drOffset = csOffset + count;\n addRel(\n drOffset + i,\n \"http://schemas.microsoft.com/office/2007/relationships/diagramDrawing\",\n `${pathPrefix}diagrams/drawing${gi + 1}.xml`,\n );\n }\n }\n}\n\n// ── Numbering placeholders (DOCX) ──\n\n/** Replace `{reference-instance}` placeholders with numId values. */\nexport function replaceNumberingPlaceholders(\n xml: string,\n concreteNumberings: readonly { reference: string; instance: number; numId: number }[],\n): string {\n if (concreteNumberings.length === 0) return xml;\n const map = new Map<string, string>();\n for (const { reference, instance, numId } of concreteNumberings) {\n map.set(`${reference}-${instance}`, numId.toString());\n }\n return replacePlaceholders(xml, map);\n}\n\n// ── Media/Video placeholders (PPTX) ──\n\n/** Replace `{media:fileName}` placeholders with relationship IDs. */\nexport function replaceMediaPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n): string {\n return replacePrefixedPlaceholders(xml, mediaData, offset, \"media:\");\n}\n\n/** Replace `{video:fileName}` placeholders with relationship IDs. */\nexport function replaceVideoPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n): string {\n return replacePrefixedPlaceholders(xml, mediaData, offset, \"video:\");\n}\n\n/** Replace `{audio:fileName}` placeholders with relationship IDs. */\nexport function replaceAudioPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n): string {\n return replacePrefixedPlaceholders(xml, mediaData, offset, \"audio:\");\n}\n\n/** Replace `{ole:fileName}` placeholders with relationship IDs. */\nexport function replaceOlePlaceholders(\n xml: string,\n embeddings: { fileName: string }[],\n offset: number,\n): string {\n return replacePrefixedPlaceholders(xml, embeddings, offset, \"ole:\");\n}\n\nfunction replacePrefixedPlaceholders(\n xml: string,\n mediaData: { fileName: string }[],\n offset: number,\n prefix: string,\n): string {\n if (mediaData.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of mediaData.entries()) {\n map.set(`${prefix}${item.fileName}`, formatId(offset, i, \"rId\"));\n }\n return replacePlaceholders(xml, map);\n}\n\n/** Collect media items referenced by `{media:...}` placeholders in XML. */\nexport function getMediaRefs(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"media:\", mediaArray);\n}\n\n/** Collect media items referenced by `{video:...}` placeholders in XML. */\nexport function getVideoRefs(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"video:\", mediaArray);\n}\n\n/** Collect media items referenced by `{audio:...}` placeholders in XML. */\nexport function getAudioRefs(\n xml: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"audio:\", mediaArray);\n}\n\n/** Collect OLE embeddings referenced by `{ole:...}` placeholders in XML. */\nexport function getOleRefs(\n xml: string,\n embeddings: { fileName: string }[],\n): { fileName: string }[] {\n return collectPrefixedRefs(xml, \"ole:\", embeddings);\n}\n\nfunction collectPrefixedRefs(\n xml: string,\n prefix: string,\n mediaArray: { fileName: string }[],\n): { fileName: string }[] {\n const keys = new Set<string>();\n const search = `{${prefix}`;\n let pos = 0;\n while ((pos = xml.indexOf(search, pos)) !== -1) {\n const keyStart = pos + search.length;\n const keyEnd = xml.indexOf(\"}\", keyStart);\n if (keyEnd === -1) break;\n keys.add(xml.substring(keyStart, keyEnd));\n pos = keyEnd + 1;\n }\n return mediaArray.filter((m) => keys.has(m.fileName));\n}\n\n// ── Hyperlink placeholders (PPTX) ──\n\n/** Replace `{prefix:key}` placeholders with relationship IDs. */\nfunction replaceKeyedPlaceholders(\n xml: string,\n items: { key: string }[],\n offset: number,\n prefix: string,\n): string {\n if (items.length === 0) return xml;\n const map = new Map<string, string>();\n for (const [i, item] of items.entries()) {\n map.set(`${prefix}${item.key}`, formatId(offset, i, \"rId\"));\n }\n return replacePlaceholders(xml, map);\n}\n\n/** Replace `{hlink:key}` placeholders with relationship IDs. */\nexport function replaceHyperlinkPlaceholders(\n xml: string,\n hyperlinks: { key: string }[],\n offset: number,\n): string {\n return replaceKeyedPlaceholders(xml, hyperlinks, offset, \"hlink:\");\n}\n\n/** Replace `{img-link:key}` placeholders with relationship IDs. */\nexport function replaceImageLinkPlaceholders(\n xml: string,\n links: { key: string }[],\n offset: number,\n): string {\n return replaceKeyedPlaceholders(xml, links, offset, \"img-link:\");\n}\n\n/** Replace `{ole-link:key}` placeholders with relationship IDs. */\nexport function replaceOleLinkPlaceholders(\n xml: string,\n links: { key: string }[],\n offset: number,\n): string {\n return replaceKeyedPlaceholders(xml, links, offset, \"ole-link:\");\n}\n"],"mappings":";;;;AAmBA,MAAM,4BAAY,IAAI,WAAW,GAAG;AACpC,KAAK,IAAI,IAAI,GAAG,IAAI,KAAK,KAAK;CAC5B,IAAI,IAAI;CACR,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK,IAAI,IAAI,IAAK,MAAM,IAAK,aAAa,MAAM;CACvE,UAAU,KAAK;AACjB;AAEA,SAAS,aAAa,MAA0B;CAC9C,IAAI,MAAM;CAGV,KAAK,MAAM,QAAQ,MACjB,MAAM,WAAW,MAAM,QAAQ,OAAU,QAAQ;CAEnD,OAAO,CAAC;AACV;AASA,IAAI;AACJ,IAAI;AACJ,IAAI;AACJ,IAAI;AAOJ,MAAM,SACJ,WAMA;AACF,IAAI,OAAO,QAAQ,gBAAgB,YAAY;CAC7C,kBAAkB,MAAkB,UAClC,OAAO,YAAa,MAAM,EAAE,MAAM,CAAC;CACrC,IAAI,OAAO,OAAO,gBAAgB,YAChC,kBAAkB,SAAiC,OAAO,YAAa,IAAI;AAE/E;AAQA,IAAI;CAGF,MAAM,OAAO,MAAM,OAAO;CAC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